def __init__(self, lsstDB, schedulingData, sky, weather, sessionID, filters, fov, weakLensConf=DefaultWLConfigFile, targetList=None, dbTableDict=None, log=True, logfile='./Proposal.log', verbose=0): """ Standard initializer. lsstDB: LSST DB Access object sky: an AsronomycalSky instance. weather: a Weather instance. sessionID: An integer identifying this particular run. filters: ... fov: FoV of the instrument. weakLensConf: Weak Lensing Proposal Configuration file exposureTime: Exposure time in seconds. maxSeeing: Maximum acceptable seeing. targetList: the name (with path) of the TEXT file containing the field list. It is assumed that the target list is a three column list of RA, Dec and field ID. RA and Dec are assumed to be in decimal degrees; filed ID is assumed to be an integer uniquely identifying any give field. dbTableDict: log ... logfile ... verbose: integer specifying the verbosity level (defaults to 0 meaning quite). """ super(WeakLensingProp, self).__init__(lsstDB=lsstDB, propConf=weakLensConf, propName='WL', propFullName='WeakLensing', sky=sky, weather=weather, sessionID=sessionID, filters=filters, targetList=targetList, dbTableDict=dbTableDict, log=log, logfile=logfile, verbose=verbose) self.lsstDB = lsstDB if (self.log and self.verbose > 1): self.log.info('WeakLensingProp: init() propID=%d' % (self.propID)) self.schedulingData = schedulingData self.weakLensConf = weakLensConf self.GoalVisitsFieldFilter = {} self.sky = sky config, pairs = readConfFile(weakLensConf) self.nextNight = 0 try: self.maxAirmass = config['MaxAirmass'] except: pass try: self.exposureTime = config['ExposureTime'] except: pass try: self.goalNVisits = config['NVisits'] except: self.goalNVisits = 30. try: filterVisits = config["Filter_Visits"] except: filterVisits = [] for filter in self.FilterNames: filterVisits.append(self.goalNVisits) # if singleton, make into a list of one if not isinstance(filterVisits, list): filterVisits = [filterVisits] for ix in range(len(self.FilterNames)): self.GoalVisitsFieldFilter[self.FilterNames[ix]] = filterVisits[ix] print 'GoalVisitsFieldFilter for propID=%d %s = %s' % ( self.propID, self.propFullName, str(self.GoalVisitsFieldFilter)) try: self.maxNeedAfterOverflow = config['MaxNeedAfterOverflow'] except: self.maxNeedAfterOverflow = 0.5 try: self.ProgressToStartBoost = config['ProgressToStartBoost'] except: self.ProgressToStartBoost = 1.0 try: self.MaxBoostToComplete = config['MaxBoostToComplete'] except: self.MaxBoostToComplete = 0.0 try: self.scale = config['RankScale'] except: self.scale = 0.1 try: self.taperB = config['taperB'] except: self.taperB = 180. try: self.taperL = config['taperL'] except: self.taperL = 5. try: self.peakL = config['peakL'] except: self.peakL = 25. try: self.deltaLST = config['deltaLST'] except: self.deltaLST = 60. try: self.maxReach = config['maxReach'] except: self.maxReach = 80. try: self.minTransparency = config['minTransparency'] except: self.minTransparency = 9. if (config.has_key('userRegion')): self.userRegion = config["userRegion"] else: self.userRegion = None if (not isinstance(self.userRegion, list)): # turn it into a list with one entry save = self.userRegion self.userRegion = [] self.userRegion.append(save) try: self.maxProximityBonus = config['MaxProximityBonus'] except: self.maxProximityBonus = 1.0 # store config to DB for line in pairs: storeParam(self.lsstDB, self.sessionID, self.propID, 'weakLensing', line['index'], line['key'], line['val']) self.dbField = dbTableDict['field'] if (self.goalNVisits <= 0): self.goalNVisits = 1. # Setup FieldFilter visit history for later ObsHistory DB ingest self.fieldVisits = {} self.lastFieldVisit = {} self.lastFieldFilterVisit = {} self.lastTarget = (0.0, 0.0) # Setup the relative importance of each filter. For # convenience we use a dictionary of the form {filter: N} # where N is the desired fraction of the total number of # observations for that particular filter. If all the filters # were equally desirable, then N would be always equal to # 1. / total_number_of_filters. n = 0. # filterNames now is assigned in the parent class using the # filters' configuration file. # If this proposal wants to observe in a subset of this filter # list, this subset should be specified in the proposal's # configuration file. self.visits = {} self.GoalVisitsField = 0 for filter in (self.FilterNames): if filter in self.GoalVisitsFieldFilter.keys(): self.visits[filter] = {} self.GoalVisitsField += self.GoalVisitsFieldFilter[filter] print('GoalVisitsField = %i' % (self.GoalVisitsField)) # DataBase specifics self.dbTableDict = dbTableDict self.dbField = self.dbTableDict['field'] # If user-defined regions have been defined, build new FieldDB if not (self.userRegion[0] == None): self.dbField = self.buildUserRegionDB(self.userRegion, self.dbField) print "WeakLensingProp:init: dbField: %s" % (self.dbField) self.winners = [] self.obsHistory = None self.sessionID = sessionID # self.targets is a convenience dictionary. Its keys are # fieldIDs, its values are the corresponding RA and Dec. self.targets = {} # Create the ObsHistory instance and cleanup any leftover self.obsHistory = ObsHistory(lsstDB=self.lsstDB, dbTableDict=self.dbTableDict, log=self.log, logfile=self.logfile, verbose=self.verbose) self.obsHistory.cleanupProposal(self.propID, self.sessionID) self.ha_maxairmass = sky.getHAforAirmass(self.maxAirmass) return
def __init__(self, lsstDB, propConf, propName, propFullName, sky, weather, sessionID, filters, targetList=None, dbTableDict=None, log=False, logfile='./TransientProp.log', verbose=0, transientConf=DefaultNEAConfigFile): """ Standard initializer. lsstDB LSST DB access object propConf file name containing the instance's configuration data propName proposal name sky: an AsronomycalSky instance. weather: a Weather instance. sessionID: An integer identifying this particular run. filters: a Filters instance targetList: the name (with path) of the TEXT file containing the field list. It is assumed that the target list is a three column list of RA, Dec and field ID. RA and Dec are assumed to be in decimal degrees; filed ID is assumed to be an integer uniquely identifying any give field. dbTableDict: log False if not set, else: log = logging.getLogger("...") logfile Name (and path) of the desired log file. Defaults "./NearEarthProp.log". verbose: Log verbosity: -1=none, 0=minimal, 1=wordy, >1=verbose transientConf: Near Earth Asteroid Configuration file """ super(TransientProp, self).__init__(lsstDB=lsstDB, propConf=propConf, propName=propName, propFullName=propFullName, sky=sky, weather=weather, sessionID=sessionID, filters=filters, targetList=targetList, dbTableDict=dbTableDict, log=log, logfile=logfile, verbose=verbose) self.lsstDB = lsstDB self.verbose = verbose self.dbTableDict = dbTableDict # DataBase specifics self.dbTable = self.dbTableDict['field'] self.dbRA = 'fieldRA' self.dbDec = 'fieldDec' self.dbID = 'fieldID' self.winners = [] self.loosers = [] self.obsHistory = None # self.seqHistory = None self.sessionID = sessionID # self.targets is a convenience dictionary. Its keys are # fieldIDs, its values are the corresponding RA and Dec. self.targets = {} self.tonightTargets = {} self.sequences = {} self.blockedTargets = [] # Create the ObsHistory instance and cleanup any leftover self.obsHistory = ObsHistory(lsstDB=self.lsstDB, dbTableDict=self.dbTableDict, log=self.log, logfile=self.logfile, verbose=self.verbose) self.obsHistory.cleanupProposal(self.propID, self.sessionID) # Create the SeqHistory instance and cleanup any leftover # self.seqHistory = SeqHistory (lsstDB=self.lsstDB, # dbTableDict=self.dbTableDict, # log=self.log, # logfile=self.logfile, # verbose=self.verbose) # self.seqHistory.cleanupProposal (self.propID, self.sessionID) self.SeqCount = 0 return