Ejemplo n.º 1
0
    def setUp(self):
        self.session = self.db.Session()

        # make 2 datasets with 2 lightcurves each. Lightcurves have different
        # band
        band1 = gen_band(central=150**6)
        band2 = gen_band(central=160**6)
        self.dataset1 = gen_dataset('sqlalchemy test')
        self.dataset2 = gen_dataset('sqlalchemy test')
        skyregion1 = gen_skyregion(self.dataset1)
        skyregion2 = gen_skyregion(self.dataset2)
        lightcurve1 = gen_lightcurve(band1, self.dataset1, skyregion1)
        lightcurve2 = gen_lightcurve(band2, self.dataset1, skyregion1)
        lightcurve3 = gen_lightcurve(band1, self.dataset2, skyregion2)
        lightcurve4 = gen_lightcurve(band2, self.dataset2, skyregion2)
        db_objecsts = lightcurve1 + lightcurve2 + lightcurve3 + lightcurve4
        self.session.add_all(db_objecsts)
        self.session.flush()
        self.session.commit()
Ejemplo n.º 2
0
    def setUp(self):
        self.session = self.db.Session()

        # make 2 datasets with 2 lightcurves each. Lightcurves have different
        # band
        band1 = gen_band(central=150 ** 6)
        band2 = gen_band(central=160 ** 6)
        self.dataset1 = gen_dataset("sqlalchemy test")
        self.dataset2 = gen_dataset("sqlalchemy test")
        skyregion1 = gen_skyregion(self.dataset1)
        skyregion2 = gen_skyregion(self.dataset2)
        lightcurve1 = gen_lightcurve(band1, self.dataset1, skyregion1)
        lightcurve2 = gen_lightcurve(band2, self.dataset1, skyregion1)
        lightcurve3 = gen_lightcurve(band1, self.dataset2, skyregion2)
        lightcurve4 = gen_lightcurve(band2, self.dataset2, skyregion2)
        db_objecsts = lightcurve1 + lightcurve2 + lightcurve3 + lightcurve4
        self.session.add_all(db_objecsts)
        self.session.flush()
        self.session.commit()
Ejemplo n.º 3
0
    def setUp(self):
        self.session = self.db.Session()

        self.dataset = gen_dataset('test varmetric step')
        band = gen_band(dataset=self.dataset, central=150**6)
        skyregion = gen_skyregion(self.dataset)
        lightcurve = gen_lightcurve(band, self.dataset, skyregion)
        self.session.add_all(lightcurve)
        self.session.flush()
        self.session.commit()
Ejemplo n.º 4
0
    def setUp(self):
        self.session = self.db.Session()

        self.dataset = gen_dataset('test varmetric step')
        band = gen_band(dataset=self.dataset, central=150**6)
        skyregion = gen_skyregion(self.dataset)
        lightcurve = gen_lightcurve(band, self.dataset, skyregion)
        self.session.add_all(lightcurve)
        self.session.flush()
        self.session.commit()
Ejemplo n.º 5
0
    def setUp(self):
        """
        make a dataset with 10 images with 2 ligthcurves + one empty image
        """
        self.session = self.database.Session()
        self.band = gen_band(central=150**6)
        self.dataset = gen_dataset('expiring runningcatalog test')
        skyregion = gen_skyregion(self.dataset)
        datapoints = 10

        start = datetime.fromtimestamp(0)
        ten_sec = timedelta(seconds=10)
        xtrsrcs1 = []
        xtrsrcs2 = []
        images = []
        assocs = []
        for i in range(datapoints):
            taustart_ts = start + ten_sec * i
            image = gen_image(self.band, self.dataset, skyregion, taustart_ts)

            if i == 5:
                image.int = 10
            images.append(image)
            xtrsrcs1.append(gen_extractedsource(image))
            xtrsrcs2.append(gen_extractedsource(image))

        # now we can make runningcatalog, we use first xtrsrc as trigger src
        self.runningcatalog1 = gen_runningcatalog(xtrsrcs1[0], self.dataset)
        runningcatalog2 = gen_runningcatalog(xtrsrcs2[0], self.dataset)
        assocskyrgn1 = gen_assocskyrgn(self.runningcatalog1, skyregion)
        assocskyrgn2 = gen_assocskyrgn(runningcatalog2, skyregion)

        # create the associations. Can't do this directly since the
        # association table has non nullable columns
        for xtrsrc in xtrsrcs1:
            assocs.append(gen_assocxtrsource(self.runningcatalog1, xtrsrc))
        for xtrsrc in xtrsrcs2:
            assocs.append(gen_assocxtrsource(runningcatalog2, xtrsrc))

        self.empty_image = gen_image(self.band, self.dataset, skyregion,
                                     taustart_ts)

        self.session.add_all([
            self.band, skyregion, self.runningcatalog1, runningcatalog2,
            assocskyrgn1, assocskyrgn2, self.empty_image
        ] + images + xtrsrcs1 + xtrsrcs2 + assocs)
        self.session.flush()
        self.session.commit()
