MapCoord#
- class gammapy.maps.MapCoord(data, frame=None, match_by_name=True)[source]#
Bases:
object
Represents a sequence of n-dimensional map coordinates.
Contains coordinates for 2 spatial dimensions and an arbitrary number of additional non-spatial dimensions. Ensure correct broadcasting of the array to allow for this.
For further information and examples see MapCoord.
- Parameters:
- data
dict
ofndarray
Dictionary of coordinate arrays.
- frame{None, “icrs”, “galactic”}
Spatial coordinate system. If None then the coordinate system will be set to the native coordinate system of the geometry. Default is None.
- match_by_namebool, optional
Match coordinates to axes by name. If False, coordinates will be matched by index. Default is True.
- data
Attributes Summary
Names of axes.
Return broadcasted coordinates.
Return flattened, valid coordinates.
Coordinate system as a string.
Latitude coordinate in degrees.
Longitude coordinate in degrees.
Boolean flag: axis lookup by name return True or by index return False.
Number of dimensions.
Phi longitude angle in radians.
Coordinate array shape.
Product of all shape elements.
Coordinate object as a
SkyCoord
.Theta co-latitude angle in radians.
Methods Summary
apply_mask
(mask)Return a masked copy of this coordinate object.
copy
()Copy
MapCoord
object.create
(data[, frame, axis_names])Create a new
MapCoord
object.to_frame
(frame)Convert to a different coordinate frame.
Attributes Documentation
- axis_names#
Names of axes.
- broadcasted#
Return broadcasted coordinates.
- flat#
Return flattened, valid coordinates.
- frame#
Coordinate system as a string.
- lat#
Latitude coordinate in degrees.
- lon#
Longitude coordinate in degrees.
- match_by_name#
Boolean flag: axis lookup by name return True or by index return False.
- ndim#
Number of dimensions.
- phi#
Phi longitude angle in radians.
- shape#
Coordinate array shape.
- size#
Product of all shape elements.
- theta#
Theta co-latitude angle in radians.
Methods Documentation
- classmethod create(data, frame=None, axis_names=None)[source]#
Create a new
MapCoord
object.This method can be used to create either unnamed (with tuple input) or named (via dict input) axes.
- Parameters:
- datatuple, dict,
MapCoord
orSkyCoord
Object containing coordinate arrays.
- frame{“icrs”, “galactic”, None}
Set the coordinate system for longitude and latitude. If None longitude and latitude will be assumed to be in the coordinate system native to a given map geometry. Default is None.
- axis_nameslist of str, optional
Axis names uses if a tuple is provided. Default is None.
- datatuple, dict,
Examples
>>> from astropy.coordinates import SkyCoord >>> from gammapy.maps import MapCoord
>>> lon, lat = [1, 2], [2, 3] >>> skycoord = SkyCoord(lon, lat, unit='deg') >>> energy = [1000] >>> c = MapCoord.create((lon,lat)) >>> c = MapCoord.create((skycoord,)) >>> c = MapCoord.create((lon,lat,energy)) >>> c = MapCoord.create(dict(lon=lon,lat=lat)) >>> c = MapCoord.create(dict(lon=lon,lat=lat,energy=energy)) >>> c = MapCoord.create(dict(skycoord=skycoord,energy=energy))