コード例 #1
0
def do_luvoir(fieldstr,
              alph,
              Q,
              rf,
              gf,
              bf,
              subim='00',
              smooth='',
              diameter=None):

    print('loading data... ')

    ra, ga, ba, pix_arcsec = load_luvoir(fieldstr, subim=subim, smooth=smooth)

    print('loaded data, making rgb... ')

    if diameter is None:
        rgb_field = make_color_image.make_interactive_nasa(ba, ga, ra, alph, Q)
        psfstr = ''
    else:
        fwhm_radians = 1.22 * np.asarray([0.40, 0.75, 1.5
                                          ]) * (1.0e-6) / diameter
        fwhm_arcsec = fwhm_radians * (180.0 / math.pi) * 3600.0
        print('applying PSF FWHM, in arcsec: ', fwhm_arcsec)
        fwhm_pixels = fwhm_arcsec / pix_arcsec
        rgb_field = make_color_image.make_interactive_nasa(
            ba, ga, ra, alph, Q, fwhm_pixels=fwhm_pixels)
        psfstr = '_' + str(diameter) + 'meter'

    print('created color image, saving...  ')

    f1 = pyplot.figure(figsize=(8.192, 8.192), dpi=1000)
    pyplot.subplots_adjust(left=0.0,
                           right=1.0,
                           bottom=0.0,
                           top=1.0,
                           wspace=0.0,
                           hspace=0.0)

    axi = f1.add_subplot(111)
    axi.imshow(rgb_field,
               interpolation='nearest',
               aspect='auto',
               origin='lower')

    f1.savefig('luvoir_render_' + fieldstr + '-subimage' + subim + smooth +
               psfstr + '.png',
               dpi=1000)
    pyplot.close(f1)
コード例 #2
0
def quickrgb(image_file,alph=1.0,Q=1.0,mid=500,delt=500,fov_comoving=True,rgb_factors=[2.0,1.5,1.15],**kwargs):

    ims,fils,hduheader,bbheader=extract_bb_images(**kwargs)

    if fov_comoving is True:
        redshift=bbheader['REDSHIFT']
        zdelt=int(float(delt)/(1.0 + redshift))
    else:
        zdelt=delt
            
    bb=rgb_factors[2]*ims[0][mid-zdelt:mid+zdelt,mid-zdelt:mid+zdelt]
    gg=rgb_factors[1]*ims[1][mid-zdelt:mid+zdelt,mid-zdelt:mid+zdelt]
    rr=rgb_factors[0]*ims[2][mid-zdelt:mid+zdelt,mid-zdelt:mid+zdelt]
    
    
    fig = pyplot.figure(figsize=(6,6), dpi=600)
    pyplot.subplots_adjust(left=0.0, right=1.0, bottom=0.0, top=1.0,wspace=0.0,hspace=0.0)
    axi = fig.add_subplot(1,1,1)
    axi.set_xticks([]) ; axi.set_yticks([])
    
    rgbthing = make_color_image.make_interactive_nasa(bb,gg,rr,alph,Q)
    axi.imshow(rgbthing,interpolation='nearest',aspect='auto',origin='lower')
    
    fig.savefig(image_file,dpi=300,facecolor='Black')
    pyplot.close(fig)

    return rgbthing
