makecube.generate_header(49.209553,-0.277137,naxis1=308,naxis2=205,pixsize=15,naxis3=int(naxis3),cd3=cd3,crval3=crval3,clobber=True, restfreq=linefreq, author='Adam Ginsburg') cubename = '/Users/adam/work/h2co/maps/w51/W51_%slpha_cube_supersampled' % linename makecube.make_blank_images(cubename,clobber=True) for date in ('0910','0911','0912','0915',): fn = '/Users/adam/observations/arecibo/2012{date}/W51_{line}_spectra_{date}.fits'.format(line=linename,date=date) if not os.path.exists(fn): fn = '/Users/adam/observations/arecibo/20120910/W51_{line}_spectra_{date}.fits'.format(line=linename,date=date) log.info(" ".join([str(x) for x in (fn, velocityrange, linename, linefreq)])) if os.path.exists(fn): makecube.add_file_to_cube(fn, cubename+'.fits', add_with_kernel=True, 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:
'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])
#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)
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])
makecube.make_blank_images(cubename,clobber=True) #makecube.make_blank_images(cubename_discrete,clobber=True) files = [outpath+'12B_221_6to21_A13_F1.fits', outpath+'12B_221_6to21_A9_F1.fits', # there was one noisy scan, so the whole damned thing gets commented out #outpath+'12B_221_22to32_A13_F1.fits', #outpath+'12B_221_22to32_A9_F1.fits', ] for fn in files: makecube.add_file_to_cube(fn, cubename+'.fits', nhits=cubename+'_nhits.fits', wcstype='V', chmod=True, add_with_kernel=True, kernel_fwhm=90./3600., velocityrange=[-400, 400], excludefitrange=[-225, 250], diagnostic_plot_name=fn.replace('.fits','_data_scrubbed.png'), smoothto=2) fstr = outpath+'12B_221_{0}to{1}_{2}_F1.fits' cn_fmt = cubename+"_{0}_sr{1}-{2}" for sr in ([6,21],[22,32]): for sampler in ('A9','A13'): cn = cn_fmt.format(sampler,sr[0],sr[1]) fn = fstr.format(sr[0],sr[1],sampler) makecube.make_blank_images(cn,clobber=True) makecube.add_file_to_cube(fn, cn+'.fits',nhits=cn+'_nhits.fits',wcstype='V', add_with_kernel=True,
files = [ "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"
ra,dec = W.wcs_pix2sky(x,y,0) yield ra,dec def velo_iterator(data,linefreq=None, **kwargs): for x,y in zip(xinds.ravel(),yinds.ravel()): yield wavel if prefilter: fn = filter(fn) # this is where all the magic happens # add_with_kernel adds each pixel as a gaussian instead of just doing # nearest-neighbor interpolation # this will avoid empty stripes makecube.add_file_to_cube(fn, cubefilename, flatheader='flat.hdr', cubeheader='cube.hdr', nhits=nhitsfilename, data_iterator=data_iterator, coord_iterator=coord_iterator, velo_iterator=velo_iterator, allow_smooth=False, progressbar=True, add_with_kernel=True, kernel_fwhm=1.0/3600., default_unit=u.um, debug=1) print "Completed file %s" % fn
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)
'14A_110_04_6to32_A13_F2.fits', '14A_110_04_32to72_A9_F1.fits', '14A_110_04_32to72_A13_F2.fits', '14A_110_04_73to99_A9_F1.fits', '14A_110_04_73to99_A13_F2.fits', '14A_110_04_99to113_A9_F1.fits', '14A_110_04_99to113_A13_F2.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=10./3600., velocityrange=[-250,250], excludefitrange=[0,50], diagnostic_plot_name=fn.replace('.fits','_data_scrubbed.png'), smoothto=2) os.system(os.path.join(outpath,'LimaBean_H2CO33_cube_starlink.sh')) makecube.make_flats(cubename,vrange=[-20,60],noisevrange=[150,200]) sampler_feeds = {'A10': 1, 'A14': 2, 'B17': 1, 'B18': 1, 'B21': 2,
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)
crval3=crval3, clobber=True, restfreq=linefreq, author='Adam Ginsburg') makecube.make_blank_images(cubename_supersampled,clobber=True) files = ['W51_h2coW_spectra_0910.fits', 'W51_h2coW_spectra_0911.fits', 'W51_h2coW_spectra_0912.fits', 'W51_h2coW_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./3600., 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, 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')