Single Dish Radio Astronomy Software Tools

For an overview of SDRAST and the current status please visit https://sdrast.github.io/.

DatesTimes Package

Supporting functions for Date and Time

Date and Time Formats

VSR time tuples

The are of the form:

(YYYY,DDD,sssss)

where the latter is seconds since midnight.

VSR filename time strings

Used in the output files, these are text strings of the form:

YYYY DDD ssssss

where the latter is seconds since midnight.

VSR script time stamps

used in filenames are of the form:

DDD/HH:MM:SS

ISO timestamps

These are of the form:

YYYYMMDDTHHMMSS      or
YYYY-MM-DDTHH:MM:SS.

We’ve extended this to include:

YYYY-DDDTHH:MM(:SS) and
YYYYDDDTHHMM.

Python times

take these forms:

datetime.datetime object
   datetime.datetime(2015, 12, 19, 10, 29, 29, 198776)
time.time (float)
   1450729528.987735
time.struct_time
   time.struct_time(tm_year=2015, tm_mon=12, tm_mday=21,
                    tm_hour=20, m_min=23, tm_sec=18,
                    tm_wday=0, tm_yday=355, tm_isdst=0)
datetime ordinal (int)
   735951
matplotlib datetime (float)
   735953.5172106482

UNIX (System) Time

Number of seconds since 1970/01/01 00:00:00 UT. Example:

In [10]: time.gmtime(0)
Out[10]: time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1,
                         tm_hour=0, tm_min=0, tm_sec=0,
                         tm_wday=3, tm_yday=1, tm_isdst=0)

Julian Date and Modified Julian Date

Julian Date is number of days since -4713:11:24 12:00:00 UT Example:

In [11]: julian_date(-4713,328.5)
Out[11]: 0.0
In [12]: calendar_date(-4713,328)
Out[12]: (-4713, 11, 24)
Modified Julian Date is::
  • Julian date - 2400000.5

  • number of days since 1858/11/17 00:00:00 UT.

  • 40587 + unixtime/(24*60*60)

Example:

In [13]: julian_date(1858,day_of_year(1858,11,17))
Out[13]: 2400000.5
In [14]: MJD(1858,11,17)
Out[14]: 0
In [15]: MJD(1970,1,1)
Out[15]: 40587

IAU position based names

These take the forms:

Jhhmm+ddmm
Bhhmm+ddmm
Gddd.d+dd.d

Functions

ISO times

Methods to convert to and from ISO times:

format_ISO_time(year,doy,timestr)
ISOtime2datetime(ISOtime):

VSR Times

To and from various VSR time formats:

incr_VSR_timestamp(timestr)  incr_VSR_timestring(timestr)
make_VSR_timestring()
VSR_to_datetime(VSR_time_tuple)
VSR_to_timetuple(VSR_tuple)
VSR_timestring_to_ISOtime(timestr)
VSR_script_time(doy,h,m,s)
VSR_script_time_to_timestamp(year,string)
VSR_tuple_to_MPL(year,doy,seconds)
VSR_tuple_to_datetime(year,doy,start_sec)
VSR_tuple_to_timestamp(year,doy,start_sec)
VSR_timestamp()

Time strings

Various functions to convert to and from time strings:

DDDMM_to_dec_deg(DDDMM)
HHMM_to_timetuple(time_string)
HHMM_to_dec_deg(HHMM)
HHMMSS_to_seconds(string)
make_date_string(date_tuple)
timetuple_to_HHMM(time)
YYYYDDD_datecode(year, midfix, doy)

Miscellaneous

Various useful functions:

datetime_to_UnixTime(t)
deg_to_IAU_str(position,format="h")
format_now()
get_current_week()
get_date()
logtime_to_timetuple(time_string)
macro_log_time_to_UnixTime(year,timestr)
mpldate2doy(mpldate)
MPLtime_to_UnixTime(MPLtime)
now_string()
parse_date(ses_date)
seconds(timedelta)
time_int_to_decimal(time)
timestamp_to_str_with_ms(TS)
timetuple_to_datetime(timetuple)
UnixTime_to_datetime(UnixTimeStamp)
UnixTime_to_MPL(UnixTimeStamp)
week_number(year,doy)
MJD_to_UnixTime(MJD)

Functions

DDDMM_to_dec_deg(DDDMM)

Converts a strin DDDMM to decimal degrees.

HHMMSS_to_seconds(string)

Converts a colon-separated time string (HH:MM:SS) to seconds since midnight

HHMM_to_dec_deg(HHMM)

