Beispiel #1
0
    def find_objects_pypeline(self, image, ivar, std=False, std_trace = None, maskslits=None,
                              show=False, show_peaks=False, show_fits=False, show_trace = False, debug=False,
                              manual_extract_dict=None):

        # create the ouptut image for skymask
        skymask = np.zeros_like(image, dtype=bool)

        plate_scale = self.spectrograph.order_platescale(binning=self.binning)
        inmask = self.mask == 0
        # Find objects
        specobj_dict = {'setup': self.setup, 'slitid': 999, 'orderindx': 999,
                        'det': self.det, 'objtype': self.objtype, 'pypeline': self.pypeline}
        # ToDO implement parsets here!
        sig_thresh = 30.0 if std else self.redux_par['sig_thresh']
        sobjs_ech, skymask[self.slitmask > -1] = \
            extract.ech_objfind(image, ivar, self.slitmask, self.tslits_dict['slit_left'], self.tslits_dict['slit_righ'],
                                inmask=inmask, ncoeff=self.redux_par['trace_npoly'],
                                hand_extract_dict=manual_extract_dict,
                                plate_scale=plate_scale, std_trace=std_trace,
                                specobj_dict=specobj_dict,sig_thresh=sig_thresh,
                                show_peaks=show_peaks, show_fits=show_fits,
                                show_trace=show_trace, debug=debug)



        # Steps
        self.steps.append(inspect.stack()[0][3])
        if show:
            self.show('image', image=image*(self.mask == 0), chname = 'ech_objfind',sobjs=sobjs_ech, slits=False)

        return sobjs_ech, len(sobjs_ech), skymask
Beispiel #2
0
    def find_objects_pypeline(self,
                              image,
                              std_trace=None,
                              show=False,
                              show_peaks=False,
                              show_fits=False,
                              show_trace=False,
                              debug=False,
                              manual_extract_dict=None):
        """
         Pipeline specific find objects routine

         Args:
             image (np.ndarray):
             std_trace (np.ndarray, optional):
             manual_extract_dict (dict, optional):
             show_peaks (bool, optional):
               Generate QA showing peaks identified by object finding
             show_fits (bool, optional):
               Generate QA  showing fits to traces
             show_trace (bool, optional):
               Generate QA  showing traces identified. Requires an open ginga RC modules window
             show (bool, optional):
             debug (bool, optional):

         Returns:
             tuple:
                 specobjs : Specobjs object
                     Container holding Specobj objects
                 nobj (int):
                     Number of objects identified
                 skymask : ndarray
                     Boolean image indicating which pixels are useful for global sky subtraction

        """
        # create the ouptut image for skymask
        skymask = np.zeros_like(image, dtype=bool)

        plate_scale = self.spectrograph.order_platescale(self.order_vec,
                                                         binning=self.binning)
        inmask = self.sciImg.fullmask == 0
        # Find objects
        specobj_dict = {
            'SLITID': 999,  #'orderindx': 999,
            'DET': self.det,
            'OBJTYPE': self.objtype,
            'PYPELINE': self.pypeline
        }

        sobjs_ech, skymask[self.slitmask > -1] = extract.ech_objfind(
            image,
            self.sciImg.ivar,
            self.slitmask,
            self.slits_left,
            self.slits_right,
            self.order_vec,
            self.reduce_bpm,
            spec_min_max=np.vstack((self.slits.specmin, self.slits.specmax)),
            inmask=inmask,
            ir_redux=self.ir_redux,
            ncoeff=self.par['reduce']['findobj']['trace_npoly'],
            hand_extract_dict=manual_extract_dict,
            plate_scale=plate_scale,
            std_trace=std_trace,
            specobj_dict=specobj_dict,
            sig_thresh=self.par['reduce']['findobj']['sig_thresh'],
            show_peaks=show_peaks,
            show_fits=show_fits,
            trim_edg=self.par['reduce']['findobj']['find_trim_edge'],
            cont_fit=self.par['reduce']['findobj']['find_cont_fit'],
            npoly_cont=self.par['reduce']['findobj']['find_npoly_cont'],
            fwhm=self.par['reduce']['findobj']['find_fwhm'],
            maxdev=self.par['reduce']['findobj']['find_maxdev'],
            max_snr=self.par['reduce']['findobj']['ech_find_max_snr'],
            min_snr=self.par['reduce']['findobj']['ech_find_min_snr'],
            nabove_min_snr=self.par['reduce']['findobj']
            ['ech_find_nabove_min_snr'],
            show_trace=show_trace,
            debug=debug)

        # Steps
        self.steps.append(inspect.stack()[0][3])
        if show:
            self.show('image',
                      image=image * (self.sciImg.fullmask == 0),
                      chname='ech_objfind',
                      sobjs=sobjs_ech,
                      slits=False)

        return sobjs_ech, len(sobjs_ech), skymask
#usepca = np.zeros(slit_mid.shape[1],dtype=bool)
#usepca[0:8] = True
#pca_out = pca_trace(slit_mid, npca = 4, npoly_cen = 3)
#sys.exit(-1)
#viewer, ch = ginga.show_image(ordermask > 0)
#ginga.show_slits(viewer,ch, slit_mid, pca_out)

