コード例 #1
0

    #
    # Plot graph of angular profiles
    #
    plt.clf()
    plt.plot(th_centers, bg, color="k", alpha=0.3, zorder=110, label="Background")
    plt.fill_between(th_centers, bg-dbg, bg+dbg, color="k", alpha=0.1, lw=0, zorder=100)
    plt.plot(th_centers, sh, color="g", alpha=0.3, zorder=111, lw=2, label="Shell center")
    plt.fill_between(th_centers, sh-dsh, sh+dsh, color="m", alpha=0.1, lw=0, zorder=101)
    m = mask["<60"] & mask["good"] & mask["shell"]
    mb = mask["<60"] & mask["good"] & mask["bg"]
    plt.scatter(theta["outer"][m].deg, hdu.data[m], s=4, c=z[m], marker="o",
                cmap=plt.cm.gist_rainbow, alpha=0.6, edgecolors='none', zorder=20)
    cb = plt.colorbar()
    cb.set_label("z = (R - R_in) / (R_out - R_in)")
    plt.scatter(theta["outer"][mb].deg, hdu.data[mb], s=2, c="k", marker="o",
                cmap=plt.cm.gist_rainbow, alpha=0.2, edgecolors='none', zorder=10)
    plt.xlabel("Angle, theta, from outer shell axis")
    plt.ylabel("Surface brightness")
    plt.legend()
    plt.title(" ".join([cmd_args.source, camera, fname]))
    plt.ylim(ymin, ymax)
    plt.grid()
    plt.savefig(plot_prefix + "-th.jpg", dpi=600)



    update_json_file(arcdata, dbfile)

コード例 #2
0
    # 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
if not cmd_args.debug:
    shutil.rmtree(tempdir)

# FIXME Check that each image has data at the position of the source

コード例 #3
0
          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)



コード例 #4
0
                    help="Name of source")
parser.add_argument("--savefig", action="store_true",
                    help="Save a figure showing the fit")
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 arc in "inner", "outer":
    if arc in db:
        update_arc_data(db[arc])

db["info"]["history"].append("Circle fits added by " + run_info())

update_json_file(db, dbfile)

region_file = dbfile.replace("-arcdata.json", "-arcfits.reg")
with open(region_file, "w") as f:
      f.writelines([s + "\n" for s in create_arc_regions(db)])

if cmd_args.savefig:
    plotfile = dbfile.replace("-arcdata.json", "-arcfits.pdf")
    plt.plot(0.0, 0.0, 'o')
    plt.axis("equal")
    plt.savefig(plotfile)