def galidselect(self): ''' Route that handle the Navbar plate/galaxy id search form ''' args = av.manual_parse(self, request, use_params='index', required='galid') galid = args.get('galid', None) if not galid: # if not galid return main page return redirect(url_for('index_page.Marvin:index')) else: idtype = parseIdentifier(galid) # check the idtype if idtype == 'plateifu' or idtype == 'mangaid': return redirect(url_for('galaxy_page.Galaxy:get', galid=galid)) elif idtype == 'plate': return redirect(url_for('plate_page.Plate:get', plateid=galid)) else: return redirect(url_for('index_page.Marvin:index'))
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'] 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 self.galaxy['error'] = 'MarvinError: {0}'.format(e) return render_template("galaxy.html", **self.galaxy) else: self.galaxy['cube'] = cube self.galaxy['daplink'] = getDapRedux(release=self._release) # get SAS url links to cube, rss, maps, image if Path: sdss_path = Path() self.galaxy['image'] = sdss_path.url('mangaimage', drpver=cube._drpver, plate=cube.plate, ifu=cube.ifu, dir3d=cube.dir3d) cubelink = sdss_path.url('mangacube', drpver=cube._drpver, plate=cube.plate, ifu=cube.ifu) rsslink = sdss_path.url('mangarss', drpver=cube._drpver, plate=cube.plate, ifu=cube.ifu) maplink = getDefaultMapPath(release=self._release, plate=cube.plate, ifu=cube.ifu, daptype='SPX-GAU-MILESHC', mode='MAPS') self.galaxy['links'] = {'cube': cubelink, 'rss': rsslink, 'map': maplink} else: self.galaxy['image'] = cube.data.image # Get the initial spectrum if cube: daplist = get_dap_maplist(self._dapver, web=True) dapdefaults = get_default_mapset(self._dapver) 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] nsatmp.extend(nsacols) self.galaxy['nsacols'] = nsatmp self.galaxy['nsadict'] = nsadict self.galaxy['dapmaps'] = daplist self.galaxy['dapmapselect'] = dapdefaults dm = datamodel[self._dapver] self.galaxy['dapbintemps'] = dm.get_bintemps(db_only=True) current_session['bintemp'] = '{0}-{1}'.format(dm.get_bintype(), dm.get_template()) # 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<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)
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 self.galaxy['daplink'] = getDapRedux(release=self._release) # get SAS url links to cube, rss, maps, image if Path: is_public = 'DR' in self._release path_release = self._release.lower() if is_public else None sdss_path = Path(public=is_public, release=path_release) self.galaxy['image'] = cube.getImage().url cubelink = sdss_path.url('mangacube', drpver=cube._drpver, plate=cube.plate, ifu=cube.ifu) rsslink = sdss_path.url('mangarss', drpver=cube._drpver, plate=cube.plate, ifu=cube.ifu) 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 # 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 maps = cube.getMaps( plateifu=cube.plateifu, mode='local', bintype=current_session['bintemp'].split('-')[0]) 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)