Beispiel #1
0
    def __init__(self,
                 input=None,
                 filename=None,
                 mangaid=None,
                 plateifu=None,
                 mode=None,
                 data=None,
                 release=None,
                 drpall=None,
                 download=None,
                 nsa_source='auto'):

        self.header = None
        self.wcs = None
        self._wavelength = None
        self._shape = None

        # Stores data from extensions that have already been accessed, so that they
        # don't need to be retrieved again.
        self._extension_data = {}

        # Datacubes and spectra
        self._flux = None
        self._spectral_resolution = None
        self._spectral_resolution_prepixel = None
        self._dispersion = None
        self._dispersion_prepixel = None
        self._bitmasks = None

        MarvinToolsClass.__init__(self,
                                  input=input,
                                  filename=filename,
                                  mangaid=mangaid,
                                  plateifu=plateifu,
                                  mode=mode,
                                  data=data,
                                  release=release,
                                  drpall=drpall,
                                  download=download)

        NSAMixIn.__init__(self, nsa_source=nsa_source)

        if self.data_origin == 'file':
            self._load_cube_from_file(data=self.data)
        elif self.data_origin == 'db':
            self._load_cube_from_db(data=self.data)
        elif self.data_origin == 'api':
            self._load_cube_from_api()

        self._init_attributes()

        # Checks that the drpver set in MarvinToolsClass matches the header
        header_drpver = self.header['VERSDRP3'].strip()
        header_drpver = 'v1_5_1' if header_drpver == 'v1_5_0' else header_drpver
        assert header_drpver == self._drpver, (
            'mismatch between cube._drpver={0} '
            'and header drpver={1}'.format(self._drpver, header_drpver))
Beispiel #2
0
    def __init__(self,
                 input=None,
                 filename=None,
                 mangaid=None,
                 plateifu=None,
                 mode=None,
                 data=None,
                 release=None,
                 drpall=None,
                 download=None,
                 nsa_source='auto',
                 bintype=None,
                 template=None,
                 template_kin=None):

        if template_kin is not None:
            warnings.warn(
                'template_kin is deprecated and will be removed in a future version.',
                DeprecationWarning)
            template = template_kin if template is None else template

        # _set_datamodel will replace these strings with datamodel objects.
        self.bintype = bintype
        self.template = template
        self._bitmasks = None

        MarvinToolsClass.__init__(self,
                                  input=input,
                                  filename=filename,
                                  mangaid=mangaid,
                                  plateifu=plateifu,
                                  mode=mode,
                                  data=data,
                                  release=release,
                                  drpall=drpall,
                                  download=download)

        NSAMixIn.__init__(self, nsa_source=nsa_source)

        self.header = None
        self.wcs = None
        self._shape = None

        if self.data_origin == 'file':
            self._load_maps_from_file(data=self.data)
        elif self.data_origin == 'db':
            self._load_maps_from_db(data=self.data)
        elif self.data_origin == 'api':
            self._load_maps_from_api()
        else:
            raise marvin.core.exceptions.MarvinError(
                'data_origin={0} is not valid'.format(self.data_origin))

        self._check_versions(self)
Beispiel #3
0
    def __init__(self, input=None, filename=None, mangaid=None, plateifu=None,
                 mode=None, data=None, release=None,
                 drpall=None, download=None, nsa_source='auto',
                 bintype=None, template=None, template_kin=None):

        if template_kin is not None:
            warnings.warn('template_kin is deprecated and will be removed in a future version.',
                          DeprecationWarning)
            template = template_kin if template is None else template

        # _set_datamodel will replace these strings with datamodel objects.
        self.bintype = bintype
        self.template = template
        self.datamodel = None
        self._bitmasks = None

        MarvinToolsClass.__init__(self, input=input, filename=filename,
                                  mangaid=mangaid, plateifu=plateifu,
                                  mode=mode, data=data, release=release,
                                  drpall=drpall, download=download)

        NSAMixIn.__init__(self, nsa_source=nsa_source)

        # Checks that DAP is at least MPL-5
        MPL5 = distutils.version.StrictVersion('2.0.2')
        if self.filename is None and distutils.version.StrictVersion(self._dapver) < MPL5:
            raise MarvinError('ModelCube requires at least dapver=\'2.0.2\'')

        self.header = None
        self.wcs = None
        self._wavelength = None
        self._redcorr = None
        self._shape = None

        # Model extensions
        self._extension_data = {}
        self._binned_flux = None
        self._redcorr = None
        self._full_fit = None
        self._emline_fit = None
        self._stellarcont_fit = None

        if self.data_origin == 'file':
            self._load_modelcube_from_file()
        elif self.data_origin == 'db':
            self._load_modelcube_from_db()
        elif self.data_origin == 'api':
            self._load_modelcube_from_api()
        else:
            raise marvin.core.exceptions.MarvinError(
                'data_origin={0} is not valid'.format(self.data_origin))

        # Confirm that drpver and dapver match the ones from the header.
        marvin.tools.maps.Maps._check_versions(self)
