def find_station(*args):
stns=0
if len(args) ==1:
station_name=args[0]
print("LOOKUP BY STATION NAME: ",station_name)
station_name=station_name.upper()
ghcnd_stations=gp.get_ghcnd_stations()
stns=filter(lambda x: re.search(station_name,x), ghcnd_stations[:,5])
print("GHCND ID LAT LON ELEV ST STATION NAME")
print("###############################################################")
for station_counter in xrange(len(stns)):
ghcnd_meta = ghcnd_stations[ghcnd_stations[:,5]== stns[station_counter]]
print(ghcnd_meta[0][0],ghcnd_meta[0][1],ghcnd_meta[0][2],ghcnd_meta[0][3],ghcnd_meta[0][4],ghcnd_meta[0][5])
elif len(args)==3:
station_lat=args[0]
station_lon=args[1]
distance_limit=args[2]
print("LOOKUP BY STATION LAT: ",station_lat," LON: ",station_lon, " DIST LIMIT (mi): ",distance_limit)
target_latlon = (float(station_lat), float(station_lon))
ghcnd_stations=gp.get_ghcnd_stations()
print("GHCND ID LAT LON ELEV ST STATION NAME")
print("###############################################################")
for ghcnd_counter in xrange(ghcnd_stations[:,0].size):
candidate_latlon=(ghcnd_stations[ghcnd_counter][1], ghcnd_stations[ghcnd_counter][2])
dist=great_circle(target_latlon, candidate_latlon).miles
if dist <= distance_limit:
print(ghcnd_stations[ghcnd_counter][0],ghcnd_stations[ghcnd_counter][1],ghcnd_stations[ghcnd_counter][2],ghcnd_stations[ghcnd_counter][3],ghcnd_stations[ghcnd_counter][4],ghcnd_stations[ghcnd_counter][5])
else:
print("USAGE\n NAME or\n LAT LON DIST")
return None
return None
#################################################
# MODULE: get_metadata
# Get Metadata From Station
# 2 sources
# - ghcnd-stations.txt
# - Historical Observing Metadata Repository
# (HOMR)
#################################################
评论列表
文章目录