Ejemplo n.º 6
0
    def setUp(self):
        """
        make a dataset with 10 images with 2 ligthcurves + one empty image
        """
        self.session = self.database.Session()
        self.band = gen_band(central=150**6)
        self.dataset = gen_dataset('expiring runningcatalog test')
        skyregion = gen_skyregion(self.dataset)
        datapoints = 10

        start = datetime.fromtimestamp(0)
        ten_sec = timedelta(seconds=10)
        xtrsrcs1 = []
        xtrsrcs2 = []
        images = []
        assocs = []
        for i in range(datapoints):
            taustart_ts = start + ten_sec * i
            image = gen_image(self.band, self.dataset, skyregion, taustart_ts)

            if i == 5:
                image.int = 10
            images.append(image)
            xtrsrcs1.append(gen_extractedsource(image))
            xtrsrcs2.append(gen_extractedsource(image))

        # now we can make runningcatalog, we use first xtrsrc as trigger src
        self.runningcatalog1 = gen_runningcatalog(xtrsrcs1[0], self.dataset)
        runningcatalog2 = gen_runningcatalog(xtrsrcs2[0], self.dataset)
        assocskyrgn1 = gen_assocskyrgn(self.runningcatalog1, skyregion)
        assocskyrgn2 = gen_assocskyrgn(runningcatalog2, skyregion)

        # create the associations. Can't do this directly since the
        # association table has non nullable columns
        for xtrsrc in xtrsrcs1:
            assocs.append(gen_assocxtrsource(self.runningcatalog1, xtrsrc))
        for xtrsrc in xtrsrcs2:
            assocs.append(gen_assocxtrsource(runningcatalog2, xtrsrc))

        self.empty_image = gen_image(self.band, self.dataset, skyregion, taustart_ts)

        self.session.add_all([self.band, skyregion, self.runningcatalog1, runningcatalog2,
                              assocskyrgn1, assocskyrgn2, self.empty_image] +
                             images + xtrsrcs1 + xtrsrcs2 + assocs)
        self.session.flush()
        self.session.commit()
Ejemplo n.º 7
0
    def test_delete_dataset(self):
        db = Database()
        dataset = gen_dataset('delete test')
        band = gen_band(dataset)
        skyregion = gen_skyregion(dataset)
        image = gen_image(band, dataset, skyregion)
        extractedsource = gen_extractedsource(image)
        runningcatalog = gen_runningcatalog(extractedsource, dataset)
        db.session.add_all((
            dataset, band, skyregion, image, extractedsource, runningcatalog,
        ))
        db.session.flush()

        db.session.delete(dataset)
        db.session.flush()

        images = db.session.query(Image).filter(Image.dataset==dataset).all()
        self.assertEqual(len(images), 0)
Ejemplo n.º 8
0
    def test_delete_dataset(self):
        db = Database()
        dataset = gen_dataset('delete test')
        band = gen_band(dataset)
        skyregion = gen_skyregion(dataset)
        image = gen_image(band, dataset, skyregion)
        extractedsource = gen_extractedsource(image)
        runningcatalog = gen_runningcatalog(extractedsource, dataset)
        db.session.add_all((
            dataset,
            band,
            skyregion,
            image,
            extractedsource,
            runningcatalog,
        ))
        db.session.flush()

        db.session.delete(dataset)
        db.session.flush()

        images = db.session.query(Image).filter(Image.dataset == dataset).all()
        self.assertEqual(len(images), 0)