class RSSModel(Spectrograph): """A model describing the RSS spectrograph""" def __init__(self, grating_name='None', gratang=45, camang=45, slit=1.0, xbin=2, ybin=2, xpos=-0.2666, ypos=0.0117, wavelength=None): # set up the parts of the grating self.grating_name = grating_name self.slitang = slit # set the telescope self.set_telescope('RSS') # set the collimator self.set_collimator('RSS') # set the camera self.set_camera('RSS', wavelength=wavelength) # set the detector self.set_detector('RSS', xbin=xbin, ybin=ybin, xpos=xpos, ypos=ypos) # set up the grating self.set_grating(self.grating_name) # set up the slit self.set_slit(self.slitang) # set up the grating angle self.gratang = gratang self.camang = camang def alpha(self, da=0.23): """Return the value of alpha for the spectrograph""" return self.gratang + da def beta(self, mF=4.2e-5, db=0.00): """Return the value of beta for the spectrograph Beta_o=(1+fA)*(camang)-gratang+beta_o """ return (1 + mF) * self.camang - self.alpha() + db def focallength(self, focallength=328.0, wavelength=None): """The camera focal lenght set oaccording to the following Wavelength should be provided in angstroms """ if wavelength is None: return focallength L = (wavelength - 4000.0) / 1000.0 return 327.66 + -0.1861 * L + 0.5061 * L**2 + -0.2100 * L**3 + 0.0365 * L**4 + -0.0023 * L**5 def get_wavelength(self, xarr, gamma=0.0): """For a given spectrograph configuration, return the wavelength coordinate associated with a pixel coordinate. xarr: 1-D Array of pixel coordinates gamma: Value of gamma for the row being analyzed returns an array of wavelengths in mm """ d = self.detector.xbin * self.detector.pix_size * ( xarr - self.detector.get_xpixcenter()) dbeta = -np.degrees(np.arctan(d / self.camera.focallength)) return self.calc_wavelength(self.alpha(), -self.beta() + dbeta, gamma=gamma) def set_telescope(self, name='RSS'): if name == 'RSS': self.telescope = Optics(name=name, focallength=46200.0) elif name == 'SALT': self.telescope = Optics(name=name, focallength=46200.0) else: raise RSSError('%s is not a supported Telescope' % name) def set_collimator(self, name='RSS', focallength=630.0): if name == 'RSS': self.collimator = Optics(name=name, focallength=focallength) else: raise RSSError('%s is not a supported collimator' % name) def set_camera(self, name='RSS', wavelength=None): if name == 'RSS': self.camera = Optics(name=name, focallength=self.focallength()) else: raise RSSError('%s is not a supported camera' % name) def set_detector(self, name='RSS', geom=None, xbin=2, ybin=2, xpos=0, ypos=0): if name == 'RSS': if geom: pass else: # version 1 # ccd1=Spectrograph.CCD(name='CCD1', xpix=2032, ypix=4102, pix_size=0.015, xpos=-32.19, ypos=0) # updated on 20120325 ccd1 = CCD(name='CCD1', xpix=2032, ypix=4102, pix_size=0.015, xpos=-32.40, ypos=0.0486) ccd2 = CCD(name='CCD1', xpix=2032, ypix=4102, pix_size=0.015, xpos=0, ypos=0) ccd3 = CCD(name='CCD1', xpix=2032, ypix=4102, pix_size=0.015, xpos=32.218, ypos=0.0196) self.detector = Detector(name=name, ccd=[ccd1, ccd2, ccd3], xbin=xbin, ybin=ybin, xpos=xpos, ypos=ypos, plate_scale=0.224) else: raise RSSError('%s is not a supported detector' % name) def set_grating(self, name=None): if name == 'PG0300': self.grating = Grating(name='PG0300', spacing=300) elif name == 'PG0900': self.grating = Grating(name='PG0900', spacing=903.20) elif name == 'PG1300': self.grating = Grating(name='PG1300', spacing=1301.20) elif name == 'PG1800': self.grating = Grating(name='PG1800', spacing=1801.65) elif name == 'PG2300': self.grating = Grating(name='PG2300', spacing=2302.15) elif name == 'PG3000': self.grating = Grating(name='PG3000', spacing=2999.98) else: raise RSSError('%s is not a supported RSS grating' % name) def set_slit(self, slitang=1.0): self.slit = Slit(name='LongSlit', phi=slitang) self.slit.width = self.slit.calc_width(self.telescope.focallength)
def set_slit(self, slitang=1.0): self.slit = Slit(name='LongSlit', phi=slitang) self.slit.width = self.slit.calc_width(self.telescope.focallength)
class RSSModel (Spectrograph): """A model describing the RSS spectrograph""" def __init__(self, grating_name='None', gratang=45, camang=45, slit=1.0, xbin=2, ybin=2, xpos=-0.2666, ypos=0.0117, wavelength=None): # set up the parts of the grating self.grating_name = grating_name self.slitang = slit # set the telescope self.set_telescope('RSS') # set the collimator self.set_collimator('RSS') # set the camera self.set_camera('RSS', wavelength=wavelength) # set the detector self.set_detector('RSS', xbin=xbin, ybin=ybin, xpos=xpos, ypos=ypos) # set up the grating self.set_grating(self.grating_name) # set up the slit self.set_slit(self.slitang) # set up the grating angle self.gratang = gratang self.camang = camang def alpha(self, da=0.23): """Return the value of alpha for the spectrograph""" return self.gratang + da def beta(self, mF=4.2e-5, db=0.00): """Return the value of beta for the spectrograph Beta_o=(1+fA)*(camang)-gratang+beta_o """ return (1 + mF) * self.camang - self.alpha() + db def focallength(self, focallength=328.0, wavelength=None): """The camera focal lenght set oaccording to the following Wavelength should be provided in angstroms """ if wavelength is None: return focallength L = (wavelength - 4000.0) / 1000.0 return 327.66 + -0.1861 * L + 0.5061 * L ** 2 + -0.2100 * L ** 3 + 0.0365 * L ** 4 + -0.0023 * L ** 5 def get_wavelength(self, xarr, gamma=0.0): """For a given spectrograph configuration, return the wavelength coordinate associated with a pixel coordinate. xarr: 1-D Array of pixel coordinates gamma: Value of gamma for the row being analyzed returns an array of wavelengths in mm """ d = self.detector.xbin * self.detector.pix_size * (xarr - self.detector.get_xpixcenter()) dbeta = -np.degrees(np.arctan(d / self.camera.focallength)) return self.calc_wavelength(self.alpha(), -self.beta() + dbeta, gamma=gamma) def set_telescope(self, name='RSS'): if name == 'RSS': self.telescope = Optics(name=name, focallength=46200.0) elif name == 'SALT': self.telescope = Optics(name=name, focallength=46200.0) else: raise RSSError('%s is not a supported Telescope' % name) def set_collimator(self, name='RSS', focallength=630.0): if name == 'RSS': self.collimator = Optics(name=name, focallength=focallength) else: raise RSSError('%s is not a supported collimator' % name) def set_camera(self, name='RSS', wavelength=None): if name == 'RSS': self.camera = Optics(name=name, focallength=self.focallength()) else: raise RSSError('%s is not a supported camera' % name) def set_detector(self, name='RSS', geom=None, xbin=2, ybin=2, xpos=0, ypos=0): if name == 'RSS': if geom: pass else: # version 1 #ccd1=Spectrograph.CCD(name='CCD1', xpix=2032, ypix=4102, pix_size=0.015, xpos=-32.19, ypos=0) # updated on 20120325 ccd1 = CCD(name='CCD1', xpix=2032, ypix=4102, pix_size=0.015, xpos=-32.40, ypos=0.0486) ccd2 = CCD(name='CCD1', xpix=2032, ypix=4102, pix_size=0.015, xpos=0, ypos=0) ccd3 = CCD(name='CCD1', xpix=2032, ypix=4102, pix_size=0.015, xpos=32.218, ypos=0.0196) self.detector = Detector(name=name, ccd=[ccd1, ccd2, ccd3], xbin=xbin, ybin=ybin, xpos=xpos, ypos=ypos, plate_scale=0.224) else: raise RSSError('%s is not a supported detector' % name) def set_grating(self, name=None): if name == 'PG0300': self.grating = Grating(name='PG0300', spacing=300) elif name == 'PG0900': self.grating = Grating(name='PG0900', spacing=903.20) elif name == 'PG1300': self.grating = Grating(name='PG1300', spacing=1301.20) elif name == 'PG1800': self.grating = Grating(name='PG1800', spacing=1801.65) elif name == 'PG2300': self.grating = Grating(name='PG2300', spacing=2302.15) elif name == 'PG3000': self.grating = Grating(name='PG3000', spacing=2999.98) else: raise RSSError('%s is not a supported RSS grating' % name) def set_slit(self, slitang=1.0): self.slit = Slit(name='LongSlit', phi=slitang) self.slit.width = self.slit.calc_width(self.telescope.focallength)
class HRSModel (Spectrograph): """HRSModel is a class that describes the High Resolution Specotrgraph on SALT """ def __init__(self, grating_name='hrs', camera_name='hrdet', slit=2.0, \ order=83, gamma=None, xbin=1, ybin=1, xpos=0.00, ypos=0.00): #set up the parts of the grating self.grating_name=grating_name #set the telescope self.set_telescope('SALT') #set the collimator self.set_collimator('hrs') #set the camera self.set_camera(camera_name) #set the detector self.set_detector(camera_name, xbin=xbin, ybin=ybin, xpos=xpos, ypos=ypos) #set up the grating self.set_grating(self.grating_name, order=order) #set up the slit self.set_slit(slit) #set up the grating angle if gamma is not None: self.gamma=gamma def alpha(self, da=0.00): """Return the value of alpha for the spectrograph""" return self.grating.blaze+self.gamma def beta(self, db=0): """Return the value of beta for the spectrograph Beta_o=(1+fA)*(camang)-gratang+beta_o """ return self.grating.blaze-self.gamma+db def get_wavelength(self, xarr, gamma=0.0): """For a given spectrograph configuration, return the wavelength coordinate associated with a pixel coordinate. xarr: 1-D Array of pixel coordinates gamma: Value of gamma for the row being analyzed returns an array of wavelengths in mm """ d=self.detector.xbin*self.detector.pix_size*(xarr-self.detector.get_xpixcenter()) dbeta=np.degrees(np.arctan(d/self.camera.focallength)) return self.calc_wavelength(self.alpha(), -self.beta()+dbeta, gamma=gamma) def set_telescope(self, name='SALT'): if name=='SALT': self.telescope=Optics(name=name, focallength=46200.0) else: raise SpectrographError('%s is not a supported Telescope' % name) def set_collimator(self, name='hrs', focallength=2000.0): if name=='hrs': self.collimator=Optics(name=name, focallength=focallength) else: raise SpectrographError('%s is not a supported collimator' % name) def set_camera(self, name='hrdet', focallength=None): if name=='hrdet': self.camera=Optics(name=name, focallength=402.26) self.gamma = 2.43 elif name=='hbdet': self.camera=Optics(name=name, focallength=333.6) self.gamma = 2.00 else: raise SpectrographError('%s is not a supported camera' % name) def set_detector(self, name='hrdet', geom=None, xbin=1, ybin=1, xpos=0, ypos=0): if name=='hrdet': ccd=CCD(name='hrdet', xpix=4122, ypix=4112, pix_size=0.015, xpos=0.00, ypos=0.00) self.detector=Detector(name=name, ccd=[ccd], xbin=xbin, ybin=ybin, \ xpos=xpos, ypos=ypos) elif name=='hbdet': ccd=CCD(name='hrdet', xpix=2100, ypix=4112, pix_size=0.015, xpos=0.00, ypos=0.00) self.detector=Detector(name=name, ccd=[ccd], xbin=xbin, ybin=ybin, \ xpos=xpos, ypos=ypos) else: raise SpectrographError('%s is not a supported detector' % name) def set_grating(self, name=None, order=83): if name=='hrs': self.grating=Grating(name='hrs', spacing=41.59, blaze=76.0, order=order) self.set_order(order) elif name=='red beam': self.grating=Grating(name='red beam', spacing=855, blaze=0, order=1) self.alpha_angle = 17.5 self.set_order(1) elif name=='blue beam': self.grating=Grating(name='blue beam', spacing=1850, blaze=0, order=1) self.alpha = 24.6 self.set_order(1) else: raise SpectrographError('%s is not a supported grating' % name) def set_order(self, order): self.order=order self.grating.order = order def set_slit(self, slitang=2.2): self.slit=Slit(name='Fiber', phi=slitang) self.slit.width=self.slit.calc_width(self.telescope.focallength)
def set_slit(self, slitang=2.2): self.slit=Slit(name='Fiber', phi=slitang) self.slit.width=self.slit.calc_width(self.telescope.focallength)