Skip to content

Commit

Permalink
Merge 8f3ccd6 into e9f34df
Browse files Browse the repository at this point in the history
  • Loading branch information
moustakas committed Mar 7, 2023
2 parents e9f34df + 8f3ccd6 commit cc7fe11
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
4 changes: 3 additions & 1 deletion doc/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ desispec Change Log
0.57.1 (unreleased)
-------------------

No changes yet.
* Fix failing ``io.photo`` unit tests (PR `#2017`_).

.. _`#2017`: https://github.com/desihub/desispec/pull/2017

0.57.0 (2023-02-17)
-------------------
Expand Down
36 changes: 19 additions & 17 deletions py/desispec/test/test_photo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,44 @@ def setUp(self):

# for testing gather_targetphot and gather_tractorphot

# sv3-dark (secondary), sv1-bright (primary), main-dark (secondary), main-dark (primary, south), main-dark (primary, north)
# sv3-dark (secondary), sv1-bright (primary), main-dark (secondary), main-dark (primary, south), main-dark (primary, north), sv3-bright (TOO)
input_cat = Table()
input_cat['TARGETID'] = [929413348720641, 39627061832191195, 2253225356951552, 39627565329026280, 39633086782113662]
input_cat['TARGET_RA'] = [216.615157366494, 59.237567466068484, 217.118753472706, 195.3373716438542, 230.3357972402121]
input_cat['TARGET_DEC'] = [1.61111164514945, -31.46536118661697, 1.40073953879623, -9.135959353230087, 40.614361185571525]
input_cat['TARGETID'] = [929413348720641, 39627061832191195, 2253225356951552, 39627565329026280, 39633086782113662, 43977491483722156]
input_cat['TARGET_RA'] = [216.615157366494, 59.237567466068484, 217.118753472706, 195.3373716438542, 230.3357972402121, 150.1306899]
input_cat['TARGET_DEC'] = [1.61111164514945, -31.46536118661697, 1.40073953879623, -9.135959353230087, 40.614361185571525, 1.505752]
input_cat['TILEID'] = [280, 80638, 1086, 1573, 1766, 19]
self.input_cat = input_cat
self.tileids = [280, 80638, 1086, 1573, 1766]

# targetphot results
targetphot = Table()
targetphot['FLUX_R'] = np.array([0.0, 22.768417, 0.0, 2.0220177, 0.3754208]).astype('f4')
targetphot['FLUX_W1'] = np.array([0.0, 38.42719, 0.0, 8.39509, 1.7937177]).astype('f4')
targetphot['FLUX_IVAR_W2'] = np.array([0.0, 0.72876793, 0.0, 0.53684264, 1.5837417]).astype('f4')
targetphot['NUMOBS_INIT'] = np.array([1,1,1,4,9]).astype(np.int64)
targetphot['FLUX_R'] = np.array([0.0, 22.768417, 0.0, 2.0220177, 0.3754208, 0.0]).astype('f4')
targetphot['FLUX_W1'] = np.array([0.0, 38.42719, 0.0, 8.39509, 1.7937177, 0.0]).astype('f4')
targetphot['FLUX_IVAR_W2'] = np.array([0.0, 0.72876793, 0.0, 0.53684264, 1.5837417, 0.0]).astype('f4')
targetphot['NUMOBS_INIT'] = np.array([1,1,1,4,9, 1]).astype(np.int64)
self.targetphot = targetphot

# tractorphot results
tractorphot = Table()
tractorphot['FLUX_R'] = np.array([0.0, 22.768417, 0.4996462, 2.0220177, 0.3754208]).astype('f4')
tractorphot['FLUX_IVAR_W1'] = np.array([0.0, 2.6306653, 2.2135038, 2.3442872, 6.2124352]).astype('f4')
tractorphot['LS_ID'] = np.array([0, 9906610122001627, 9906622040377206, 9906617989139688, 9907735053993854]).astype(np.int64)
tractorphot['FLUX_R'] = np.array([0.0, 22.768417, 0.4996462, 2.0220177, 0.3754208, 4.8209643]).astype('f4')
tractorphot['FLUX_IVAR_W1'] = np.array([0.0, 2.6306653, 2.2135038, 2.3442872, 6.2124352, 2.5682714]).astype('f4')
tractorphot['LS_ID'] = np.array([0, 9906610122001627, 9906622040377206, 9906617989139688, 9907735053993854, 9906622022814265]).astype(np.int64)
self.tractorphot = tractorphot

@unittest.skipUnless(standard_nersc_environment, "not at NERSC")
def test_gather_targetdirs(self):
"""Test that we get the correct targeting directories given a tile."""
surveyops_dir = os.environ['DESI_SURVEYOPS']
truedirs = {
# sv1
'80613': ['/global/cfs/cdirs/desi/target/catalogs/dr9/0.47.0/targets/sv1/resolve/bright/'],
# sv3 including ToOs
'19': ['/global/cfs/cdirs/desi/survey/ops/surveyops/trunk/mtl/sv3/ToO/ToO.ecsv',
'19': [surveyops_dir+'/mtl/sv3/ToO/ToO.ecsv',
'/global/cfs/cdirs/desi/target/catalogs/dr9/0.57.0/targets/sv3/resolve/bright',
'/global/cfs/cdirs/desi/target/catalogs/dr9/0.57.0/targets/sv3/secondary/bright'],
'/global/cfs/cdirs/desi/target/catalogs/dr9/0.57.0/targets/sv3/secondary/bright/sv3targets-bright-secondary.fits'],
# main
'2070': ['/global/cfs/cdirs/desi/target/catalogs/dr9/1.1.1/targets/main/resolve/dark',
'/global/cfs/cdirs/desi/target/catalogs/dr9/1.1.1/targets/main/secondary/dark']
'2070': [surveyops_dir+'/mtl/main/ToO/ToO.ecsv',
'/global/cfs/cdirs/desi/target/catalogs/dr9/1.1.1/targets/main/resolve/dark',
'/global/cfs/cdirs/desi/target/catalogs/dr9/1.1.1/targets/main/secondary/dark/targets-dark-secondary.fits']
}

for tileid in truedirs.keys():
Expand All @@ -68,7 +70,7 @@ def test_gather_targetdirs(self):
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, tileids=self.tileids)
targetphot = gather_targetphot(self.input_cat)
for col in self.targetphot.colnames:
self.assertTrue(np.all(targetphot[col] == self.targetphot[col]))

Expand Down

0 comments on commit cc7fe11

Please sign in to comment.