IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 31810


Ignore:
Timestamp:
Jul 1, 2011, 9:01:00 AM (15 years ago)
Author:
rhenders
Message:

now creating XML doc for config and passing to super-constructor; implemented and using printMe() methid to dump status of program prior to batch creation; DVO label now taken from config file prior to query from GPC1 to get cam_ids; removing of useFullTables and testMode variables as these are now in config and handled by superclass; when in test mode, a regex ensures on extension XY33.psf is read; new fields populated: kron, kronErr, bias, biasScat, analsisVer (taken from config)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/jython/detectionbatch.py

    r31504 r31810  
    77from java.sql import *
    88
     9from xml.etree.ElementTree import ElementTree, Element, tostring
     10
    911from batch import Batch
    1012from gpc1db import Gpc1Db
     
    2426    def __init__(self,
    2527                 logger,
     28                 configDoc,
    2629                 gpc1Db,
    2730                 ippToPspsDb,
    28                  scratchDb,
    2931                 camID,
    30                  inputFile,
    31                  test=False,
    32                  useFullTables=False):
     32                 inputFile):
    3333
    3434       super(DetectionBatch, self).__init__(
    3535               logger,
     36               configDoc,
    3637               gpc1Db,
    3738               ippToPspsDb,
    38                scratchDb,
    3939               camID,
    4040               "detection",
    4141               inputFile,
    42                "MD04", # TODO
    43                #"3PI") # TODO
    44                useFullTables)
     42               #"MD04") # TODO
     43               "3PI")
    4544
    4645       if not self.everythingOK: return
    47 
    48        # meta data to the log
    49        self.logger.info("New Detection Batch:")
    50        self.logger.info("Cam ID:             %d" % self.id)
    51        self.logger.info("file:               %s" % inputFile)
    52        self.logger.info("Exp ID:             %d" % self.expID)
    53        self.logger.info("Exp name:           %s" % self.expName)
    54        self.logger.info("Distribution group: %s" % self.distGroup)
    5546
    5647       # create an output filename, which is {expID}.FITS
     
    5950
    6051       # if test mode
    61        if test:
     52       if self.testMode:
    6253           self.startX = 3
    6354           self.endX = 4
     
    7970       # set up some defauts
    8071       self.calibModNum = 0
    81        self.dataRelease = 0
    8272
    8373       self.totalNumPhotoRef = 0
     
    8878       # insert what we know about this stack batch into the stack table
    8979       self.ippToPspsDb.insertDetectionMeta(self.batchID, self.expID, self.filter)
     80
     81    '''
     82    Prints metadata to the log
     83    '''
     84    def printMe(self):
     85
     86        super(DetectionBatch, self).printMe()
     87
     88        self.logger.info("Cam ID:                 %d" % self.id)
     89        self.logger.info("Exp ID:                 %d" % self.expID)
     90        self.logger.info("Exp name:               %s" % self.expName)
     91        self.logger.info("Distribution group:     %s" % self.distGroup)
     92
    9093
    9194
     
    145148        ,1  \
    146149        ,1  \
    147         ,' ' \
     150        ,'" + str(self.analysisVer) + "' \
    148151        ,' ' \
    149152        ,' ' \
     
    207210               frameID \
    208211               ,ccdID \
     212               ,bias \
     213               ,biasScat \
    209214               ,sky \
    210215               ,skyScat \
     
    267272               " + str(self.expID) + " \
    268273               ," + ota[2:4] + " \
     274               ," + str(self.bias) + " \
     275               ," + str(self.biasScat) + " \
    269276               ," + self.safeDictionaryAccess(header, 'MSKY_MN') + " \
    270277               ," + self.safeDictionaryAccess(header, 'MSKY_SIG') + " \
     
    364371               ,momentYY \
    365372               ,apMag \
     373               ,kronFlux \
     374               ,kronFluxErr \
    366375               ,infoFlag \
    367376               ,sky \
     
    386395               ,MOMENTS_YY \
    387396               ,AP_MAG \
     397               ,KRON_FLUX \
     398               ,KRON_FLUX_ERR \
    388399               ,FLAGS\
    389400               ,SKY \
     
    645656        self.expName = meta[1];
    646657        self.distGroup = meta[2];
    647 
    648         return self.ippToPspsDb.alreadyProcessed("detection", "exp_id", self.expID)
     658        self.analysisVer = meta[3];
     659        self.bias = meta[4];
     660        self.biasScat = meta[5];
     661
     662        if not self.analysisVer: self.analysisVer = -999
     663
     664        #return self.ippToPspsDb.alreadyProcessed("detection", "exp_id", self.expID)
     665        return 0
    649666
    650667
     
    664681    '''
    665682    def importIppTables(self, filter=""):
    666        return super(DetectionBatch, self).importIppTables(".*.psf")
     683
     684       if self.testMode: regex = "XY33.psf"
     685       else : regex = ".*.psf"
     686
     687       return super(DetectionBatch, self).importIppTables(regex)
    667688
    668689
     
    674695
    675696
    676 # TODO put in config
    677 useFullTables=True
    678 testMode=False
    679 
    680697logging.config.fileConfig("logging.conf")
    681 logger = logging.getLogger("detectionbatch")
     698logger = logging.getLogger("ippToPspsLog")
    682699logger.setLevel(logging.INFO)
    683700logger.info("Starting")
    684701
     702configDoc = ElementTree(file="config.xml")
     703dvoGpc1Label = configDoc.find("dvo/gpc1Label").text
     704
    685705gpc1Db = Gpc1Db(logger)
    686706ippToPspsDb = IppToPspsDb(logger)
    687 scratchDb = ScratchDb(logger, useFullTables)
    688 
    689 camIDs = gpc1Db.getIDsInThisDVODbForThisStage("MD04.V2", "cam")
    690 logger.info("Found %d exposures" % len(camIDs))
    691 
    692 i = 0
    693 for camID in camIDs:
    694 
    695     #if camID < 43764: continue # TODO
    696 
    697     file = gpc1Db.getCameraStageSmf(camID)
     707
     708ids = gpc1Db.getIDsInThisDVODbForThisStage(dvoGpc1Label, "cam")
     709for id in ids:
     710
     711    if not int(configDoc.find("options/force").text) and ippToPspsDb.alreadyProcessed(id): continue
     712
     713    file = gpc1Db.getCameraStageSmf(id)
    698714
    699715    detectionBatch = DetectionBatch(logger,
     716                                    configDoc,
    700717                                    gpc1Db,
    701718                                    ippToPspsDb,
    702                                     scratchDb,
    703                                     camID,
    704                                     file,
    705                                     testMode,
    706                                     useFullTables)
     719                                    id,
     720                                    file)
     721    detectionBatch.printMe()
    707722    detectionBatch.run()
    708723
Note: See TracChangeset for help on using the changeset viewer.