def getData(self,ext=0): """No tested, to check !!!""" if ext!=0 and not self.mef: log.error("Wrong extension number especified. Not a MEF file.") else: try: myfits = pyfits.open(self.pathname, ignore_missing_end=True) # since some problems with O2k files temp = myfits[0].data myfits.close(output_verify='ignore') return temp except: log.error('Could not open frame - something wrong with input data') raise
def addHistory(self, string_history): """ Add a history keyword to the header NOTE: The update is only done in memory-header(my_header). To flush to disk, we should to write/update to a new file. STILL NOT USED !!!! """ log.warning("Header not updated nicely !!") try: #t=pyfits.open(self.pathname,'update') self.my_header.add_history(string_history) #t.close(output_verify='ignore') log.warning('History added') except: log.error('Error while adding history to header')
def recognize(self, retries=5): ###log.info("Recognizing file %s" %self.filename) # Check the file exists if not os.path.exists( self.pathname ): log.error('Cannot find frame : "%s"' % self.pathname) raise Exception("File %s not found"%self.pathname) # check FITS-file integrity nTry = 0 while True: try: fits_simple_verify(self.pathname) except Exception,e: if nTry<retries: nTry +=1 time.sleep(nTry*0.5) log.warning("Trying to re-read integrity of FITS-file : %s\n %s"%(self.pathname, str(e))) else: log.error("Could not read with integrity FITS-file: %s\n %s"%(self.pathname, str(e))) log.error("File discarded : %s"%self.pathname) raise e else: break
self.type = "DOME_FLAT_LAMP_ON" elif ltype.count('dusk'): self.type = "TW_FLAT_DUSK" elif ltype.count('dawn'): self.type = "TW_FLAT_DAWN" elif ltype.count('sky_flat') or ltype.count('flat'): self.type = "SKY_FLAT" elif ltype.count('sky'): self.type = "SKY" elif ltype.count('object'): self.type = "SCIENCE" else: #By default, the image is classified as SCIENCE object self.type = "SCIENCE" except KeyError: log.error('PAPITYPE/OBJECT/IMAGETYP keyword not found') self.type = 'UNKNOW' elif self.instrument=='hawki': try: if myfits[0].header[keyword_with_frame_type].lower().count('dark') : self.type = "DARK" elif myfits[0].header[keyword_with_frame_type].lower().count('lamp off'): self.type = "DOME_FLAT_LAMP_OFF" elif myfits[0].header[keyword_with_frame_type].lower().count('lamp on'): self.type = "DOME_FLAT_LAMP_ON" elif myfits[0].header[keyword_with_frame_type].lower().count('dusk'): self.type = "TW_FLAT_DUSK" elif myfits[0].header[keyword_with_frame_type].lower().count('dawn'): self.type = "TW_FLAT_DAWN" elif myfits[0].header[keyword_with_frame_type].lower().count('sky_flat') or \ myfits[0].header[keyword_with_frame_type].lower().count('flat'):