Пример #1
0
    print 'processing img %s: (RA=%s, DEC=%s)  <=>  (x=%s, y=%s)' % (
        str(id), str(ra), str(dec), str(lens_xy[0]), str(lens_xy[1]))
    #<<<140607>>> the chopped size (2*rad) is plausible as long as the lens fitting pixel is larger than the HST image pixel
    alpha1 = alpha1_tot[lens_xy[1] - rad:lens_xy[1] + rad,
                        lens_xy[0] - rad:lens_xy[0] + rad]
    alpha2 = alpha2_tot[lens_xy[1] - rad:lens_xy[1] + rad,
                        lens_xy[0] - rad:lens_xy[0] + rad]
    #    kappa  =  kappa_tot[lens_xy[1]-rad:lens_xy[1]+rad,lens_xy[0]-rad:lens_xy[0]+rad]
    #    gamma1 = gamma1_tot[lens_xy[1]-rad:lens_xy[1]+rad,lens_xy[0]-rad:lens_xy[0]+rad]
    #    gamma2 = gamma2_tot[lens_xy[1]-rad:lens_xy[1]+rad,lens_xy[0]-rad:lens_xy[0]+rad]
    mag = mag_tot[lens_xy[1] - rad:lens_xy[1] + rad,
                  lens_xy[0] - rad:lens_xy[0] + rad]

    lens_x = np.arange(int(lens_xy[0] - rad + 1), int(lens_xy[0] + rad + 1))
    lens_y = np.arange(int(lens_xy[1] - rad + 1), int(lens_xy[1] + rad + 1))
    lens_wcs = ft.pix2coords(mag_name, (lens_x, lens_y))

    # output ASCII files for all relevant quantities to feed into matlab
    np.savetxt(alpha1_stamp, alpha1, fmt='%s')
    np.savetxt(alpha2_stamp, alpha2, fmt='%s')
    #    np.savetxt(kappa_stamp  ,kappa,fmt='%s')
    #    np.savetxt(gamma1_stamp ,gamma1,fmt='%s')
    #    np.savetxt(gamma2_stamp ,gamma2,fmt='%s')
    np.savetxt(mag_stamp, mag, fmt='%s')
    np.savetxt(lensra_stamp, lens_wcs[0], fmt='%s')
    np.savetxt(lensdec_stamp, lens_wcs[1], fmt='%s')

#-------------------------------------------------------------------------------------------------------------
#                                                      END
#-------------------------------------------------------------------------------------------------------------
Пример #2
0
"""# RXJ1347 - a1
x = 4689.6758
y = 5428.9874
rad = 115"""
# RXJ1347 - a2
x = 4935.8924 
y = 4149.0681
rad = 45

cut = img[y-rad:y+rad,x-rad:x+rad]
# Create fits file
pf.PrimaryHDU(cut).writeto('img_cut.fits',clobber=True)

#-------------------------------------------------------------------------------------------------------------
# to cut off a postage stamp from lens model as well
img_WCS_center=fitstools.pix2coords(img_name,(x,y))
lens_xy=fitstools.coords2pix(mag_name,img_WCS_center)

print "center in HST image's pixel space: x=", x, "y=", y
print "center in WCS coordinate (deg): RA=", img_WCS_center[0], "DEC=", img_WCS_center[1]
print "center in lens model's pixel space: x=", lens_xy[0], "y=", lens_xy[1]

f = open('img_WCS_ctr.dat', 'w')
f.write("%s  %s\n" % (x, y))
f.write("%s  %s\n" % (img_WCS_center[0], img_WCS_center[1]))
f.write("%s  %s\n" % (lens_xy[0], lens_xy[1]))
f.close()

