Пример #1
0
#cd3 = 1.0 # Arecibo is limited to 0.64 because one of the receivers went bad at hi-res mode once
#naxis3 = int(np.ceil((velocityrange[1]-velocityrange[0])/cd3))+4 # +4 is BAD!  don't do that.
naxis3 = int((velocityrange[1]-velocityrange[0]) / cd3) + 1 # +1 is good: include -50
crval3 = 50.0
# dumb debug stuff
vels = crval3+cd3*(np.arange(naxis3)+1-naxis3/2-1)
# this will probably cause an error but I must insist..
#if velocityrange[0]<=vels.min() or velocityrange[1]>=vels.max():
#    raise ValueError("Add more points.  Something's going to be out of range for stupid star stupid link")
makecube.generate_header(49.209553, -0.277137, naxis1=192, naxis2=128,
                         pixsize=24, naxis3=naxis3, cd3=cd3, crval3=crval3,
                         clobber=True, restfreq=14.488479e9)
makecube.make_blank_images(cubename_lores,clobber=True)


for fn in [filename]:
    print "Adding file %s" % fn
    fullfn = fn
    makecube.add_file_to_cube(fullfn,
                              cubename_lores+".fits",
                              add_with_kernel=True,
                              kernel_fwhm=50./3600.,
                              nhits=cubename_lores+"_nhits.fits",
                              diagnostic_plot_name=fullfn.replace('.fits','_data_scrubbed.png'),
                              velocityrange=velocityrange,excludefitrange=[40,75],noisecut=1.0)
                              # more aggressive noisecut

makecube.runscript(cubename_lores)
makecube.make_flats(cubename_lores,vrange=[45,75],noisevrange=[-15,30])
makecube.make_taucube(cubename_lores,cubename_lores+"_continuum.fits",etamb=0.886)
from astropy import units as u
from sdpy import makecube
from paths import dpath

flat_vrange = [45,75]

cubename_lores_supersampled = dpath('W51_H2CO22_pyproc_cube_lores_supersampled')
linefreq = 14.488479e9
makecube.make_taucube(cubename_lores_supersampled,
                      cubename_lores_supersampled+"_continuum.fits",
                      etamb=0.886, linefreq=linefreq*u.Hz, tex=0)
makecube.make_flats(cubename_lores_supersampled.replace("cube","taucube"),
                    vrange=flat_vrange,noisevrange=[-50,-1],suffix='.fits')
makecube.make_flats(cubename_lores_supersampled, vrange=[45,75],
                    noisevrange=[-15,30])


linefreq = 4.8296594e9
cubename_supersampled = dpath('W51_H2CO11_cube_supersampled')
makecube.make_taucube(cubename_supersampled,
                      continuum=cubename_supersampled+"_continuum.fits",
                      linefreq=linefreq, tex=0) # etamb accounted for already , etamb=0.51)
makecube.make_flats(cubename_supersampled.replace("cube","taucube"),
                    vrange=flat_vrange,noisevrange=[-50,-1],suffix='.fits')
    "W51_h213coW_spectra_0910.fits",
    "W51_h213coW_spectra_0911.fits",
    "W51_h213coW_spectra_0912.fits",
    "W51_h213coW_spectra_0915.fits",
]

for fn in files:
    fullfn = fix_TDIM_in_header(prefix + fn)
    makecube.add_file_to_cube(
        fullfn,
        cubename_supersampled + ".fits",
        add_with_kernel=True,
        kernel_fwhm=20.0 / 3600.0,
        nhits=cubename_supersampled + "_nhits.fits",
        diagnostic_plot_name=fullfn.replace(".fits", "_data_scrubbed.png"),
        velocityrange=velocityrange,
        excludefitrange=[vmin, vmax],
        linefreq=linefreq,
    )

flat_vrange = [45, 75]

makecube.runscript(cubename_supersampled)
makecube.make_flats(cubename_supersampled, vrange=flat_vrange, noisevrange=[-50, -1])
makecube.make_taucube(
    cubename_supersampled, continuum=cubename_supersampled + "_continuum.fits", linefreq=linefreq
)  # etamb accounted for already , etamb=0.51)
makecube.make_flats(
    cubename_supersampled.replace("cube", "taucube"), vrange=flat_vrange, noisevrange=[-50, -1], suffix=".fits"
)
                                  kernel_fwhm=90./3600.,
                                  velocityrange=[-400,400],excludefitrange=[-225,250],
                                  smoothto=2)
    c1 = fits.getdata(cn_fmt.format('A9',sr[0],sr[1])+".fits")
    c2 = fits.getdata(cn_fmt.format('A13',sr[0],sr[1])+".fits")
    hdr = fits.getheader(cn+".fits")
    poldiff = c1-c2
    hdu = fits.PrimaryHDU(data=poldiff,header=hdr)
    hdu.writeto(cn_fmt.format("poldiff",sr[0],sr[1])+".fits",clobber=True)



os.system(outpath+'LimaBean_H2CO11_cube_starlink.sh')

makecube.make_flats(cubename,vrange=[-20,60],noisevrange=[250,300])
makecube.make_taucube(cubename,cubename+"_continuum.fits",etamb=0.98)


