lib.timelib module¶
Time conversion utilities
-
pygeotools.lib.timelib.dt_cluster(dt_list, dt_thresh=16.0)[source]¶ Find clusters of similar datetimes within datetime list
-
pygeotools.lib.timelib.dt_filter_rel_annual_idx(dt_list, min_rel_dt=(1, 1), max_rel_dt=(12, 31))[source]¶ Return dictionary containing indices of timestamps that fall within relative month/day bounds of each year
-
pygeotools.lib.timelib.fix_repeat_dt(dt_list, offset_s=0.001)[source]¶ Add some small offset to remove duplicate times Needed for xarray interp, which expects monotonically increasing times
-
pygeotools.lib.timelib.fn_getdatetime_list(fn)[source]¶ Extract all datetime strings from input filename
-
pygeotools.lib.timelib.get_closest_dt_idx(dt, dt_list)[source]¶ Get indices of dt_list that is closest to input dt
-
pygeotools.lib.timelib.get_closest_dt_padded_idx(dt, dt_list, pad=datetime.timedelta(30))[source]¶ Get indices of dt_list that is closest to input dt +/- pad days
-
pygeotools.lib.timelib.get_dt_list(fn_list)[source]¶ Get list of datetime objects, extracted from a filename
-
pygeotools.lib.timelib.get_t_factor(t1, t2)[source]¶ Time difference between two datetimes, expressed as decimal year
-
pygeotools.lib.timelib.mat2dt(o)[source]¶ Convert Matlab ordinal to Python datetime
Need to account for AD 0 and AD 1 discrepancy between the two: http://sociograph.blogspot.com/2011/04/how-to-avoid-gotcha-when-converting.html
python_datetime = datetime.fromordinal(int(o)) + timedelta(days=o%1) - timedelta(days = 366)
-
pygeotools.lib.timelib.solarTime(utc_dt, lat, lon)[source]¶ Compute local solar time for given (lat, lon)