Esempio n. 1
0
 def test_getdir3d_local_newplate_nocubes(self):
     self._update_release('MPL-5')
     config.forceDbOff()
     errmsg = 'this is the end of the road. Try using some reasonable inputs.'
     with self.assertRaises(MarvinError) as cm:
         self._getdir3d('stack', mode='local', plateifu=self.new_plate)
     self.assertIn(errmsg, str(cm.exception))
Esempio n. 2
0
 def test_getdir3d_remote_newplate_fail(self):
     self._update_release('MPL-5')
     config.forceDbOff()
     errmsg = 'Could not retrieve a remote plate.  If it is a mastar'
     with self.assertRaises(MarvinError) as cm:
         self._getdir3d('stack', mode='remote', plateifu=self.new_plate)
     self.assertIn(errmsg, str(cm.exception))
Esempio n. 3
0
def usedb(request):
    ''' fixture for optional turning off the db '''
    if request.param:
        config.forceDbOn()
    else:
        config.forceDbOff()
    return config.db is not None
Esempio n. 4
0
 def test_mode_local_nodb(self):
     config.forceDbOff()
     self.mode = 'local'
     errmsg = 'Query cannot be run in local mode'
     with self.assertRaises(MarvinError) as cm:
         self._set_modes(expmode='local')
     self.assertIn(errmsg, str(cm.exception))
Esempio n. 5
0
 def test_convert_tool_auto_nodb(self):
     self._set_remote()
     config.forceDbOff()
     r = self._run_query()
     r.convertToTool('cube', mode='auto', limit=1)
     self.assertEqual('remote', r.mode)
     self.assertEqual('local', r.objects[0].mode)
     self.assertEqual('file', r.objects[0].data_origin)
Esempio n. 6
0
def fxnr(mode):
    if mode == 'remote':
        config.forceDbOff()
    q = Query(search_filter='nsa.z < 0.1', release='MPL-4', mode=mode)
    r = q.run()
    yield r
    q = None
    r = None
    if mode == 'remote':
        config.forceDbOn()
Esempio n. 7
0
def db(request):
    """Turn local db on or off.

    Use this to parametrize over all db options.
    """
    if travis and request.param not in travis.new_dbs:
        pytest.skip('Skipping non-requested dbs')
    if request.param == 'db':
        config.forceDbOn()
    else:
        config.forceDbOff()
    yield config.db is not None
    config.forceDbOn()
Esempio n. 8
0
 def test_get_images_download_remote(self):
     self._update_release('MPL-4')
     config.forceDbOff()
     self._get_cube()
     localpath = self._make_paths(self.mangaredux,
                                  mode='local',
                                  inputs=[self.new_plateifu])
     remotepath = self._make_paths(self.remoteredux,
                                   mode='remote',
                                   inputs=[self.new_plateifu])
     self.assertFalse(os.path.isfile(localpath[0]))
     image = getImagesByPlate(self.new_plate,
                              mode='remote',
                              as_url=True,
                              download=True)
     self.assertTrue(os.path.isfile(localpath[0]))
     self.assertIsNone(image)
Esempio n. 9
0
 def test_pickle_save_auto(self):
     self._set_remote()
     config.forceDbOff()
     self._pickle_query(mode='auto', name='test_query.mpf')
Esempio n. 10
0
def db_off():
    """Turn the DB off for a test, and reset it after."""
    config.forceDbOff()
    yield
    config.forceDbOn()
Esempio n. 11
0
 def test_mode_auto_nodb(self):
     config.forceDbOff()
     self.set_sasurl(loc='local')
     self.mode = 'auto'
     self._set_modes(expmode='remote')
Esempio n. 12
0
def db_off():
    config.forceDbOff()
    yield
    config.forceDbOn()
Esempio n. 13
0
#      ymax [arcsec],
#      image size [units of spaxel number])
spaxel_binid = fin['SPAXEL_BINID'].data

# Ngal x Nbin x (Mstar, Mstar_err)
mstar_all = fin['STELLAR_MASS_VORONOI'].data

# Select galaxy and binids
ind1 = np.where(plateifus == args.plateifu)[0][0]
ind_binid = spaxel_binid[ind1, :, :, 0].astype(int)

# Create 2D stellar mass array
mstar = np.ones(ind_binid.shape) * np.nan
for row, inds in enumerate(ind_binid):
    ind_nans = np.where(inds == -99)
    mstar[row] = mstar_all[ind1, inds, 0]
    mstar[row][ind_nans] = np.nan

# trim mstar to match size of DAP maps and write to csv
config.forceDbOff()
cube = Cube(args.plateifu)
len_x = int(cube.header['NAXIS1'])

df = pd.DataFrame(mstar[:len_x, :len_x])
fout = join(path_data, 'manga-{}_mstar.csv'.format(args.plateifu))
df.to_csv(fout, index=False)

print('\nWrote:', fout)

fin.close()
Esempio n. 14
0
def dboff():
    config.forceDbOff()
    yield True
    config.forceDbOn()
Esempio n. 15
0
 def test_mma(self, mode):
     if mode == 'remote':
         config.forceDbOff()
     q = Query()
     assert q.mode == mode
Esempio n. 16
0
 def test_getdir3d_auto_plate_nodb(self):
     self._update_release('MPL-5')
     config.forceDbOff()
     self._getdir3d('stack', mode='auto', plateifu=self.plate)
Esempio n. 17
0
 def test_getdir3d_auto_newplate(self):
     self._update_release('MPL-4')
     config.forceDbOff()
     self._getdir3d('stack', mode='auto', plateifu=self.new_plate)
Esempio n. 18
0
 def test_getdir3d_mastar_auto(self):
     self._update_release('MPL-5')
     config.forceDbOff()
     self._getdir3d('mastar', mode='auto', plateifu=self.mastar_plateifu)