l3py.time

” Convenience functions for Python datetime objects

time.date_iterator(stop, step)

Generator for a sequence of datetime objects.

To be consistent with Python ranges, the last epoch generated will be strictly less than stop.

Parameters:
  • start (datetime object) – first epoch
  • stop (datetime object) – upper bound of datetime sequence, last epoch will be strictly less than stop
  • step (timedelta object) – step size of sequence (negative steps are allowed)
Returns:

g – Generator for datetime objects

Return type:

Generator object

time.datetime()

Convert MJD to datetime.datetime object

Parameters:mjd (float) – datetime.datetime object expressed in modified julian date
Returns:dtime – datetime.datetime object
Return type:datetime.datetime
time.day_iterator(stop, use_middle=False)

Generator for a daily sequence of datetime objects.

To be consistent with Python ranges, the last epoch generated will be strictly less than stop.

Parameters:
  • start (datetime object) – epoch from which the first day will be generated
  • stop (datetime object) – epoch from which the last day will be generated (last month will be strictly less than stop)
  • use_middle (bool) – If True, the midpoint of each day (12:00) will be returned, otherwise 00:00 used (default: False)
Returns:

g – Generator for monthly datetime objects

Return type:

Generator object

time.decyear2mjd()

Convert decimal year to MJD.

Parameters:dy (float) – epoch as decimal year
Returns:mjd – epoch as MJD
Return type:float
time.gpsweekday()

Compute GPS week and day in week from datetime object

Parameters:dt (datetime.datetime) – epoch as datetime object
Returns:
  • week (int) – GPS week
  • days (int) – day in GPS week
time.gpsweekday2datetime(day)

Convert GPS week and day in week to datetime object.

Parameters:
  • week (int) – GPS week
  • days (int) – day in GPS week
Returns:

dt – epoch as datetime objec

Return type:

datetime.datetime

time.gpsweekseconds()

Compute GPS week and seconds in week from datetime object

Parameters:dt (datetime.datetime) – epoch as datetime object
Returns:
  • week (int) – GPS week
  • seconds (float) – seconds in GPS week
time.mjd()

Convert datetime.datetime object to MJD.

Parameters:dtime (datetime.datetime) – datetime.datetime object
Returns:mjd – datetime.datetime object expressed in modified julian date
Return type:float
time.mjd2decyear()

Convert MJD to decimal year.

Parameters:mjd (float) – epoch as MJD
Returns:dy – epoch as decimal year
Return type:float
time.month_iterator(stop, use_middle=False)

Generator for a monthly sequence of datetime objects.

To be consistent with Python ranges, the last epoch generated will be strictly less than stop.

Parameters:
  • start (datetime object) – epoch from which the first month will be generated
  • stop (datetime object) – epoch from which the last month will be generated (last month will be strictly less than stop)
  • use_middle (bool) – If True, the midpoint of each month will be returned, otherwise the first of each month is used (default: False)
Returns:

g – Generator for monthly datetime objects

Return type:

Generator object