def __init__(self, filename, debug=False): he = 'HIERARCH ESO ' self.data = pyfits.open(filename) self.date_obs = self.data[0].header['DATE-OBS'] self.targname = self.data[0].header['HIERARCH ESO OBS TARG NAME'] self.PS_ID = self.data[0].header['HIERARCH ESO OCS PS ID'] self.SS_ID = self.data[0].header['HIERARCH ESO OCS SS ID'] self.mjd_obs = self.data[0].header['MJD-OBS'] self.lst_obs = self.data[0].header['LST']/3600. self.mjd= self.data['ASTROMETRY_BINNED'].data.field('MJD') # simple linear interpolation self.lst = self.lst_obs + (self.mjd - self.mjd_obs)*(23.+56/60.+4/3600.) self.d_al= self.data['ASTROMETRY_BINNED'].data.field('D_AL') self.d_al_err= self.data['ASTROMETRY_BINNED'].data.field('D_AL_err') try: self.rot1= self.data['ASTROMETRY_BINNED'].data.field('ROT1') self.rot2= self.data['ASTROMETRY_BINNED'].data.field('ROT2') except: self.rot1= np.zeros(len(self.d_al)) self.rot2= np.zeros(len(self.d_al)) self.mjd_PCR_start = astro.tag2mjd(self.data[0].header[he+'PCR ACQ START']) self.mjd_PCR_end = astro.tag2mjd(self.data[0].header[he+'PCR ACQ END']) self.lst_PCR_start = astro.tag2lst(self.data[0].header['ESO PCR ACQ START'], longitude=self.data[0].header['ESO ISS GEOLON']) self.A1L = self.data[0].header[he+'ISS CONF A1L'] self.A2L = self.data[0].header[he+'ISS CONF A2L'] try: self.insmode = self.data[0].header[he+'ISS PRI STS3 GUIDE_MODE'] except: self.insmode = self.data[0].header[he+'INS MODE'] cP = self.data[0].header[he+'ISS PRI MET C'] # in m/s dnuP = self.data[0].header[he+'ISS PRI MET F_SHIFT']*1e6 # in Hz nuP = self.data[0].header[he+'ISS PRI MET LASER_F'] #self.jump = (cP * dnuP/2/(nuP**2) ) * ( 2**24-1 ) # PRIMET jump in m, COMM14 self.jump = (cP * dnuP/2/(nuP**2) ) * ( 2**31-1 ) # PRIMET jump in m, COMM15 if 'SWAP' in self.insmode: # legacy: was SWAP at some point, now is SWAPPED self.swapped = np.ones(len(self.mjd)) else: astro.tag2lst(self.data[0].header['ESO PCR ACQ START'], longitude=self.data[0].header['ESO ISS GEOLON']) self.swapped = np.zeros(len(self.mjd)) # dictionnary of variables(mjd) START names = ['base', 'PA', 'OPL1', 'OPL2', 'airmass', 'tau0','seeing', 'parang'] keyw = ['ISS PBL12', 'ISS PBLA12', 'DEL DLT1 OPL', 'DEL DLT2 OPL', 'ISS AIRM', 'ISS AMBI TAU0', 'ISS AMBI FWHM', 'ISS PARANG'] self.var_start_end = {} for k in range(len(names)): self.var_start_end[names[k]] =(self.data[0].header[he+keyw[k]+' START'], self.data[0].header[he+keyw[k]+' END']) self.var_mjd={} # linear interpolation for k in self.var_start_end.keys(): if k != 'base' and k != 'PA': self.var_mjd[k] = self.var_start_end[k][0]+\ (self.mjd - self.mjd_PCR_start)/\ (self.mjd_PCR_end - self.mjd_PCR_start)*\ (self.var_start_end[k][1]- self.var_start_end[k][0]) else: # compute baselines self.baseXYZ = [self.data[0].header[he+'ISS CONF T1X']- self.data[0].header[he+'ISS CONF T2X'], self.data[0].header[he+'ISS CONF T1Y']- self.data[0].header[he+'ISS CONF T2Y'], self.data[0].header[he+'ISS CONF T1Z']- self.data[0].header[he+'ISS CONF T2Z'], self.data[0].header[he+'ISS CONF A1L']- self.data[0].header[he+'ISS CONF A2L']] # coordinates, corrected for proper motion self.radec = [astro.ESOcoord2decimal(self.data[0].header['ESO OCS TARG1 ALPHAPMC']), astro.ESOcoord2decimal(self.data[0].header['ESO OCS TARG2 DELTAPMC'])] self.radec = [self.data[0].header['RA']/15., self.data[0].header['DEC']] bb = prima.projBaseline(self.baseXYZ, self.radec, self.lst) if k == 'base': self.var_mjd[k] = bb['B'] if debug: print 'DEBUG: PBL12 START: computed', self.var_mjd[k][0],\ 'in header:', self.data[0].header[he+'ISS PBL12 START'], \ 'DELTA=', self.var_mjd[k][0]-self.data[0].header[he+'ISS PBL12 START'] print 'DEBUG: PBL12 END : computed', self.var_mjd[k][-1],\ 'in header:', self.data[0].header[he+'ISS PBL12 END'], \ 'DELTA=', self.var_mjd[k][-1]-self.data[0].header[he+'ISS PBL12 END'] if k == 'PA': self.var_mjd[k] = bb['PA'] if debug: print 'DEBUG: PBLA12 START: computed', self.var_mjd[k][0],\ 'in header:', self.data[0].header[he+'ISS PBLA12 START'],\ 'DELTA=', self.var_mjd[k][0]-self.data[0].header[he+'ISS PBLA12 START'] print 'DEBUG: PBLA12 END : computed', self.var_mjd[k][-1],\ 'in header:', self.data[0].header[he+'ISS PBLA12 END'],\ 'DELTA=', self.var_mjd[k][-1]-self.data[0].header[he+'ISS PBLA12 END'] self.data.close() return
def __init__(self, filename, debug=False): he = "HIERARCH ESO " self.data = pyfits.open(filename) self.filename = filename self.date_obs = self.data[0].header["DATE-OBS"] self.targname = self.data[0].header["HIERARCH ESO OBS TARG NAME"] self.PS_ID = self.data[0].header["HIERARCH ESO OCS PS ID"] self.SS_ID = self.data[0].header["HIERARCH ESO OCS SS ID"] self.mjd_obs = self.data[0].header["MJD-OBS"] self.lst_obs = self.data[0].header["LST"] / 3600.0 self.mjd = self.data["ASTROMETRY_BINNED"].data.field("MJD") try: self.lst = self.data["ASTROMETRY_BINNED"].data.field("LST") except: print "WARNING: USING BAD LST!" self.lst = self.lst_obs + (self.mjd - self.mjd_obs) * (23.0 + 56 / 60.0 + 4 / 3600.0) self.d_al = self.data["ASTROMETRY_BINNED"].data.field("D_AL") if self.PS_ID == "HD129926" and self.mjd_obs < 56005.0: # problem with these observations print "WARNING: KLUDGING D_AL -> -DA_L!!!" self.d_al *= -1 self.d_al_err = self.data["ASTROMETRY_BINNED"].data.field("D_AL_err") try: self.rot3 = self.data["ASTROMETRY_BINNED"].data.field("ROT3") self.rot4 = self.data["ASTROMETRY_BINNED"].data.field("ROT4") self.az3 = self.data["ASTROMETRY_BINNED"].data.field("AZ3") self.az4 = self.data["ASTROMETRY_BINNED"].data.field("AZ4") self.alt3 = self.data["ASTROMETRY_BINNED"].data.field("ALT3") self.alt4 = self.data["ASTROMETRY_BINNED"].data.field("ALT4") except: self.rot3 = np.zeros(len(self.d_al)) self.rot4 = np.zeros(len(self.d_al)) self.az3 = np.zeros(len(self.d_al)) self.az4 = np.zeros(len(self.d_al)) self.alt3 = np.zeros(len(self.d_al)) self.alt4 = np.zeros(len(self.d_al)) self.mjd_PCR_start = astro.tag2mjd(self.data[0].header[he + "PCR ACQ START"]) self.mjd_PCR_end = astro.tag2mjd(self.data[0].header[he + "PCR ACQ END"]) self.lst_PCR_start = astro.tag2lst( self.data[0].header["ESO PCR ACQ START"], longitude=self.data[0].header["ESO ISS GEOLON"] ) self.A1L = self.data[0].header[he + "ISS CONF A1L"] self.A2L = self.data[0].header[he + "ISS CONF A2L"] try: self.insmode = self.data[0].header[he + "ISS PRI STS3 GUIDE_MODE"] except: self.insmode = self.data[0].header[he + "INS MODE"] if not self.insmode in ["NORMAL", "SWAPPED"]: # print 'WARNING: unknown INSMODE=', self.insmode pass if self.insmode == "INCONSISTENT": # -- try to guess if self.data[0].header[he + "DEL FT SENSOR"] == "FSUB": self.insmode = "NORMAL" elif self.data[0].header[he + "DEL FT SENSOR"] == "FSUA": self.insmode = "SWAPPED" # print ' -> guessing: INSMODE=', self.insmode cP = self.data[0].header[he + "ISS PRI MET C"] # in m/s dnuP = self.data[0].header[he + "ISS PRI MET F_SHIFT"] * 1e6 # in Hz nuP = self.data[0].header[he + "ISS PRI MET LASER_F"] # self.jump = (cP*dnuP/2/(nuP**2))*(2**24-1) # PRIMET jump in m, COMM14 self.jump = (cP * dnuP / 2 / (nuP ** 2)) * (2 ** 31 - 1) # PRIMET jump in m, COMM15 if "SWAP" in self.insmode: # legacy: was SWAP at some point self.swapped = np.ones(len(self.mjd)) else: astro.tag2lst(self.data[0].header["ESO PCR ACQ START"], longitude=self.data[0].header["ESO ISS GEOLON"]) self.swapped = np.zeros(len(self.mjd)) # dictionnary of variables(mjd) START names = ["base", "PA", "OPL1", "OPL2", "airmass", "tau0", "seeing", "parang"] keyw = [ "ISS PBL12", "ISS PBLA12", "DEL DLT1 OPL", "DEL DLT2 OPL", "ISS AIRM", "ISS AMBI TAU0", "ISS AMBI FWHM", "ISS PARANG", ] self.var_start_end = {} for k in range(len(names)): self.var_start_end[names[k]] = ( self.data[0].header[he + keyw[k] + " START"], self.data[0].header[he + keyw[k] + " END"], ) self.var_mjd = {} # linear interpolation for k in self.var_start_end.keys(): if k != "base" and k != "PA": self.var_mjd[k] = self.var_start_end[k][0] + (self.mjd - self.mjd_PCR_start) / ( self.mjd_PCR_end - self.mjd_PCR_start ) * (self.var_start_end[k][1] - self.var_start_end[k][0]) else: # compute baselines self.baseXYZ = [ self.data[0].header[he + "ISS CONF T1X"] - self.data[0].header[he + "ISS CONF T2X"], self.data[0].header[he + "ISS CONF T1Y"] - self.data[0].header[he + "ISS CONF T2Y"], self.data[0].header[he + "ISS CONF T1Z"] - self.data[0].header[he + "ISS CONF T2Z"], self.data[0].header[he + "ISS CONF A1L"] - self.data[0].header[he + "ISS CONF A2L"], ] # coordinates, corrected for proper motion try: self.radec = [ astro.ESOcoord2decimal(self.data[0].header["ESO OCS TARG1 ALPHAPMC"]), astro.ESOcoord2decimal(self.data[0].header["ESO OCS TARG1 DELTAPMC"]), ] except: print "WARNING: could not find precessed coordinates in header!" self.radec = [ astro.ESOcoord2decimal(self.data[0].header["ESO ISS REF RA"]), astro.ESOcoord2decimal(self.data[0].header["ESO ISS REF DEC"]), ] self.radec = [self.data[0].header["RA"] / 15.0, self.data[0].header["DEC"]] bb = prima.projBaseline(self.baseXYZ, self.radec, self.lst) if k == "base": self.var_mjd[k] = bb["B"] if debug: print "DEBUG: PBL12 START: computed", self.var_mjd[k][0], "in header:", self.data[0].header[ he + "ISS PBL12 START" ], "DELTA=", self.var_mjd[k][0] - self.data[0].header[he + "ISS PBL12 START"] print "DEBUG: PBL12 END : computed", self.var_mjd[k][-1], "in header:", self.data[0].header[ he + "ISS PBL12 END" ], "DELTA=", self.var_mjd[k][-1] - self.data[0].header[he + "ISS PBL12 END"] if k == "PA": self.var_mjd[k] = bb["PA"] if debug: print "DEBUG: PBLA12 START: computed", self.var_mjd[k][0], "in header:", self.data[0].header[ he + "ISS PBLA12 START" ], "DELTA=", self.var_mjd[k][0] - self.data[0].header[he + "ISS PBLA12 START"] print "DEBUG: PBLA12 END : computed", self.var_mjd[k][-1], "in header:", self.data[0].header[ he + "ISS PBLA12 END" ], "DELTA=", self.var_mjd[k][-1] - self.data[0].header[he + "ISS PBLA12 END"] self.data.close() return