from pyraf import iraf from pyraf.iraf import gemini, gmos os.chdir(current_dir) iraf.chdir(current_dir) iraf.unlearn('gfreduce') iraf.unlearn('gfdisplay') # ---------- Trace reference ---------- # iraf.imdelete('g@' + ic.lst_flat) iraf.imdelete('rg@' + ic.lst_flat) iraf.imdelete('erg@' + ic.lst_flat) for flat in iraf.type(ic.lst_flat, Stdout=1): flat = flat.strip() iraf.gfreduce(flat, rawpath=ic.rawdir, fl_extract='yes', bias=ic.bias, fl_over='yes', fl_trim='yes', mdffile=ic.nmdf, mdfdir='./', slits='both', line=1400, fl_fluxcal='no', fl_gscrrej='no', fl_wavtran='no', fl_skysub='no',
import g0_init_cfg as ic # ----- Importing IRAF from the root directory ----- # current_dir = os.getcwd() os.chdir(ic.dir_iraf) from pyraf import iraf from pyraf.iraf import gemini, gmos os.chdir(current_dir) iraf.chdir(current_dir) # ---------- Fixing a bad column ---------- # from astropy.io import fits for sci in iraf.type(ic.lst_sci, Stdout=1): sci = sci.strip() fits.open('eqxbrg' + sci + '.fits').info() # 2-slit mode dt1, hd1 = fits.getdata('eqxbrg' + sci + '.fits', ext=2, header=True) dt2, hd2 = fits.getdata('eqxbrg' + sci + '.fits', ext=5, header=True) # os.system('ds9 &') # iraf.sleep(5.0) # iraf.display(image = 'eqxbrg'+sci+'.fits[sci,1]', frame = 1) # iraf.display(image = 'eqxbrg'+sci+'.fits[sci,2]', frame = 2) # # Stop point #1 : please check the 'physical' coordinates in the images! # import sys # sys.exit('Image check ...')
iraf.chdir(current_dir) iraf.unlearn('gfreduce') iraf.unlearn('gfextract') # ---------- Verifying the MDF ---------- # os.system('rm -rfv ' + ic.dir_db + ' *.fits tmp*') # Copy the MDF iraf.copy('gmos$data/' + ic.mdf, '.', verbose='no') # Extract a flat iraf.imdelete('g@' + ic.lst_flat) iraf.imdelete('rg@' + ic.lst_flat) flat0 = iraf.type(ic.lst_flat, Stdout=1)[0] iraf.gfreduce(flat0, rawpath=ic.rawdir, fl_extract='no', bias=ic.bias, fl_over='yes', fl_trim='yes', mdffile=ic.mdf, mdfdir='./', slits='both', line=1400, fl_fluxcal='no', fl_gscrrej='no', fl_wavtran='no', fl_skysub='no', fl_inter='no',
mdfdir='./', slits='both', line=1400, fl_fluxcal='no', fl_gscrrej='no', fl_wavtran='no', fl_skysub='no', fl_vardq='yes', fl_inter='no') # Scattered light blkmsk_ref = 'newblkmask_S20190228S0015_hdr01' iraf.imdelete('brg@' + ic.lst_sci) for sci in iraf.type(ic.lst_sci, Stdout=1): sci = sci.strip() iraf.gfscatsub('rg' + sci, blkmsk_ref, outimage='', prefix='b', xorder='3,3,3,3,3,3,3,3,3,3,3,3', yorder='3,3,3,3,3,3,3,3,3,3,3,3', cross='yes', fl_inter='no') # os.system('ds9 &') # iraf.sleep(5.0) # for sci in iraf.type(ic.lst_sci, Stdout=1): # sci = sci.strip() # for i in range(12):
os.chdir(ic.dir_iraf) from pyraf import iraf from pyraf.iraf import gemini, gmos os.chdir(current_dir) iraf.chdir(current_dir) iraf.unlearn('gftransform') iraf.unlearn('gfskysub') # ---------- Rectify the spectra ---------- # from astropy.io import fits # Angstroms per pixel arc0 = iraf.type(ic.lst_arc, Stdout=1)[0].strip() for sci in iraf.type(ic.lst_sci, Stdout=1): sci = sci.strip() iraf.imdelete('txeqxbrg' + sci, verify='no') iraf.gftransform('xeqxbrg' + sci, wavtraname='erg' + arc0, fl_vardq='no') fits.open('txeqxbrg' + sci + '.fits').info() dat, hdr = fits.getdata('txeqxbrg' + sci + '.fits', ext=2, header=True) dw = float(hdr['CD1_1']) print('dw : {0:f}'.format(dw)) # # Stop point #1 # import sys # sys.exit("Please check 'dw'.") # Rectify
os.chdir(ic.dir_iraf) from pyraf import iraf from pyraf.iraf import gemini, gmos os.chdir(current_dir) iraf.chdir(current_dir) iraf.unlearn('gfreduce') iraf.unlearn('gswavelength') # ---------- Wavelength solution ---------- # # Extract the arc flatref = iraf.type(ic.lst_flat, Stdout=1)[0].strip() iraf.imdelete('g@'+ic.lst_arc) iraf.imdelete('rg@'+ic.lst_arc) iraf.imdelete('erg@'+ic.lst_arc) for arc in iraf.type(ic.lst_arc, Stdout=1): arc = arc.strip() iraf.gfreduce(arc, rawpath=ic.rawdir, fl_extract='yes', recenter='no', trace='no', reference='erg'+flatref, fl_bias='no', fl_over='yes', fl_trim='yes', mdffile=ic.nmdf, mdfdir='./', slits='both', fl_fluxcal='no', fl_gscrrej='no', fl_wavtran='no', fl_skysub='no', fl_inter='no') iraf.sleep(10.0)
iraf.unlearn('gfscatsub') iraf.unlearn('gfreduce') iraf.unlearn('gfdisplay') iraf.unlearn('gfresponse') # ---------- Reduce the lamp flat ---------- # # Model and remove the light iraf.imdelete('brg@'+ic.lst_flat) # os.system('ds9 &') # iraf.sleep(5.0) for flat in iraf.type(ic.lst_flat, Stdout=1): flat = flat.strip() blkmsk = 'newblkmask_S20190228S0015_hdr01' iraf.gfscatsub('rg'+flat, blkmsk, outimage='', prefix='b', xorder='3,3,3,3,3,3,3,3,3,3,3,3', yorder='3,3,3,3,3,3,3,3,3,3,3,3', cross='yes', fl_inter='no') # os.system('ds9 &') # iraf.sleep(5.0) # for flat in iraf.type(ic.lst_flat, Stdout=1): # flat = flat.strip() # for i in np.arange(12): # iraf.imexamine('brg'+flat+'[sci,'+str(i+1)+']', 1)