TimeMapAxis#
- class gammapy.maps.TimeMapAxis(edges_min, edges_max, reference_time, name='time', interp='lin')[source]#
Bases:
object
Class representing a time axis.
Provides methods for transforming to/from axis and pixel coordinates. A time axis can represent non-contiguous sequences of non-overlapping time intervals.
Time intervals must be provided in increasing order.
- Parameters
- edges_min
Quantity
Array of edge time values. This the time delta w.r.t. to the reference time.
- edges_max
Quantity
Array of edge time values. This the time delta w.r.t. to the reference time.
- reference_time
Time
Reference time to use.
- namestr
Axis name
- interpstr
Interpolation method used to transform between axis and pixel coordinates. For now only ‘lin’ is supported.
- edges_min
Attributes Summary
Plot center
Plot edges
Plot labels
Plot x error
Return time interval width (
Quantity
).Bounds of the axis (~astropy.units.Quantity)
Return
Quantity
at interval centers.Return array of bin edges values.
Return array of bin edges min values.
Return array of bin edges max values.
Interp
Whether the axis is contiguous
Iterate by intervals defined by the edges
Return axis name.
Return number of bins in the axis.
Return reference time used for the axis.
Bounds of the axis (~astropy.units.Quantity)
Return axis time bin width (
TimeDelta
).Time edges
Return axis upper edges as Time objects.
Return time bin center (
Time
).Return axis lower edges as Time objects.
Axes unit
Methods Summary
assert_name
(required_name)Assert axis name if a specific one is required.
coord_to_idx
(coord, **kwargs)Transform from axis time coordinate to bin index.
coord_to_pix
(coord, **kwargs)Transform from time to coordinate to pixel position.
copy
(**kwargs)Copy
MapAxis
instance and overwrite given attributes.Format plot axis
from_gti
(gti[, name])Create a time axis from an input GTI.
from_gti_bounds
(gti, t_delta[, name])Create a time axis from an input GTI.
from_table
(table[, format, idx])Create time map axis from table
from_time_bounds
(time_min, time_max, nbin[, ...])Create linearly spaced time axis from bounds
from_time_edges
(time_min, time_max[, unit, ...])Create TimeMapAxis from the time interval edges defined as
Time
.is_aligned
(other[, atol])is_allclose
(other, **kwargs)Check if other map axis is all close.
pix_to_idx
(pix[, clip])slice
(idx)Create a new axis object by extracting a slice from this axis.
squash
()Create a new axis object by squashing the axis into one bin.
Make the time axis contiguous
to_header
([format, idx])Create FITS header
upsample
()Attributes Documentation
- as_plot_center#
Plot center
- as_plot_edges#
Plot edges
- as_plot_labels#
Plot labels
- as_plot_xerr#
Plot x error
- bounds#
Bounds of the axis (~astropy.units.Quantity)
- edges#
Return array of bin edges values.
- edges_max#
Return array of bin edges min values.
- edges_min#
Return array of bin edges max values.
- interp#
Interp
- is_contiguous#
Whether the axis is contiguous
- iter_by_edges#
Iterate by intervals defined by the edges
- name#
Return axis name.
- nbin#
Return number of bins in the axis.
- node_type = 'intervals'#
- reference_time#
Return reference time used for the axis.
- time_bounds#
Bounds of the axis (~astropy.units.Quantity)
- time_edges#
Time edges
- time_format = 'iso'#
- time_max#
Return axis upper edges as Time objects.
- time_min#
Return axis lower edges as Time objects.
- unit#
Axes unit
Methods Documentation
- assert_name(required_name)[source]#
Assert axis name if a specific one is required.
- Parameters
- required_namestr
Required
- coord_to_idx(coord, **kwargs)[source]#
Transform from axis time coordinate to bin index.
Indices of time values falling outside time bins will be set to -1.
- coord_to_pix(coord, **kwargs)[source]#
Transform from time to coordinate to pixel position.
Pixels of time values falling outside time bins will be set to -1.
- copy(**kwargs)[source]#
Copy
MapAxis
instance and overwrite given attributes.- Parameters
- **kwargsdict
Keyword arguments to overwrite in the map axis constructor.
- Returns
- copy
MapAxis
Copied map axis.
- copy
- format_plot_xaxis(ax)[source]#
Format plot axis
- Parameters
- ax
Axis
Plot axis to format
- ax
- Returns
- ax
Axis
Formatted plot axis
- ax
- classmethod from_gti(gti, name='time')[source]#
Create a time axis from an input GTI.
- Parameters
- gti
GTI
GTI table
- namestr
Axis name
- gti
- Returns
- axis
TimeMapAxis
Time map axis.
- axis
- classmethod from_gti_bounds(gti, t_delta, name='time')[source]#
Create a time axis from an input GTI.
The unit for the axis is taken from the t_delta quantity.
- Parameters
- gti
GTI
GTI table
- t_delta
Quantity
Time binning
- namestr
Axis name
- gti
- Returns
- axis
TimeMapAxis
Time map axis.
- axis
- classmethod from_table(table, format='gadf', idx=0)[source]#
Create time map axis from table
- Parameters
- table
Table
Bin table HDU
- format{“gadf”, “fermi-fgl”, “lightcurve”}
Format to use.
- table
- Returns
- axis
TimeMapAxis
Time map axis.
- axis
- classmethod from_time_bounds(time_min, time_max, nbin, unit='d', name='time')[source]#
Create linearly spaced time axis from bounds
- classmethod from_time_edges(time_min, time_max, unit='d', interp='lin', name='time')[source]#
Create TimeMapAxis from the time interval edges defined as
Time
.The reference time is defined as the lower edge of the first interval.
- Parameters
- Returns
- axis
TimeMapAxis
Time map axis.
- axis
- is_allclose(other, **kwargs)[source]#
Check if other map axis is all close.
- Parameters
- other
TimeMapAxis
Other map axis
- **kwargsdict
Keyword arguments forwarded to
allclose
- other
- Returns
- is_allclosebool
Whether other axis is allclose
- slice(idx)[source]#
Create a new axis object by extracting a slice from this axis.
- Parameters
- idxslice
Slice object selecting a subselection of the axis.
- Returns
- axis
TimeMapAxis
Sliced axis object.
- axis
- squash()[source]#
Create a new axis object by squashing the axis into one bin.
- Returns
- axis
MapAxis
Sliced axis object.
- axis
- to_contiguous()[source]#
Make the time axis contiguous
- Returns
- axis
TimeMapAxis
Contiguous time axis
- axis