IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 9, 2014, 2:32:00 PM (12 years ago)
Author:
eugene
Message:

fix header fields to use formatted floats

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140717/ippToPsps/jython/detectionbatch.py

    r37204 r37208  
    9898           raise
    9999       
     100       # MJD-OBS is the exposure start, EXTIME / 172800 = (EXPTIME sec / 84600 sec/day) / 2
    100101       self.obsTime = float(self.header['MJD-OBS']) + (float(self.header['EXPTIME']) / 172800.0)
    101102     
     
    135136        sqlLine.group("telescopeID",           "1");
    136137        sqlLine.group("analysisVer",           self.analysisVer);
    137         sqlLine.group("photoScat",             self.getKeyValue(self.header, 'ZPT_ERR'));
    138         sqlLine.group("expStart",              self.getKeyValue(self.header, 'MJD-OBS'));
    139         sqlLine.group("expTime",               self.getKeyValue(self.header, 'EXPREQ'));
    140         sqlLine.group("airmass",               self.getKeyValue(self.header, 'AIRMASS'));
    141         sqlLine.group("raBore",                self.getKeyValue(self.header, 'RA'));
    142         sqlLine.group("decBore",               self.getKeyValue(self.header, 'DEC'));
     138        sqlLine.group("photoScat",             self.getKeyFloat(self.header, "%.8f", 'ZPT_ERR'));
     139        sqlLine.group("expStart",              self.getKeyFloat(self.header, "%.10f", 'MJD-OBS'));
     140        sqlLine.group("expTime",               self.getKeyFloat(self.header, "%.8f", 'EXPREQ'));
     141        sqlLine.group("airmass",               self.getKeyFloat(self.header, "%.8f", 'AIRMASS'));
     142        sqlLine.group("raBore",                self.getKeyFloat(self.header, "%.10f", 'RA'));
     143        sqlLine.group("decBore",               self.getKeyFloat(self.header, "%.10f", 'DEC'));
    143144        sqlLine.group("ctype1",                self.getKeyValue(self.header, 'CTYPE1'));
    144145        sqlLine.group("ctype2",                self.getKeyValue(self.header, 'CTYPE2'));
    145         sqlLine.group("crval1",                self.getKeyValue(self.header, 'CRVAL1'));
    146         sqlLine.group("crval2",                self.getKeyValue(self.header, 'CRVAL2'));
    147         sqlLine.group("crpix1",                self.getKeyValue(self.header, 'CRPIX1'));
    148         sqlLine.group("crpix2",                self.getKeyValue(self.header, 'CRPIX2'));
    149         sqlLine.group("cdelt1",                self.getKeyValue(self.header, 'CDELT1'));
    150         sqlLine.group("cdelt2",                self.getKeyValue(self.header, 'CDELT2'));
    151         sqlLine.group("pc001001",              self.getKeyValue(self.header, 'PC001001'));
    152         sqlLine.group("pc001002",              self.getKeyValue(self.header, 'PC001002'));
    153         sqlLine.group("pc002001",              self.getKeyValue(self.header, 'PC002001'));
    154         sqlLine.group("pc002002",              self.getKeyValue(self.header, 'PC002002'));
     146        sqlLine.group("crval1",                self.getKeyFloat(self.header, "%.8f", 'CRVAL1'));
     147        sqlLine.group("crval2",                self.getKeyFloat(self.header, "%.8f", 'CRVAL2'));
     148        sqlLine.group("crpix1",                self.getKeyFloat(self.header, "%.8f", 'CRPIX1'));
     149        sqlLine.group("crpix2",                self.getKeyFloat(self.header, "%.8f", 'CRPIX2'));
     150        sqlLine.group("cdelt1",                self.getKeyFloat(self.header, "%.8e", 'CDELT1'));
     151        sqlLine.group("cdelt2",                self.getKeyFloat(self.header, "%.8e", 'CDELT2'));
     152        sqlLine.group("pc001001",              self.getKeyFloat(self.header, "%.8e", 'PC001001'));
     153        sqlLine.group("pc001002",              self.getKeyFloat(self.header, "%.8e", 'PC001002'));
     154        sqlLine.group("pc002001",              self.getKeyFloat(self.header, "%.8e", 'PC002001'));
     155        sqlLine.group("pc002002",              self.getKeyFloat(self.header, "%.8e", 'PC002002'));
    155156        sqlLine.group("polyOrder",             self.getKeyValue(self.header, 'NPLYTERM'));
    156         sqlLine.group("pca1x3y0",              self.getKeyValue(self.header, 'PCA1X3Y0'));
    157         sqlLine.group("pca1x2y1",              self.getKeyValue(self.header, 'PCA1X2Y1'));
    158         sqlLine.group("pca1x1y2",              self.getKeyValue(self.header, 'PCA1X1Y2'));
    159         sqlLine.group("pca1x0y3",              self.getKeyValue(self.header, 'PCA1X0Y3'));
    160         sqlLine.group("pca1x2y0",              self.getKeyValue(self.header, 'PCA1X2Y0'));
    161         sqlLine.group("pca1x1y1",              self.getKeyValue(self.header, 'PCA1X1Y1'));
    162         sqlLine.group("pca1x0y2",              self.getKeyValue(self.header, 'PCA1X0Y2'));
    163         sqlLine.group("pca2x3y0",              self.getKeyValue(self.header, 'PCA2X3Y0'));
    164         sqlLine.group("pca2x2y1",              self.getKeyValue(self.header, 'PCA2X2Y1'));
    165         sqlLine.group("pca2x1y2",              self.getKeyValue(self.header, 'PCA2X1Y2'));
    166         sqlLine.group("pca2x0y3",              self.getKeyValue(self.header, 'PCA2X0Y3'));
    167         sqlLine.group("pca2x2y0",              self.getKeyValue(self.header, 'PCA2X2Y0'));
    168         sqlLine.group("pca2x1y1",              self.getKeyValue(self.header, 'PCA2X1Y1'));
    169         sqlLine.group("pca2x0y2",              self.getKeyValue(self.header, 'PCA2X0Y2'));
     157        sqlLine.group("pca1x3y0",              self.getKeyFloat(self.header, "%.8e", 'PCA1X3Y0'));
     158        sqlLine.group("pca1x2y1",              self.getKeyFloat(self.header, "%.8e", 'PCA1X2Y1'));
     159        sqlLine.group("pca1x1y2",              self.getKeyFloat(self.header, "%.8e", 'PCA1X1Y2'));
     160        sqlLine.group("pca1x0y3",              self.getKeyFloat(self.header, "%.8e", 'PCA1X0Y3'));
     161        sqlLine.group("pca1x2y0",              self.getKeyFloat(self.header, "%.8e", 'PCA1X2Y0'));
     162        sqlLine.group("pca1x1y1",              self.getKeyFloat(self.header, "%.8e", 'PCA1X1Y1'));
     163        sqlLine.group("pca1x0y2",              self.getKeyFloat(self.header, "%.8e", 'PCA1X0Y2'));
     164        sqlLine.group("pca2x3y0",              self.getKeyFloat(self.header, "%.8e", 'PCA2X3Y0'));
     165        sqlLine.group("pca2x2y1",              self.getKeyFloat(self.header, "%.8e", 'PCA2X2Y1'));
     166        sqlLine.group("pca2x1y2",              self.getKeyFloat(self.header, "%.8e", 'PCA2X1Y2'));
     167        sqlLine.group("pca2x0y3",              self.getKeyFloat(self.header, "%.8e", 'PCA2X0Y3'));
     168        sqlLine.group("pca2x2y0",              self.getKeyFloat(self.header, "%.8e", 'PCA2X2Y0'));
     169        sqlLine.group("pca2x1y1",              self.getKeyFloat(self.header, "%.8e", 'PCA2X1Y1'));
     170        sqlLine.group("pca2x0y2",              self.getKeyFloat(self.header, "%.8e", 'PCA2X0Y2'));
    170171
    171172        sql = sqlLine.make(") VALUES ( ", ")")
     
    199200            psfFwhm = "NULL"
    200201        else:
    201             psfFwhm = 0.5*(psfFwhmMajor + psfFwhmMinor)
     202            psfFwhm = 0.5*(float(psfFwhmMajor) + float(psfFwhmMinor))
    202203
    203204        # insert image metadata into table
     
    208209        sqlLine.group("bias",             str(self.bias))
    209210        sqlLine.group("biasScat",         str(self.biasScat))
    210         sqlLine.group("sky",              self.getKeyValue(header, 'MSKY_MN'))
    211         sqlLine.group("skyScat",          self.getKeyValue(header, 'MSKY_SIG'))
    212         sqlLine.group("magSat",           self.getKeyValue(header, 'FSATUR'))
    213         sqlLine.group("completMag",       self.getKeyValue(header, 'FLIMIT'))
    214         sqlLine.group("astroScat",        self.getKeyValue(header, 'CERROR'))
    215         sqlLine.group("photoScat",        self.getKeyValue(self.header, 'ZPT_OBS'))
     211        sqlLine.group("sky",              self.getKeyFloat(header, "%.8f", 'MSKY_MN'))
     212        sqlLine.group("skyScat",          self.getKeyFloat(header, "%.8f", 'MSKY_SIG'))
     213        sqlLine.group("magSat",           self.getKeyFloat(header, "%.8f", 'FSATUR'))
     214        sqlLine.group("completMag",       self.getKeyFloat(header, "%.8f", 'FLIMIT'))
     215        sqlLine.group("astroScat",        self.getKeyFloat(header, "%.8f", 'CERROR'))
     216        sqlLine.group("photoScat",        self.getKeyFloat(self.header, "%.8f", 'ZPT_OBS'))
    216217        sqlLine.group("numAstroRef",      self.getKeyValue(header, 'NASTRO'))
    217218        sqlLine.group("numPhotoRef",      self.getKeyValue(header, 'NASTRO'))
     
    221222        sqlLine.group("psfWidMajor",      str(psfFwhmMajor))
    222223        sqlLine.group("psfWidMinor",      str(psfFwhmMinor))
    223         sqlLine.group("psfTheta",         self.getKeyValue(header, 'ANGLE'))
    224         sqlLine.group("momentXX",         "-999")
    225         sqlLine.group("momentXY",         "-999")
    226         sqlLine.group("momentYY",         "-999")
    227         sqlLine.group("momentM3C",        "-999")
    228         sqlLine.group("momentM3S",        "-999")
    229         sqlLine.group("momentM4C",        "-999")
    230         sqlLine.group("momentM4S",        "-999")
    231         sqlLine.group("momentR1",         "-999")
    232         sqlLine.group("momentRH",         "-999")
    233         sqlLine.group("apResid",          self.getKeyValue(header, 'APMIFIT'))
    234         sqlLine.group("dapResid",         self.getKeyValue(header, 'DAPMIFIT'))
     224        sqlLine.group("psfTheta",         self.getKeyFloat(header, "%.8f", 'ANGLE'))
     225        sqlLine.group("momentsMajor",     self.getKeyFloat(header, "%.8f", 'IQ_FW1'))
     226        sqlLine.group("momentsMinor",     self.getKeyFloat(header, "%.8f", 'IQ_FW2'))
     227        sqlLine.group("momentM2C",        self.getKeyFloat(header, "%.8f", 'IQ_M2C'))
     228        sqlLine.group("momentM2S",        self.getKeyFloat(header, "%.8f", 'IQ_M2S'))
     229        sqlLine.group("momentM3",         self.getKeyFloat(header, "%.8f", 'IQ_M3'))
     230        sqlLine.group("momentM4",         self.getKeyFloat(header, "%.8f", 'IQ_M4'))
     231        sqlLine.group("apResid",          self.getKeyFloat(header, "%.8f", 'APMIFIT'))
     232        sqlLine.group("dapResid",         self.getKeyFloat(header, "%.8f", 'DAPMIFIT'))
    235233        sqlLine.group("detectorID",       self.getKeyValue(header, 'DETECTOR'))
    236234        sqlLine.group("qaFlags",          str(self.scratchDb.getDvoImageFlags(header['IMAGEID'])))
     
    243241        # sqlLine.group("detrend7",         " ")
    244242        # sqlLine.group("detrend8",         " ")
    245         sqlLine.group("photoZero",        self.getKeyValue(self.header, 'ZPT_OBS'))
     243        sqlLine.group("photoZero",        self.getKeyFloat(self.header, "%.8f", 'ZPT_OBS'))
    246244        sqlLine.group("ctype1",           self.getKeyValue(header, 'CTYPE1'))
    247245        sqlLine.group("ctype2",           self.getKeyValue(header, 'CTYPE2'))
    248         sqlLine.group("crval1",           self.getKeyValue(header, 'CRVAL1'))
    249         sqlLine.group("crval2",           self.getKeyValue(header, 'CRVAL2'))
    250         sqlLine.group("crpix1",           self.getKeyValue(header, 'CRPIX1'))
    251         sqlLine.group("crpix2",           self.getKeyValue(header, 'CRPIX2'))
    252         sqlLine.group("cdelt1",           self.getKeyValue(header, 'CDELT1'))
    253         sqlLine.group("cdelt2",           self.getKeyValue(header, 'CDELT2'))
    254         sqlLine.group("pc001001",         self.getKeyValue(header, 'PC001001'))
    255         sqlLine.group("pc001002",         self.getKeyValue(header, 'PC001002'))
    256         sqlLine.group("pc002001",         self.getKeyValue(header, 'PC002001'))
    257         sqlLine.group("pc002002",         self.getKeyValue(header, 'PC002002'))
     246        sqlLine.group("crval1",           self.getKeyFloat(header, "%.8f", 'CRVAL1'))
     247        sqlLine.group("crval2",           self.getKeyFloat(header, "%.8f", 'CRVAL2'))
     248        sqlLine.group("crpix1",           self.getKeyFloat(header, "%.8f", 'CRPIX1'))
     249        sqlLine.group("crpix2",           self.getKeyFloat(header, "%.8f", 'CRPIX2'))
     250        sqlLine.group("cdelt1",           self.getKeyFloat(header, "%.8e", 'CDELT1'))
     251        sqlLine.group("cdelt2",           self.getKeyFloat(header, "%.8e", 'CDELT2'))
     252        sqlLine.group("pc001001",         self.getKeyFloat(header, "%.8e", 'PC001001'))
     253        sqlLine.group("pc001002",         self.getKeyFloat(header, "%.8e", 'PC001002'))
     254        sqlLine.group("pc002001",         self.getKeyFloat(header, "%.8e", 'PC002001'))
     255        sqlLine.group("pc002002",         self.getKeyFloat(header, "%.8e", 'PC002002'))
    258256        sqlLine.group("polyOrder",        self.getKeyValue(header, 'NPLYTERM'))
    259257
    260258        nPolyterm = int(self.getKeyValue(header, 'NPLYTERM'))
    261259        if nPolyterm > 1:
    262             sqlLine.group("pca1x2y0",         self.getKeyValue(header, 'PCA1X2Y0'))
    263             sqlLine.group("pca1x1y1",         self.getKeyValue(header, 'PCA1X1Y1'))
    264             sqlLine.group("pca1x0y2",         self.getKeyValue(header, 'PCA1X0Y2'))
    265             sqlLine.group("pca2x2y0",         self.getKeyValue(header, 'PCA2X2Y0'))
    266             sqlLine.group("pca2x1y1",         self.getKeyValue(header, 'PCA2X1Y1'))
    267             sqlLine.group("pca2x0y2",         self.getKeyValue(header, 'PCA2X0Y2'))
     260            sqlLine.group("pca1x2y0",         self.getKeyFloat(header, "%.8e", 'PCA1X2Y0'))
     261            sqlLine.group("pca1x1y1",         self.getKeyFloat(header, "%.8e", 'PCA1X1Y1'))
     262            sqlLine.group("pca1x0y2",         self.getKeyFloat(header, "%.8e", 'PCA1X0Y2'))
     263            sqlLine.group("pca2x2y0",         self.getKeyFloat(header, "%.8e", 'PCA2X2Y0'))
     264            sqlLine.group("pca2x1y1",         self.getKeyFloat(header, "%.8e", 'PCA2X1Y1'))
     265            sqlLine.group("pca2x0y2",         self.getKeyFloat(header, "%.8e", 'PCA2X0Y2'))
    268266        else:
    269267            sqlLine.group("pca1x2y0",         "-999")
     
    275273           
    276274        if nPolyterm > 2:
    277             sqlLine.group("pca1x3y0",         self.getKeyValue(header, 'PCA1X3Y0'))
    278             sqlLine.group("pca1x2y1",         self.getKeyValue(header, 'PCA1X2Y1'))
    279             sqlLine.group("pca1x1y2",         self.getKeyValue(header, 'PCA1X1Y2'))
    280             sqlLine.group("pca1x0y3",         self.getKeyValue(header, 'PCA1X0Y3'))
    281             sqlLine.group("pca2x3y0",         self.getKeyValue(header, 'PCA2X3Y0'))
    282             sqlLine.group("pca2x2y1",         self.getKeyValue(header, 'PCA2X2Y1'))
    283             sqlLine.group("pca2x1y2",         self.getKeyValue(header, 'PCA2X1Y2'))
    284             sqlLine.group("pca2x0y3",         self.getKeyValue(header, 'PCA2X0Y3'))
     275            sqlLine.group("pca1x3y0",         self.getKeyFloat(header, "%.8e", 'PCA1X3Y0'))
     276            sqlLine.group("pca1x2y1",         self.getKeyFloat(header, "%.8e", 'PCA1X2Y1'))
     277            sqlLine.group("pca1x1y2",         self.getKeyFloat(header, "%.8e", 'PCA1X1Y2'))
     278            sqlLine.group("pca1x0y3",         self.getKeyFloat(header, "%.8e", 'PCA1X0Y3'))
     279            sqlLine.group("pca2x3y0",         self.getKeyFloat(header, "%.8e", 'PCA2X3Y0'))
     280            sqlLine.group("pca2x2y1",         self.getKeyFloat(header, "%.8e", 'PCA2X2Y1'))
     281            sqlLine.group("pca2x1y2",         self.getKeyFloat(header, "%.8e", 'PCA2X1Y2'))
     282            sqlLine.group("pca2x0y3",         self.getKeyFloat(header, "%.8e", 'PCA2X0Y3'))
    285283        else:
    286284            sqlLine.group("pca1x3y0",         "-999")
     
    346344        sqlLine.group("pltScale",        "PLTSCALE")                                     
    347345        sqlLine.group("posAngle",        "POSANGLE")                                     
     346        sqlLine.group("raErr",           "X_PSF_SIG * abs(PLTSCALE)")
     347        sqlLine.group("decErr",          "Y_PSF_SIG * abs(PLTSCALE)")
    348348        sqlLine.group("psfFlux",         "PSF_INST_FLUX / " + extTimeString)
    349349        sqlLine.group("psfFluxErr",      "PSF_INST_FLUX_SIG / " + extTimeString)
     
    367367        sqlLine.group("apFlux",          "AP_FLUX / " + extTimeString)
    368368        sqlLine.group("apFluxErr",       "AP_FLUX_SIG / " + extTimeString)
    369         sqlLine.group("apFillF",         "AP_NPIX / (3.1416 * AP_MAG_RADIUS * AP_MAG_RADIUS)")
     369        sqlLine.group("apFillF",         "AP_NPIX / (3.14159265359 * POW(AP_MAG_RADIUS - 0.5, 2))")
    370370        sqlLine.group("apRadius",        "AP_MAG_RADIUS")
    371371        sqlLine.group("kronFlux",        "KRON_FLUX / " + extTimeString)
     
    525525                    ota = "XY%d%d" % (x, y)
    526526               
     527                    if self.config.test and not ((x == 0) and (y == 1)):
     528                        print "skipping ota: " + ota
     529                        continue
     530                       
    527531                    self.alterPspsTablesChip(ota, ota + ".hdr", x, y)
    528532
     
    576580               a.detectID     = b.detectID, \
    577581               a.ippObjID     = b.ippObjID, \
     582               a.dvoRegionID  = b.catID \
    578583               a.ra           = b.ra, \
    579584               a.dec          = b.dec_, \
    580                a.raErr        = b.raErr, \
    581                a.decErr       = b.decErr, \
    582585               a.zp           = b.zp, \
    583586               a.telluricExt  = b.telluricExt, \
     
    587590               WHERE a.ippDetectID = b.ippDetectID \
    588591               AND b.imageID = " + str(imageID)
    589 
    590         # XXX need to add dvoRegion
    591592
    592593        self.scratchDb.execute(sql)
     
    704705                if ota not in self.imageIDs: continue
    705706
     707                if self.config.test and not ((x == 0) and (y == 1)):
     708                    print "skipping ota " + ota
     709                    continue
     710
    706711                if self.populatePspsTablesChip(ota, x, y, results, tables): otaCount = otaCount + 1
    707712                if self.skipBatch:
     
    814819    def importIppTables(self, filter=""):
    815820
    816        ## if self.config.test: regex = "XY33.psf"
    817        ## else : regex = ".*.psf"
    818        regex = ".*.psf"
     821       if self.config.test:
     822           regex = "XY01.psf"
     823       else:
     824           regex = ".*.psf"
    819825 
    820826       # XXX EAM NOTE : this is fragile : requires PS1_V4
Note: See TracChangeset for help on using the changeset viewer.