# create the ouptut images skymask and objmask
#skymask = np.zeros_like(objminsky, dtype=bool)
#objmask = np.zeros_like(objminsky, dtype=bool)
image = objminsky.copy()
inmask = mask.copy()
#Routine starts here.
#------
ncoeff = 5
box_radius = 2.0  # arcseconds
min_snr = 0.2
nabove_min_snr = 2
npca = None
pca_explained_var = 99.8
sig_thresh = 3.0
box_radius = 2.0
ncoeff = 5
trim_edg = (5,5)


sobjs_final = extract.ech_objfind(image, ivar, ordermask, slit_left, slit_righ,inmask=inmask,plate_scale=plate_scale,
                                  std_trace =  std_trace, pca_explained_var=pca_explained_var, min_snr=min_snr,
                                  nabove_min_snr=nabove_min_snr,box_radius=box_radius,sig_thresh=sig_thresh,
                                  show_peaks=False,show_fits=False,show_trace=True,debug=True)
Beispiel #4
0
#Routine starts here.
#------
ncoeff = 5
box_radius = 2.0  # arcseconds
min_snr = 0.2
nabove_min_snr = 2
npca = None
pca_explained_var = 99.8
sig_thresh = 3.0
box_radius = 2.0
ncoeff = 5
trim_edg = (5, 5)

sobjs_final = extract.ech_objfind(image,
                                  ivar,
                                  ordermask,
                                  slit_left,
                                  slit_righ,
                                  inmask=inmask,
                                  plate_scale=plate_scale,
                                  std_trace=std_trace,
                                  pca_explained_var=pca_explained_var,
                                  min_snr=min_snr,
                                  nabove_min_snr=nabove_min_snr,
                                  box_radius=box_radius,
                                  sig_thresh=sig_thresh,
                                  show_peaks=False,
                                  show_fits=False,
                                  show_trace=True,
                                  debug=True)
Beispiel #5
0
    def find_objects_pypeline(self,
                              image,
                              std_trace=None,
                              show=False,
                              show_peaks=False,
                              show_fits=False,
                              show_trace=False,
                              debug=False,
                              manual_extract_dict=None):
        """
         Pipeline specific find objects routine

         Args:
             image (np.ndarray):
             std_trace (np.ndarray, optional):
             manual_extract_dict (dict, optional):
             show_peaks (bool, optional):
               Generate QA showing peaks identified by object finding
             show_fits (bool, optional):
               Generate QA  showing fits to traces
             show_trace (bool, optional):
               Generate QA  showing traces identified. Requires an open ginga RC modules window
             show (bool, optional):
             debug (bool, optional):

         Returns:
             tuple:
                 specobjs : Specobjs object
                     Container holding Specobj objects
                 nobj (int):
                     Number of objects identified
                 skymask : ndarray
                     Boolean image indicating which pixels are useful for global sky subtraction

        """
        # create the ouptut image for skymask
        skymask = np.zeros_like(image, dtype=bool)

        # TODO: Figure out where to do this properly
        spec_min = np.zeros(self.tslits_dict['nslits'], dtype=int) \
                        if self.tslits_dict['spec_min'] is None else self.tslits_dict['spec_min']
        spec_max = np.full(self.tslits_dict['nslits'], self.tslits_dict['nspec']-1, dtype=int) \
                        if self.tslits_dict['spec_max'] is None else self.tslits_dict['spec_max']

        plate_scale = self.spectrograph.order_platescale(self.order_vec,
                                                         binning=self.binning)
        inmask = self.sciImg.mask == 0
        # Find objects
        specobj_dict = {
            'setup': self.setup,
            'slitid': 999,  #'orderindx': 999,
            'det': self.det,
            'objtype': self.objtype,
            'pypeline': self.pypeline
        }
        # TODO This is a bad idea -- we want to find everything for standards
        #sig_thresh = 30.0 if std else self.redux_par['sig_thresh']
        sobjs_ech, skymask[self.slitmask > -1] = extract.ech_objfind(
            image,
            self.sciImg.ivar,
            self.slitmask,
            self.tslits_dict['slit_left'],
            self.tslits_dict['slit_righ'],
            self.order_vec,
            self.maskslits,
            spec_min_max=np.vstack((spec_min, spec_max)),
            inmask=inmask,
            ir_redux=self.ir_redux,
            ncoeff=self.par['reduce']['findobj']['trace_npoly'],
            hand_extract_dict=manual_extract_dict,
            plate_scale=plate_scale,
            std_trace=std_trace,
            specobj_dict=specobj_dict,
            sig_thresh=self.par['reduce']['findobj']['sig_thresh'],
            show_peaks=show_peaks,
            show_fits=show_fits,
            trim_edg=self.par['reduce']['findobj']['find_trim_edge'],
            cont_fit=self.par['reduce']['findobj']['find_cont_fit'],
            npoly_cont=self.par['reduce']['findobj']['find_npoly_cont'],
            fwhm=self.par['reduce']['findobj']['find_fwhm'],
            maxdev=self.par['reduce']['findobj']['find_maxdev'],
            max_snr=self.par['reduce']['findobj']['ech_find_max_snr'],
            min_snr=self.par['reduce']['findobj']['ech_find_min_snr'],
            nabove_min_snr=self.par['reduce']['findobj']
            ['ech_find_nabove_min_snr'],
            show_trace=show_trace,
            debug=debug)

        # Steps
        self.steps.append(inspect.stack()[0][3])
        if show:
            self.show('image',
                      image=image * (self.sciImg.mask == 0),
                      chname='ech_objfind',
                      sobjs=sobjs_ech,
                      slits=False)

        return sobjs_ech, len(sobjs_ech), skymask