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')
                                      kernel_fwhm=20./3600.,
                                      nhits=cubename+'_nhits.fits',
                                      velocityrange=velocityrange,
                                      excludefitrange=[vmin,vmax],
                                      linefreq=linefreq,
                                      progressbar=True,
                                      chmod=True) # security risk, but too many files!
        else:
            raise IOError("Did not find file {0}".format(fn))


    flat_vrange = [20,100]

    if os.path.exists(cubename+".fits"):
        makecube.runscript(cubename)
        makecube.make_flats(cubename,vrange=flat_vrange,noisevrange=[-50,-1])
        #makecube.make_flats(cubename,vrange=flat_vrange,noisevrange=[-50,-1],suffix='.fits')
    else:
        print "Failure at ",line


    # 6/18/2014: add "superresolution" maps of HELIUM

    helium_freq = {112: 4.62067,
                   111: 4.74612,
                   110: 4.87614,
                   109: 5.01096,
                   108:  5.1508,
                   107: 5.29589,
                   106: 5.44648,}
Ejemplo n.º 3
0
          '15B_129_1_77to134_D1_5_F1.fits',
          '15B_129_1_149to194_D1_5_F1.fits',
          '15B_129_1_196to242_D1_5_F1.fits',
          '15B_129_1_248to305_D1_5_F1.fits',
          '15B_129_1_306to352_D1_5_F1.fits',
          '15B_129_1_19to76_D2_5_F1.fits',
          '15B_129_1_77to134_D2_5_F1.fits',
          '15B_129_1_149to194_D2_5_F1.fits',
          '15B_129_1_196to242_D2_5_F1.fits',
          '15B_129_1_248to305_D2_5_F1.fits',
          '15B_129_1_306to352_D2_5_F1.fits',
         )
        ]

for fn in files:
    makecube.add_file_to_cube(fn,
                              cubename+'.fits',nhits=cubename+'_nhits.fits',
                              chmod=True,
                              add_with_kernel=True,
                              kernel_fwhm=20./3600.,
                              velocityrange=[-200,200],
                              excludefitrange=[-25,150],
                              diagnostic_plot_name=fn.replace('.fits','_data_scrubbed.png'),
                              progressbar=True
                             )

#os.system(os.path.join(outpath,'CMZ_East_H2CO22_cube_starlink.sh'))

makecube.make_flats(cubename,vrange=[-20,60],noisevrange=[250,300])

Ejemplo n.º 4
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)
Ejemplo n.º 5
0
        for obsrun in scanranges
        for scan1, scan2 in scanranges[obsrun]
        for x in [
            os.path.join(
                outpath, fntemplate.format(scan1, scan2, samplers[ii], sampler_feeds[samplers[ii][0]], obsrun=obsrun)
            )
            for ii in range(len(samplers))
        ]
    ]

    iterator = makecube.freq_iterator if ctype3 == "FREQ" else makecube.velo_iterator

    for fn in files:
        makecube.add_file_to_cube(
            fn,
            cubename + ".fits",
            nhits=cubename + "_nhits.fits",
            add_with_kernel=True,
            chmod=True,
            velo_iterator=iterator,
            kernel_fwhm=20.0 / 3600.0,
            default_unit=u.Unit(cunit3),
            progressbar=True,
            linefreq=restfreq,
            flatheader=cubename + "flatheader.txt",
            cubeheader=cubename + "cubeheader.txt",
        )

    if ctype3 == "VRAD":
        makecube.make_flats(cubename, vrange=[-20, 80], noisevrange=[150, 200])
    "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"
)
from set_headers import set_header_keywords
from paths import dpath

"""
H107, 108 are affected by the missing sampler on day 1
H111 has terrible baseline issues throughout.  I don't know why.
"""

fn = dpath('W51_h%ialpha_cube_supersampled_sub.fits')
halpha_6cm_cube = np.mean([fits.getdata(fn % i) for i in (110,112)],axis=0)
# use 111's header as an average of 110/112
halpha_6cm_hdr = set_header_keywords(fits.getheader(fn % 111), telescope='Arecibo')
halpha_6cm_hdr['RESTFREQ'] = (4.74418e9,"H110alpha rest frequency")
halpha_6cm_hdu = fits.PrimaryHDU(halpha_6cm_cube, halpha_6cm_hdr)
halpha_6cm_hdu.writeto(dpath('W51_Halpha_6cm_cube_supersampled_sub.fits'),clobber=True)
makecube.make_flats(dpath('W51_Halpha_6cm_cube_supersampled'),vrange=[35,85],noisevrange=[-15,30])

fn = dpath('W51_h%ialpha_cube_supersampled_continuum.fits')
halpha_6cm_cont = np.mean([fits.getdata(fn % i) for i in (110,112)],axis=0)
# use 111's header as an average of 110/112
halpha_6cm_hdr = set_header_keywords(fits.getheader(fn % 111), telescope='Arecibo')
halpha_6cm_hdr['RESTFREQ'] = (4.74418e9,"H110alpha rest frequency")
halpha_6cm_conthdu = fits.PrimaryHDU(halpha_6cm_cont, halpha_6cm_hdr)
halpha_6cm_conthdu.writeto(dpath('W51_Halpha_6cm_cube_supersampled_continuum.fits'),clobber=True)

fn = dpath('W51_he%ialpha_cube_supersampled_sub.fits')
healpha_6cm_cube = np.mean([fits.getdata(fn % i) for i in (110,112)],axis=0)
# use 111's header as an average of 110/112
healpha_6cm_hdr = set_header_keywords(fits.getheader(fn % 111), telescope='Arecibo')
healpha_6cm_hdr['NOTE'] = 'Average of He110 and He112alpha'
halpha_6cm_hdr['RESTFREQ'] = (4.74418e9,"He110alpha rest frequency")
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)
makecube.make_blank_images(cubename_supersampled,clobber=True)


for fn in filelist+filelist2:
    log.info("Adding file %s" % fn)
    fullfn = '/Users/adam/observations/gbt/W51map/'+fn
    d = fits.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_supersampled+".fits",
                              add_with_kernel=True,
                              kernel_fwhm=20./3600.,
                              nhits=cubename_supersampled+"_nhits.fits", 
                              diagnostic_plot_name=fullfn.replace('.fits','_data_scrubbed.png'),
                              velocityrange=velocityrange,excludefitrange=[20,100],noisecut=50,
                              continuum_prefix=cubename_supersampled+fn.replace(".fits",''),
                              progressbar=True,
                              chmod=True,
                              negative_mean_cut=-1)
                              # noisecut was probably a bad idea: it cut SIGNAL  
                              # more aggressive noisecut

makecube.runscript(cubename_supersampled)
makecube.make_flats(cubename_supersampled,vrange=[20,100],noisevrange=[-15,20])
Ejemplo n.º 10
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)