Exemplo n.º 1
0
    def __init__(self,
                 input=None,
                 filename=None,
                 mangaid=None,
                 plateifu=None,
                 mode=None,
                 data=None,
                 release=None,
                 drpall=None,
                 download=None):

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

        CacheMixIn.__init__(self)

        # drop breadcrumb
        breadcrumb.drop(message='Initializing MarvinTool {0}'.format(
            self.__class__),
                        category=self.__class__)

        # Load VACs
        from marvin.contrib.vacs.base import VACMixIn
        self.vacs = VACMixIn.get_vacs(self)
Exemplo n.º 2
0
    def __init__(self,
                 x,
                 y,
                 cube=True,
                 maps=True,
                 modelcube=True,
                 lazy=False,
                 **kwargs):

        if not cube and not maps and not modelcube:
            raise MarvinError('no inputs defined.')

        self.cube_quantities = FuzzyDict({})
        self.maps_quantities = FuzzyDict({})
        self.modelcube_quantities = FuzzyDict({})

        self._cube = cube
        self._maps = maps
        self._modelcube = modelcube

        for attr in ['mangaid', 'plateifu', 'release', 'bintype', 'template']:

            value = kwargs.pop(attr, None) or \
                getattr(cube, attr, None) or \
                getattr(maps, attr, None) or \
                getattr(modelcube, attr, None)

            setattr(self, attr, value)

        self._kwargs = kwargs
        self._parent_shape = None

        # drop breadcrumb
        breadcrumb.drop(message='Initializing MarvinSpaxel {0}'.format(
            self.__class__),
                        category=self.__class__)

        self.x = int(x)
        self.y = int(y)

        self.loaded = False
        self.datamodel = None

        if lazy is False:
            self.load()

        # Load VACs
        from marvin.contrib.vacs.base import VACMixIn
        self.vacs = VACMixIn.get_vacs(self)
Exemplo n.º 3
0
    def restore(cls, path, delete=False):
        """Restores a MarvinToolsClass object from a pickled file.

        If ``delete=True``, the pickled file will be removed after it has been
        unplickled. Note that, for objects with ``data_origin='file'``, the
        original file must exists and be in the same path as when the object
        was first created.

        """

        from marvin.contrib.vacs.base import VACMixIn

        res = marvin_pickle.restore(path, delete=delete)
        res.vacs = VACMixIn.get_vacs(res)

        return res
Exemplo n.º 4
0
    def __new__(cls, *args, **kwargs):
        ''' load relevant VACMixIns upon new class creation '''
        # reset the vacs
        cls._reset_vacs()
        # initiate vacs for a given release
        cls._vacs = []
        cls.release = config.release
        for subvac in VACMixIn.__subclasses__():
            # Exclude any hidden VACs
            if subvac._hidden:
                continue

            # Excludes VACs from other releases
            if config.release not in subvac.version:
                continue

            sv = subvac()
            if sv.summary_file is None:
                log.info(
                    'VAC {0} has no summary file to load.  Skipping.'.format(
                        sv.name))
                continue

            # create the VAC data class
            vacdc = VACDataClass(subvac.name, subvac.description,
                                 sv.summary_file)

            # add any custom methods to the VAC
            if hasattr(subvac, 'add_methods'):
                for method in getattr(subvac, 'add_methods'):
                    assert isinstance(
                        method,
                        six.string_types), 'method name must be a string'
                    svmod = importlib.import_module(subvac.__module__)
                    assert hasattr(
                        svmod, method
                    ), 'method name must be defined in VAC module file'
                    setattr(vacdc, method,
                            types.MethodType(getattr(svmod, method), vacdc))

            # add vac to the container class
            cls._vacs.append(subvac.name)
            setattr(cls, subvac.name, vacdc)

        return super(VACs, cls).__new__(cls, *args, **kwargs)
Exemplo n.º 5
0
#
# Licensed under a 3-clause BSD license.
#
# @Author: Brian Cherinka
# @Date:   2018-07-17 23:36:37
# @Last modified by:   Brian Cherinka
# @Last Modified time: 2018-07-19 15:44:42

from __future__ import print_function, division, absolute_import

from collections import defaultdict
from marvin.utils.datamodel.drp import datamodel
from marvin.contrib.vacs.base import VACMixIn
from .base import VACList, VACDataModel

subvacs = VACMixIn.__subclasses__()
vacdms = []

# create a dictionary of VACs by release
vacdict = defaultdict(list)
for sv in subvacs:
    for k in sv.version.keys():
        vacdict[k].append(sv)

# create VAC datamodels
for release, vacs in vacdict.items():
    vc = VACList(vacs)
    dm = datamodel[release] if release in datamodel else None
    aliases = dm.aliases if dm else None
    vacdm = VACDataModel(release, vacs=vc, aliases=aliases)
    vacdms.append(vacdm)