def _roundTripThroughApdb(objects, sources, forcedSources, dateTime): """Run object and source catalogs through the Apdb to get the correct table schemas. Parameters ---------- objects : `pandas.DataFrame` Set of test DiaObjects to round trip. sources : `pandas.DataFrame` Set of test DiaSources to round trip. forcedSources : `pandas.DataFrame` Set of test DiaForcedSources to round trip. dateTime : `lsst.daf.base.DateTime` Time for the Apdb. Returns ------- objects : `pandas.DataFrame` Round tripped objects. sources : `pandas.DataFrame` Round tripped sources. """ tmpFile = tempfile.NamedTemporaryFile() apdbConfig = ApdbSqlConfig() apdbConfig.db_url = "sqlite:///" + tmpFile.name apdbConfig.dia_object_index = "baseline" apdbConfig.dia_object_columns = [] apdb = ApdbSql(config=apdbConfig) apdb.makeSchema() wholeSky = Box.full() diaObjects = pd.concat([apdb.getDiaObjects(wholeSky), objects]) diaSources = pd.concat( [apdb.getDiaSources(wholeSky, [], dateTime), sources]) diaForcedSources = pd.concat( [apdb.getDiaForcedSources(wholeSky, [], dateTime), forcedSources]) apdb.store(dateTime, diaObjects, diaSources, diaForcedSources) diaObjects = apdb.getDiaObjects(wholeSky) diaSources = apdb.getDiaSources(wholeSky, np.unique(diaObjects["diaObjectId"]), dateTime) diaForcedSources = apdb.getDiaForcedSources( wholeSky, np.unique(diaObjects["diaObjectId"]), dateTime) diaObjects.set_index("diaObjectId", drop=False, inplace=True) diaSources.set_index(["diaObjectId", "filterName", "diaSourceId"], drop=False, inplace=True) diaForcedSources.set_index(["diaObjectId"], drop=False, inplace=True) return (diaObjects, diaSources, diaForcedSources)
def test_construction(self): b = Box(Box.allLongitudes(), Box.allLatitudes()) self.assertTrue(b.isFull()) b = Box.fromDegrees(-90, -45, 90, 45) self.assertEqual(b, Box(b.getLon(), b.getLat())) a = Box.fromRadians(-0.5 * math.pi, -0.25 * math.pi, 0.5 * math.pi, 0.25 * math.pi) b = Box(LonLat.fromRadians(-0.5 * math.pi, -0.25 * math.pi), LonLat.fromRadians(0.5 * math.pi, 0.25 * math.pi)) c = Box(LonLat.fromRadians(0, 0), Angle(0.5 * math.pi), Angle(0.25 * math.pi)) d = c.clone() self.assertEqual(a, b) self.assertEqual(b, c) self.assertEqual(c, d) self.assertNotEqual(id(c), id(d)) b = Box() self.assertTrue(b.isEmpty()) self.assertTrue(Box.empty().isEmpty()) self.assertTrue(Box.full().isFull())