Exemple #1
0
def reduce_dither_pair(dither_a, dither_b, traces, trace_direction=1, 
                       lamp_image=None):
    '''dither_a and dither_b are two dither positions of the same source,
    already flat-fielded. traces is a list of initial guesses for trace parameters.
    trace_direction is 1 for a horizontal trace and 0 for a vertical trace.'''
    #p_init = composite_model(traces, model_type='gaussian')
    lamps = lamp_image != None
    pdb.set_trace()
    difference_image = im_subtract(dither_a, dither_b)[1]
    postrace, negtrace = fit_trace(difference_image, traces, 
                              tracedir=trace_direction)
    dither_a = fix_distortion(dither_a, postrace, trace_direction)
    dither_b = fix_distortion(dither_b, negtrace, trace_direction)
    difference_image = im_subtract(dither_a, dither_b)[1]
    all_profiles = fit_trace(difference_image, traces, 
                             tracedir=trace_direction)
    telluric_image = im_minimum(dither_a, dither_b)[1]
    return extract(all_profiles, difference_image, telluric_image, 
                   tracedir=trace_direction, lamps=lamps, lamp=lamp_image)
    
    
    
    
    
    
    
    
    
Exemple #2
0
 def on_enter(self):
     flat = os.path.join(self.paths['cal'],'Flat.fits')
     header = [0]
     if not os.path.exists(flat):
         if self.theapp.current_night.flaton and self.theapp.current_night.flaton[0]:
             fon = fitsimage(str(os.path.join(self.paths['cal'], self.theapp.current_night.flaton[0])), header)
             if self.theapp.current_night.flatoff and self.theapp.current_night.flatoff[0]:
                 foff = fitsimage(str(os.path.join(self.paths['cal'], self.theapp.current_night.flatoff[0])), header)
                 im_subtract(fon, foff, outputfile = flat)
             else:
                 fits.writeto(flat, fon, header=header[0])
     self.current_flats = fitsimage(flat, header)
     self.pairstrings = ['{0} - {1}'.format(*map(os.path.basename,x)) for x in self.extract_pairs]
 def on_enter(self):
     flat = os.path.join(self.paths['cal'],'Flat.fits')
     if self.theapp.current_night.flaton and self.theapp.current_night.flaton[0]:
         fon = FitsImage(os.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(os.path.join(self.paths['cal'], \
                 self.theapp.current_night.flatoff[0]), load=True)
             im_subtract(fon, foff, outputfile = flat)
         else:
             fits.writeto(flat, fon.data_array, header=fon.header)
         self.current_flats = FitsImage(flat, load = True)
     self.pairstrings = ['{0} - {1}'.format(*[os.path.basename(x.fitsfile) for x in y]) for y in self.extract_pairs]
 def on_enter(self):
     flat = os.path.join(self.paths['cal'],'Flat.fits')
     header = object()
     if not os.path.exists(flat):
         if self.theapp.current_night.flaton and self.theapp.current_night.flaton[0]:
             #fon = FitsImage(os.path.join(self.paths['cal'], \
             #    self.theapp.current_night.flaton[0]), load=True)
             fon = fitsimage(os.path.join(self.paths['cal'], self.theapp.current_night.flaton[0]), header)
             if self.theapp.current_night.flatoff and self.theapp.current_night.flatoff[0]:
                 #foff = FitsImage(os.path.join(self.paths['cal'], \
                 #    self.theapp.current_night.flatoff[0]), load=True)
                 foff = fitsimage(os.path.join(self.paths['cal'], self.theapp.current_night.flatoff[0]), header)
                 im_subtract(fon, foff, outputfile = flat)
             else:
                 fits.writeto(flat, fon.data_array, header=fon.header)
     self.current_flats = fitsimage(flat, header)
     self.pairstrings = ['{0} - {1}'.format(*map(os.path.basename,x)) for x in self.extract_pairs]
 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
     pair_index = self.pairstrings.index(val)
     fitsfile = self.paths['out']+re.sub(' ','',re.sub('.fits','',val))+'.fits'
     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)
     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])