def test_getFullPath_no_plateifu(self, galaxy): cube = Cube(mangaid=galaxy.mangaid) cube.plateifu = None assert cube._getFullPath() is None
def get(self, galid): ''' Retrieve info for a given cube ''' # determine type of galid args = av.manual_parse(self, request, use_params='galaxy') self.galaxy['id'] = args['galid'] self.galaxy['latest_dr'] = self._release.lower() if 'DR' in self._release else marvin.config._get_latest_release(dr_only=True).lower() idtype = parseIdentifier(galid) if idtype in ['plateifu', 'mangaid']: # set plateifu or mangaid self.galaxy['idtype'] = idtype galaxyid = {self.galaxy['idtype']: galid, 'release': self._release} # Get cube try: cube = Cube(**galaxyid) except MarvinError as e: self.galaxy['cube'] = None errmsg = 'MarvinError: {0}'.format(e) # check target status and fine-tune the error message if idtype == 'mangaid': status = target_status(galid, drpver=self._drpver) if status == 'not yet observed': errmsg = '{0} is a valid target but has not yet been observed'.format(galid) elif status == 'not valid target': errmsg = '{0} is not valid MaNGA target. Check your syntax'.format(galid) self.galaxy['error'] = errmsg return render_template("galaxy.html", **self.galaxy) else: dm = datamodel[self._dapver] self.galaxy['cube'] = cube g.cube = cube self.galaxy['daplink'] = getDapRedux(release=self._release) # get SAS url links to cube, rss, maps, image if Path: sdss_path = Path(release=self._release) self.galaxy['image'] = cube.getImage().url cubelink = sdss_path.url('', full=cube._getFullPath()) rsslink = sdss_path.url('mangarss', drpver=cube._drpver, plate=cube.plate, ifu=cube.ifu, wave='LOG') daptype = "{0}-{1}".format(dm.default_bintype, dm.default_template) maplink = getDefaultMapPath(release=self._release, plate=cube.plate, ifu=cube.ifu, daptype=daptype, mode='MAPS') mclink = getDefaultMapPath(release=self._release, plate=cube.plate, ifu=cube.ifu, daptype=daptype, mode='LOGCUBE') self.galaxy['links'] = {'cube': cubelink, 'rss': rsslink, 'map': maplink, 'mc': mclink} else: self.galaxy['image'] = cube.data.image infile = get_manga_image(cube, local=True) current_session['imagefile'] = infile current_session['wcs'] = cube.wcs.to_header_string() current_session['cube_shape'] = cube.wcs.array_shape[-1] # Get the initial spectrum if cube: dm = datamodel[self._dapver] daplist = [p.full(web=True) for p in dm.properties] dapdefaults = dm.get_default_mapset() self.galaxy['cube'] = cube self.galaxy['toggleon'] = current_session.get('toggleon', 'false') self.galaxy['cubehdr'] = cube.header self.galaxy['quality'] = ('DRP3QUAL', cube.quality_flag.mask, cube.quality_flag.labels) self.galaxy['mngtarget'] = {'bits': [it.mask for it in cube.target_flags if it.mask != 0], 'labels': [it.labels for it in cube.target_flags if len(it.labels) > 0], 'names': [''.join(('MNGTARG', it.name[-1])) for it in cube.target_flags if it.mask != 0]} # make the nsa dictionary hasnsa = cube.nsa is not None self.galaxy['hasnsa'] = hasnsa if hasnsa: cols = self.galaxy.get('nsaplotcols') nsadict, nsacols = make_nsa_dict(cube.nsa) nsatmp = [nsacols.pop(nsacols.index(i)) for i in cols if i in nsacols] nsatmp.extend(nsacols) self.galaxy['nsacols'] = nsatmp self.galaxy['nsadict'] = nsadict self.galaxy['dapmaps'] = daplist self.galaxy['dapmapselect'] = current_session.get('selected_dapmaps', dapdefaults) dm = datamodel[self._dapver] self.galaxy['dapbintemps'] = dm.get_bintemps(db_only=True) if 'bintemp' not in current_session or current_session['bintemp'] not in self.galaxy['dapbintemps']: current_session['bintemp'] = '{0}-{1}'.format(dm.get_bintype(), dm.get_template()) # get default map quality try: maps = cube.getMaps(plateifu=cube.plateifu, mode='local', bintype=current_session['bintemp'].split('-')[0]) except MarvinError: mapqual = ('DAPQUAL', [], []) else: mapqual = ('DAPQUAL', maps.quality_flag.mask, maps.quality_flag.labels) self.galaxy['mapquality'] = mapqual # TODO - make this general - see also search.py for querystr self.galaxy['cubestr'] = ("<html><samp>from marvin.tools.cube import Cube<br>cube = \ Cube(plateifu='{0}')<br># access the header<br>cube.header<br># get NSA data<br>\ cube.nsa<br></samp></html>".format(cube.plateifu)) self.galaxy['spaxelstr'] = ("<html><samp>from marvin.tools.cube import Cube<br>cube = \ Cube(plateifu='{0}')<br># get a spaxel by slicing cube[i,j]<br>spaxel=cube[16, 16]<br>flux = \ spaxel.flux<br>wave = flux.wavelength<br>ivar = flux.ivar<br>mask = \ flux.mask<br>flux.plot()<br></samp></html>".format(cube.plateifu)) self.galaxy['mapstr'] = ("<html><samp>from marvin.tools.maps import Maps<br>maps = \ Maps(plateifu='{0}')<br>print(maps)<br># get an emission \ line map<br>haflux = maps.emline_gflux_ha_6564<br>values = \ haflux.value<br>ivar = haflux.ivar<br>mask = haflux.mask<br>haflux.plot()<br>\ </samp></html>".format(cube.plateifu)) else: self.galaxy['error'] = 'Error: Galaxy ID {0} must either be a Plate-IFU, or MaNGA-Id designation.'.format(galid) return render_template("galaxy.html", **self.galaxy) return render_template("galaxy.html", **self.galaxy)