Skip to content

Instantly share code, notes, and snippets.

@dennissergeev
Created November 9, 2016 20:24
Show Gist options
  • Save dennissergeev/8a41443caf391d086a7ca6e4b79878ea to your computer and use it in GitHub Desktop.
Save dennissergeev/8a41443caf391d086a7ca6e4b79878ea to your computer and use it in GitHub Desktop.
import numpy as np
raob_station_list = 'http://www.raob.com/assets/downloads/raob.stn.txt'
raob_codes = np.genfromtxt(raob_station_list,
skip_header=9, dtype=None, delimiter=',', skip_footer=1, unpack=True)
nrow = len(raob_codes)
ncol = len(raob_codes[0])
raob_lat = np.zeros(nrow)
raob_lon = np.zeros(nrow)
raob_wmo = np.zeros(nrow, dtype=np.int64)
# raob_wmo = np.empty(nrow, dtype='U5')17609
for i, irow in enumerate(raob_codes):
# raob_wmo[i] = str(irow[0]).zfill(5)
raob_wmo[i] = irow[0]
if irow[6].decode().replace(' ', '') == 'N':
lat_sign = 1
elif irow[6].decode().replace(' ', '') == 'S':
lat_sign = -1
else:
raise ValueError('Unrecognised hemisphere {}'.format(irow[6]))
if irow[8].decode().replace(' ', '') == 'E':
lon_sign = 1
elif irow[8].decode().replace(' ', '') == 'W':
lon_sign = -1
else:
raise ValueError('Unrecognised hemisphere {}'.format(irow[8]))
raob_lat[i] = irow[5]*lat_sign
raob_lon[i] = irow[7]*lon_sign
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment