Esempio n. 1
0
 def fix_distort(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
     pdistort, ndistort = draw_trace(self.extractregion, self.xx, self.fit_params['pmodel'], \
         self.fit_params['nmodel'], fixdistort = True, fitdegree = self.fit_params['deg'])
     
     im1, im2 = [x for x in copy.deepcopy(self.theapp.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)
     im_subtract(im1, im2, outputfile=self.current_impair.fitsfile)
     tmp = self.current_impair
     self.current_impair = FitsImage(self.current_impair.fitsfile)
     self.current_impair.header['EXREGX1'] = (tmp.get_header_keyword('EXREGX1'), 'extraction region coordinate X1')
     self.current_impair.header['EXREGY1'] = (tmp.get_header_keyword('EXREGY1'), 'extraction region coordinate Y1')
     self.current_impair.header['EXREGX2'] = (tmp.get_header_keyword('EXREGX2'), 'extraction region coordinate X2')
     self.current_impair.header['EXREGY2'] = (tmp.get_header_keyword('EXREGY2'), 'extraction region coordinate Y2')
     self.current_impair.update_fits(header_only = True)
     self.set_imagepair(self.pairstrings[self.pair_index])
     self.fit_params['nmodel'] = None
     self.fit_params['pmodel'] = None
Esempio n. 2
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]
Esempio n. 3
0
 def set_imagepair(self, val):
     if not self.theapp.current_target:
         popup = WarningDialog(text='You need to select a target (on the Observing Screen) before proceeding!')
         popup.open()
         return
     pair_index = self.pairstrings.index(val)
     fitsfile = self.paths['out']+re.sub(' ','',re.sub('.fits','',val))+'.fits'
     if not path.isfile(fitsfile):
         im1, im2 = [x for x in copy.deepcopy(self.extract_pairs[pair_index])]
         im1.load(); im2.load()
         #if self.current_flats:
         #    tmp = im_divide(im1, self.current_flats)
         #    im1.header, im1.data_array = tmp
         #    tmp = im_divide(im2, self.current_flats)
         #    im2.header, im2.data_array = tmp
         im_subtract(im1, im2, outputfile=path.join(self.paths['out'],fitsfile))
     self.current_impair = FitsImage(path.join(self.paths['out'],fitsfile), load=True)
     self.ids.ipane.load_data(self.current_impair)
     self.imwid, self.imht = self.current_impair.dimensions
     if self.current_impair.get_header_keyword('EXREGX1'):
         for x in ['x1', 'y1', 'x2', 'y2']:
             tmp = self.current_impair.get_header_keyword('EXREG'+x.upper())
             if tmp[0] is not None:
                 self.set_coord(x, tmp[0])