コード例 #3
0
def export_hdst_filters(hdu_obj,camnum,vl,outdir='.',nonscatter=False):

    if hdu_obj.__class__ != fits.hdu.hdulist.HDUList:
        #pass filenames instead of hdu obj
        these_files=hdu_obj
        fn_u=these_files[np.where(np.core.defchararray.find(these_files, 'cam{:02d}'.format(camnum)+'_U_') != -1)[0]][0] ; u=(fits.open(fn_u)[0]).data
        fn_b=these_files[np.where(np.core.defchararray.find(these_files, 'cam{:02d}'.format(camnum)+'_B_') != -1)[0]][0] ; b=fits.open(fn_b)[0].data
        fn_v=these_files[np.where(np.core.defchararray.find(these_files, 'cam{:02d}'.format(camnum)+'_V_') != -1)[0]][0] ; v=fits.open(fn_v)[0].data
        fn_i=these_files[np.where(np.core.defchararray.find(these_files, 'cam{:02d}'.format(camnum)+'_I_') != -1)[0]][0] ; i=fits.open(fn_i)[0].data
        fn_z=these_files[np.where(np.core.defchararray.find(these_files, 'cam{:02d}'.format(camnum)+'_Z_') != -1)[0]][0] ; z=fits.open(fn_z)[0].data

        fn_j=these_files[np.where(np.core.defchararray.find(these_files, 'cam{:02d}'.format(camnum)+'_nircam_f115w_') != -1)[0]][0] ; j=fits.open(fn_j)[0].data
        fn_h=these_files[np.where(np.core.defchararray.find(these_files, 'cam{:02d}'.format(camnum)+'_nircam_f150w_') != -1)[0]][0] ; h=fits.open(fn_h)[0].data
        fn_k=these_files[np.where(np.core.defchararray.find(these_files, 'cam{:02d}'.format(camnum)+'_nircam_f200w_') != -1)[0]][0] ; k=fits.open(fn_k)[0].data

        redshift=fits.open(fn_v)[0].header['redshift']
        
    else:
        u,fn_u=export_image(hdu_obj,camnum,'hst/wfc3_f336w',label=vl,outdir=outdir,filterlabel='U')
        b,fn_b=export_image(hdu_obj,camnum,'hst/acs_f435w',label=vl,outdir=outdir,filterlabel='B')
        v,fn_v=export_image(hdu_obj,camnum,'hst/acs_f606w',label=vl,outdir=outdir,filterlabel='V')
        i,fn_i=export_image(hdu_obj,camnum,'hst/acs_f775w',label=vl,outdir=outdir,filterlabel='I')
        z,fn_z=export_image(hdu_obj,camnum,'hst/acs_f850lp',label=vl,outdir=outdir,filterlabel='Z')
        
        j,fn_j=export_image(hdu_obj,camnum,'jwst/nircam_f115w',label=vl,outdir=outdir,filterlabel='nircam_f115w')
        h,fn_h=export_image(hdu_obj,camnum,'jwst/nircam_f150w',label=vl,outdir=outdir,filterlabel='nircam_f150w')
        k,fn_k=export_image(hdu_obj,camnum,'jwst/nircam_f200w',label=vl,outdir=outdir,filterlabel='nircam_f200w')

        redshift=hdu_obj['BROADBAND'].header['redshift']


    scalefactor=(1.0/(1.0+redshift))
    
    rr=h+k
    gg=i+z+j
    bb=u+b+v

    fig = pyplot.figure(figsize=(6,6), dpi=600)
    pyplot.subplots_adjust(left=0.0, right=1.0, bottom=0.0, top=1.0,wspace=0.0,hspace=0.0)
  
    axi = fig.add_subplot(1,1,1)
    axi.set_xticks([]) ; axi.set_yticks([])
    
    alph=10.0*(0.33/scalefactor)**5 ; Q=5.0
    
    rgbthing = make_color_image.make_interactive_nasa(bb,gg,rr,alph,Q)
    axi.imshow(rgbthing,interpolation='nearest',aspect='auto',origin='lower')

    outfile=os.path.join(outdir,'rgb_'+vl+'.pdf')
    
    fig.savefig(outfile,dpi=300,facecolor='Black')
    pyplot.close(fig)
    
    return
