Skip to content

Commit

Permalink
simplify NERSC environment check
Browse files Browse the repository at this point in the history
  • Loading branch information
moustakas committed Jan 3, 2024
1 parent d4e3ef9 commit da9a28d
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions py/desispec/test/test_photo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,7 @@
from desispec.io.photo import gather_targetphot, gather_tractorphot, gather_targetdirs
from desispec.io.meta import get_desi_root_readonly

if 'NERSC_HOST' in os.environ:
desi_root = get_desi_root_readonly()
if os.getenv('DESI_SPECTRO_DATA') == os.path.join(desi_root, 'spectro', 'data'):
standard_nersc_environment = True
else:
standard_nersc_environment = False
else:
standard_nersc_environment = False

class TestFibermap(unittest.TestCase):
class TestPhoto(unittest.TestCase):

def setUp(self):
from astropy.table import Table
Expand Down Expand Up @@ -63,11 +54,12 @@ def setUp(self):
tractorphot['LS_ID'] = np.array([10995128657712508, 10995128743167117, 10995128743105186]).astype(np.int64)
self.tractorphot_dr10 = tractorphot

@unittest.skipUnless(standard_nersc_environment, "not at NERSC")
@unittest.skipUnless('NERSC_HOST' in os.environ, "not at NERSC")
def test_gather_targetdirs(self):
"""Test that we get the correct targeting directories given a tile."""
desi_root = get_desi_root_readonly()
surveyops_dir = os.environ['DESI_SURVEYOPS']
#surveyops_dir = os.environ['DESI_SURVEYOPS']
surveyops_dir = desi_root+'/survey/ops/surveyops/trunk' # assumes a standard installation / environment
truedirs = {
# sv1
'80613': np.array([desi_root+'/target/catalogs/dr9/0.47.0/targets/sv1/resolve/bright/']),
Expand All @@ -86,23 +78,23 @@ def test_gather_targetdirs(self):
print(tileid, targetdirs, truedirs[tileid])
self.assertTrue(np.all(targetdirs == truedirs[tileid]))

@unittest.skipUnless(standard_nersc_environment, "not at NERSC")
@unittest.skipUnless('NERSC_HOST' in os.environ, "not at NERSC")
def test_gather_targetphot(self):
"""Test that we get the correct targeting photometry for an input set of objects."""

targetphot = gather_targetphot(self.input_cat)
for col in self.targetphot.colnames:
self.assertTrue(np.all(targetphot[col] == self.targetphot[col]))

@unittest.skipUnless(standard_nersc_environment, "not at NERSC")
@unittest.skipUnless('NERSC_HOST' in os.environ, "not at NERSC")
def test_gather_tractorphot(self):
"""Test that we get the correct Tractor photometry for an input set of objects."""

tractorphot = gather_tractorphot(self.input_cat)
for col in self.tractorphot.colnames:
self.assertTrue(np.all(tractorphot[col] == self.tractorphot[col]))

@unittest.skipUnless(standard_nersc_environment, "not at NERSC")
@unittest.skipUnless('NERSC_HOST' in os.environ, "not at NERSC")
def test_gather_tractorphot_dr10(self):
"""Like test_gather_tractorphot but for DR10 photometry."""
desi_root = get_desi_root_readonly()
Expand Down

0 comments on commit da9a28d

Please sign in to comment.