Example #1
0
    def read_file(self, file, netcdf=0):
        """
      Reads a disk file into an Med object. The file contains the information
      from the Med object which it makes sense to store permanently, but does
      not contain all of the internal state information for the Med.

      Inputs:
         file:
            The name of the disk file to read.
      """
        if (netcdf != 0):
            r = Mca.read_netcdf_file(file)
        else:
            r = Mca.read_ascii_file(file)
        self.name = file
        self.n_detectors = r['n_detectors']
        self.mcas = []
        for i in range(self.n_detectors):
            self.mcas.append(Mca.Mca())
            self.mcas[i].set_rois(r['rois'][i])
            self.mcas[i].set_data(r['data'][i])
            self.mcas[i].set_name(self.name + ':' + str(i + 1))
        self.set_elapsed(r['elapsed'])
        self.set_calibration(r['calibration'])
        self.set_environment(r['environment'])
Example #2
0
    def __init__(self, n_detectors=16, file=None):
        """
      Initialization code for creating a new Med object.

      Keywords:
         n_detectors:
            The number of detectors (Mca objects) in the Med.

         file:
            The name of a disk file to read into the Med after it is created.
            The number of detectors in the Med will be changed if the number of
            Mca objects in the disk file is different from the Med.
      """
        Mca.Mca.__init__(self)  # Invoke base class initialization
        self.n_detectors = n_detectors
        self.mcas = []
        for i in range(n_detectors):
            self.mcas.append(Mca.Mca())
        if (file != None): self.read_file(file)