lib.timelib module

Time conversion utilities

pygeotools.lib.timelib.center_date(dt1, dt2)[source]
pygeotools.lib.timelib.decyear2dt(t)[source]

Convert decimal year to datetime

pygeotools.lib.timelib.doy2dt(yr, j)[source]

Convert year + integer DOY (Julian) to datetime

pygeotools.lib.timelib.dt2decyear(dt)[source]

Convert datetime to decimal year

pygeotools.lib.timelib.dt2doy(dt)[source]

Convert datetime to integer DOY (Julian)

pygeotools.lib.timelib.dt2jd(dt)[source]

Convert datetime to julian date

pygeotools.lib.timelib.dt2mat(dt)[source]

Convert Python datetime to Matlab ordinal

pygeotools.lib.timelib.dt2o(dt)[source]

Convert datetime to Python ordinal

pygeotools.lib.timelib.dt_check(dt)[source]
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.dt_ptp(dt_list)[source]
pygeotools.lib.timelib.dt_range(dt1, dt2, interval)[source]
pygeotools.lib.timelib.filter_fn_list(dt, fn_list, pad)[source]
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(fn)[source]

Extract datetime from input filename

pygeotools.lib.timelib.fn_getdatetime_list(fn)[source]

Extract all datetime strings from input filename

pygeotools.lib.timelib.gen_ts_fn(fn, dt_ref=None, ma=False)[source]
pygeotools.lib.timelib.getLocalTime(utc_dt, tz)[source]

Return local timezone time

pygeotools.lib.timelib.getTimeZone(lat, lon)[source]

Get timezone for a given lat/lon

pygeotools.lib.timelib.get_closest_dt_fn(fn, fn_list)[source]
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_bounds(dt_list, min_rel_dt=(1, 1), max_rel_dt=(12, 31))[source]
pygeotools.lib.timelib.get_dt_bounds_fn(list_fn, min_rel_dt=(5, 31), max_rel_dt=(6, 1))[source]
pygeotools.lib.timelib.get_dt_bounds_monthyear(dt_list)[source]
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.get_t_factor_fn(fn1, fn2, ds=None)[source]
pygeotools.lib.timelib.get_unique_monthyear(dt_list)[source]
pygeotools.lib.timelib.get_unique_years(dt_list)[source]
pygeotools.lib.timelib.gps2dt(gps_week, gps_ms)[source]

Convert GPS week and ms to a datetime

pygeotools.lib.timelib.jd2dt(jd)[source]

Convert julian date to datetime

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.mean_date(dt_list)[source]

Calcuate mean datetime from datetime list

pygeotools.lib.timelib.median_date(dt_list)[source]

Calcuate median datetime from datetime list

pygeotools.lib.timelib.mid_date(dt_list)[source]
pygeotools.lib.timelib.o2dt(o)[source]

Convert Python ordinal to datetime

pygeotools.lib.timelib.print_dt(dt)[source]
pygeotools.lib.timelib.rel_dt_list_idx(dt_list, min_rel_dt=(1, 1), max_rel_dt=(12, 31))[source]
pygeotools.lib.timelib.rel_dt_test(dt, min_rel_dt=(1, 1), max_rel_dt=(12, 31))[source]
pygeotools.lib.timelib.round_dt(dt)[source]
pygeotools.lib.timelib.seconds2timedelta(s)[source]
pygeotools.lib.timelib.sinceEpoch(dt)[source]
pygeotools.lib.timelib.solarTime(utc_dt, lat, lon)[source]

Compute local solar time for given (lat, lon)

pygeotools.lib.timelib.sort_fn_list(fn_list)[source]

Sort input filename list by datetime

pygeotools.lib.timelib.strptime_fuzzy(s)[source]

Fuzzy date string parsing

Note: this returns current date if not found. If only year is provided, will return current month, day

pygeotools.lib.timelib.timedelta2decdays(d)[source]
pygeotools.lib.timelib.timedelta2decyear(d)[source]
pygeotools.lib.timelib.timedelta_div(t, d)[source]
pygeotools.lib.timelib.tsx_cdate(t1)[source]
pygeotools.lib.timelib.tsx_cdate_print(t1)[source]
pygeotools.lib.timelib.tsx_orbit2dt(orbits)[source]
pygeotools.lib.timelib.ul_time(utc_dt, lon)[source]

Compute local time for input longitude

pygeotools.lib.timelib.uniq_days_dt(dt_list)[source]
pygeotools.lib.timelib.uniq_days_o(dt_list)[source]