예제 #1
0
 def test_host_observations_removed(self):
     sns = tuple(SNS_HAVE_HOST_OBSERVATIONS)
     sn_files = SNFiles(sns)
     for i, file_path in enumerate(sn_files.filepaths):
         sn = sns[i]
         with open(file_path) as f:
             j = json.load(f)[sn]
         host_dots_count = _remove_photometry_fields(j, ('host',))
         curve_w_host = OSCCurve(j)
         all_dots_count = len(curve_w_host.y)
         curve_wo_host = OSCCurve.from_json(file_path)
         normal_dots_count = len(curve_wo_host.y)
         self.assertLessEqual(normal_dots_count, all_dots_count - host_dots_count)
         self.assertLess(normal_dots_count, all_dots_count)
예제 #2
0
 def test_model_data_removed(self):
     sns = tuple(SNS_HAVE_MODEL_DATA)
     sn_files = SNFiles(sns)
     for i, file_path in enumerate(sn_files.filepaths):
         sn = sns[i]
         with open(file_path) as f:
             j = json.load(f)[sn]
         model_dots_count = _remove_photometry_fields(j, ('model', 'realization'))
         curve_w_model = OSCCurve(j)
         all_dots_count = len(curve_w_model.y)
         curve_wo_model = OSCCurve.from_json(file_path)
         normal_dots_count = len(curve_wo_model.y)
         self.assertLessEqual(normal_dots_count, all_dots_count - model_dots_count)
         self.assertLess(normal_dots_count, all_dots_count)
예제 #3
0
 def setUp(self):
     self.band = 'X'
     self.time = np.arange(9, dtype=np.int)
     self.bin_width = 1
     osc_curve = OSCCurve.from_json(BINNING_JSON_PATH)
     self.curve = osc_curve[self.band]
     self.binned_curve = osc_curve.binned(bin_width=1, discrete_time=False)[self.band]
     self.binned_curve_discrete = osc_curve.binned(bin_width=1, discrete_time=True)[self.band]
예제 #4
0
 def test_read(self):
     for tde in TDE_PHOTOMETRY_WITH_TWO_VALUED_TIME:
         OSCCurve.from_name(tde, down_args={'baseurl':TDE_URL})
예제 #5
0
 def test_download_and_read(self):
     for fname in self.sn_files.filepaths:
         OSCCurve.from_json(fname)
예제 #6
0
 def test_y_U(self):
     curve = OSCCurve(self.json_data, bands='U')
     assert_allclose(-2.5*np.log10(curve.y*curve.norm), self.u_magn)
예제 #7
0
 def test_X_states(self):
     curve = OSCCurve(self.json_data)
     assert_equal(curve.X[:len(self.time),0], np.zeros_like(self.time))
     assert_equal(curve.X[len(self.time):,0], np.ones_like(self.time))
예제 #8
0
 def test_X_U(self):
     curve = OSCCurve(self.json_data, bands='U')
     assert_equal(curve.X, np.stack((np.zeros_like(self.time), self.time), axis=1))
예제 #9
0
 def test_unordered_logging(self):
     for fpath in self.sn_files.filepaths:
         with self.assertLogs(level=logging.INFO):
             OSCCurve.from_json(fpath)
예제 #10
0
 def test_order(self):
     for fpath in self.sn_files.filepaths:
         curve = OSCCurve.from_json(fpath)
         for lc in curve.values():
             self.assertTrue(np.all(np.diff(lc['x']) >= 0))
예제 #11
0
def _get_curves(sns, *args, **kwargs):
    return [OSCCurve.from_name(sn, *args, **kwargs) for sn in sns]
예제 #12
0
 def test_has_not_observations_for_the_band(self):
     band = 'MDUzZDJ'
     for snname in SNS_ALL_TUPLE:
         with self.assertRaises(EmptyPhotometryError,
                                msg='{} should not contain any observations in the band {}'.format(snname, band)):
             OSCCurve.from_name(snname, bands=band)
예제 #13
0
 def test_has_zero_valid_photometry_dots(self):
     sn_files = SNFiles(SNS_ZERO_VALID_PHOTOMETRY_DOTS)
     for fpath in sn_files.filepaths:
         with self.assertRaises(EmptyPhotometryError,
                                msg='{} should not contain any valid photometry dot'.format(fpath)):
             OSCCurve.from_json(fpath)
예제 #14
0
 def test_has_not_photometry_field(self):
     sn_files = SNFiles(SNS_HAVE_NOT_PHOTOMETRY)
     for fpath in sn_files.filepaths:
         with self.assertRaises(NoPhotometryError,
                                msg='{} should not contain photometry and KeyError should be raised'.format(fpath)):
             OSCCurve.from_json(fpath)
예제 #15
0
 def test_has_not_band(self):
     band = 'HBRW'
     sn = SNS_ALL_TUPLE[0]
     with self.assertRaises(ValueError):
         OSCCurve.from_name(sn, bands=band)
예제 #16
0
 def test_has_band(self):
     band = 'B'
     for sn in SNS_HAVE_B_BAND:
         curve = OSCCurve.from_name(sn, bands=band)
         self.assertEqual(len(curve.bands), 1)
         self.assertIn(band, curve)