# below is the chopped maps of lensing quantities for specific image cuts
alpha1 = alpha1_tot[lens_xy[1]-rad:lens_xy[1]+rad,lens_xy[0]-rad:lens_xy[0]+rad]  
alpha2 = alpha2_tot[lens_xy[1]-rad:lens_xy[1]+rad,lens_xy[0]-rad:lens_xy[0]+rad]
Пример #3
0
    #--------------------------------------------------------------------------
    # make .dat files
    (x, y) = ft.coords2pix(img_name, (ra, dec))  # NOTE this usage - tuple !!
    print 'processing img %s: (RA=%s, DEC=%s)  <=>  (x=%s, y=%s), with rad=%s' % (
        str(id), str(ra), str(dec), str(x), str(y), str(rad))
    cut = img[y - rad:y + rad, x - rad:x + rad]
    if str(id) == '4.3':
        cut[0:34, 24:rad * 2] = 0
        print 'contamination on %s is cleaned' % id

    img_x = np.arange(int(x - rad + 1), int(x + rad + 1))
    img_y = np.arange(int(y - rad + 1), int(y + rad + 1))
    X, Y = np.meshgrid(img_x, img_y)
    img_x_tot = X.flatten()
    img_y_tot = Y.flatten()
    img_wcs_tot = ft.pix2coords(img_name, (img_x_tot, img_y_tot))
    np.savetxt(stampname, cut.flatten(), fmt='%s')
    np.savetxt(raname, img_wcs_tot[0], fmt='%s')
    np.savetxt(decname, img_wcs_tot[1], fmt='%s')
    #--------------------------------------------------------------------------
    # plot .png files
    plt.figure()  # create a figure object
    plt.clf()  # clearing figure
    pl.imshow(cut, origin='lower', interpolation='nearest')
    pl.colorbar()
    plt.savefig(plotname, dpi=200)
    #    pl.ion()
    #    pl.show()
    #--------------------------------------------------------------------------
    # write fits files, with valid header information <<<140814>>>
    hdu[0].header['CRPIX1'] = crpix1 + rad + -int(x)
Пример #4
0
    lensra_stamp = loc+str(id)+'_lensra.dat'
    lensdec_stamp= loc+str(id)+'_lensdec.dat'
    #-------------------------------------------------------------------------- make .dat files
    lens_xy=ft.coords2pix(mag_name,(ra,dec))
    print 'processing img %s: (RA=%s, DEC=%s)  <=>  (x=%s, y=%s)' % (str(id), str(ra), str(dec), str(lens_xy[0]), str(lens_xy[1]))
    #<<<140607>>> the chopped size (2*rad) is plausible as long as the lens fitting pixel is larger than the HST image pixel
    alpha1 = alpha1_tot[lens_xy[1]-rad:lens_xy[1]+rad,lens_xy[0]-rad:lens_xy[0]+rad]
    alpha2 = alpha2_tot[lens_xy[1]-rad:lens_xy[1]+rad,lens_xy[0]-rad:lens_xy[0]+rad]
#    kappa  =  kappa_tot[lens_xy[1]-rad:lens_xy[1]+rad,lens_xy[0]-rad:lens_xy[0]+rad]
#    gamma1 = gamma1_tot[lens_xy[1]-rad:lens_xy[1]+rad,lens_xy[0]-rad:lens_xy[0]+rad]
#    gamma2 = gamma2_tot[lens_xy[1]-rad:lens_xy[1]+rad,lens_xy[0]-rad:lens_xy[0]+rad]
    mag    =    mag_tot[lens_xy[1]-rad:lens_xy[1]+rad,lens_xy[0]-rad:lens_xy[0]+rad]

    lens_x = np.arange(int(lens_xy[0]-rad+1),int(lens_xy[0]+rad+1))
    lens_y = np.arange(int(lens_xy[1]-rad+1),int(lens_xy[1]+rad+1))
    lens_wcs=ft.pix2coords(mag_name,(lens_x,lens_y))

    # output ASCII files for all relevant quantities to feed into matlab
    np.savetxt(alpha1_stamp ,alpha1,fmt='%s')
    np.savetxt(alpha2_stamp ,alpha2,fmt='%s')
