@@ -213,35 +213,35 @@ def transform(ts, name, how, siminfo):
213213 NOTE: these routines work for both regular and sparse timeseries input
214214 """
215215
216- tsfreq = ts .index .freq . delta . to_timedelta64 ()
216+ tsfreq = ts .index .freq
217217 fmins = Minute (siminfo ["delt" ])
218- freq = Timedelta ( fmins ). to_timedelta64 ()
218+ freq = fmins . nanos
219219 stop = siminfo ["stop" ]
220220
221221 # append duplicate of last point to force processing last full interval
222222 if ts .index [- 1 ] < stop :
223223 ts [stop ] = ts .iloc [- 1 ]
224224
225- if freq == tsfreq :
225+ if freq == tsfreq . nanos :
226226 pass
227227 elif tsfreq is None : # Sparse time base, frequency not defined
228228 ts = ts .reindex (siminfo ["tbase" ]).ffill ().bfill ()
229229 elif how == "SAME" :
230- ts = ts .resample (fmins ).ffill () # tsfreq >= freq assumed, or bad user choice
230+ ts = ts .resample (fmins ).ffill () # tsfreq.nanos >= freq assumed, or bad user choice
231231 elif not how :
232232 if name in flowtype :
233- if "Y" in str (tsfreq ) or "M" in str (tsfreq ) or tsfreq > freq :
233+ if "Y" in str (tsfreq ) or "M" in str (tsfreq ) or tsfreq . nanos > freq :
234234 if "M" in str (tsfreq ):
235235 ratio = 1.0 / 730.5
236236 elif "Y" in str (tsfreq ):
237237 ratio = 1.0 / 8766.0
238238 else :
239- ratio = freq / tsfreq
239+ ratio = freq / tsfreq . nanos
240240 ts = (ratio * ts ).resample (fmins ).ffill () # HSP2 how = div
241241 else :
242242 ts = ts .resample (fmins ).sum ()
243243 else :
244- if "Y" in str (tsfreq ) or "M" in str (tsfreq ) or tsfreq > freq :
244+ if "Y" in str (tsfreq ) or "M" in str (tsfreq ) or tsfreq . nanos > freq :
245245 ts = ts .resample (fmins ).ffiio_managerll ()
246246 else :
247247 ts = ts .resample (fmins ).mean ()
@@ -268,10 +268,10 @@ def transform(ts, name, how, siminfo):
268268 elif "Y" in str (tsfreq ):
269269 ratio = 1.0 / (8766.0 * mult )
270270 else :
271- ratio = freq / tsfreq
271+ ratio = freq / tsfreq . nanos
272272 ts = (ratio * ts ).resample (fmins ).ffill () # HSP2 how = div
273273 else :
274- ts = (ts * (freq / tsfreq )).resample (fmins ).ffill ()
274+ ts = (ts * (freq / tsfreq . nanos )).resample (fmins ).ffill ()
275275 elif how == "ZEROFILL" :
276276 ts = ts .resample (fmins ).fillna (0.0 )
277277 elif how == "INTERPOLATE" :
@@ -289,7 +289,7 @@ def hoursval(siminfo, hours24, dofirst=False, lapselike=False):
289289 start = siminfo ["start" ]
290290 stop = siminfo ["stop" ]
291291 fmins = Minute (siminfo ["delt" ])
292- freq = Timedelta ( fmins ). to_timedelta64 ()
292+ freq = fmins . nanos
293293
294294 dr = date_range (
295295 start = f"{ start .year } -01-01" , end = f"{ stop .year } -12-31" , freq = Minute (60 )
@@ -299,16 +299,16 @@ def hoursval(siminfo, hours24, dofirst=False, lapselike=False):
299299 hours [0 ] = 1
300300
301301 ts = Series (hours [0 : len (dr )], dr )
302- tsfreq = ts .index .freq . delta . to_timedelta64 ()
302+ tsfreq = ts .index .freq
303303 if lapselike :
304- if tsfreq > freq : # upsample
304+ if tsfreq . nanos > freq : # upsample
305305 ts = ts .resample (fmins ).asfreq ().ffill ()
306- elif tsfreq < freq : # downsample
306+ elif tsfreq . nanos < freq : # downsample
307307 ts = ts .resample (fmins ).mean ()
308308 else :
309- if tsfreq > freq : # upsample
309+ if tsfreq . nanos > freq : # upsample
310310 ts = ts .resample (fmins ).asfreq ().fillna (0.0 )
311- elif tsfreq < freq : # downsample
311+ elif tsfreq . nanos < freq : # downsample
312312 ts = ts .resample (fmins ).max ()
313313 return ts .truncate (start , stop ).to_numpy ()
314314
@@ -325,16 +325,16 @@ def monthval(siminfo, monthly):
325325 start = siminfo ["start" ]
326326 stop = siminfo ["stop" ]
327327 fmins = Minute (siminfo ["delt" ])
328- freq = Timedelta ( fmins ). to_timedelta64 ()
328+ freq = fmins . nanos
329329
330330 months = tile (monthly , stop .year - start .year + 1 ).astype (float )
331331 dr = date_range (start = f"{ start .year } -01-01" , end = f"{ stop .year } -12-31" , freq = "MS" )
332332 ts = Series (months , index = dr ).resample ("D" ).ffill ()
333- tsfreq = ts .index .freq . delta . to_timedelta64 ()
333+ tsfreq = ts .index .freq
334334
335- if tsfreq > freq : # upsample
335+ if tsfreq . nanos > freq : # upsample
336336 ts = ts .resample (fmins ).asfreq ().ffill ()
337- elif tsfreq < freq : # downsample
337+ elif tsfreq . nanos < freq : # downsample
338338 ts = ts .resample (fmins ).mean ()
339339 return ts .truncate (start , stop ).to_numpy ()
340340
@@ -345,17 +345,17 @@ def dayval(siminfo, monthly):
345345 start = siminfo ["start" ]
346346 stop = siminfo ["stop" ]
347347 fmins = Minute (siminfo ["delt" ])
348- freq = Timedelta ( fmins ). to_timedelta64 ()
348+ freq = fmins . nanos
349349
350350 months = tile (monthly , stop .year - start .year + 1 ).astype (float )
351351 dr = date_range (start = f"{ start .year } -01-01" , end = f"{ stop .year } -12-31" , freq = "MS" )
352352 ts = Series (months , index = dr ).resample ("D" ).interpolate ("time" )
353- tsfreq = ts .index .freq . delta . to_timedelta64 ()
353+ tsfreq = ts .index .freq
354354
355355
356- if tsfreq > freq : # upsample
356+ if tsfreq . nanos > freq : # upsample
357357 ts = ts .resample (fmins ).ffill ()
358- elif tsfreq < freq : # downsample
358+ elif tsfreq . nanos < freq : # downsample
359359 ts = ts .resample (fmins ).mean ()
360360 return ts .truncate (start , stop ).to_numpy ()
361361
0 commit comments