Exemplo n.º 1
0
 def wavecal(self):
     if not self.linelist:
         popup = WarningDialog(text="Please select a line list first.")
         popup.open()
         return
     calfile = self.paths['cal'] + self.speclist[self.spec_index]
     if self.ids.lampcal.state == 'down':
         calfile += '-lamp.fits'
     else:
         calfile += '-sky.fits'
     try:
         calib = ExtractedSpectrum(calfile)
     except:
         popup = WarningDialog(text="You don't have a calibration of this type...")
         popup.open()
         return
     niter = self.ids.numiter.text
     if self.linelist in self.linelists:
         #lldb = shelve.open('storage/linelists')
         #linelist_path = ird.deserialize(linelistdb[self.lineslist])
         linelist_path = linelistdb[self.linelist]
         #lldb.close()
     else:
         linelist_path = self.linelist
     self.calibration = calibrate_wavelength(calib, linelist_path, (self.wmin, self.wmax), niter)
     for i, w in self.calibration.parameters:
         self.current_spectrum.header['WAVECAL%i'%i] = (w, 'Wavelength calibration coefficient')
     self.current_spectrum.wav = self.calibration(range(len(self.current_spectrum.spec)))
     self.wmin = self.current_spectrum.wav.min()
     self.wmax = self.current_spectrum.wav.max()
     self.current_spectrum.plot.points = zip(self.current_spectrum.wav, self.current_spectrum.spec)
Exemplo n.º 2
0
 def wavecal(self):
     if not self.linelist:
         popup = AlertDialog(text="Please select a line list first.")
         popup.open()
         return
     if not self.assignment.assignment:
         popup = AlertDialog(text='Please designate initial line assignments.')
         popup.open()
         return
     calfile = os.path.join(self.paths['cal'],self.speclist[self.spec_index])
     if self.ids.lampcal_toggle.state == 'down':
         calfile += '-lamp.fits'
     else:
         calfile += '-sky.fits'
     try:
         calib = ExtractedSpectrum(str(calfile))
     except IOError:
         popup = AlertDialog(text="You don't have a calibration of this type...")
         popup.open()
         return
     self.calibration = calibrate_wavelength(medfilt(calib.spec), list(self.synthspec), zip(*self.assignment.assignment))
     try:
         for i, w in enumerate(self.calibration.parameters):
             self.current_spectrum.header['WAVECAL%i'%i] = (w, 'Wavelength calibration coefficient')
         self.current_spectrum.wav = self.calibration(range(len(self.current_spectrum.spec)))
         self.ids.specdisplay.xmin = float(floor_round(self.current_spectrum.wav.min(), dec=1))
         self.ids.specdisplay.xmax = float(ceil_round(self.current_spectrum.wav.max(), dec=1))
         self.ids.specdisplay.xlabel = 'Wavelength'
         self.current_spectrum.plot.points = zip(self.current_spectrum.wav, self.current_spectrum.spec)
         self.save_spectrum()
     except Exception as e:
         print e