コード例 #4
0
def do_jwst_illustris(fieldstr, alph, Q, rf, gf, bf, x=None, y=None, n=None):

    #in nJy
    ui = 'IMAGE_PSF'

    fielda_f435 = fits.open(
        hlsp_dir + 'mag30-' + fieldstr +
        '-11-10/hlsp_misty_illustris_hst-acs_f435w_mag30-' + fieldstr +
        '-11-10_v1_lightcone.fits')[ui].data
    fielda_f606 = fits.open(
        hlsp_dir + 'mag30-' + fieldstr +
        '-11-10/hlsp_misty_illustris_hst-acs_f606w_mag30-' + fieldstr +
        '-11-10_v1_lightcone.fits')[ui].data
    fielda_f775 = fits.open(
        hlsp_dir + 'mag30-' + fieldstr +
        '-11-10/hlsp_misty_illustris_hst-acs_f775w_mag30-' + fieldstr +
        '-11-10_v1_lightcone.fits')[ui].data

    fielda_f090 = fits.open(
        hlsp_dir + 'mag30-' + fieldstr +
        '-11-10/hlsp_misty_illustris_jwst-nircam_f090w_mag30-' + fieldstr +
        '-11-10_v1_lightcone.fits')[ui].data

    fielda_f115 = fits.open(
        hlsp_dir + 'mag30-' + fieldstr +
        '-11-10/hlsp_misty_illustris_jwst-nircam_f115w_mag30-' + fieldstr +
        '-11-10_v1_lightcone.fits')[ui].data
    fielda_f150 = fits.open(
        hlsp_dir + 'mag30-' + fieldstr +
        '-11-10/hlsp_misty_illustris_jwst-nircam_f150w_mag30-' + fieldstr +
        '-11-10_v1_lightcone.fits')[ui].data
    fielda_f200 = fits.open(
        hlsp_dir + 'mag30-' + fieldstr +
        '-11-10/hlsp_misty_illustris_jwst-nircam_f200w_mag30-' + fieldstr +
        '-11-10_v1_lightcone.fits')[ui].data

    fielda_f277 = fits.open(
        hlsp_dir + 'mag30-' + fieldstr +
        '-11-10/hlsp_misty_illustris_jwst-nircam_f277w_mag30-' + fieldstr +
        '-11-10_v1_lightcone.fits')[ui].data
    fielda_f356 = fits.open(
        hlsp_dir + 'mag30-' + fieldstr +
        '-11-10/hlsp_misty_illustris_jwst-nircam_f356w_mag30-' + fieldstr +
        '-11-10_v1_lightcone.fits')[ui].data
    fielda_f444 = fits.open(
        hlsp_dir + 'mag30-' + fieldstr +
        '-11-10/hlsp_misty_illustris_jwst-nircam_f444w_mag30-' + fieldstr +
        '-11-10_v1_lightcone.fits')[ui].data

    ra = rf * (0.50 * fielda_f150 + 0.50 * fielda_f200)
    ga = gf * (0.50 * fielda_f090 + 0.50 * fielda_f115)
    ba = bf * (0.33 * fielda_f435 + 0.33 * fielda_f606 + 0.33 * fielda_f775)

    gnew = congrid.congrid(ga, ra.shape) * 1.0  #preserve surface brightness
    bnew = congrid.congrid(ba, ra.shape) * 1.0

    print(fielda_f435.shape)
    print(ra.shape, ga.shape, gnew.shape)

    if n is not None:
        rgb_field = make_color_image.make_interactive_nasa(
            bnew[x:x + n, y:y + n], gnew[x:x + n, y:y + n],
            ra[x:x + n, y:y + n], alph, Q)
    else:
        rgb_field = make_color_image.make_interactive_nasa(
            bnew, gnew, ra, alph, Q)

    f1 = pyplot.figure(figsize=(10.0, 10.0), dpi=600)
    pyplot.subplots_adjust(left=0.0,
                           right=1.0,
                           bottom=0.0,
                           top=1.0,
                           wspace=0.0,
                           hspace=0.0)

    axi = f1.add_subplot(111)
    axi.imshow(rgb_field,
               interpolation='nearest',
               aspect='auto',
               origin='lower')

    if n is not None:
        saven = 'illustris_jwstzoom_' + fieldstr + '.pdf'
    else:
        saven = 'illustris_jwst_' + fieldstr + '.pdf'

    f1.savefig(saven, dpi=600)
    pyplot.close(f1)