#    np.savetxt(kappa_stamp  ,kappa,fmt='%s')
#    np.savetxt(gamma1_stamp ,gamma1,fmt='%s')
#    np.savetxt(gamma2_stamp ,gamma2,fmt='%s')
    np.savetxt(mag_stamp    ,mag,fmt='%s')
    np.savetxt(lensra_stamp ,lens_wcs[0],fmt='%s')
    np.savetxt(lensdec_stamp,lens_wcs[1],fmt='%s')

#-------------------------------------------------------------------------------------------------------------
#                                                      END
#-------------------------------------------------------------------------------------------------------------
Пример #5
0
    #--------------------------------------------------------------------------
    # make .dat files
    (x,y)=ft.coords2pix(img_name,(ra,dec))   # NOTE this usage - tuple !!
    print 'processing img %s: (RA=%s, DEC=%s)  <=>  (x=%s, y=%s), with rad=%s' % (str(id), str(ra), str(dec), str(x), str(y),
    str(rad))
    cut = img[y-rad:y+rad,x-rad:x+rad]
    if str(id) == '4.3':
        cut[0:34,24:rad*2]=0
        print 'contamination on %s is cleaned' % id

    img_x = np.arange(int(x-rad+1),int(x+rad+1))
    img_y = np.arange(int(y-rad+1),int(y+rad+1))
    X,Y = np.meshgrid(img_x,img_y)
    img_x_tot=X.flatten()
    img_y_tot=Y.flatten()
    img_wcs_tot = ft.pix2coords(img_name,(img_x_tot,img_y_tot))
    np.savetxt(stampname,cut.flatten(),fmt='%s')
    np.savetxt(raname,img_wcs_tot[0],fmt='%s')
    np.savetxt(decname,img_wcs_tot[1],fmt='%s')
    #--------------------------------------------------------------------------
    # plot .png files
    plt.figure()    # create a figure object
    plt.clf()       # clearing figure
    pl.imshow(cut,origin='lower',interpolation='nearest')
    pl.colorbar()
    plt.savefig(plotname,dpi=200)
#    pl.ion()
#    pl.show()
    #--------------------------------------------------------------------------
    # write fits files, with valid header information <<<140814>>>
    hdu[0].header['CRPIX1'] = crpix1+rad+-int(x)
Пример #6
0
#x = 2731.7342; y = 2908.9482; rad = 25;     # 14.1
#x = 3502.9053; y = 3604.6515; rad = 12;     # 14.2
#x = 2238.8085; y = 2374.8719; rad = 15;     # 14.3

cut = img[y - rad:y + rad, x - rad:x + rad]

# clean some noises
#cut[0:34,24:rad*2]=0       # 4.3

# Create fits file
pf.PrimaryHDU(cut).writeto('img_cut.fits', clobber=True)

#-------------------------------------------------------------------------------------------------------------
# to cut off a postage stamp from lens model as well
img_WCS_center = fitstools.pix2coords(img_name, (x, y))
lens_xy = fitstools.coords2pix(mag_name, img_WCS_center)

print "center in HST image's pixel space: x=", x, "y=", y
print "center in WCS coordinate (deg): RA=", img_WCS_center[
    0], "DEC=", img_WCS_center[1]
print "center in lens model's pixel space: x=", lens_xy[0], "y=", lens_xy[1]

f = open('img_WCS_ctr.dat', 'w')
f.write("%s  %s\n" % (x, y))
f.write("%s  %s\n" % (img_WCS_center[0], img_WCS_center[1]))
f.write("%s  %s\n" % (lens_xy[0], lens_xy[1]))
f.close()

# below is the chopped maps of lensing quantities for specific image cuts
#<<<140607>>> the chopped size (2*rad) is plausible as long as the lens fitting pixel is larger than the HST image pixel