def test_ou_hz_error(self): """ Test hz error extraction from origin_uncertainty """ self.zmap_fields += _EXT_ZMAP_FIELDS self.test_data.update({ 'h_err': '1.000000', 'z_err': '0.000000', 'm_err': '0.000000' }) pickler = zmap.Pickler(with_uncertainties=True) o = self.test_event.preferred_origin() o.origin_uncertainty.preferred_description = 'horizontal uncertainty' o.origin_uncertainty.horizontal_uncertainty = 1.0 dump = pickler.dumps(self.catalog) self.assertIn(self._expected_string(self.test_data), dump) # with unsupported preferred_description self.test_data.update({ 'h_err': 'NaN', 'z_err': '0.000000', 'm_err': '0.000000' }) o.origin_uncertainty.preferred_description = 'uncertainty ellipse' dump = pickler.dumps(self.catalog) self.assertIn(self._expected_string(self.test_data), dump)
def test_dump_with_uncertainty(self): """ Test export of non-standard (CSEP) uncertainty fields """ self.zmap_fields += _EXT_ZMAP_FIELDS self.test_data.update({'h_err': 'NaN', 'z_err': '0.000000', 'm_err': '0.000000'}) pickler = zmap.Pickler(with_uncertainties=True) dump = pickler.dumps(self.catalog) self.assertIn(self._expected_string(self.test_data), dump)
def test_lat_lon_hz_error(self): """ Test hz error extraction from lat/lon """ self.zmap_fields += _EXT_ZMAP_FIELDS self.test_data.update({'h_err': '0.138679', 'z_err': '0.000000', 'm_err': '0.000000'}) pickler = zmap.Pickler(with_uncertainties=True) o = self.test_event.preferred_origin() o.latitude_errors.uncertainty = .001 o.longitude_errors.uncertainty = .001 dump = pickler.dumps(self.catalog) self.assertIn(self._expected_string(self.test_data), dump)
def test_serialize(self): """ Test serialization to zmap format """ pickler = zmap.Pickler() # test full event (including origin/magnitude) dump = pickler.dumps(self.catalog) self.assertIn(self._expected_string(self.test_data), dump) self.assertEqual(dump.count('\n'), 3) # no preferred origin oid = self.test_event.preferred_origin_id self.test_event.preferred_origin_id = None dump = pickler.dumps(self.catalog) self.assertIn(self._expected_string({'mag': '4.400000'}), dump) self.test_event.preferred_origin_id = oid # no preferred magnitude self.test_event.preferred_magnitude_id = None dump = pickler.dumps(self.catalog) test_data = self.test_data.copy() del test_data['mag'] self.assertIn(self._expected_string(test_data), dump)
def test_serialize(self): """ Test serialization to zmap format """ pickler = zmap.Pickler() # test full event (including origin/magnitude) dump = pickler.dumps(self.catalog) self.assertIn(self._expected_string(self.test_data), dump) self.assertEqual(dump.count('\n'), 3) # no preferred origin -- still dump first origin oid = self.test_event.preferred_origin_id self.test_event.preferred_origin_id = None dump = pickler.dumps(self.catalog) self.assertIn(self._expected_string(self.test_data), dump) self.test_event.preferred_origin_id = oid # no preferred magnitude -- still dump first magnitude mid = self.test_event.preferred_origin_id self.test_event.preferred_magnitude_id = None dump = pickler.dumps(self.catalog) self.assertIn(self._expected_string(self.test_data), dump) self.test_event.preferred_magnitude_id = mid