Exemplo n.º 1
0
Arquivo: roi.py Projeto: FHe/tdl
def med_copy_rois(med, source_mca=0):
    """
    This procedure copies the ROIs defined for one Mca in the Med to all of
    the other Mcas.

    Parameters:
    -----------
    * source_mca: The index number of the Mca from which the ROIs are to
      be copied.  This number ranges from 0 to self.n_detectors-1.
      The default is the first Mca (index=0).

    Notes:
    ------
    The ROIs are copied by their position
    in energy rather than in channels. This is very useful when 
    copying ROIs when the calibration parameters for each Mca in 
    the Med are not identical.
    """
    if energy == True:
        units = "keV"
    else:
        units = "channel"
    
    rois  = med.mca[source_mca].rois
    off   = med.mca[source_mca].offset
    slope = med.mca[source_mca].slope
    quad  = med.mca[source_mca].quad
    clip  = len(med.mca[source_mca].data)

    left  = []
    right = []
    label = []
    bgr_width = []
    for roi in rois:
        left.append(calib.channel_to_energy(roi.left, offset=off,slope=slope,quad=quad,clip=clip))
        right.append(calib.channel_to_energy(roi.right, offset=off,slope=slope,quad=quad,clip=clip)) 
        label.append(roi.label)
        bgr_width.append(roi.bgr)

    for j in range(med.n_detectors):
        off   = med.mca[j].offset
        slope = med.mca[j].slope
        quad  = med.mca[j].quad
        clip  = len(med.mca[j].data)
        med.mca[j].rois = []
        for k in range(len(left)):
            l = calib.energy_to_channel(left[k],offset=off,slope=slope,quad=quad,clip=clip)
            r = calib.energy_to_channel(right[k],offset=off,slope=slope,quad=quad,clip=clip)
            roi = ROI(left=int(l),right=int(r), label=label[k], bgr_width=bgr_width[k])
Exemplo n.º 2
0
Arquivo: xrf_peaks.py Projeto: FHe/tdl
 def get_energy(self):
     """
     Returns the energy array
     """
     #calc energy with updated params
     en = calib.channel_to_energy(self.channels, offset=self.energy_offset,
                                  slope=self.energy_slope)
     return en
Exemplo n.º 3
0
Arquivo: mca.py Projeto: ttrainor/_tdl
 def get_energy(self):
     """
     Returns a list containing the energy of each channel in the MCA spectrum.
     """
     energy = calib.channel_to_energy(self.channels,
                                      offset=self.offset,
                                      slope=self.slope,
                                      quad=self.quad)
     return energy
Exemplo n.º 4
0
 def get_energy(self):
     """
     Returns the energy array
     """
     #calc energy with updated params
     en = calib.channel_to_energy(self.channels,
                                  offset=self.energy_offset,
                                  slope=self.energy_slope)
     return en
Exemplo n.º 5
0
Arquivo: roi.py Projeto: ttrainor/_tdl
def med_copy_rois(med, source_mca=0):
    """
    This procedure copies the ROIs defined for one Mca in the Med to all of
    the other Mcas.

    Parameters:
    -----------
    * source_mca: The index number of the Mca from which the ROIs are to
      be copied.  This number ranges from 0 to self.n_detectors-1.
      The default is the first Mca (index=0).

    Notes:
    ------
    The ROIs are copied by their position
    in energy rather than in channels. This is very useful when 
    copying ROIs when the calibration parameters for each Mca in 
    the Med are not identical.
    """
    if energy == True:
        units = "keV"
    else:
        units = "channel"

    rois = med.mca[source_mca].rois
    off = med.mca[source_mca].offset
    slope = med.mca[source_mca].slope
    quad = med.mca[source_mca].quad
    clip = len(med.mca[source_mca].data)

    left = []
    right = []
    label = []
    bgr_width = []
    for roi in rois:
        left.append(
            calib.channel_to_energy(roi.left,
                                    offset=off,
                                    slope=slope,
                                    quad=quad,
                                    clip=clip))
        right.append(
            calib.channel_to_energy(roi.right,
                                    offset=off,
                                    slope=slope,
                                    quad=quad,
                                    clip=clip))
        label.append(roi.label)
        bgr_width.append(roi.bgr)

    for j in range(med.n_detectors):
        off = med.mca[j].offset
        slope = med.mca[j].slope
        quad = med.mca[j].quad
        clip = len(med.mca[j].data)
        med.mca[j].rois = []
        for k in range(len(left)):
            l = calib.energy_to_channel(left[k],
                                        offset=off,
                                        slope=slope,
                                        quad=quad,
                                        clip=clip)
            r = calib.energy_to_channel(right[k],
                                        offset=off,
                                        slope=slope,
                                        quad=quad,
                                        clip=clip)
            roi = ROI(left=int(l),
                      right=int(r),
                      label=label[k],
                      bgr_width=bgr_width[k])