Beispiel #4
0
    def __init__(self,
                 input=None,
                 filename=None,
                 mangaid=None,
                 plateifu=None,
                 mode=None,
                 data=None,
                 release=None,
                 plate=None,
                 download=None,
                 nocubes=None):

        self._cubes = None
        self._plate = None
        self._pdict = None
        self.platedir = None
        self.nocubes = nocubes

        # If plateid specified, force a temp plateifu
        if plate:
            self.plateid = plate
            plateifu = '{0}-XXXX'.format(self.plateid)

        self.plateifu = plateifu

        args = [plate, plateifu]
        assert any(args), 'Enter plate or plateifu!'

        MarvinToolsClass.__init__(self,
                                  input=input,
                                  filename=filename,
                                  mangaid=mangaid,
                                  plateifu=plateifu,
                                  mode=mode,
                                  data=data,
                                  release=release,
                                  download=download)

        # sort out any plateid, plate-ifu, mangaid name snafus
        self._sortOutNames()

        # grab the plate info
        if self.data_origin == 'file':
            self._getPlateFromFile()
        elif self.data_origin == 'db':
            self._getPlateFromDB()
        elif self.data_origin == 'api':
            self._getPlateFromAPI()

        # load the plate params and init the Marvin Cubes
        self._setParams()
        if not self.nocubes:
            self._initCubes()
Beispiel #5
0
    def _getFullPath(self):
        """Returns the full path of the file in the tree."""

        params = self._getPathParams()
        path_type = params.pop('path_type')

        return MarvinToolsClass._getFullPath(self, path_type, **params)
Beispiel #6
0
    def __init__(self, *args, **kwargs):

        self.data_origin = None
        self._drpver = kwargs.get('drpver', config.drpver)
        self._dapver = kwargs.get('dapver', config.dapver)
        self._mplver = kwargs.get('mplver', config.mplver)
        self.download = kwargs.get('download', config.download)

        MarvinToolsClass.__init__(self, *args, **kwargs)

        if self.mode == 'local':
            if self.filename:
                # do any file stuff
                pass
            else:
                # do any db stuff
                self.plate, self.ifu = self.plateifu.split('-')

        else:
            # do any remote stuff
            pass
Beispiel #7
0
    def __init__(self, *args, **kwargs):

        self.plateid = kwargs.get('plateid', None)
        self._cubes = None
        self._plate = None
        self._pdict = None
        self.platedir = None
        self.nocubes = kwargs.get('nocubes', None)

        # If plateid specified, force a temp plateifu
        if self.plateid:
            self.plateifu = '{0}-XXXX'.format(self.plateid)
            kwargs['plateifu'] = self.plateifu

        self.plateifu = kwargs.get('plateifu', None)

        args = [self.plateid, self.plateifu]
        assert any(args), 'Enter plateid or plateifu!'

        MarvinToolsClass.__init__(self, *args, **kwargs)

        # sort out any plateid, plate-ifu, mangaid name snafus
        self._sortOutNames()

        # grab the plate info
        if self.data_origin == 'file':
            self._getPlateFromFile()
        elif self.data_origin == 'db':
            self._getPlateFromDB()
        elif self.data_origin == 'api':
            self._getPlateFromAPI()

        # load the plate params and init the Marvin Cubes
        self._setParams()
        if not self.nocubes:
            self._initCubes()
Beispiel #8
0
    def __init__(self, *args, **kwargs):

        valid_kwargs = [
            'filename', 'mangaid', 'plateifu', 'mode', 'drpall', 'release',
            'nsa_source'
        ]

        assert len(args) == 0, 'RSS does not accept arguments, only keywords.'
        for kw in kwargs:
            assert kw in valid_kwargs, 'keyword {0} is not valid'.format(kw)

        self.data = None

        MarvinToolsClass.__init__(self, *args, **kwargs)

        if self.data_origin == 'file':
            self._load_rss_from_file()
        elif self.data_origin == 'db':
            self._load_rss_from_db()
        elif self.data_origin == 'api':
            self._load_rss_from_api()

        _fibers = self._init_fibers()
        list.__init__(self, _fibers)