Ejemplo n.º 1
0
    def query(self, corner1, corner2, corner3, corner4):
        """
        Queries the database for stars within an area.
        
        @param corner1 [in] The first corner of the sensor defined as (RA, Decl).
        
        @param corner2 [in] The second corner of the sensor defined as (RA, Decl).
        
        @param corner3 [in] The third corner of the sensor defined as (RA, Decl).
        
        @param corner4 [in] The fourth corner of the sensor defined as (RA, Decl).
        """

        ra = [corner1[0], corner2[0], corner3[0], corner4[0]]
        decl = [corner1[1], corner2[1], corner3[1], corner4[1]]
        top = max(decl)
        bottom = min(decl)
        left = min(ra)
        right = max(ra)

        raStddev = numpy.std(ra)
        if raStddev >= stddevSplit:
            left = max([x for x in ra if x < 180])
            right = min([x for x in ra if x >= 180])
            above0Set = self.queryInternal(top, bottom, 0, left)
            below0Set = self.queryInternal(top, bottom, right, 360)
            return StarData.StarData(
                above0Set.RA + below0Set.RA, above0Set.Decl + below0Set.Decl,
                above0Set.ObsMagU + below0Set.ObsMagU, above0Set.ObsMagUNew +
                below0Set.ObsMagUNew, above0Set.LSSTMagU + below0Set.LSSTMagU,
                above0Set.LSSTMagUNoATM + below0Set.LSSTMagUNoATM,
                above0Set.ObsMagG + below0Set.ObsMagG, above0Set.ObsMagGNew +
                below0Set.ObsMagGNew, above0Set.LSSTMagG + below0Set.LSSTMagG,
                above0Set.LSSTMagGNoATM + below0Set.LSSTMagGNoATM,
                above0Set.ObsMagR + below0Set.ObsMagR, above0Set.ObsMagRNew +
                below0Set.ObsMagRNew, above0Set.LSSTMagR + below0Set.LSSTMagR,
                above0Set.LSSTMagRNoATM + below0Set.LSSTMagRNoATM,
                above0Set.ObsMagI + below0Set.ObsMagI, above0Set.ObsMagINew +
                below0Set.ObsMagINew, above0Set.LSSTMagI + below0Set.LSSTMagI,
                above0Set.LSSTMagINoATM + below0Set.LSSTMagINoATM,
                above0Set.ObsMagZ + below0Set.ObsMagZ, above0Set.ObsMagZNew +
                below0Set.ObsMagZNew, above0Set.LSSTMagZ + below0Set.LSSTMagZ,
                above0Set.LSSTMagZNoATM + below0Set.LSSTMagZNoATM,
                above0Set.ObsMagY + below0Set.ObsMagY, above0Set.ObsMagYNew +
                below0Set.ObsMagYNew, above0Set.LSSTMagY + below0Set.LSSTMagY,
                above0Set.LSSTMagYNoATM + below0Set.LSSTMagYNoATM)
        else:
            return self.queryInternal(top, bottom, left, right)
 def setUp(self):
     self.stars = StarData.StarData([100, 200, 300], [1, 2, 3], [4, 5, 6], [7, 8, 9], [7, 8, 9])
     self.stars.populateDetector("Foobar")
     self.survey = SkyCoverageSurvey()
Ejemplo n.º 3
0
    def queryInternal(self, top, bottom, left, right):
        """
        Queries the database for stars within an area.
        
        @param top [in] The top edge of the box (Decl).
        
        @param bottom [in] The bottom edge of the box (Decl).
        
        @param left [in] The left edge of the box (RA).
        
        @param right [in] The right edge of the box (RA).
        """

        query = "SELECT ra, decl, sdssu, newSDSSu, umag, umag_noatm, sdssg, newSDSSg, gmag, gmag_noatm, sdssr, newSDSSr, rmag, rmag_noatm, sdssi, newSDSSi, imag, imag_noatm, sdssz, newSDSSz, zmag, zmag_noatm, ymag, ymag_noatm FROM bright_stars WHERE decl <= %f AND decl >= %f AND ra >= %f AND ra <= %f" % (
            top, bottom, left, right)
        self.cursor.execute(query)
        ra = []
        decl = []
        obsMagU = []
        obsMagUNew = []
        lsstMagU = []
        lsstMagUNoATM = []
        obsMagG = []
        obsMagGNew = []
        lsstMagG = []
        lsstMagGNoATM = []
        obsMagR = []
        obsMagRNew = []
        lsstMagR = []
        lsstMagRNoATM = []
        obsMagI = []
        obsMagINew = []
        lsstMagI = []
        lsstMagINoATM = []
        obsMagZ = []
        obsMagZNew = []
        lsstMagZ = []
        lsstMagZNoATM = []
        obsMagY = []
        obsMagYNew = []
        lsstMagY = []
        lsstMagYNoATM = []
        for item in self.cursor.fetchall():
            ra.append(item[0])
            decl.append(item[1])
            obsMagU.append(item[2])
            obsMagUNew.append(item[3])
            lsstMagU.append(item[4])
            lsstMagUNoATM.append(item[5])
            obsMagG.append(item[6])
            obsMagGNew.append(item[7])
            lsstMagG.append(item[8])
            lsstMagGNoATM.append(item[9])
            obsMagR.append(item[10])
            obsMagRNew.append(item[11])
            lsstMagR.append(item[12])
            lsstMagRNoATM.append(item[13])
            obsMagI.append(item[14])
            obsMagINew.append(item[15])
            lsstMagI.append(item[16])
            lsstMagINoATM.append(item[17])
            obsMagZ.append(item[18])
            obsMagZNew.append(item[19])
            lsstMagZ.append(item[20])
            lsstMagZNoATM.append(item[21])
            obsMagY.append(-99)
            obsMagYNew.append(-99)
            lsstMagY.append(item[22])
            lsstMagYNoATM.append(item[23])
        return StarData.StarData(ra, decl, obsMagU, obsMagUNew, lsstMagU,
                                 lsstMagUNoATM, obsMagG, obsMagGNew, lsstMagG,
                                 lsstMagGNoATM, obsMagR, obsMagRNew, lsstMagR,
                                 lsstMagRNoATM, obsMagI, obsMagINew, lsstMagI,
                                 lsstMagINoATM, obsMagZ, obsMagZNew, lsstMagZ,
                                 lsstMagZNoATM, obsMagY, obsMagYNew, lsstMagY,
                                 lsstMagYNoATM)