def _checkFilename(self): ''' Checks the filename for a proper FITS file ''' # if filename is not FITS, then try to load one if 'fits' not in self.filename.lower(): if not Path: raise MarvinError('sdss_access is not installed') else: # is_public = 'DR' in self._release # path_release = self._release.lower() if is_public else None sdss_path = Path(release=self._release) # try a cube full = sdss_path.full('mangacube', drpver=self._drpver, plate=self.plateid, ifu='*', wave='LOG') cubeexists = sdss_path.any('', full=full) if cubeexists: file = sdss_path.one('', full=full) else: # try an rss full = sdss_path.full('mangarss', drpver=self._drpver, plate=self.plateid, ifu='*', wave='LOG') rssexists = sdss_path.any('', full=full) if rssexists: file = sdss_path.one('', full=full) else: file = None # load the file if file: self.filename = file else: self.filename = None
def _getFullPath(self, pathType=None, url=None, **pathParams): """Returns the full path of the file in the tree. This method must be overridden by each subclass. """ # # check for public release # is_public = 'DR' in self._release # ismpl = 'MPL' in self._release # path_release = self._release.lower() if is_public or ismpl else None if not Path: raise MarvinMissingDependency('sdss_access is not installed') else: path = Path(release=self._release) try: if url: fullpath = path.url(pathType, **pathParams) else: fullpath = path.full(pathType, **pathParams) except Exception as ee: warnings.warn( 'sdss_access was not able to retrieve the full path of the file. ' 'Error message is: {0}'.format(str(ee)), MarvinUserWarning) fullpath = None return fullpath
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) p = Path() self.template = p.templates[self.name] if self.kwargs: self.full = p.full(self.name, **self.kwargs) self.url = p.url(self.name, **self.kwargs) self.file = p.name(self.name, **self.kwargs) self.location = p.location(self.name, **self.kwargs) self.exists = p.exists(self.name, **self.kwargs)
class Galaxy(object): """An example galaxy for Marvin-tools testing.""" sasbasedir = os.getenv('SAS_BASE_DIR') mangaredux = os.getenv('MANGA_SPECTRO_REDUX') mangaanalysis = os.getenv('MANGA_SPECTRO_ANALYSIS') dir3d = 'stack' def __init__(self, plateifu): """Initialize plate and ifu.""" self.plateifu = plateifu self.plate, self.ifu = self.plateifu.split('-') self.plate = int(self.plate) def set_galaxy_data(self, data_origin=None): """Set galaxy properties from the configuration file.""" if self.plateifu not in galaxy_data: return data = copy.deepcopy(galaxy_data[self.plateifu]) for key in data.keys(): setattr(self, key, data[key]) # sets specfic data per release releasedata = self.releasedata[self.release] for key in releasedata.keys(): setattr(self, key, releasedata[key]) # remap NSA drpall names for MPL-4 vs 5+ drpcopy = self.nsa_data['drpall'].copy() for key, val in self.nsa_data['drpall'].items(): if isinstance(val, list): newval, newkey = drpcopy.pop(key) if self.release == 'MPL-4': drpcopy[newkey] = newval else: drpcopy[key] = newval self.nsa_data['drpall'] = drpcopy def set_params(self, bintype=None, template=None, release=None): """Set bintype, template, etc.""" self.release = release self.drpver, self.dapver = config.lookUpVersions(self.release) self.drpall = 'drpall-{0}.fits'.format(self.drpver) self.bintype = datamodel[self.dapver].get_bintype(bintype) self.template = datamodel[self.dapver].get_template(template) self.bintemp = '{0}-{1}'.format(self.bintype.name, self.template.name) if release == 'MPL-4': self.niter = int('{0}{1}'.format(self.template.n, self.bintype.n)) else: self.niter = '*' self.access_kwargs = { 'plate': self.plate, 'ifu': self.ifu, 'drpver': self.drpver, 'dapver': self.dapver, 'dir3d': self.dir3d, 'mpl': self.release, 'bintype': self.bintype.name, 'n': self.niter, 'mode': '*', 'daptype': self.bintemp } def set_filepaths(self, pathtype='full'): """Set the paths for cube, maps, etc.""" self.path = Path() self.imgpath = self.path.__getattribute__(pathtype)( 'mangaimage', **self.access_kwargs) self.cubepath = self.path.__getattribute__(pathtype)( 'mangacube', **self.access_kwargs) self.rsspath = self.path.__getattribute__(pathtype)( 'mangarss', **self.access_kwargs) if self.release == 'MPL-4': self.mapspath = self.path.__getattribute__(pathtype)( 'mangamap', **self.access_kwargs) self.modelpath = None else: self.access_kwargs.pop('mode') self.mapspath = self.path.__getattribute__(pathtype)( 'mangadap5', mode='MAPS', **self.access_kwargs) self.modelpath = self.path.__getattribute__(pathtype)( 'mangadap5', mode='LOGCUBE', **self.access_kwargs) def get_location(self, path): """Extract the location from the input path.""" return self.path.location("", full=path) def partition_path(self, path): """Partition the path into non-redux/analysis parts.""" endredux = path.partition(self.mangaredux)[-1] endanalysis = path.partition(self.mangaanalysis)[-1] end = (endredux or endanalysis) return end def new_path(self, name, newvar): ''' Sets a new path with the subsituted name ''' access_copy = self.access_kwargs.copy() access_copy['mode'] = '*' access_copy.update(**newvar) if name == 'maps': access_copy['mode'] = 'MAPS' name = 'mangamap' if self.release == 'MPL-4' else 'mangadap5' elif name == 'modelcube': access_copy['mode'] = 'LOGCUBE' name = None if self.release == 'MPL-4' else 'mangadap5' path = self.path.full(name, **access_copy) if name else None return path