def fudge_wcs(input_file, ds9, output_file, target_coords): # ds9.set("file "+input_file) hdulist = pyfits.open(input_file) # ds9.set_pyfits(hdulist[extension]) # ds9.set_np2arr(hdulist[extension].data) ds9.set("mosaicimage iraf "+input_file) # ds9.set("multiframe "+input_file) coords = ds9.get("imexam coordinate image")
# Check if the 3rd parameter is a filename or a number if (os.path.isfile(sys.argv[3])): # Start ds9 ds9 = ds9.ds9(target="whirc", start="-scale scope global", wait=15) extension = sys.argv[2] # # This is the mode to determine the offsets. # ds9.set_np2arr(hdulist[extension].data.astype(numpy.float32)) ds9.set("cmap grey") ds9.set("scale mode minmax") coords = ds9.get("imexam coordinate image") #print coords coords_ref = [float(coords.split()[0]), float(coords.split()[1])] # convert the pixel coords to Ra/Dec refwcs = astLib.astWCS.WCS(hdulist[extension].header, mode='pyfits') ra_dec = numpy.array(refwcs.pix2wcs(coords_ref[0], coords_ref[1])) #print ra_dec # Now we have the reference coordinates # Load the second frame to get the offset align_file = sys.argv[3] align_ext = sys.argv[4]