def __init__(self,fname,linelist=None,extv=1,nsum=10,match=6,radius=10): self.extv = extv self.nsum = nsum self.match = match self.radius = radius ad = AstroData(fname) self.imdata = ad['SCI',extv].data if ad.dispersion_axis() == 2: # Transpose to work on the X-axis. self.imdata = self.imdata.transpose() self.filename = ad.filename self.ad = ad linelist_file = linelist scrpix = 'crpix1' scrval = 'crval1' scdelt = 'cd1_1' fpath=os.path.dirname(spu.__file__) if ad.is_type('F2_SPECT') or self.ad.is_type('GNIRS'): reffile = 'calibrated_arc.fits' wmin = 7035.14 # x*0.24321 + 7035.1381. wavelength at [0] wmax = 25344.54 # wavelength at [-1] scrpix = 'crpix2' scrval = 'crval2' scdelt = 'cd2_2' sz = np.shape(self.imdata) if len(sz) == 3: self.imdata = self.imdata.reshape(sz[1],sz[2]) if linelist_file==None: linelist_file = 'argon.dat' #linelist_file = 'lowresargon.dat' elif ad.is_type('GMOS_SPECT'): if linelist_file==None: linelist_file = 'cuar.dat' reffile = 'cuar.fits' wmin = 3053. # x*0.25 + 3053. cuar.fits wavelength at cuarf[0] wmax = 10423. # cuar.fits wavelength at cuarf[-1] elif ad.is_type('NIRI_SPECT'): reffile = 'calibrated_arc.fits' wmin = 7032.706 wmax = 25342.113 if linelist_file==None: linelist_file = 'lowresargon.dat' elif ad.is_type('NIFS_SPECT'): filtername = str(self.ad.filter_name()) if 'JH' in filtername: if linelist_file==None: linelist_file = 'argon.dat' wmin = 7032.706 wmax = 25342.113 reffile = 'calibrated_arc.fits' elif 'HK' in filtername: if linelist_file==None: linelist_file = 'ArXe_K.dat' wmin = 20140.259 wmax = 24491.320 reffile = 'NIFS_K_arc_1D.fits' elif 'ZJ' in filtername: if linelist_file==None: linelist_file = 'argon.dat' wmin = 7035.14 wmax = 25344.54 reffile = 'calibrated_arc.fits' else: raise ValueError('Input file is not supported: '+ad.filename) self.reffile = os.path.join(fpath,reffile) self.wmin = wmin self.wmax = wmax self.pixs=[] self.users=[] linelist_file = os.path.join(fpath,linelist_file) linelist = np.loadtxt(linelist_file,usecols=(0,)) hdr = ad['SCI',extv].header self.wcs={'crpix':hdr[scrpix], 'crval':hdr[scrval], 'cdelt':hdr[scdelt]} cdelt = self.wcs['cdelt'] if cdelt < 0: linelist = linelist[::-1] # Change to decreasing order self.cuar = linelist # cuar is the IRAF name self.ad = ad sz = np.shape(self.imdata) nsum = 6 if len(sz) == 2: ny = max(3,nsum/2) ym = sz[0]/2 lpix = np.mean(self.imdata[ym-ny:ym+ny],axis=0) elif len(sz) == 1: lpix = self.imdata else: raise ValueError("Image dimesions are greater than 2.") self.lpix = lpix # Now find the arc peaks pixel coordinates upeaks,uflux,fw = spu.find_upeaks(self.lpix, 2, nmax=50, cradius=12) self.xfluxs = uflux self.xpeaks = upeaks # A synonim