Beispiel #1
0
 def on_enter(self):
     flat = path.join(self.paths['cal'],'Flat.fits')
     if self.theapp.current_night.flaton and self.theapp.current_night.flaton[0]:
         fon = FitsImage(path.join(self.paths['cal'], \
             self.theapp.current_night.flaton[0]), load=True)
         if self.theapp.current_night.flatoff and self.theapp.current_night.flatoff[0]:
             foff = FitsImage(path.join(self.paths['cal'], \
                 self.theapp.current_night.flatoff[0]), load=True)
             im_subtract(fon, foff, outputfile = flat)
         else:
             write_fits(flat, fon.header, fon.data_array)
         self.current_flats = FitsImage(flat, load = True)
     self.pairstrings = ['{0} - {1}'.format(*[path.basename(x.fitsfile) for x in y]) for y in self.extract_pairs]
Beispiel #2
0
 def extract_spectrum(self):
     if not (self.fit_params.get('pmodel',False) or \
         self.fit_params.get('nmodel',False)):
         popup = WarningDialog(text='Make sure you fit the trace centers first!')
         popup.open()
         return
     
     #need a calibration, too
     self.lamp = None
     if theapp.current_night.cals:
         self.lamp = theapp.current_night.cals.data_array if not self.current_flats \
             else im_divide(theapp.current_night.cals, self.current_flats).data_array
         self.lamp = self.lamp[self.region[1]:self.region[3]+1,self.region[0]:self.region[2]+1]
     im1, im2 = [x for x in copy.deepcopy(the_app.extract_pairs[self.pair_index])]
     im1.load(); im2.load()
     #if self.current_flats:
     #    im1 = im_divide(im1, self.current_flats)
     #    im2 = im_divide(im2, self.current_flats)
     im1.data_array = undistort_imagearray(im1.data_array, pdistort)
     im2.data_array = undistort_imagearray(im2.data_array, ndistort)
     self.tell = make_region(im1, im2, self.region, flat=self.current_flats, telluric=True)
     #tmp, self.tell = im_minimum(im1.data_array, im2.data_array)
     #self.tell = self.tell[self.region[1]:self.region[3]+1,self.region[0]:self.region[2]+1]
     self.pextract = extract(self.fit_params['pmodel'], self.extractregion, self.tell, 'pos', lamp = self.lamp)
     self.nextract = extract(self.fit_params['nmodel'], self.extractregion, self.tell, 'neg', lamp = self.lamp)
     
     #write uncalibrated spectra to fits files (will update after calibration)
     pstub = self.paths['out'] + re.sub('.fits','-ap%i',im1.fitsfile)
     ext = ('.fits','-sky.fits','-lamp.fits')
     h = im1.header
     for i, p_ap in enumerate(self.pextract):
         for j in range(p_ap.shape[1]):
             spec = p_ap[:,j]
             write_fits((pstub + ext[i]) % j, h, spec)
     
     nstub = self.paths['out'] + re.sub('.fits','-ap%i',im2.fitsfile)
     h = im2.header
     for i, n_ap in enumerate(self.nextract):
         for j in range(n_ap.shape[1]):
             spec = n_ap[:,j]
             write_fits((nstub + ext[i]) % j, h, spec)
Beispiel #3
0
 def combine(self):
     out = self.ids.savefile.text
     h = self.the_specs[self.ind].header
     write_fits(out, h, zip(*self.combined_spectrum.points))