def show_trace(specobjs, det, viewer, ch): if specobjs is None: return in_det = np.where(specobjs.DET == det)[0] for kk in in_det: trace = specobjs[kk]['TRACE_SPAT'] obj_id = specobjs[kk].NAME display.show_trace(viewer, ch, trace, obj_id, color='orange') #hdu.name)
def show_trace(specobjs, det, viewer, ch): if specobjs is None: return in_det = np.where(specobjs.DET == det)[0] for kk in in_det: trace = specobjs[kk]['TRACE_SPAT'] obj_id = specobjs[kk].NAME maskdef_objname = specobjs[kk].MASKDEF_OBJNAME if maskdef_objname is not None: trc_name = '{} OBJNAME:{}'.format(obj_id, maskdef_objname) else: trc_name = obj_id display.show_trace(viewer, ch, trace, trc_name, color='orange') #hdu.name)
def show_alignment(alignframe, align_traces=None, slits=None, clear=False): """ Show one of the class internals Parameters ---------- alignframe : `numpy.ndarray`_ Image to be plotted (i.e. the master align frame) align_traces : list, optional The align traces slits : :class:`pypeit.slittrace.SlitTraceSet`, optional properties of the slits, including traces. clear : bool, optional Clear the plotting window in ginga? Returns ------- """ display.connect_to_ginga(raise_err=True, allow_new=True) ch_name = 'alignment' viewer, channel = display.show_image(alignframe, chname=ch_name, clear=clear, wcs_match=False) # Display the slit edges if slits is not None and viewer is not None: left, right, mask = slits.select_edges() display.show_slits(viewer, channel, left, right) # Display the alignment traces if align_traces is not None and viewer is not None: for bar in range(align_traces.shape[1]): for slt in range(align_traces.shape[2]): # Alternate the colors of the slits color = 'orange' if slt % 2 == 0: color = 'magenta' # Display the trace display.show_trace(viewer, channel, align_traces[:, bar, slt], trc_name="", color=color)
def show_trace(specobjs, det, viewer, ch): """ Overplot the extracted object traces for this detector in the provided ginga channel. Args: specobjs (:class:`~pypeit.specobjs.SpecObjs`): Object holding the 1D spectral extractions. If None, the function doesn't do anything. det (:obj:`str`): The string identifier for the detector or mosaic used to select the extractions to show. viewer (?): ch (?): """ if specobjs is None: return in_det = np.where(specobjs.DET == det)[0] for kk in in_det: trace = specobjs[kk]['TRACE_SPAT'] obj_id = specobjs[kk].NAME maskdef_objname = specobjs[kk].MASKDEF_OBJNAME maskdef_extr_flag = specobjs[kk].MASKDEF_EXTRACT manual_extr_flag = specobjs[kk].hand_extract_flag if maskdef_objname is not None: trc_name = '{} OBJNAME:{}'.format(obj_id, maskdef_objname) else: trc_name = obj_id if maskdef_extr_flag is not None and maskdef_extr_flag is True: display.show_trace(viewer, ch, trace, trc_name, color='#f0e442') #hdu.name) elif manual_extr_flag is True: display.show_trace(viewer, ch, trace, trc_name, color='#33ccff') #hdu.name) else: display.show_trace(viewer, ch, trace, trc_name, color='orange') #hdu.name)
def show(self, attr, image=None, showmask=False, sobjs=None, chname=None, slits=False,clear=False): """ Show one of the internal images .. todo:: Should probably put some of these in ProcessImages Parameters ---------- attr : str global -- Sky model (global) sci -- Processed science image rawvar -- Raw variance image modelvar -- Model variance image crmasked -- Science image with CRs set to 0 skysub -- Science image with global sky subtracted image -- Input image display : str, optional image : ndarray, optional User supplied image to display """ if showmask: mask_in = self.sciImg.fullmask bitmask_in = self.sciImg.bitmask else: mask_in = None bitmask_in = None img_gpm = self.sciImg.select_flag(invert=True) detname = self.spectrograph.get_det_name(self.det) # TODO Do we still need this here? if attr == 'global' and all([a is not None for a in [self.sciImg.image, self.global_sky, self.sciImg.fullmask]]): # global sky subtraction # sky subtracted image image = (self.sciImg.image - self.global_sky) * img_gpm.astype(float) mean, med, sigma = stats.sigma_clipped_stats(image[img_gpm], sigma_lower=5.0, sigma_upper=5.0) cut_min = mean - 1.0 * sigma cut_max = mean + 4.0 * sigma ch_name = chname if chname is not None else f'global_sky_{detname}' viewer, ch = display.show_image(image, chname=ch_name, bitmask=bitmask_in, mask=mask_in, clear=clear, wcs_match=True) #, cuts=(cut_min, cut_max)) elif attr == 'local' and all([a is not None for a in [self.sciImg.image, self.skymodel, self.sciImg.fullmask]]): # local sky subtraction # sky subtracted image image = (self.sciImg.image - self.skymodel) * img_gpm.astype(float) mean, med, sigma = stats.sigma_clipped_stats(image[img_gpm], sigma_lower=5.0, sigma_upper=5.0) cut_min = mean - 1.0 * sigma cut_max = mean + 4.0 * sigma ch_name = chname if chname is not None else f'local_sky_{detname}' viewer, ch = display.show_image(image, chname=ch_name, bitmask=bitmask_in, mask=mask_in, clear=clear, wcs_match=True) #, cuts=(cut_min, cut_max)) elif attr == 'sky_resid' and all([a is not None for a in [self.sciImg.image, self.skymodel, self.objmodel, self.ivarmodel, self.sciImg.fullmask]]): # sky residual map with object included image = (self.sciImg.image - self.skymodel) * np.sqrt(self.ivarmodel) image *= img_gpm.astype(float) ch_name = chname if chname is not None else f'sky_resid_{detname}' viewer, ch = display.show_image(image, chname=ch_name, cuts=(-5.0, 5.0), bitmask=bitmask_in, mask=mask_in, clear=clear, wcs_match=True) elif attr == 'resid' and all([a is not None for a in [self.sciImg.image, self.skymodel, self.objmodel, self.ivarmodel, self.sciImg.fullmask]]): # full residual map with object model subtractede # full model residual map image = (self.sciImg.image - self.skymodel - self.objmodel) * np.sqrt(self.ivarmodel) image *= img_gpm.astype(float) ch_name = chname if chname is not None else f'resid_{detname}' viewer, ch = display.show_image(image, chname=ch_name, cuts=(-5.0, 5.0), bitmask=bitmask_in, mask=mask_in, clear=clear, wcs_match=True) elif attr == 'image': ch_name = chname if chname is not None else 'image' viewer, ch = display.show_image(image, chname=ch_name, clear=clear, wcs_match=True) else: msgs.warn("Not an option for show") if sobjs is not None: for spec in sobjs: color = 'magenta' if spec.hand_extract_flag else 'orange' display.show_trace(viewer, ch, spec.TRACE_SPAT, spec.NAME, color=color) if slits and self.slits_left is not None: display.show_slits(viewer, ch, self.slits_left, self.slits_right)