Bases: TimeBase
Represent and manipulate times and dates for astronomy.
A Time
object is initialized with one or more times in the val
argument. The input times in val
must conform to the specified format
and must correspond to the specified time scale
. The optional val2
time input should be supplied only for numeric input formats (e.g. JD) where very high precision (better than 64-bit precision) is required.
The allowed values for format
can be listed with:
>>> list(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']
See also: http://docs.astropy.org/en/stable/time/
ndarray
, number, str
, bytes
, or Time
object
Value(s) to initialize the time or times. Bytes are decoded as ascii.
ndarray
, or number; optional
Value(s) to initialize the time or times. Only used for numerical input, to help preserve precision.
str
, optional
Format of input value(s), specifying how to interpret them (e.g., ISO, JD, or Unix time). By default, the same format will be used for output representation.
str
, optional
Time scale of input value(s), must be one of the following: (‘tai’, ‘tcb’, ‘tcg’, ‘tdb’, ‘tt’, ‘ut1’, ‘utc’)
int
, optional
Digits of precision in string representation of time
str
, optional
Unix glob to select subformats for parsing input times
str
, optional
Unix glob to select subformat for outputting times
EarthLocation
or tuple
, optional
If given as an tuple, it should be able to initialize an an EarthLocation instance, i.e., either contain 3 items with units of length for geocentric coordinates, or contain a longitude, latitude, and an optional height for geodetic coordinates. Can be a single location, or one for each input time. If not given, assumed to be the center of the Earth for time scale transformations to and from the solar-system barycenter.
Make a copy of the input values
Attributes Summary
Methods Summary
Attributes Documentation
Dict of time formats
List of time scales
Return an instance with the data transposed.
Parameters are as for T
. All internal data are views of the data of the original.
Return the cache associated with this instance.
TDB - TT time scale offset
UT1 - UTC time scale offset
Get or set time format.
The format defines the way times are represented when accessed via the .value
attribute. By default it is the same as the format used for initializing the Time
instance, but it can be set to any other value that could be used for initialization. These can be listed with:
>>> list(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']
Unix wildcard pattern to select subformats for parsing string input times.
Container for meta information like name, description, format. This is required when the object is used as a mixin column within a table, but can be used as a general way to store meta information.
First of the two doubles that internally store time value(s) in JD.
Second of the two doubles that internally store time value(s) in JD.
The number of dimensions of the instance and underlying arrays.
Unix wildcard pattern to select subformats for outputting times.
Decimal precision when outputting seconds as floating point (int value between 0 and 9 inclusive).
Time scale.
The shape of the time instances.
Like shape
, can be set to a new shape by assigning a tuple. Note that if different instances share some but not all underlying data, setting the shape of one instance can make the other instance unusable. Hence, it is strongly recommended to get new, reshaped instances with the reshape
method.
ValueError
If the new shape has the wrong total number of elements.
AttributeError
If the shape of the jd1
, jd2
, location
, delta_ut1_utc
, or delta_tdb_tt
attributes cannot be changed without the arrays being copied. For these cases, use the Time.reshape
method (which copies any arrays that cannot be reshaped in-place).
The size of the object, as calculated from its shape.
Get an instance without the mask.
Note that while one gets a new instance, the underlying data will be shared.
See also
filled
get a copy of the underlying data, with masked values filled in.
Time value(s) in current format.
Methods Documentation
Return indices of the maximum values along the given axis.
This is similar to argmax()
, but adapted to ensure that the full precision given by the two doubles jd1
and jd2
is used. See argmax()
for detailed documentation.
Return indices of the minimum values along the given axis.
This is similar to argmin()
, but adapted to ensure that the full precision given by the two doubles jd1
and jd2
is used. See argmin()
for detailed documentation.
Returns the indices that would sort the time array.
This is similar to argsort()
, but adapted to ensure that the full precision given by the two doubles jd1
and jd2
is used, and that corresponding attributes are copied. Internally, it uses lexsort()
, and hence no sort method can be chosen.
int
, optional
Axis along which to sort. Default is -1, which means sort along the last axis.
Sorting is done with lexsort()
so this argument is ignored, but kept for compatibility with argsort()
. The sorting is stable, meaning that the order of equal elements is preserved.
ndarray
An array of indices that sort the time array.
Return a fully independent copy the Time object, optionally changing the format.
If format
is supplied then the time format of the returned Time object will be set accordingly, otherwise it will be unchanged from the original.
In this method a full copy of the internal time arrays will be made. The internal time arrays are normally not changeable by the user so in most cases the replicate()
method should be used.
str
, optional
Time format of the copy.
Time
object
Copy of this object
Return an instance with the specified diagonals.
Parameters are as for diagonal()
. All internal data are views of the data of the original.
Calculate local Earth rotation angle.
Quantity
, EarthLocation
, str
, or None; optional
The longitude on the Earth at which to compute the Earth rotation angle (taken from a location as needed). If None
(default), taken from the location
attribute of the Time instance. If the special string ‘tio’, the result will be relative to the Terrestrial Intermediate Origin (TIO) (i.e., the output of era00
).
Longitude
Local Earth rotation angle with units of hourangle.
Notes
The difference between apparent sidereal time and Earth rotation angle is the equation of the origins, which is the angle between the Celestial Intermediate Origin (CIO) and the equinox. Applying apparent sidereal time to the hour angle yields the true apparent Right Ascension with respect to the equinox, while applying the Earth rotation angle yields the intermediate (CIRS) Right Ascension with respect to the CIO.
The result includes the TIO locator (s’), which positions the Terrestrial Intermediate Origin on the equator of the Celestial Intermediate Pole (CIP) and is rigorously corrected for polar motion. (except when longitude='tio'
).
References
IAU 2006 NFA Glossary (currently located at: https://syrte.obspm.fr/iauWGnfa/NFA_Glossary.html)
Get a copy of the underlying data, with masked values filled in.
object
Value to replace masked values with.
Copy of self
with masked items replaced by fill_value
.
See also
unmasked
get an instance without the mask.
Return a copy with the array collapsed into one dimension.
Parameters are as for flatten()
.
Find UT1 - UTC differences by interpolating in IERS Table.
IERS
, optional
Table containing UT1-UTC differences from IERS Bulletins A and/or B. Default: earth_orientation_table
(which in turn defaults to the combined version provided by IERS_Auto
).
Whether to return status values. If False
(default), iers raises IndexError
if any time is out of the range covered by the IERS table.
float
or float
array
UT1-UTC, interpolated in IERS Table
int
or int
array
Status values (if return_status=`True`
):: astropy.utils.iers.FROM_IERS_B
astropy.utils.iers.FROM_IERS_A
astropy.utils.iers.FROM_IERS_A_PREDICTION
astropy.utils.iers.TIME_BEFORE_IERS_RANGE
astropy.utils.iers.TIME_BEYOND_IERS_RANGE
Notes
In normal usage, UT1-UTC differences are calculated automatically on the first instance ut1 is needed.
Examples
To check in code whether any times are before the IERS table range:
>>> from astropy.utils.iers import TIME_BEFORE_IERS_RANGE >>> t = Time(['1961-01-01', '2000-01-01'], scale='utc') >>> delta, status = t.get_delta_ut1_utc(return_status=True) >>> status == TIME_BEFORE_IERS_RANGE array([ True, False]...)
Insert values before the given indices in the column and return a new Time
or TimeDelta
object.
The values to be inserted must conform to the rules for in-place setting of Time
objects (see Get and set values
in the Time
documentation).
The API signature matches the np.insert
API, but is more limited. The specification of insert index obj
must be a single integer, and the axis
must be 0
for simple row insertion before the index.
int
Integer index before which values
is inserted.
Value(s) to insert. If the type of values
is different from that of quantity, values
is converted to the matching type.
int
, optional
Axis along which to insert values
. Default is 0, which is the only allowed value and will insert a row.
Time
subclass
New time object with inserted value(s)
Returns a boolean or boolean array where two Time objects are element-wise equal within a time tolerance.
This evaluates the expression below:
abs(self - other) <= atol
Time
Time object for comparison.
Quantity
or TimeDelta
Absolute tolerance for equality with units of time (e.g. u.s
or u.day
). Default is two bits in the 128-bit JD time representation, equivalent to about 40 picosecs.
Light travel time correction to the barycentre or heliocentre.
The frame transformations used to calculate the location of the solar system barycentre and the heliocentre rely on the erfa routine epv00, which is consistent with the JPL DE405 ephemeris to an accuracy of 11.2 km, corresponding to a light travel time of 4 microseconds.
The routine assumes the source(s) are at large distance, i.e., neglects finite-distance effects.
SkyCoord
The sky location to calculate the correction for.
str
, optional
'barycentric'
(default) or 'heliocentric'
EarthLocation
, optional
The location of the observatory to calculate the correction for. If no location is given, the location
attribute of the Time object is used
str
, optional
Solar system ephemeris to use (e.g., ‘builtin’, ‘jpl’). By default, use the one set with astropy.coordinates.solar_system_ephemeris.set
. For more information, see solar_system_ephemeris
.
TimeDelta
The time offset between the barycentre or Heliocentre and Earth, in TDB seconds. Should be added to the original time to get the time in the Solar system barycentre or the Heliocentre. Also, the time conversion to BJD will then include the relativistic correction as well.
Maximum along a given axis.
This is similar to max()
, but adapted to ensure that the full precision given by the two doubles jd1
and jd2
is used, and that corresponding attributes are copied.
Note that the out
argument is present only for compatibility with np.max
; since Time
instances are immutable, it is not possible to have an actual out
to store the result in.
Mean along a given axis.
This is similar to mean()
, but adapted to ensure that the full precision given by the two doubles jd1
and jd2
is used, and that corresponding attributes are copied.
Note that the out
argument is present only for compatibility with np.mean
; since Time
instances are immutable, it is not possible to have an actual out
to store the result in.
Similarly, the dtype
argument is also present for compatibility only; it has no meaning for Time
.
None
or int
or tuple
of int
, optional
Axis or axes along which the means are computed. The default is to compute the mean of the flattened array.
None
None
If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
Elements to include in the mean. See reduce
for details.
Time
A new Time instance containing the mean values
Minimum along a given axis.
This is similar to min()
, but adapted to ensure that the full precision given by the two doubles jd1
and jd2
is used, and that corresponding attributes are copied.
Note that the out
argument is present only for compatibility with np.min
; since Time
instances are immutable, it is not possible to have an actual out
to store the result in.
Creates a new object corresponding to the instant in time this method is called.
Note
“Now” is determined using the now
function, so its accuracy and precision is determined by that function. Generally that means it is set by the accuracy of your system clock. The timezone is set to UTC.
Deprecated since version 7.0: The ptp function is deprecated and may be removed in a future version. Use np.ptp instead.
Peak to peak (maximum - minimum) along a given axis.
This method is similar to the numpy.ptp()
function, but adapted to ensure that the full precision given by the two doubles jd1
and jd2
is used.
Note that the out
argument is present only for compatibility with ptp
; since Time
instances are immutable, it is not possible to have an actual out
to store the result in.
Return an instance with the array collapsed into one dimension.
Parameters are as for ravel()
. Note that it is not always possible to unravel an array without copying the data. If you want an error to be raise if the data is copied, you should should assign shape (-1,)
to the shape attribute.
Return a replica of the Time object, optionally changing the format.
If format
is supplied then the time format of the returned Time object will be set accordingly, otherwise it will be unchanged from the original.
If copy
is set to True
then a full copy of the internal time arrays will be made. By default the replica will use a reference to the original arrays when possible to save memory. The internal time arrays are normally not changeable by the user so in most cases it should not be necessary to set copy
to True
.
The convenience method copy() is available in which copy
is True
by default.
str
, optional
Time format of the replica.
Return a true copy instead of using references where possible.
Time
object
Replica of this object
Returns an instance containing the same data with a new shape.
Parameters are as for reshape()
. Note that it is not always possible to change the shape of an array without copying the data (see reshape()
documentation). If you want an error to be raise if the data is copied, you should assign the new shape to the shape attribute (note: this may not be implemented for all classes using NDArrayShapeMethods
).
Calculate sidereal time.
str
'mean'
or 'apparent'
, i.e., accounting for precession only, or also for nutation.
Quantity
, EarthLocation
, str
, or None; optional
The longitude on the Earth at which to compute the Earth rotation angle (taken from a location as needed). If None
(default), taken from the location
attribute of the Time instance. If the special string ‘greenwich’ or ‘tio’, the result will be relative to longitude 0 for models before 2000, and relative to the Terrestrial Intermediate Origin (TIO) for later ones (i.e., the output of the relevant ERFA function that calculates greenwich sidereal time).
str
or None; optional
Precession (and nutation) model to use. The available ones are: - apparent: [‘IAU1994’, ‘IAU2000A’, ‘IAU2000B’, ‘IAU2006A’] - mean: [‘IAU1982’, ‘IAU2000’, ‘IAU2006’] If None
(default), the last (most recent) one from the appropriate list above is used.
Longitude
Local sidereal time, with units of hourangle.
Notes
The difference between apparent sidereal time and Earth rotation angle is the equation of the origins, which is the angle between the Celestial Intermediate Origin (CIO) and the equinox. Applying apparent sidereal time to the hour angle yields the true apparent Right Ascension with respect to the equinox, while applying the Earth rotation angle yields the intermediate (CIRS) Right Ascension with respect to the CIO.
For the IAU precession models from 2000 onwards, the result includes the TIO locator (s’), which positions the Terrestrial Intermediate Origin on the equator of the Celestial Intermediate Pole (CIP) and is rigorously corrected for polar motion (except when longitude='tio'
or 'greenwich'
).
References
IAU 2006 NFA Glossary (currently located at: https://syrte.obspm.fr/iauWGnfa/NFA_Glossary.html)
Return a copy sorted along the specified axis.
This is similar to sort()
, but internally uses indexing with lexsort()
to ensure that the full precision given by the two doubles jd1
and jd2
is kept, and that corresponding attributes are properly sorted and copied as well.
int
or None
Axis to be sorted. If None
, the flattened array is sorted. By default, sort over the last axis.
Return an instance with single-dimensional shape entries removed.
Parameters are as for squeeze()
. All internal data are views of the data of the original.
Convert Time to a string or a numpy.array of strings according to a format specification. See time.strftime
documentation for format specification.
str
Format definition of return string.
str
or numpy.array
String or numpy.array of strings formatted according to the given format string.
Parse a string to a Time according to a format specification. See time.strptime
documentation for format specification.
>>> Time.strptime('2012-Jun-30 23:59:60', '%Y-%b-%d %H:%M:%S') <Time object: scale='utc' format='isot' value=2012-06-30T23:59:60.000>
str
, sequence, or ndarray
Objects containing time data of type string
str
String specifying format of time_string.
dict
Any keyword arguments for Time
. If the format
keyword argument is present, this will be used as the Time format.
Time
A new Time
object corresponding to the input time_string
.
Return an instance with the given axes interchanged.
Parameters are as for swapaxes()
: axis1, axis2
. All internal data are views of the data of the original.
Return a new instance formed from the elements at the given indices.
Parameters are as for take()
, except that, obviously, no output array can be given.
Convert to (potentially timezone-aware) datetime
object.
If timezone
is not None
, return a timezone-aware datetime object.
Since the datetime
class does not natively handle leap seconds, the behavior when converting a time within a leap second is controlled by the leap_second_strict
argument. For example:
>>> from astropy.time import Time >>> t = Time("2015-06-30 23:59:60.500") >>> print(t.to_datetime(leap_second_strict='silent')) 2015-07-01 00:00:00.500000
tzinfo
, None
}, optional
If not None
, return timezone-aware datetime.
str
, optional
If raise
(default), raise an exception if the time is within a leap second. If warn
then issue a warning. If silent
then silently handle the leap second.
datetime
If timezone
is not None
, output will be timezone-aware.
Output a string representation of the Time or TimeDelta object.
Similar to str(self.value)
(which uses numpy array formatting) but array values are evaluated only for the items that actually are output. For large arrays this can be a substantial performance improvement.
str
String representation of the time values.
Get time values expressed in specified output format.
This method allows representing the Time
object in the desired output format
and optional sub-format subfmt
. Available built-in formats include jd
, mjd
, iso
, and so forth. Each format can have its own sub-formats
For built-in numerical formats like jd
or unix
, subfmt
can be one of ‘float’, ‘long’, ‘decimal’, ‘str’, or ‘bytes’. Here, ‘long’ uses numpy.longdouble
for somewhat enhanced precision (with the enhancement depending on platform), and ‘decimal’ decimal.Decimal
for full precision. For ‘str’ and ‘bytes’, the number of digits is also chosen such that time values are represented accurately.
For built-in date-like string formats, one of ‘date_hms’, ‘date_hm’, or ‘date’ (or ‘longdate_hms’, etc., for 5-digit years in TimeFITS
). For sub-formats including seconds, the number of digits used for the fractional seconds is as set by precision
.
str
The format in which one wants the time values. Default: the current format.
str
or None
, optional
Value or wildcard pattern to select the sub-format in which the values should be given. The default of ‘*’ picks the first available for a given format, i.e., ‘float’ or ‘date_hms’. If None
, use the instance’s out_subfmt
.
Return an instance with the data transposed.
Parameters are as for transpose()
. All internal data are views of the data of the original.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4