Created
November 9, 2016 20:24
-
-
Save dennissergeev/8a41443caf391d086a7ca6e4b79878ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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