# Load the source info database db = json.load(open(dbfile)) # Extract relevant data source = db["star"]["id"] ra = db["star"]["RA_dg"] dec = db["star"]["Dec_dg"] # Look for source in both tables source_table = os.path.join(tempdir, "{}-images.tbl".format(source)) if cmd_args.debug: print("\n\nWriting", source_table) # FIXME mCoverage check has a bug where it needs two extra args montage_wrapper.mCoverageCheck(mcov_prefix() + combo_table, source_table, "point", None, ra=ra, dec=dec) # Grab the names of the FITS images from the table that # mCoverageCheck wrote candidate_images = [misc_utils.contract_fits_path(line.split()[-1]) for line in open(source_table).readlines() if ".fits" in line] # And optionally check that there is really data at the relevant position if cmd_args.full_check: imdb[source] = [fitsfile for fitsfile in candidate_images if has_data(fitsfile, ra, dec)] else: imdb[source] = candidate_images # # Fourth, write it out to a JSON file # misc_utils.update_json_file(imdb, "all-images.json") # And clean up
print("Fixing EQUINOX from string or zero value") outhdu.header["EQUINOX"] = 2000.0 hdu.header["EQUINOX"] = 2000.0 ## TODO: copy over more keywords from the original FITS header ## E.g., filter, camera, etc ## ## Save the small image ## outfile = "-".join([cmd_args.source, image_name, "extract.fits"]) outhdu.writeto(outfile, output_verify="fix", clobber=True) ## ## Update the JSON database with information about the image ## # Always overwrite an existing section with the same name db[image_name] = { "original FITS file": misc_utils.contract_fits_path(fits_path), "extracted FITS file": outfile, } db[image_name].update(fits_utils.get_instrument_configuration(hdu)) db["info"]["history"].append("Image " + image_name + " added by " + misc_utils.run_info()) misc_utils.update_json_file(db, dbfile)
parser.add_argument("--user", type=str, default="angel@crya", help="User@system ID use for guessing paths") parser.add_argument("--debug", action="store_true", help="Print out verbose debugging info") cmd_args = parser.parse_args() dbfile = cmd_args.source + "-arcdata.json" db = json.load(open(dbfile)) for secname, section in db.items(): if "original FITS file" in section: oldpath = section["original FITS file"] newpath = misc_utils.contract_fits_path(oldpath, user=cmd_args.user) if cmd_args.debug: print("Contracting full paths in", secname) print("From", oldpath, "to", newpath) section["original FITS file"] = newpath db["info"]["history"].append("Paths corrected by " + misc_utils.run_info()) misc_utils.update_json_file(db, dbfile)