Comments (2)
diff --git a/wu_locate.py b/wu_locate.py
index 60165bc..a8370cd 100755
--- a/wu_locate.py
+++ b/wu_locate.py
@@ -6,6 +6,9 @@ import wu_gather
baseurl_lonlat = 'http://api.wunderground.com/api/%s/geolookup/q/%s,%s.json'
make_url_lonlat = lambda u,x,y : baseurl_lonlat % (u,x,y)
+# added this function cause it looks like Wunderground defies convention and has lat first
+# Converts params given as x,y to y,x
+make_url_latlon = lambda u,x,y : baseurl_lonlat % (u,x,y)
baseurl_state = 'http://api.wunderground.com/api/%s/geolookup/q/%s.json'
make_url_state = lambda u,s : baseurl_state % (u,s)
@@ -14,6 +17,7 @@ locstring = lambda slocs : '|'.join([k+':'+','.join(slocs[k]) for k in slocs])
def plot_stationpoints(pts,lon,lat,bndf = 10.0):
+ print('Calling fn plot_stationpoints()')
'''Useful function for plotting the locations of stations around a lon,lat point.'''
print('... found %d nearby stations to lon,lat %s,%s ...' % (len(pts),lon,lat))
xs,ys = zip(*pts)
@@ -29,6 +33,7 @@ def plot_stationpoints(pts,lon,lat,bndf = 10.0):
@contextlib.contextmanager
def nostdout():
+ print('Calling fn nostdout()')
'''Context manager that supresses stdout.'''
save_stdout = sys.stdout
sys.stdout = io.BytesIO()
@@ -37,6 +42,7 @@ def nostdout():
def query(url,outpath):
+ print('Calling fn query(%s, %s)' % (url, outpath))
'''Download json file from url, save at output, and return associated data.'''
if wu_gather.urlfetch(url,outpath):lastcall = time.time()
with open(outpath) as f:data = json.load(f)
@@ -44,11 +50,12 @@ def query(url,outpath):
def lonlat(cache,apikey,lon,lat):
+ print('Calling fn lonlat()')
'''Fetch list of up to 50 station locations within 40 km of a longitude,latitude.
"The nearby Personal Weather Stations returned in the feed represent the closest
stations within a 40km radius, with a max number of stations returned of 50."'''
outpath = wu_gather.make_outpath(cache,'LonLat_'+str(lon),str(lat),'X')
- url = make_url_lonlat(apikey,lon,lat)
+ url = make_url_latlon(apikey,lat,lon)
data = query(url,outpath)
pts = []
stationlocs = {}
@@ -72,11 +79,14 @@ def lonlat(cache,apikey,lon,lat):
def state(cache,apikey,state):
+ print('Calling fn state()')
'''Fetch state wide list of station locations (one per city).'''
outpath = wu_gather.make_outpath(cache,state,'X','X')
url = make_url_state(apikey,state)
+ print('... Searching %s with key %s, final URL: %s' % (state,apikey,url))
data = query(url,outpath)
stationlocs = {}
+ print(data)
for r in data['response']['results']:
state,city = r['state'],r['city']
if state in stationlocs:stationlocs[state].append(city)
@@ -111,10 +121,10 @@ if __name__ == '__main__':
if not os.path.exists(cfg.cache):os.mkdir(cfg.cache)
if cfg.state:
- with nostdout():
+ #with nostdout():
stationlocs = state(cfg.cache,cfg.apikey,cfg.state)
elif cfg.longitude and cfg.latitude:
- with nostdout():
+ #with nostdout():
stationlocs = lonlat(cfg.cache,cfg.apikey,cfg.longitude,cfg.latitude)
else:
emsg = '... need either --state option or --longitude and --latitude options ...'
from grapeipm_support.
Closing this as I figured out how to do a pull request.
from grapeipm_support.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grapeipm_support.