Converts a string HHMM to decimal hours.

HHMM_to_timetuple(time_string)

This converts a time string of the form used in DSN schedules (HHMM) to a time tuple (h,m).

ISOtime2datetime(ISOtime)

Converts an ISO string to a datetime object

MJD(*args)

Returns modified Julian date from UNIX time or (year,doy) or (year,month,day)

MJD_to_UnixTime(MJD)

Converts MJD time to UNIX time

MPLtime_to_UnixTime(MPLtime)

Converts an MPL time to a UNIX time stamp

UnixTime_to_MJD(UnixTime)

Convert UnixTime to fractional MJD

UnixTime_to_MPL(UnixTime)

Converts a UNIX time stamp (seconds since the epoch) to matplotlib date/time.

UnixTime_to_datetime(UnixTimeStamp)

Converts a UNIX time stamp to a Python datetime object

VSR_script_time(doy, h, m, s)

This creates a timestamp such as VSR script files use.

VSR_script_time_to_timestamp(year, string)

Converts a VSR time string like 123/12:34:45 to a UNIX time stamp.

VSR_timestamp()

Alias for make_VSR_timestring, for backwards compatibility

VSR_timestring_to_ISOtime(timestr)

Formats a VSR time string as YYYYMMDDTHHMMSS.

VSR_to_datetime(VSR_time_tuple)

Converts a VSR time tuple to a datetime object.

VSR_to_timetuple(VSR_tuple)

Converts a VSR time tuple to a Python time tuple.

VSR_tuple_to_MPL(year, doy, seconds)

Converts a VSR time tuple to a matplotlib date/time float.

VSR_tuple_to_datetime(year, doy, start_sec)

Converts VSR time specification toa datetime object.

VSR_tuple_to_timestamp(year, doy, start_sec)

Converts a VSR time specification to a UNIX time stamp.

WVSR_script_time_to_timestamp(yrdoystr, timestr)

Converts a VSR time string like 16/237 08:45:01 to a UNIX time stamp.

YYYYDDD_datecode(year, midfix, doy)

Format the datecode pattern used in many log files.

calendar_date(year, doy)

Calendar date from day of year

datetime_to_UnixTime(t)

Converts a Python datetime object to a UNIX timestamp.

day_of_week(doy, year)

Numeric value for the day of week

day_of_year(year, month, day)

Day of year

deg_to_IAU_str(position[, format])

The position is a longitude-like, latitude-like tuple.

format_ISO_time(year, doy, timestr)

Format an ISO-like time string: YYYY-DDDTHH:MM

format_now()

Return the current time as a formatted string:

get_current_week()

get_date()

This gets a date string of the form YYY-MM-DD from the command line or requests it from the user.

incr_VSR_timestamp(timestr)

Alias for inc_VSR_timestring for backwards compatibility

incr_VSR_timestring(timestr)

Increments a VSR timestamp.

julian_date(year, doy)

Julian date

leap_year(year)

Leap year

logtime_to_timetuple(time_string)

This converts a time string of the form used in EAC and RAC logs (HH:MM:SS) to a time tuple (h,m,s).

macro_log_time_to_UnixTime(year, timestr)

Given a time string DDD_HH:MM:SS it returns the UNIX timestamp

make_VSR_timestring()

Creates a time string for the current time in the format that the VSR uses: ‘YYYY DDD SSSSS’.

make_date_string(date_tuple)

Accepts a date tuple (year,month,day) and returns a formatted string of the form YYYY-MM-DD.

mpldate2doy(mpldate)

get day of year from matplotlib date number

now_string()

Current minute formatted as YYYY/DDD-HHMM

num2date(MPLtime)

Replacement for matplotlib.dates function

parse_date(ses_date)

This parses a date string of the form YYYY-MM-DD and returns the string, year, month, day and day of year.

seconds(timedelta[, unit])

Computes the length of a datetime interval to specified units

time_int_to_decimal(time)

Takes a number of the form HHMMSS or +/-DDMMSS and converts it to a decimal.

timestamp_to_str_with_ms(TS)

Converts a UNIX time.time float to a date time string with milliseconds.

timetuple_to_HHMM(time)

Converts a time in time() format, seconds since the epoch, to an HHMM string.

timetuple_to_datetime(timetuple)

Converts a timetuple (y,mo,d,h,mi,s) to a datetime object.

week_number(year, doy)

Computes the week number given the year and day of year.

Classes

ST

This subclass of tzinfo defines standard time in the current timezone

UTC

This subclass of tzinfo defines UTC

Indices and tables