Mixins¶
-
class
marvin.tools.mixins.mma.
MMAMixIn
(input=None, filename=None, mangaid=None, plateifu=None, mode=None, data=None, release=None, drpall=None, download=None, ignore_db=False)[source]¶ A mixin that provides multi-modal data access.
Add this mixin to any new class object to provide that class with the Multi-Modal Data Access System for using local files, database, or remote connection when initializing new objects. See decision tree
Parameters: - input (str) – A string that can be a filename, plate-ifu, or mangaid. It will be automatically identified based on its unique format. This argument is always the first one, so it can be defined without the keyword for convenience.
- filename (str) – The path of the file containing the file to load. If set,
input
is ignored. - mangaid (str) – The mangaid of the file to load. If set,
input
is ignored. - plateifu (str) – The plate-ifu of the data cube to load. If set,
input
is ignored. - mode ({'local', 'remote', 'auto'}) – The load mode to use. See Mode Decision Tree.
- data (
HDUList
, SQLAlchemy object, or None) – An astropyHDUList
or a SQLAlchemy object, to be used for initialisation. IfNone
, the normal <marvin-dma>` mode will be used. - release (str) – The MPL/DR version of the data to use.
- drpall (str) – The path to the
drpall
file to use. If not set it will use the default path for the file
based on the
release
- download (bool) – If
True
, the data will be downloaded on instantiation. See Downloading Objects. - ignore_db (bool) – If
True
, the local data-origindb
will be ignored.
Variables: - data (
HDUList
, SQLAlchemy object, or dict) – Depending on the access mode,data
is populated with theHDUList
from the FITS file, a SQLAlchemy object, or a dictionary of values returned by an API call. - data_origin ({'file', 'db', 'api'}) – Indicates the origin of the data, either from a file, the DB, or an API call.
- filename (str) – The path of the file used, if any.
- mangaid (str) – The mangaid of the target.
- plateifu – The plateifu of the target
- release – The data release
-
ifu
¶ Returns the IFU.
-
plate
¶ Returns the plate id.
-
release
¶ Returns the release.
-
class
marvin.tools.mixins.nsa.
NSAMixIn
(nsa_source='auto')[source]¶ A mixin that provides access to NSA paremeters.
Must be used in combination with
MarvinToolsClass
and initialised beforensa
can be called.Parameters: nsa_source ({'auto', 'drpall', 'nsa'}) – Defines how the NSA data for this object should loaded when .nsa
is first called. Ifdrpall
, the drpall file will be used (note that this will only contain a subset of all the NSA information); ifnsa
, the full set of data from the DB will be retrieved. If the drpall file or a database are not available, a remote API call will be attempted. Ifnsa_source='auto'
, the source will depend on how the parent object has been instantiated. If the parent hasdata_origin='file'
, the drpall file will be used (as it is more likely that the user has that file in their system). Otherwise,nsa_source='nsa'
will be assumed. This behaviour can be modified during runtime by modifying thensa_mode
attribute with one of the valid values.-
nsa
¶ Returns the contents of the NSA catalogue for this target.
-
-
class
marvin.tools.mixins.dapall.
DAPallMixIn
[source]¶ A mixin that provides access to DAPall paremeters.
Must be used in combination with
MarvinToolsClass
and initialised beforedapall
can be called.DAPallMixIn
uses theMarvinToolsClass.data_origin
of the object to determine how to obtain the DAPall information. However, if the object contains adapall
attribute with the path to a DAPall file, that file will be used.-
dapall
¶ Returns the contents of the DAPall data for this target.
-
-
class
marvin.tools.mixins.aperture.
MarvinAperture
[source]¶ Bases:
photutils.aperture.core.Aperture
Extends
photutils.Aperture
allowing to extract spaxels in the aperture.This class is not intended for general use and it is dynamically set as the base for a
Aperture
instance.-
getSpaxels
(threshold=0.5, lazy=True, mask=None, **kwargs)[source]¶ Returns the spaxels that fall within the aperture.
Parameters: - threshold (float) – The minimum fractional overlap between the spaxel and the aperture grid for the spaxel to be returned.
- lazy (bool) – Whether the returned spaxels must be fully loaded or lazily instantiated.
- mask (numpy.ndarray) – A mask that defines the fractional pixel overlap with the
apertures. If
None
, the mask returned byMarvinAperture.mask
will be used. - kwargs (dict) – Additional parameters to be passed to the parent
getSpaxel
method. Can be used to define what information is loaded in the spaxels.
-
isscalar
¶ Whether the instance is scalar (i.e. a single position).
-
mask
¶ Returns the fractional overlap mask.
Equivalent to using
photutils.PixelAperture.to_mask
followed byphotutils.ApertureMask.to_image
using the shape of the parent object. Combines all the apertures in a single mask.
-
parent
¶ Returns or sets the parent object.
-
positions
= array([], dtype=float64)¶
-
shape
¶ The shape of the instance.
-
theta
= None¶
-
-
class
marvin.tools.mixins.aperture.
GetApertureMixIn
[source]¶ -
getAperture
(coords, aperture_params, aperture_type='circular', coord_type='pixel')[source]¶ Defines an aperture.
This method is mostly a wrapper around the aperture classes defined in photutils. It allows to
Parameters: - coords (tuple or
ndarray
) – Either a 2-element tuple(x, y)
or(ra, dec)
to define the centre of a single aperture, or a list of N tuples or a Nx2 array to define N apertures. - aperture_params (tuple) –
A tuple with the parameters of the aperture.
- For
aperture_type='rectangular'
:- If
coord_type='pixel'
, a tuple(w, h, theta)
wherew
is the full width of the aperture (fortheta=0
the width side is along thex
axis);h
is the full height of the aperture (fortheta=0
the height side is along they
axis); andtheta
is the rotation angle in radians of the width (w
) side from the positivex
axis (the rotation angle increases counterclockwise). - If
coord_type='sky'
, same format butw
andh
must be in arcsec andtheta
is the position angle (in degrees) of the width side. The position angle increases counterclockwise, from North (PA=0) towards East.
- If
- For
aperture_type='circular'
:- The radius
r
in units of pixels or arcsec depending on the value ofcoord_type
. Can be a tuple or a float.
- The radius
- For
aperture_type='elliptical'
:- If
coord_type='pixel'
, a tuple(a, b, theta)
wherea
andb
are the semi-major and semi-minor axes of the ellipse, respectively, andtheta
is the rotation angle in radians of the semi-major axis from the positive x axis (the rotation angle increases counterclockwise). Ifcoord_type='sky'
,a
andb
must be in arcsec, andtheta
is the position angle (in degrees) of the semi-major axis. The position angle increases counterclockwise, from North (PA=0) towards East.
- If
- For
- aperture_type ({'rectangular', 'circular', 'elliptical'}) – The type of aperture to define.
- coord_type ({'pixel', 'sky'}) – Determines whether the coordinates and aperture parameters refer to to the frame of the image or to sky coordinates. The conversion between the image and sky frames is determined using the WCS headers from the image.
Returns: marvin_aperture (MarvinAperture object) – A
MarvinAperture
instance with the definition of the aperture, which can be used to extract the associated spaxels or to return the mask.Examples
A single circular aperture with a radius of 3 pixels can created as
>>> cube = marvin.tools.Cube('8485-1901') >>> aperture = cube.getAperture((17, 15), 3)
aperture
can then be used to return all spaxels that have a fractional overlap with the aperture of more than 0.6 pixels>>> spaxels = aperture.getSpaxels(threshold=0.6, lazy=True) >>> spaxels[0] <Marvin Spaxel (x=15, y=13, loaded=False)
Apertures can also be defined from sky coordinates. To define two elliptical apertures with semi-axes 3 and 1 arcsec and rotated 30 degrees we do
>>> ap_ell = cube.getAperture([(232.546173, 48.6892288), (232.544069, 48.6906177)], (3, 1, 30), aperture_type='elliptical') >>> ap_ell <MarvinAperture([[232.546173 , 48.6892288], [232.544069 , 48.6906177]], a=3.0, b=1.0, theta=30.0)>
- coords (tuple or
-