def save_offsets(summary, offsets): """Store the detector timing offset data in database :param summary: summary of data source (station and date) :type summary: histograms.models.Summary instance :param offsets: list of 4 timing offsets """ logger.debug("Saving detector timing offsets for %s" % summary) off = {'offset_%d' % i: round_in_base(o, 0.25) if not np.isnan(o) else None for i, o in enumerate(offsets, 1)} DetectorTimingOffset.objects.update_or_create(source=summary, defaults=off) logger.debug("Saved succesfully")
def test_integers(self): self.assertEqual(utils.ceil_in_base(3, 4), 4) self.assertEqual(utils.floor_in_base(3, 4), 0) self.assertEqual(utils.round_in_base(3, 4), 4)
def test_round(self): self.assertEqual(utils.round_in_base(2.4, 2.5), 2.5) self.assertEqual(utils.round_in_base(0.1, 2.5), 0)