def genImexamInstsAlt(starList, fn): #figure out which is target star insts = [] for star in starList: insts.append(':s ' + str(star.field('x')) + ' ' + str(star.field('y'))) fs.writeListToFile(fn, insts) return insts
def genCooFile(ooi, starList, fn): #We want x&y for center #We want index_ra&dec for coords #Would be interesting to see if flux&background give enough to lightcurve... coords = [] coords.append(str(int(ooi["x"])) + " " + str(int(ooi["y"]))) for line in starList: if int(ooi["x"]) != int(line.field("x")) or int(ooi["y"]) != int(line.field("y")): coords.append(str(int(line.field("x"))) + " " + str(int(line.field("y")))) fs.writeListToFile(fn, coords) return coords
def indexFiles(root): logger = logging.getLogger(__name__) logger.debug("Looking for all *.fit* in " + root) fitsFiles = [os.path.relpath(os.path.join(dirpath, f), root) for dirpath, dirnames, files in os.walk(root) for f in fnmatch.filter(files, "*.fit")] fitsFiles.sort() #print(fitsFiles) listDarks = fs.readFileToArray(root + ".darks") listBiass = fs.readFileToArray(root + ".biass") listFlats = fs.readFileToArray(root + ".flats") listLights = fs.readFileToArray(root + ".lights") listUnknowns = fs.readFileToArray(root + ".unknowns") listErrors = fs.readFileToArray(root + ".errors") index = fs.readFileToArray(root + ".index") for f in fitsFiles: if f in index: continue if "b.fit" in f or "d.fit" in f or "atlas_" in f: continue logger.debug("Indexing "+f) hdr = fs.getHeader(root + f) imgType = hdr["PICTTYPE"] outFile = "None" date = hdr["DATE-OBS"].split("T")[0] if isFlat(imgType): #logger.debug(f + " is a flat.") listFlats.append(f) elif isDark(imgType): #logger.debug(f + " is a dark") listDarks.append(f) elif isBias(imgType): #logger.debug(f + " is a bias") listBiass.append(f) elif isLight(imgType): #logger.debug(f + " is a light frame!") listLights.append(f + ":" + date) elif isUnknown(imgType): logger.warning(f + " is of unknown type?") listUnknowns.append(f) else: logger.error("ImgType not unknown or anything else??") listErrors.append(f) #TODO only open file once in w+ mode index.append(f) fs.writeListToFile(root+".flats", listFlats) fs.writeListToFile(root+".darks", listDarks) fs.writeListToFile(root+".biass", listBiass) fs.writeListToFile(root+".lights", listLights) fs.writeListToFile(root+".unknowns", listUnknowns) fs.writeListToFile(root+".errors", listErrors) fs.writeListToFile(root+".index", index) return
for img in unprocImgNames: logger.debug("Getting calibration images for " + img) hdr = fs.getHeader(root + img) exptime = hdr['EXPTIME'] date = hdr['DATE-OBS'].split('T') date = date[0] datexp = date + ":" + str(exptime) #Darks if date in darksFiles: darksFiles[date].append(img) else: darks = getDarks(root, img) darksFiles[date] = [img] if len(darks) > 0: fs.writeListToFile(root + outputDir + ".darks:" + date, darks) #Biass if date in biassFiles: biassFiles[date].append(img) else: biass = getBiass(root, img) biassFiles[date] = [img] if len(biass) > 0: fs.writeListToFile(root + outputDir + ".biass:" + date, biass) #Flats if date in flatsFiles: flatsFiles[date].append(img) else: flats = getFlats(root, img) flatsFiles[date] = [img] if len(flats) > 0:
def genImexamInsts(star, fn): #figure out which is target star insts = [':s ' + str(int(star["x"])) + ' ' + str(int(star["y"]))] fs.writeListToFile(fn, insts) return insts
new = [] for source in runs[index]: if isInField(root + bfn, source["RA"], source["DEC"]): new.append(source) runs[index] = new else: runs[index] = rdSources runBfns[index] = [bfn] runOOI[index] = ooi #Output to files for index in runs: logger.info("Writing common stars for " + index) fs.writeListToFile(root + "atlas_" + index + ".atlas.rdls", runs[index]) ooi = runOOI[index] for bfn in runBfns[index]: x, y = getxyFromRaDec(root + bfn, ooi["ra"], ooi["dec"]) coords = [str(x) + " " + str(y)] for ra, dec in runs[index]: if not areEqual(ra, ooi["ra"]) or not areEqual(dec, ooi['dec']): x, y = getxyFromRaDec(root + bfn, ra, dec) coords.append(str(x) + " " + str(y)) fs.writeListToFile(root + bfn + ".coo", coords) magFileArray = [root + fn + ".mag" for fn in runBfns[index]] fs.writeListToFile(root + "atlas_" + index + ".txdmp", magFileArray)