コード例 #5
0
def do_xdf(alph, Q, rf, gf, bf):

    xdf_file = '/astro/snyder_lab2/Illustris/Illustris_MockUDFs/L75n1820FP/XDF/HST_XDF2012_SunriseUnits_60mas.fits'

    xdf_hdus = fits.open(xdf_file)
    print(xdf_hdus.info())

    pixsize_arcsec = 0.06
    pixel_Sr = (pixsize_arcsec**2) / sq_arcsec_per_sr
    to_nJy_per_Sr_perlambdasqum = (1.0e9) * (1.0e14) / c
    to_nJy_per_pix = to_nJy_per_Sr_perlambdasqum * pixel_Sr

    dx = 200
    dy = 200
    xx1 = 2200 + dx
    xx2 = 5042 + dx
    xy1 = 2200 + dy
    xy2 = 5042 + dy
    #gives 2.841 arcmin

    xdf_f435 = scipy.ndimage.interpolation.rotate(
        fits.open(xdf_file)['F435W'].data,
        42)[xx1:xx2, xy1:xy2] * to_nJy_per_pix * (0.435)**2
    xdf_f606 = scipy.ndimage.interpolation.rotate(
        fits.open(xdf_file)['F606W'].data,
        42)[xx1:xx2, xy1:xy2] * to_nJy_per_pix * (0.606)**2
    xdf_f775 = scipy.ndimage.interpolation.rotate(
        fits.open(xdf_file)['F775W'].data,
        42)[xx1:xx2, xy1:xy2] * to_nJy_per_pix * (0.775)**2
    xdf_f814 = scipy.ndimage.interpolation.rotate(
        fits.open(xdf_file)['F814W'].data,
        42)[xx1:xx2, xy1:xy2] * to_nJy_per_pix * (0.814)**2
    xdf_f850 = scipy.ndimage.interpolation.rotate(
        fits.open(xdf_file)['F850LP'].data,
        42)[xx1:xx2, xy1:xy2] * to_nJy_per_pix * (0.850)**2

    xdf_f105 = scipy.ndimage.interpolation.rotate(
        fits.open(xdf_file)['F105W'].data,
        42)[xx1:xx2, xy1:xy2] * to_nJy_per_pix * (1.05)**2
    xdf_f125 = scipy.ndimage.interpolation.rotate(
        fits.open(xdf_file)['F125W'].data,
        42)[xx1:xx2, xy1:xy2] * to_nJy_per_pix * (1.25)**2
    xdf_f140 = scipy.ndimage.interpolation.rotate(
        fits.open(xdf_file)['F140W'].data,
        42)[xx1:xx2, xy1:xy2] * to_nJy_per_pix * (1.40)**2
    xdf_f160 = scipy.ndimage.interpolation.rotate(
        fits.open(xdf_file)['F160W'].data,
        42)[xx1:xx2, xy1:xy2] * to_nJy_per_pix * (1.60)**2

    print(xdf_f435.shape)

    rx = rf * (0.25 * xdf_f105 + 0.25 * xdf_f125 + 0.25 * xdf_f140 +
               0.25 * xdf_f160)
    gx = gf * (0.50 * xdf_f850 + 0.50 * xdf_f775)
    bx = bf * (0.50 * xdf_f435 + 0.50 * xdf_f606)

    rgb_xdf = make_color_image.make_interactive_nasa(bx, gx, rx, alph, Q)

    f1 = pyplot.figure(figsize=(10.0, 10.0), dpi=600)
    pyplot.subplots_adjust(left=0.0,
                           right=1.0,
                           bottom=0.0,
                           top=1.0,
                           wspace=0.0,
                           hspace=0.0)

    axi = f1.add_subplot(111)
    axi.imshow(rgb_xdf, interpolation='nearest', aspect='auto', origin='lower')

    f1.savefig('xdf_render.pdf', dpi=600)
    pyplot.close(f1)

    return