cubename=outpath+'LimaBean_H2CO11_cube_scan2'
files = [outpath+'12B_221_22to32_A13_F1.fits',
         outpath+'12B_221_22to32_A9_F1.fits',
         ]
makecube.generate_header(0.256, 0.0220, naxis1=100, naxis2=100, pixsize=15,
                         naxis3=800, cd3=1.0, clobber=True, restfreq=4.8296594e9)
makecube.make_blank_images(cubename,clobber=True)
for fn in files:
    makecube.add_file_to_cube(fn,
                              cubename+'.fits',
                              nhits=cubename+'_nhits.fits',
                              wcstype='V',
                              add_with_kernel=True,
for fn in filelist+filelist2:
    log.info("Adding file %s" % fn)
    fullfn = '/Users/adam/observations/gbt/W51map/'+fn
    d = pyfits.getdata(fullfn)
    pl.clf()
    pl.imshow(d['DATA'],norm=asinh_norm.AsinhNorm())
    pl.savefig(fullfn.replace(".fits","_data.png"))
    pl.clf()
    dsub = d['DATA']-np.median(d['DATA'],axis=1)[:,None]
    pl.imshow(dsub)
    pl.savefig(fullfn.replace(".fits","_data_subbed.png"))
    makecube.add_file_to_cube(fullfn,
                              cubename_lores_supersampled+".fits",
                              add_with_kernel=True,
                              kernel_fwhm=20./3600.,
                              nhits=cubename_lores_supersampled+"_nhits.fits",
                              diagnostic_plot_name=fullfn.replace('.fits','_data_scrubbed.png'),
                              velocityrange=velocityrange,excludefitrange=[40,75],noisecut=np.inf,
                              continuum_prefix=cubename_lores_supersampled+fn.replace(".fits",''),
                              progressbar=True,
                              chmod=True,
                              linefreq=linefreq,
                              negative_mean_cut=-1)

makecube.runscript(cubename_lores_supersampled)
makecube.make_flats(cubename_lores_supersampled, vrange=[45,75],
                    noisevrange=[-15,30])
makecube.make_taucube(cubename_lores_supersampled,
                      cubename_lores_supersampled+"_continuum.fits",
                      etamb=0.886, linefreq=linefreq*u.Hz, tex=0)
    # kernel = ((2.5*60)**2 -  50.**2)**0.5 / sqrt(8*log(2)) = 60 arcsec
    # 60 arcsec / 15 "/pixel = 4
    cubesm2 = FITS_tools.cube_regrid.gsmooth_cube(cube[0].data, [5,4,4], use_fft=True, psf_pad=False, fft_pad=False)
    cubesm = smooth_cube(cube[0].data, kernelwidth=4, interpolate_nan=True)
    cube[0].data = cubesm
    cube.writeto(cubename+"_sub_smoothtoCband.fits",clobber=True)
    cube[0].data = cubesm2
    cube.writeto(cubename+"_sub_smoothtoCband_vsmooth.fits",clobber=True)

    #makecube.make_taucube(cubename,cubename+"_continuum.fits",etamb=0.886)
    #makecube.make_taucube(cubename,cubename+"_continuum.fits",etamb=0.886, suffix="_sub_smoothtoCband.fits")
    # -0.4 is the most negative point in the continuum map...
    makecube.make_taucube(cubename,
                          cubename+"_continuum.fits",
                          etamb=0.886,
                          tex=2.0,
                          suffix="_sub_smoothtoCband_vsmooth.fits",
                          outsuffix="_smoothtoCband_vsmooth.fits",
                          TCMB=2.7315+0.4)

    makecube.make_taucube(cubename,
                          cubename+"_continuum.fits",
                          etamb=0.886,
                          tex=2.0,
                          suffix="_sub_smoothtoCband.fits",
                          outsuffix="_smoothtoCband.fits",
                          TCMB=2.7315+0.4)

    makecube.make_taucube(cubename,
                          cubename+"_continuum.fits",
                          etamb=0.886,
Пример #7
0
                         naxis1=192,
                         naxis2=128,
                         pixsize=24,
                         naxis3=naxis3,
                         cd3=cd3,
                         crval3=crval3,
                         clobber=True,
                         restfreq=14.488479e9)
makecube.make_blank_images(cubename_lores, clobber=True)

for fn in [filename]:
    print "Adding file %s" % fn
    fullfn = fn
    makecube.add_file_to_cube(fullfn,
                              cubename_lores + ".fits",
                              add_with_kernel=True,
                              kernel_fwhm=50. / 3600.,
                              nhits=cubename_lores + "_nhits.fits",
                              diagnostic_plot_name=fullfn.replace(
                                  '.fits', '_data_scrubbed.png'),
                              velocityrange=velocityrange,
                              excludefitrange=[40, 75],
                              noisecut=1.0)
    # more aggressive noisecut

makecube.runscript(cubename_lores)
makecube.make_flats(cubename_lores, vrange=[45, 75], noisevrange=[-15, 30])
makecube.make_taucube(cubename_lores,
                      cubename_lores + "_continuum.fits",
                      etamb=0.886)