Example #1
0
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")
Example #2
0
    plt.plot([LST_min.hour(), LST_min.hour()], [0, 90], color='red')  #Overplot LST limits telescope can observe object
    plt.plot([LST_max.hour(), LST_max.hour()], [0, 90], color='red')
    #plt.xlim(LST_min.hour-2.0,LST_max.hour+2.0)
    #plt.yticks(alt_arr, "%.2f" % airmass_arr) #set ticks to be airmass instead of altitude
    plt.ylim(0, 90)  #Set y axis to be limited to altiude of 0-90 degrees
    plt.xlabel('LST', fontsize=18)  #X-axis label
    plt.ylabel('Altitude', fontsize=18)  #Y-axis label
    plt.grid(color='gray')  #Set up gray background grid to help you use your eye to find things
    plt.title('Object visible between LST:  ' + LST_min.hm() + ' ---> ' + LST_max.hm())  #plot title
    plt.show()  #show plot

#Load up DS9 and create a finder chart
if show_finder_chart == 'y':
    ds9.open()  #Open DS9
    #ds9.wait(2.0) #Used to be needed, commented out for now because I think I fixed this bug and can now speed things up
    ds9.set('single')  #set single display mode
    if finder_chart_fits == '':  #Use built in skyserver if no user specified fits file is found
        #Use HEASARC Sky View server to get mosaicced 2MASS images, to get rid of bug from where images got sliced from the 2MASS server
        ds9.set('skyview survey 2MASS-'+band) #Use HEASARC Sky View server to get mosaicced 2MASS images
        ds9.set('skyview pixels 600 600') #Set resoultion of image retrieved
        ds9.set('skyview size '+ str(img_size) + ' ' + str(img_size) + ' arcmin')#Set size of image
        if obj_choice == '2':  #If user specifies object name
           ds9.set('skyview name ' + obj_input.replace(" ", "_"))  #Retrieve 2MASS image
        else:  #If user specifies object coordiantes
           ds9.set('skyview coord ' + str(obj_coords.ra.deg()) + ' ' + str(
               obj_coords.dec.deg()) + ' degrees')  #Retrieve 2MASS image
        ds9.set('skyview close') #Close skyserver window
        #Old 2MASS server commented out for now, probably obselete, using HEASARC Sky View server now
        #ds9.set('2mass close')  #Close 2MASS window
        #ds9.set('2mass survey ' + band)  #Load 2MASS survey
        #ds9.set('2mass size ' + str(img_size) + ' ' + str(
Example #3
0
    hdulist = pyfits.open(reffile)

    # 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
Example #4
0
    hdulist = pyfits.open(reffile)

    # 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
Example #5
0
    #plt.yticks(alt_arr, "%.2f" % airmass_arr) #set ticks to be airmass instead of altitude
    plt.ylim(0, 90)  #Set y axis to be limited to altiude of 0-90 degrees
    plt.xlabel('LST', fontsize=18)  #X-axis label
    plt.ylabel('Altitude', fontsize=18)  #Y-axis label
    plt.grid(
        color='gray'
    )  #Set up gray background grid to help you use your eye to find things
    plt.title('Object visible between LST:  ' + LST_min.hm() + ' ---> ' +
              LST_max.hm())  #plot title
    plt.show()  #show plot

#Load up DS9 and create a finder chart
if show_finder_chart == 'y':
    ds9.open()  #Open DS9
    #ds9.wait(2.0) #Used to be needed, commented out for now because I think I fixed this bug and can now speed things up
    ds9.set('single')  #set single display mode
    if finder_chart_fits == '':  #Use 2MASS K-band if no user specified fits file is found
        ds9.set('2mass survey ' + band)  #Load 2MASS survey
        ds9.set(
            '2mass size ' + str(img_size) + ' ' + str(img_size) + ' arcmin'
        )  #Set size of image (weird issues here, only strips extracted)
        if obj_choice == '2':  #If user specifies object name
            ds9.set('2mass name ' +
                    obj_input.replace(" ", "_"))  #Retrieve 2MASS image
        else:  #If user specifies object coordiantes
            ds9.set('2mass coord ' + str(obj_coords.ra.deg()) + ' ' +
                    str(obj_coords.dec.deg()) +
                    ' degrees')  #Retrieve 2MASS image
        ds9.set('2mass close')  #Close 2MASS window
    else:  #If user does specify their own fits file, use it
        ds9.set('fits ' + finder_chart_fits)  #Load fits fits file