Skip to content

Commit

Permalink
account for re-ordering of gs_objects by new down-selction code
Browse files Browse the repository at this point in the history
  • Loading branch information
jchiang87 committed Oct 11, 2018
1 parent 33c058a commit 5515011
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions tests/test_instcat_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def setUpClass(cls):
cls.data_dir = os.path.join(os.environ['IMSIM_DIR'], 'tests', 'data')
cls.scratch_dir = tempfile.mkdtemp(prefix=cls.data_dir)


@classmethod
def tearDownClass(cls):
if os.path.exists(cls.scratch_dir):
Expand Down Expand Up @@ -165,6 +164,8 @@ def test_object_extraction_stars(self):
truth_data = np.genfromtxt(os.path.join(self.data_dir, 'truth_stars.txt'),
dtype=truth_dtype, delimiter=';')

truth_data.sort()
id_arr = sorted(id_arr)
np.testing.assert_array_equal(truth_data['uniqueId'], id_arr)

######## test that pupil coordinates are correct to within
Expand All @@ -178,8 +179,8 @@ def test_object_extraction_stars(self):
parallax=truth_data['parallax'],
obs_metadata=obs_md)

for i_obj, gs_obj in enumerate(gs_object_arr):
self.assertEqual(truth_data['uniqueId'][i_obj], gs_obj.uniqueId)
for gs_obj in gs_object_arr:
i_obj = np.where(truth_data['uniqueId'] == gs_obj.uniqueId)[0][0]
dd = np.sqrt((x_pup_test[i_obj]-gs_obj.xPupilRadians)**2 +
(y_pup_test[i_obj]-gs_obj.yPupilRadians)**2)
dd = arcsecFromRadians(dd)
Expand All @@ -192,7 +193,8 @@ def test_object_extraction_stars(self):
imsim_bp.imsimBandpass()
phot_params = PhotometricParameters(nexp=1, exptime=30.0)

for i_obj, gs_obj in enumerate(gs_object_arr):
for gs_obj in gs_object_arr:
i_obj = np.where(truth_data['uniqueId'] == gs_obj.uniqueId)[0][0]
sed = Sed()
full_sed_name = os.path.join(os.environ['SIMS_SED_LIBRARY_DIR'],
truth_data['sedFilename'][i_obj])
Expand Down Expand Up @@ -270,14 +272,17 @@ def test_object_extraction_galaxies(self):
truth_data = np.genfromtxt(os.path.join(self.data_dir, 'truth_galaxies.txt'),
dtype=truth_dtype, delimiter=';')

truth_data.sort()
id_arr = sorted(id_arr)
np.testing.assert_array_equal(truth_data['uniqueId'], id_arr)

######## test that galaxy parameters are correctly read in

g1 = truth_data['gamma1']/(1.0-truth_data['kappa'])
g2 = truth_data['gamma2']/(1.0-truth_data['kappa'])
mu = 1.0/((1.0-truth_data['kappa'])**2 - (truth_data['gamma1']**2 + truth_data['gamma2']**2))
for i_obj, gs_obj in enumerate(gs_object_arr):
for gs_obj in gs_object_arr:
i_obj = np.where(truth_data['uniqueId'] == gs_obj.uniqueId)[0][0]
self.assertAlmostEqual(gs_obj.mu/mu[i_obj], 1.0, 6)
self.assertAlmostEqual(gs_obj.g1/g1[i_obj], 1.0, 6)
self.assertAlmostEqual(gs_obj.g2/g2[i_obj], 1.0, 6)
Expand All @@ -303,8 +308,8 @@ def test_object_extraction_galaxies(self):
truth_data['decJ2000'],
obs_metadata=obs_md)

for i_obj, gs_obj in enumerate(gs_object_arr):
self.assertEqual(truth_data['uniqueId'][i_obj], gs_obj.uniqueId)
for gs_obj in gs_object_arr:
i_obj = np.where(truth_data['uniqueId'] == gs_obj.uniqueId)[0][0]
dd = np.sqrt((x_pup_test[i_obj]-gs_obj.xPupilRadians)**2 +
(y_pup_test[i_obj]-gs_obj.yPupilRadians)**2)
dd = arcsecFromRadians(dd)
Expand All @@ -317,7 +322,8 @@ def test_object_extraction_galaxies(self):
imsim_bp.imsimBandpass()
phot_params = PhotometricParameters(nexp=1, exptime=30.0)

for i_obj, gs_obj in enumerate(gs_object_arr):
for gs_obj in gs_object_arr:
i_obj = np.where(truth_data['uniqueId'] == gs_obj.uniqueId)[0][0]
sed = Sed()
full_sed_name = os.path.join(os.environ['SIMS_SED_LIBRARY_DIR'],
truth_data['sedFilename'][i_obj])
Expand Down Expand Up @@ -365,7 +371,6 @@ def test_object_extraction_galaxies(self):
self.assertGreater(valid, 10)
self.assertGreater(len(valid_chip_names), 5)


def test_parsePhoSimInstanceFile_warning(self):
"Test the warnings emitted by the instance catalog parser."
commands = desc.imsim.metadata_from_file(self.extra_commands)
Expand Down

0 comments on commit 5515011

Please sign in to comment.