示例#1
0
 def set_imagepair(self, val):
     if not self.theapp.current_target:
         popup = AlertDialog(text='You need to select a target (on the Observing Screen) before proceeding!')
         popup.open()
         return
     header = [[0],[0]]
     pair = self.extract_pairs[self.pairstrings.index(val)]
     self.current_extraction = self.current_target.extractions.get(str(hash(':'.join(pair))), None)
     if not self.current_extraction:
         im1, im2 = [fitsimage(os.path.join(self.paths['raw'], x), header[i]) for i, x in enumerate(pair)]
         if 'EXREGX1' in header[0] or 'EXREGX1' in header[1]:
             for x in ['x1','y1','x2','y2']:
                 tmp = header[0]['EXREG'+x.upper()] or header[1]['EXREG'+x.upper()]
                 if tmp:
                     self.set_coord(x, tmp)
         region = map(int,[self.bx1, self.by1, self.bx2, self.by2])
         td = int(tracedir(self.current_target.instrument_id) == 'horizontal')
         self.current_extraction = extraction(im1, im2, self.current_flats, region,
                                              td, 'Gaussian')
         self.current_extraction.file1 = pair[0]
         self.current_extraction.file2 = pair[1]
         self.current_extraction.flatfile = os.path.join(self.paths['cal'],'Flat.fits')
         self.theapp.current_target.extractions[self.current_extraction.name] = self.current_extraction
     else:
         self.bx1, self.by1, self.bx2, self.by2 = self.current_extraction.region
     im = scalable_image(self.current_extraction.diff)
     self.ids.ipane.load_data(im)
     self.imwid, self.imht = im.dimensions
示例#2
0
 def set_imagepair(self, val):
     if not self.theapp.current_target:
         popup = AlertDialog(text='You need to select a target (on the Observing Screen) before proceeding!')
         popup.open()
         return
     header = [fits.Header()]*2
     pair = self.extract_pairs[self.pairstrings.index(val)]
     #im1, im2 = [FitsImage(os.path.join(self.paths['raw'], x), 
     #                      load=True) for x in pair]
     self.current_extraction = self.current_target.extractions.get(str(hash(':'.join(pair))), None)
     if not self.current_extraction:
         im1, im2 = [fitsimage(os.path.join(self.paths['raw'], x), header[i]) for i, x in enumerate(pair)]
         if 'EXREGX1' in header[0] or 'EXREGX1' in header[1]:
             for x in ['x1','y1','x2','y2']:
                 tmp = header[0]['EXREG'+x.upper()] or header[1]['EXREG'+x.upper()]
                 if tmp:
                     self.set_coord(x, tmp)
         region = map(int,[self.bx1, self.by1, self.bx2, self.by2])
         td = int(tracedir(self.current_target.instrument_id) == 'horizontal')
         #pdb.set_trace()
         self.current_extraction = extraction(im1, im2, self.current_flats, region,
                                              td, 'Gaussian')
         self.current_extraction.file1 = pair[0]
         self.current_extraction.file2 = pair[1]
         self.current_extraction.flatfile = os.path.join(self.paths['cal'],'Flat.fits')
         self.theapp.current_target.extractions[self.current_extraction.name] = self.current_extraction
     else:
         self.bx1, self.by1, self.bx2, self.by2 = self.current_extraction.region
     #fitsfile = self.paths['out']+re.sub(' ','',re.sub('.fits','',val))+'.fits'
     #im1, im2 = [x for x in copy.deepcopy(self.extract_pairs[pair_index])]
     #if not os.path.isfile(fitsfile):
     #    im1, im2 = [x for x in copy.deepcopy(self.extract_pairs[pair_index])]
     #    im1.load(); im2.load()
     #    im_subtract(im1, im2, outputfile=os.path.join(self.paths['out'],fitsfile))
     #self.current_impair = FitsImage(os.path.join(self.paths['out'],fitsfile), load=True)
     #self.ids.ipane.load_data(self.current_impair)
     im = scalable_image(self.current_extraction.diff)
     self.ids.ipane.load_data(im)
     self.imwid, self.imht = im.dimensions