parse_time#
- sunpy.time.parse_time(time_string, *, format=None, **kwargs)[source]#
Takes a time input and will parse and return a
astropy.time.Time
.- Parameters:
time_string (
tuple
,list
,str
,pandas.Timestamp
,pandas.Series
,pandas.DatetimeIndex
,datetime.datetime
,datetime.date
,numpy.datetime64
,numpy.ndarray
,astropy.time.Time
) – Time to parse.format (
str
, optional) – Specifies the format user has provided the time_string in. We support the same formats asastropy.time.Time
, which are:>>> list(astropy.time.Time.FORMATS) ['jd', 'mjd', 'decimalyear', 'unix', 'unix_tai', 'cxcsec', 'gps', 'plot_date', 'stardate', 'datetime', 'ymdhms', 'iso', 'isot', 'yday', 'datetime64', 'fits', 'byear', 'jyear', 'byear_str', 'jyear_str', 'utime', 'tai_seconds']
**kwargs – Additional keyword arguments are passed to
astropy.time.Time
- Returns:
astropy.time.Time
–Time
corresponding to input time string.
Examples
>>> import sunpy.time >>> sunpy.time.parse_time('2012/08/01') <Time object: scale='utc' format='isot' value=2012-08-01T00:00:00.000> >>> sunpy.time.parse_time('2016.05.04_21:08:12_TAI') <Time object: scale='tai' format='isot' value=2016-05-04T21:08:12.000>
Notes
Additional keyword arguments can be passed to
astropy.time.Time
The list of time formats are show by the following examples:
2017-01-01T11:10:09.000000 2017/01/01T11:10:09.000000 2017-01-01T11:10:09.000000Z 2017-01-01T11:10:09 2017/01/01T11:10:09 20170101T111009.000000 20170101T111009 2017/01/01 11:10:09 2017/01/01 11:10 2017/01/01 11:10:09.000000 2017-01-01 11:10:09.000000 2017-01-01 11:10:09 2017-01-01 11:10 2017-Jan-01 11:10:09.000000 2017-Jan-01 11:10:09 2017-Jan-01 11:10 2017-Jan-01 2017-01-01 2017/01/01 01-Jan-2017 01-Jan-2017 11:10:09 01-Jan-2017 11:10:09.000000 20170101_111009 2017:001:11:10:09 2017:001:11:10:09.000000 20170101111009 2017.01.01_11:10:09_TAI 2017.01.01_11:10:09.000000_TAI 2017.01.01_11:10:09_UTC 2017.01.01_11:10:09 2017/01/01T11:10