pyacs.lib.astrotime.guess_date

Guess a date from input (string or float) and return decimal year.

pyacs.lib.astrotime.guess_date.guess_date(date)[source]

Guess a date from input (string or float) and return decimal year.

Parameters:

date (str or float) – Date as string (e.g. ‘2016/04/16’, ‘2016 107’, ‘57500.0’) or float (MJD or decimal year).

Returns:

Decimal year.

Return type:

float

Examples

Calendar date formats (year/month/day or day/month/year): >>> import pyacs >>> pyacs.guess_date(‘2016/04/16’) 2016.2909836065573 >>> pyacs.guess_date(‘2016-04-16’) 2016.2909836065573

Day of year format (year doy or doy year): >>> pyacs.guess_date(‘2016 107’) 2016.2909836065573 >>> pyacs.guess_date(‘107 2016’) 2016.2909836065573

Decimal year format: >>> pyacs.guess_date(‘2016.29’) 2016.29 >>> pyacs.guess_date(2016.29) 2016.29

MJD (Modified Julian Date) format: >>> pyacs.guess_date(‘57500.0’) 2016.2909836065573 >>> pyacs.guess_date(57500.0) 2016.2909836065573