def checkOB(self, ob, p2container=None): ui = self.ui instrumentConfiguration = ob.instrumentConfiguration BASELINE = ob.interferometerConfiguration.stations # Compute tel = UT or AT # TODO move code into common part if "U" in BASELINE: tel = "UT" else: tel = "AT" instrumentMode = instrumentConfiguration.instrumentMode # Retrieve SPEC and POL info from instrumentMode for disp in self.getRange("PIONIER_acq.tsf", "INS.DISP.NAME"): if disp in instrumentMode[0:len(disp)]: ins_disp = disp for observationConfiguration in self.getSequence(ob): # create keywords storage objects acqTSF = TSF(self, "PIONIER_acq.tsf") obsTSF = TSF(self, "PIONIER_obs_calibrator.tsf") # alias for PIONIER_obs_calibrator.tsf and # PIONIER_obs_science.tsf") kappaTSF = TSF(self, "PIONIER_gen_cal_kappa.tsf") darkTSF = TSF(self, "PIONIER_gen_cal_dark.tsf") obTarget = OBTarget() obConstraints = OBConstraints(self) # set common properties acqTSF.INS_DISP_NAME = ins_disp if 'SCIENCE' in observationConfiguration.type: OBJTYPE = 'SCIENCE' else: OBJTYPE = 'CALIBRATOR' scienceTarget = observationConfiguration.SCTarget # define target # acqTSF.SEQ_INS_SOBJ_NAME = scienceTarget.name.strip() obTarget.name = scienceTarget.name.strip().replace( ' ', '_' ) # allowed characters: letters, digits, + - _ . and no spaces obTarget.ra, obTarget.dec = self.getCoords(scienceTarget) obTarget.properMotionRa, obTarget.properMotionDec = self.getPMCoords( scienceTarget) # Set baseline interferometric array code (should be a keywordlist) acqTSF.ISS_BASELINE = [self.getBaselineCode(BASELINE)] self.checkIssVltiType(acqTSF) # define some default values DIAMETER = float(self.get(scienceTarget, "DIAMETER", 0.0)) VIS = 1.0 # FIXME # Retrieve Fluxes TEL_COU_MAG = self.getFlux(scienceTarget, "V") acqTSF.ISS_IAS_HMAG = self.getFlux(scienceTarget, "H") # setup some default values, to be changed below TEL_COU_GSSOURCE = 'SCIENCE' # by default GSRA = '00:00:00.000' GSDEC = '00:00:00.000' # initialize FT variables (must exist) # AO target aoTarget = ob.get(observationConfiguration, "AOTarget") if aoTarget != None: AONAME = aoTarget.name TEL_COU_GSSOURCE = 'SETUPFILE' # since we have an AO # TODO check if AO coords should be required by template # AORA, AODEC = self.getCoords(aoTarget, # requirePrecision=False) acqTSF.TEL_COU_PMA, acqTSF.TEL_COU_PMD = self.getPMCoords( aoTarget) # Guide Star gsTarget = ob.get(observationConfiguration, 'GSTarget') if gsTarget != None: TEL_COU_GSSOURCE = 'SETUPFILE' # since we have an GS GSRA, GSDEC = self.getCoords(gsTarget, requirePrecision=False) # no PMRA, PMDE for GS !! TEL_COU_MAG = float(gsTarget.FLUX_V) # LST interval try: obsConstraint = observationConfiguration.observationConstraints LSTINTERVAL = obsConstraint.LSTinterval except: LSTINTERVAL = None # Constraints obConstraints.name = 'Aspro-created constraints' skyTransparencyMagLimits = {"AT": 3, "UT": 5} if acqTSF.ISS_IAS_HMAG < skyTransparencyMagLimits[tel]: obConstraints.skyTransparency = 'Variable, thin cirrus' else: obConstraints.skyTransparency = 'Clear' if acqTSF.ISS_IAS_HMAG > 7.5: acqTSF.INS_DISP_NAME = "FREE" # FIXME: error (OB): "Phase 2 constraints must closely follow what was requested in the Phase 1 proposal. # The seeing value allowed for this OB is >= java0x0 arcsec." # FIXME REPLACE SEEING THAT IS NO MORE SUPPORTED # obConstraints.seeing = 1.0 # FIXME: default values NOT IN ASPRO! # constaints.airmass = 5.0 # constaints.fli = 1 # compute dit, ndit, nexp # and store computed values in obsTSF obsTSF.SEQ_NEXPO = 5 # obsTSF.NSCANS = 100 # kappaTSF.SEQ_DOIT=False # darkTSF.SEQ_DOIT=True # then call the ob-creation using the API if p2container exists. if p2container == None: ui.addToLog(obTarget.name + " ready for p2 upload (details logged)") ui.addToLog(obTarget, False) ui.addToLog(obConstraints, False) ui.addToLog(acqTSF, False) ui.addToLog(obsTSF, False) ui.addToLog(kappaTSF, False) ui.addToLog(darkTSF, False) else: self.createPionierOB(p2container, obTarget, obConstraints, acqTSF, obsTSF, kappaTSF, darkTSF, OBJTYPE, instrumentMode, TEL_COU_GSSOURCE, GSRA, GSDEC, TEL_COU_MAG, LSTINTERVAL) ui.addToLog(obTarget.name + " submitted on p2")
def checkOB(self, ob, p2container, dryMode=True): api = self.facility.getAPI() ui = self.ui containerId = p2container.containerId instrumentConfiguration = ob.instrumentConfiguration BASELINE = ob.interferometerConfiguration.stations # Compute tel = UT or AT # TODO move code into common part if "U" in BASELINE: tel = "UT" else: tel = "AT" instrumentMode = instrumentConfiguration.instrumentMode # Retrieve SPEC and POL info from instrumentMode for disp in self.getRange("PIONIER_acq.tsf", "INS.DISP.NAME"): if disp in instrumentMode[0:len(disp)]: ins_disp = disp # if we have more than 1 obs, then better put it in a subfolder waiting # for the existence of a block sequence not yet implemented in P2 obsconflist = ob.observationConfiguration doFolder = (len(obsconflist) > 1) parentContainerId = containerId if doFolder and not dryMode: folderName = obsconflist[0].Target.name folderName = re.sub('[^A-Za-z0-9]+', '_', folderName.strip()) folder, _ = api.createFolder(containerId, folderName) containerId = folder['containerId'] for observationConfiguration in ob.observationConfiguration: # create keywords storage objects acqTSF = TSF(self, "PIONIER_acq.tsf") obsTSF = TSF(self, "PIONIER_obs_calibrator.tsf") # alias for PIONIER_obs_calibrator.tsf and # PIONIER_obs_science.tsf") obTarget = OBTarget() obConstraints = OBConstraints() # set common properties acqTSF.INS_DISP = ins_disp if 'SCIENCE' in observationConfiguration.type: OBJTYPE = 'SCIENCE' else: OBJTYPE = 'CALIBRATOR' # define target # acqTSF.SEQ_INS_SOBJ_NAME = scienceTarget.name.strip() # obTarget.name = acqTSF.SEQ_INS_SOBJ_NAME.replace(' ', '_') # # allowed characters: letters, digits, + - _ . and no spaces obTarget.ra, obTarget.dec = self.getCoords(scienceTarget) obTarget.properMotionRa, obTarget.properMotionDec = self.getPMCoords( scienceTarget) # define some default values DIAMETER = float(self.get(scienceTarget, "DIAMETER", 0.0)) VIS = 1.0 # FIXME # Retrieve Fluxes COU_GS_MAG = self.getFlux(scienceTarget, "V") acqTSF.SEQ_IAS_HMAG = self.getFlux(scienceTarget, "H") # setup some default values, to be changed below COU_AG_GSSOURCE = 'SCIENCE' # by default GSRA = '00:00:00.000' GSDEC = '00:00:00.000' dualField = False # initialize FT variables (must exist) # TODO remove next lines using a dual_acq TSF that would handle # them # AO target aoTarget = ob.get(observationConfiguration, "AOTarget") if aoTarget != None: AONAME = aoTarget.name COU_AG_GSSOURCE = 'SETUPFILE' # since we have an AO # TODO check if AO coords should be required by template # AORA, AODEC = self.getCoords(aoTarget, # requirePrecision=False) acqTSF.COU_PMA, acqTSF.COU_PMD = self.getPMCoords(aoTarget) # Guide Star gsTarget = ob.get(observationConfiguration, 'GSTarget') if gsTarget != None: COU_GS_SOURCE = 'SETUPFILE' # since we have an GS GSRA, GSDEC = self.getCoords(gsTarget, requirePrecision=False) # no PMRA, PMDE for GS !! COU_GS_MAG = float(gsTarget.FLUX_V) # LST interval try: obsConstraint = observationConfiguration.observationConstraints LSTINTERVAL = obsConstraint.LSTinterval except: LSTINTERVAL = None # Constraints obConstraints.name = 'Aspro-created constraints' skyTransparencyMagLimits = {"AT": 3, "UT": 5} if acqTSF.IAS.HMAG < skyTransparencyMagLimits[tel]: obConstraints.skyTransparency = 'Variable, thin cirrus' else: obConstraints.skyTransparency = 'Clear' # FIXME: error (OB): "Phase 2 constraints must closely follow what was requested in the Phase 1 proposal. # The seeing value allowed for this OB is >= java0x0 arcsec." obConstraints.seeing = 1.0 obConstraints.baseline = BASELINE.replace(' ', '-') # FIXME: default values NOT IN ASPRO! # constaints.airmass = 5.0 # constaints.fli = 1 # compute dit, ndit, nexp my_sequence = sequence[0:2 * nexp] # and store computed values in obsTSF obsTSF.NEXPO = 5 obsTSF.NSCANS = 100 # then call the ob-creation using the API. if dryMode: ui.addToLog( obTarget.name + " ready for p2 upload (details logged)") ui.addToLog(obTarget, False) ui.addToLog(obConstraints, False) ui.addToLog(acqTSF, False) ui.addToLog(obsTSF, False) else: self.createPionierOB( ui, self.facility.a2p2client.getUsername( ), api, containerId, obTarget, obConstraints, acqTSF, obsTSF, OBJTYPE, instrumentMode, DIAMETER, COU_AG_GSSOURCE, GSRA, GSDEC, COU_GS_MAG, dualField, SEQ_FT_ROBJ_NAME, SEQ_FT_ROBJ_MAG, SEQ_FT_ROBJ_DIAMETER, SEQ_FT_ROBJ_VIS, LSTINTERVAL) ui.addToLog(obTarget.name + " submitted on p2") # endfor if doFolder: containerId = parentContainerId doFolder = False
def checkOB(self, ob, p2container=None): ui = self.ui instrumentConfiguration = ob.instrumentConfiguration BASELINE = ob.interferometerConfiguration.stations # Compute tel = UT or AT # TODO move code into common part if "U" in BASELINE: tel = "UT" else: tel = "AT" instrumentMode = instrumentConfiguration.instrumentMode # Retrieve SPEC_RES and POL info from instrumentMode # We could force ins_spec_res to be default but prefer a bad keyword value # that throws a Value Error if instrumentMode does not start with an accepted one # ins_spec_res = self.getDefault("GRAVITY_gen_acq.tsf", "INS.SPEC.RES") ins_spec_res = "BAD_SPEC_RES" for res in self.getRange("GRAVITY_gen_acq.tsf", "INS.SPEC.RES"): if res in instrumentMode[0:len(res)]: ins_spec_res = res if "COMBINED" in instrumentMode: ins_pol = "OUT" else: ins_pol = 'IN' for observationConfiguration in ob.observationConfiguration: # create keywords storage objects acqTSF = TSF(self, "GRAVITY_gen_acq.tsf") obsTSF = TSF(self, "GRAVITY_single_obs_exp.tsf") # alias for # ,GRAVITY_single_obs_calibrator.tsf,GRAVITY_dual_obs_exp.tsf,GRAVITY_dual_obs_calibrator.tsf") obTarget = OBTarget() obConstraints = OBConstraints(self) # set common properties if any if ins_spec_res: acqTSF.INS_SPEC_RES = ins_spec_res acqTSF.INS_FT_POL = ins_pol acqTSF.INS_SPEC_POL = ins_pol if 'SCIENCE' in observationConfiguration.type: OBJTYPE = 'SCIENCE' else: OBJTYPE = 'CALIBRATOR' scienceTarget = observationConfiguration.SCTarget # define target acqTSF.SEQ_INS_SOBJ_NAME = scienceTarget.name.strip() obTarget.name = acqTSF.SEQ_INS_SOBJ_NAME.replace( ' ', '_' ) # allowed characters: letters, digits, + - _ . and no spaces obTarget.ra, obTarget.dec = self.getCoords(scienceTarget) obTarget.properMotionRa, obTarget.properMotionDec = self.getPMCoords( scienceTarget) # Set baseline interferometric array code (should be a keywordlist) acqTSF.ISS_BASELINE = [self.getBaselineCode(BASELINE)] # define some default values DIAMETER = float(self.get(scienceTarget, "DIAMETER", 0.0)) VIS = 1.0 # FIXME # Retrieve Fluxes COU_GS_MAG = self.getFlux(scienceTarget, "V") acqTSF.SEQ_INS_SOBJ_MAG = self.getFlux(scienceTarget, "K") acqTSF.SEQ_FI_HMAG = self.getFlux(scienceTarget, "H") # setup some default values, to be changed below COU_AG_GSSOURCE = 'SCIENCE' # by default GSRA = '00:00:00.000' GSDEC = '00:00:00.000' dualField = False dualFieldDistance = 0.0 # needed as must exist for the argument list of createGravityOB # initialize FT variables (must exist) # TODO remove next lines using a dual_acq TSF that would handle # them SEQ_FT_ROBJ_NAME = "" SEQ_FT_ROBJ_MAG = -99.99 SEQ_FT_ROBJ_DIAMETER = -1.0 SEQ_FT_ROBJ_VIS = -1.0 # if FT Target is not ScTarget, we are in dual-field (TBD) ftTarget = ob.get(observationConfiguration, "FTTarget") if ftTarget != None: SEQ_FT_ROBJ_NAME = ftTarget.name FTRA, FTDEC = self.getCoords(ftTarget) # no PMRA, PMDE for FT !! SEQ_FI_HMAG = float(ftTarget.FLUX_H) # just to say we must treat the case there # is no FT Target SEQ_FT_ROBJ_MAG = self.getFlux(ftTarget, "K") SEQ_FT_ROBJ_DIAMETER = 0.0 # FIXME SEQ_FT_ROBJ_VIS = 1.0 # FIXME dualField = True # test distance in dual field mode if tel == "UT": SCtoREFmaxDist = 2000 SCtoREFminDist = 0 # before P103: 400 else: SCtoREFminDist = 0 # before P103: 1500 SCtoREFmaxDist = 4000 # compute x,y between science and ref beams: dualFieldDistance = self.getSkyDiff(obTarget.ra, obTarget.dec, FTRA, FTDEC) if np.abs(dualFieldDistance[0]) < SCtoREFminDist: raise ValueError( "Dual-Field distance of two stars is < " + str(SCtoREFminDist) + " mas, Please Correct.") elif np.abs(dualFieldDistance[0]) > SCtoREFmaxDist: raise ValueError( "Dual-Field distance of two stars is > " + str(SCtoREFmaxDist) + " mas, Please Correct.") # AO target aoTarget = ob.get(observationConfiguration, "AOTarget") if aoTarget != None: AONAME = aoTarget.name COU_AG_GSSOURCE = 'SETUPFILE' # since we have an AO GSRA, GSDEC = self.getCoords(aoTarget, requirePrecision=False) acqTSF.COU_AG_PMA, acqTSF.COU_AG_PMD = self.getPMCoords( aoTarget) # Case of CIAO to be implemented...based on v and k magnitudes? COU_GS_MAG = float(aoTarget.FLUX_V) # Guide Star gsTarget = ob.get(observationConfiguration, 'GSTarget') if gsTarget != None and aoTarget == None: COU_AG_SOURCE = 'SETUPFILE' # since we have an GS GSRA, GSDEC = self.getCoords(gsTarget, requirePrecision=False) acqTSF.COU_AG_PMA, acqTSF.COU_AG_PMD = self.getPMCoords( gsTarget) COU_GS_MAG = float(gsTarget.FLUX_V) # LST interval try: obsConstraint = observationConfiguration.observationConstraints LSTINTERVAL = obsConstraint.LSTinterval except: LSTINTERVAL = None # Constraints obConstraints.name = 'Aspro-created constraints' skyTransparencyMagLimits = {"AT": 3, "UT": 5} if acqTSF.SEQ_INS_SOBJ_MAG < skyTransparencyMagLimits[tel]: obConstraints.skyTransparency = 'Variable, thin cirrus' else: obConstraints.skyTransparency = 'Clear' # FIXME: error (OB): "Phase 2 constraints must closely follow what was requested in the Phase 1 proposal. # The seeing value allowed for this OB is >= java0x0 arcsec." # FIXME REPLACE SEEING THAT IS NO MORE SUPPORTED # obConstraints.seeing = 1.0 # FIXME: default values NOT IN ASPRO! # constaints.airmass = 5.0 # constaints.fli = 1 # compute dit, ndit, nexp dit = self.getDit(tel, acqTSF.INS_SPEC_RES, acqTSF.INS_SPEC_POL, acqTSF.SEQ_INS_SOBJ_MAG, dualField, showWarning=(p2container == None)) ndit = 300 / dit if ndit < 10: ndit = 10 if ndit > 300: ndit = 300 ndit = int(ndit) # must be integer exptime = int(ndit * dit + 40) # 40 sec overhead by exp nexp = (1800 - 900) / exptime nexp = int(nexp) ui.addToLog('number of exposures to reach 1800 s per OB is ' + str(nexp)) if nexp < 3: nexp = 3 # min is O S O # recompute ndit exptime = (1800 - 900) / nexp ndit = (exptime - 40) / dit ndit = int(ndit) if ndit < 10: ndit = 10 ui.addToLog( "**Warning**, OB NDIT has been set to min value=%d, but OB will take longer than 1800 s" % (ndit)) nexp %= 40 sequence = 'O S O O S O O S O O S O O S O O S O O S O O S O O S O O S O O S O O S O O S O O' my_sequence = sequence[0:2 * nexp] # and store computed values in obsTSF obsTSF.DET2_DIT = str(dit) obsTSF.DET2_NDIT_OBJECT = ndit obsTSF.DET2_NDIT_SKY = ndit obsTSF.SEQ_OBSSEQ = my_sequence obsTSF.SEQ_SKY_X = 2000 obsTSF.SEQ_SKY_Y = 2000 # then call the ob-creation using the API if p2container exists. if p2container == None: ui.addToLog(obTarget.name + " ready for p2 upload (details logged)") ui.addToLog(obTarget, False) ui.addToLog(obConstraints, False) ui.addToLog(acqTSF, False) ui.addToLog(obsTSF, False) else: self.createGravityOB(p2container, obTarget, obConstraints, acqTSF, obsTSF, OBJTYPE, instrumentMode, DIAMETER, COU_AG_GSSOURCE, GSRA, GSDEC, COU_GS_MAG, dualField, dualFieldDistance, SEQ_FT_ROBJ_NAME, SEQ_FT_ROBJ_MAG, SEQ_FT_ROBJ_DIAMETER, SEQ_FT_ROBJ_VIS, LSTINTERVAL) ui.addToLog(obTarget.name + " submitted on p2")
def checkOB(self, ob, p2container=None): ui = self.ui instrumentConfiguration = ob.instrumentConfiguration BASELINE = ob.interferometerConfiguration.stations # Compute tel = UT or AT # TODO move code into common part if "U" in BASELINE: tel = "UT" else: tel = "AT" instrumentMode = instrumentConfiguration.instrumentMode for observationConfiguration in ob.observationConfiguration: # create keywords storage objects acqTSF = TSF(self, "MATISSE_img_acq.tsf") # or .tsfx? obsTSF = TSF(self, "MATISSE_hyb_obs.tsf") obTarget = OBTarget() obConstraints = OBConstraints(self) if 'SCIENCE' in observationConfiguration.type: OBJTYPE = 'SCIENCE' else: OBJTYPE = 'CALIBRATOR' scienceTarget = observationConfiguration.SCTarget # define target obTarget.name = scienceTarget.name.replace( ' ', '_' ) # allowed characters: letters, digits, + - _ . and no spaces # allowed characters: letters, digits, + - _ . and no spaces obTarget.ra, obTarget.dec = self.getCoords(scienceTarget) obTarget.properMotionRa, obTarget.properMotionDec = self.getPMCoords( scienceTarget) # Set baseline interferometric array code (should be a keywordlist) acqTSF.ISS_BASELINE = [self.getBaselineCode(BASELINE)] # define some default values VIS = 1.0 # FIXME # Retrieve Fluxes COU_GS_MAG = self.getFlux(scienceTarget, "V") # setup some default values, to be changed below COU_AG_GSSOURCE = 'SCIENCE' # by default GSRA = '00:00:00.000' GSDEC = '00:00:00.000' dualField = False # initialize FT variables (must exist) # TODO remove next lines using a dual_acq TSF that would handle # them # AO target aoTarget = ob.get(observationConfiguration, "AOTarget") if aoTarget != None: AONAME = aoTarget.name COU_AG_GSSOURCE = 'SETUPFILE' # since we have an AO # TODO check if AO coords should be required by template # AORA, AODEC = self.getCoords(aoTarget, # requirePrecision=False) acqTSF.COU_PMA, acqTSF.COU_PMD = self.getPMCoords(aoTarget) # Guide Star gsTarget = ob.get(observationConfiguration, 'GSTarget') if gsTarget != None: COU_GS_SOURCE = 'SETUPFILE' # since we have an GS GSRA, GSDEC = self.getCoords(gsTarget, requirePrecision=False) # no PMRA, PMDE for GS !! COU_GS_MAG = float(gsTarget.FLUX_V) # LST interval try: obsConstraint = observationConfiguration.observationConstraints LSTINTERVAL = obsConstraint.LSTinterval except: LSTINTERVAL = None # Constraints obConstraints.name = 'Aspro-created constraints' skyTransparencyMagLimits = {"AT": 3, "UT": 5} # if acqTSF.IAS.HMAG < skyTransparencyMagLimits[tel]: # obConstraints.skyTransparency = 'Variable, thin cirrus' # else: # obConstraints.skyTransparency = 'Clear' obConstraints.skyTransparency = 'Clear' # FIXME: error (OB): "Phase 2 constraints must closely follow what was requested in the Phase 1 proposal. # The seeing value allowed for this OB is >= java0x0 arcsec." # FIXME REPLACE SEEING THAT IS NO MORE SUPPORTED # obConstraints.seeing = 1.0 # baseline not in instrumecnstraints obConstraints.baseline = BASELINE.replace(' ', '-') # FIXME: default values NOT IN ASPRO! # constaints.airmass = 5.0 # constaints.fli = 1 # and store computed values in obsTSF # then call the ob-creation using the API if p2container exists. if p2container == None: ui.addToLog(obTarget.name + " ready for p2 upload (details logged)") ui.addToLog(obTarget, False) ui.addToLog(obConstraints, False) ui.addToLog(acqTSF, False) ui.addToLog(obsTSF, False) else: self.createMatisseOB(p2container, obTarget, obConstraints, acqTSF, obsTSF, OBJTYPE, instrumentMode, COU_AG_GSSOURCE, GSRA, GSDEC, COU_GS_MAG, LSTINTERVAL) ui.addToLog(obTarget.name + " submitted on p2")