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,
inputis ignored.mangaid (str) – The mangaid of the file to load. If set,
inputis ignored.plateifu (str) – The plate-ifu of the data cube to load. If set,
inputis ignored.mode ({'local', 'remote', 'auto'}) – The load mode to use. See Mode Decision Tree.
data (
HDUList, SQLAlchemy object, or None) – An astropyHDUListor 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
releasedownload (bool) – If
True, the data will be downloaded on instantiation. See Downloading Objects.ignore_db (bool) – If
True, the local data-origindbwill be ignored.
- Variables:
data (
HDUList, SQLAlchemy object, or dict) – Depending on the access mode,datais populated with theHDUListfrom 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
- property ifu¶
Returns the IFU.
- property plate¶
Returns the plate id.
- property 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
MarvinToolsClassand initialised beforensacan be called.- Parameters:
nsa_source ({'auto', 'drpall', 'nsa'}) – Defines how the NSA data for this object should loaded when
.nsais 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_modeattribute with one of the valid values.
- property 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
MarvinToolsClassand initialised beforedapallcan be called.DAPallMixInuses theMarvinToolsClass.data_originof the object to determine how to obtain the DAPall information. However, if the object contains adapallattribute with the path to a DAPall file, that file will be used.- property dapall¶
Returns the contents of the DAPall data for this target.
- class marvin.tools.mixins.aperture.MarvinAperture[source]¶
Bases:
ApertureExtends
photutils.aperture.Apertureallowing to extract spaxels in the aperture.This class is not intended for general use and it is dynamically set as the base for a
Apertureinstance.- copy()¶
Make an deep copy of this object.
- Returns:
result (
Aperture) – A deep copy of the Aperture object.
- 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.maskwill be used.kwargs (dict) – Additional parameters to be passed to the parent
getSpaxelmethod. Can be used to define what information is loaded in the spaxels.
- property isscalar¶
Whether the instance is scalar (i.e., a single position).
- property mask¶
Returns the fractional overlap mask.
Equivalent to using
photutils.aperture.PixelAperture.to_maskfollowed byphotutils.aperture.ApertureMask.to_imageusing the shape of the parent object. Combines all the apertures in a single mask.
- property parent¶
Returns or sets the parent object.
- property shape¶
The shape of the instance.
- 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)wherewis the full width of the aperture (fortheta=0the width side is along thexaxis);his the full height of the aperture (fortheta=0the height side is along theyaxis); andthetais the rotation angle in radians of the width (w) side from the positivexaxis (the rotation angle increases counterclockwise).If
coord_type='sky', same format butwandhmust be in arcsec andthetais the position angle (in degrees) of the width side. The position angle increases counterclockwise, from North (PA=0) towards East.
For
aperture_type='circular':The radius
rin units of pixels or arcsec depending on the value ofcoord_type. Can be a tuple or a float.
For
aperture_type='elliptical':If
coord_type='pixel', a tuple(a, b, theta)whereaandbare the semi-major and semi-minor axes of the ellipse, respectively, andthetais the rotation angle in radians of the semi-major axis from the positive x axis (the rotation angle increases counterclockwise). Ifcoord_type='sky',aandbmust be in arcsec, andthetais the position angle (in degrees) of the semi-major axis. The position angle increases counterclockwise, from North (PA=0) towards East.
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
MarvinApertureinstance 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)
aperturecan 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)>