コード例 #6
0
def do_hst_illustris(fieldstr, alph, Q, rf, gf, bf):

    #in nJy
    fielda_f435 = fits.open(
        hlsp_dir + 'mag30-' + fieldstr +
        '-11-10/hlsp_misty_illustris_hst-acs_f435w_mag30-' + fieldstr +
        '-11-10_v1_lightcone.fits')['IMAGE_PSF'].data
    fielda_f606 = fits.open(
        hlsp_dir + 'mag30-' + fieldstr +
        '-11-10/hlsp_misty_illustris_hst-acs_f606w_mag30-' + fieldstr +
        '-11-10_v1_lightcone.fits')['IMAGE_PSF'].data
    fielda_f775 = fits.open(
        hlsp_dir + 'mag30-' + fieldstr +
        '-11-10/hlsp_misty_illustris_hst-acs_f775w_mag30-' + fieldstr +
        '-11-10_v1_lightcone.fits')['IMAGE_PSF'].data
    fielda_f814 = fits.open(
        hlsp_dir + 'mag30-' + fieldstr +
        '-11-10/hlsp_misty_illustris_hst-acs_f814w_mag30-' + fieldstr +
        '-11-10_v1_lightcone.fits')['IMAGE_PSF'].data
    fielda_f850 = fits.open(
        hlsp_dir + 'mag30-' + fieldstr +
        '-11-10/hlsp_misty_illustris_hst-acs_f850lp_mag30-' + fieldstr +
        '-11-10_v1_lightcone.fits')['IMAGE_PSF'].data

    fielda_f105 = fits.open(
        hlsp_dir + 'mag30-' + fieldstr +
        '-11-10/hlsp_misty_illustris_hst-wfc3_f105w_mag30-' + fieldstr +
        '-11-10_v1_lightcone.fits')['IMAGE_PSF'].data
    fielda_f125 = fits.open(
        hlsp_dir + 'mag30-' + fieldstr +
        '-11-10/hlsp_misty_illustris_hst-wfc3_f125w_mag30-' + fieldstr +
        '-11-10_v1_lightcone.fits')['IMAGE_PSF'].data
    fielda_f140 = fits.open(
        hlsp_dir + 'mag30-' + fieldstr +
        '-11-10/hlsp_misty_illustris_hst-wfc3_f140w_mag30-' + fieldstr +
        '-11-10_v1_lightcone.fits')['IMAGE_PSF'].data
    fielda_f160 = fits.open(
        hlsp_dir + 'mag30-' + fieldstr +
        '-11-10/hlsp_misty_illustris_hst-wfc3_f160w_mag30-' + fieldstr +
        '-11-10_v1_lightcone.fits')['IMAGE_PSF'].data

    ra = rf * (0.25 * fielda_f105 + 0.25 * fielda_f125 + 0.25 * fielda_f140 +
               0.25 * fielda_f160)
    ga = gf * (0.50 * fielda_f850 + 0.50 * fielda_f775)
    ba = bf * (0.50 * fielda_f435 + 0.50 * fielda_f606)

    gnew = congrid.congrid(ga, ra.shape) * 4.0  #preserve surface brightness
    bnew = congrid.congrid(ba, ra.shape) * 4.0

    print(fielda_f435.shape)
    print(ra.shape, ga.shape, gnew.shape)

    rgb_field = make_color_image.make_interactive_nasa(bnew, gnew, ra, alph, Q)

    f1 = pyplot.figure(figsize=(10.0, 10.0), dpi=600)
    pyplot.subplots_adjust(left=0.0,
                           right=1.0,
                           bottom=0.0,
                           top=1.0,
                           wspace=0.0,
                           hspace=0.0)

    axi = f1.add_subplot(111)
    axi.imshow(rgb_field,
               interpolation='nearest',
               aspect='auto',
               origin='lower')

    f1.savefig('illustris_render_' + fieldstr + '.pdf', dpi=600)
    pyplot.close(f1)
コード例 #7
0
        r = hmap * fluxscale

        alph = 5.0
        Q = 9.0

        sigma_nJySr = header['RMS']
        pixel_Sr = (header['PIXSCALE']**2) / sq_arcsec_per_sr
        sigma_nJy = sigma_nJySr * pixel_Sr
        N = (3.0 * FWHM_arcsec / header['PIXSCALE'])**2
        mag_equiv = -2.5 * np.log10(5.0 * sigma_nJy * (1.0e-9) / (3631.0 /
                                                                  (N**0.5)))
        mag_string = '{:4.1f}'.format(mag_equiv)

        slw = 2.0

        rgbdata = make_color_image.make_interactive_nasa(
            b, g * gscale, r * rscale, alph, Q)
        axi = pyplot.axes([startx, starty, deltax, deltay],
                          frameon=True,
                          axisbg='black')
        axi.set_xticks([])
        axi.set_yticks([])
        axi.imshow(rgbdata,
                   interpolation='nearest',
                   origin='lower',
                   extent=[0, 1, 0, 1])
        axi.annotate(mag_string, (0.5, 0.09),
                     xycoords='axes fraction',
                     ha='center',
                     va='center',
                     color='white',
                     size=12)