5
5
from dweather_client .aliases_and_units import \
6
6
lookup_station_alias , STATION_UNITS_LOOKUP as SUL , METRIC_TO_IMPERIAL as M2I , IMPERIAL_TO_METRIC as I2M , UNIT_ALIASES
7
7
from dweather_client .struct_utils import tupleify , convert_nans_to_none
8
- from dweather_client .df_loader import get_atcf_hurricane_df , get_historical_hurricane_df , get_simulated_hurricane_df
9
8
import datetime , pytz , csv , inspect
10
9
from astropy import units as u
11
10
import numpy as np
@@ -30,6 +29,7 @@ def get_gridcell_history(
30
29
also_return_snapped_coordinates = False ,
31
30
also_return_metadata = False ,
32
31
use_imperial_units = True ,
32
+ convert_to_local_time = True ,
33
33
ipfs_timeout = None ):
34
34
"""
35
35
Get the historical timeseries data for a gridded dataset in a dictionary
@@ -69,18 +69,19 @@ def get_gridcell_history(
69
69
raise DatasetError ("No such dataset in dClimate" )
70
70
71
71
try :
72
- (lat , lon ), resp_series = GRIDDED_DATASETS [ dataset ]( ipfs_timeout = ipfs_timeout ) .get_data (lat , lon )
72
+ (lat , lon ), resp_series = dataset_obj .get_data (lat , lon )
73
73
74
74
except (ipfshttpclient .exceptions .ErrorResponse , ipfshttpclient .exceptions .TimeoutError , KeyError , FileNotFoundError ) as e :
75
75
raise CoordinateNotFoundError ("Invalid coordinate for dataset" )
76
76
77
77
# try a timezone-based transformation on the times in case we're using an hourly set.
78
- try :
79
- tf = TimezoneFinder ()
80
- local_tz = pytz .timezone (tf .timezone_at (lng = lon , lat = lat ))
81
- resp_series = resp_series .tz_localize ("UTC" ).tz_convert (local_tz )
82
- except (AttributeError , TypeError ): # datetime.date (daily sets) doesn't work with this, only datetime.datetime (hourly sets)
83
- pass
78
+ if convert_to_local_time :
79
+ try :
80
+ tf = TimezoneFinder ()
81
+ local_tz = pytz .timezone (tf .timezone_at (lng = lon , lat = lat ))
82
+ resp_series = resp_series .tz_localize ("UTC" ).tz_convert (local_tz )
83
+ except (AttributeError , TypeError ): # datetime.date (daily sets) doesn't work with this, only datetime.datetime (hourly sets)
84
+ pass
84
85
85
86
if type (missing_value ) == str :
86
87
resp_series = resp_series .replace (missing_value , np .NaN ).astype (float )
0 commit comments