def set_filenames(self, bintype=None, template=None): default_bintemp = _get_bintemps(self.dapver, default=True) default_bin, default_temp = default_bintemp.split('-', 1) self.bintype = bintype if bintype is not None else default_bin self.template = template if template is not None else default_temp self.bintemp = '{0}-{1}'.format(self.bintype, self.template) self.cubename = 'manga-{0}-LOGCUBE.fits.gz'.format(self.plateifu) self.rssname = 'manga-{0}-LOGRSS.fits.gz'.format(self.plateifu) self.imgname = '{0}.png'.format(self.ifu) self.mapsname = 'manga-{0}-MAPS-{1}.fits.gz'.format( self.plateifu, self.bintemp) self.modelname = 'manga-{0}-LOGCUBE-{1}.fits.gz'.format( self.plateifu, self.bintemp)
def setUpClass(cls): config.use_sentry = False config.add_github_message = False # set initial config variables cls.init_mode = config.mode cls.init_sasurl = config.sasurl cls.init_urlmap = config.urlmap cls.init_xyorig = config.xyorig cls.init_traceback = config._traceback cls.init_keys = ['mode', 'sasurl', 'urlmap', 'xyorig', 'traceback'] # set db stuff cls._marvindb = marvindb cls.session = marvindb.session # set paths cls.sasbasedir = os.getenv("$SAS_BASE_DIR") cls.mangaredux = os.getenv("MANGA_SPECTRO_REDUX") cls.mangaanalysis = os.getenv("MANGA_SPECTRO_ANALYSIS") # testing data for 8485-1901 cls.set_plateifu(plateifu='8485-1901') cls.mangaid = '1-209232' cls.cubepk = 10179 cls.ra = 232.544703894 cls.dec = 48.6902009334 cls.redshift = 0.0407447 cls.dir3d = 'stack' cls.release = 'MPL-5' cls.drpver, cls.dapver = config.lookUpVersions(cls.release) cls.bintemp = _get_bintemps(cls.dapver, default=True) cls.defaultbin, cls.defaulttemp = cls.bintemp.split('-', 1) cls.cubename = 'manga-{0}-LOGCUBE.fits.gz'.format(cls.plateifu) cls.rssname = 'manga-{0}-LOGRSS.fits.gz'.format(cls.plateifu) cls.imgname = '{0}.png'.format(cls.ifu) cls.mapsname = 'manga-{0}-MAPS-{1}.fits.gz'.format(cls.plateifu, cls.bintemp) cls.modelname = 'manga-{0}-LOGCUBE-{1}.fits.gz'.format(cls.plateifu, cls.bintemp)
def initDynamic(self): ''' Route to run when the dynamic toggle is initialized This creates the web spectrum and dap heatmaps ''' # get the form parameters args = av.manual_parse(self, request, use_params='galaxy', required='plateifu') #self._drpver, self._dapver, self._release = parseSession() # turning toggle on current_session['toggleon'] = args.get('toggleon') # get the cube cubeinputs = { 'plateifu': args.get('plateifu'), 'release': self._release } cube = Cube(**cubeinputs) output = {'specstatus': -1, 'mapstatus': -1} # get web spectrum webspec, specmsg = getWebSpectrum(cube, cube.ra, cube.dec, byradec=True) daplist = get_dap_maplist(self._dapver, web=True) dapdefaults = get_default_mapset(self._dapver) # build the uber map dictionary try: mapdict = buildMapDict(cube, dapdefaults, self._dapver) mapmsg = None except Exception as e: mapdict = [{ 'data': None, 'msg': 'Error', 'plotparams': None } for m in dapdefaults] mapmsg = 'Error getting maps: {0}'.format(e) else: output['mapstatus'] = 1 if not webspec: output['error'] = 'Error: {0}'.format(specmsg) else: output['specstatus'] = 1 sdss_path = Path() output['image'] = sdss_path.url('mangaimage', drpver=cube._drpver, plate=cube.plate, ifu=cube.ifu, dir3d=cube.dir3d) output['spectra'] = webspec output['specmsg'] = specmsg output['maps'] = mapdict output['mapmsg'] = mapmsg output['dapmaps'] = daplist output['dapbintemps'] = _get_bintemps(self._dapver) current_session['bintemp'] = '{0}-{1}'.format( _get_bintype(self._dapver), _get_template_kin(self._dapver)) return jsonify(result=output)
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) self.galaxy['cube'] = cube self.galaxy['toggleon'] = current_session.get( 'toggleon', 'false') self.galaxy['cubehdr'] = cube.header self.galaxy['quality'] = cube.qualitybit self.galaxy['mngtarget'] = cube.targetbit # 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['dapbintemps'] = _get_bintemps(self._dapver) current_session['bintemp'] = '{0}-{1}'.format( _get_bintype(self._dapver), _get_template_kin(self._dapver)) # 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>spec = \ spaxel.spectrum<br>wave = spectrum.wavelength<br>flux = spectrum.flux<br>ivar = \ spectrum.ivar<br>mask = spectrum.mask<br>spec.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.getMap('emline_gflux', channel='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)
from marvin.tools.maps import _get_bintemps # class MarvinTest # TODO Replace skipTest and skipBrian with skipif # TODO use monkeypatch to set initial config variables # TODO replace _reset_the_config with monkeypatch # TODO reimplement set_sasurl (use function-level fixture?) releases = ['MPL-4', 'MPL-5'] plateifus = ['8485-1901'] bintypes = {} for release in releases: __, dapver = config.lookUpVersions(release) bintypes[release] = [ bintemp.split('-')[0] for bintemp in _get_bintemps(dapver) ] class Galaxy: """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): self.plateifu = plateifu self.plate, self.ifu = self.plateifu.split('-') self.plate = int(self.plate)
def _get_bin_temps(self): ''' Gets the bintemps for a given release ''' bintemps = _get_bintemps(self.dapver) return bintemps