@@ -136,7 +136,6 @@ def cdec_dataset(station,start_date,end_date,sensor,
136136 cache_fn = os .path .join (cache_dir ,base_fn )
137137 else :
138138 cache_fn = None
139-
140139 if (cache_mode != 'refresh' ) and (cache_fn is not None ) and os .path .exists (cache_fn ):
141140 log .info ("Cached %s -- %s" % (interval_start ,interval_end ))
142141 ds = xr .open_dataset (cache_fn )
@@ -146,7 +145,8 @@ def cdec_dataset(station,start_date,end_date,sensor,
146145 else :
147146 log .info ("Fetching %s" % (base_fn ))
148147 req = requests .get (base_url ,params = params )
149- df = pd .read_csv (StringIO (req .text ),na_values = ['---' ],
148+ # BRT = below rating table
149+ df = pd .read_csv (StringIO (req .text ),na_values = ['---' , 'BRT' ],
150150 parse_dates = [ 'DATE TIME' ])
151151 if len (df )== 0 :
152152 continue
@@ -176,6 +176,8 @@ def cdec_dataset(station,start_date,end_date,sensor,
176176
177177 if len (datasets )> 1 :
178178 # it's possible that not all variables appear in all datasets
179+ # drop NaT time values
180+ datasets = [d .sel (time = d .time .notnull ()) for d in datasets ]
179181 dataset = datasets [0 ]
180182 for other in datasets [1 :]:
181183 dataset = dataset .combine_first (other )
@@ -191,7 +193,6 @@ def cdec_dataset(station,start_date,end_date,sensor,
191193 dataset .load () # force read into memory before closing files
192194 for d in datasets :
193195 d .close ()
194-
195196 return dataset
196197
197198
0 commit comments