def buildSummary(folder="."): '''Look through all FITS files in the folder given and return an observationSummary containing summary information about the object frames (i.e. the number of images in each filter for each target) defaults to current directory''' summary = observationSummary() for f in os.listdir(folder): fullName = os.path.join(folder, f) if fitsHeader.isFits(fullName): header = pyfits.getheader(fullName) summary.parseHeader(header) return summary
def recordDir(dir): '''record information for all fits files of images in the given directory and subdirectories''' logger.info("Recording observations in "+dir) obsDB.login() for root, dirs, files in os.walk(dir): logger.info("root = "+root) for f in files: fullPath = os.path.join(root,f) if isFits(fullPath): #logger.info("Attempting to record observation for "+f) try: header = pyfits.getheader(fullPath) if frameTypes.getFrameType(header) != 'object': continue recordObservation(header,fullPath) except Exception as e: logger.error(traceback.format_exc()) break #keep going and record everything else