Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _climo_wind(config, dates=None):
"""
Fetches climatological wind data using ulmo package to retrieve NCDC archives.
:param config:
:param dates: list of datetime objects
:return: dict: dictionary of wind values
"""
import ulmo
if config['verbose']:
print('_climo_wind: fetching data from NCDC (may take a while)...')
v = 'WSF2'
wind_dict = {}
D = ulmo.ncdc.ghcn_daily.get_data(get_ghcn_stid(config), as_dataframe=True, elements=[v])
if dates is None:
dates = list(D[v].index.to_timestamp().to_pydatetime())
for date in dates:
wind_dict[date] = {'wind': D[v].loc[date]['value'] / 10. * 1.94384}
return wind_dict