Esempio n. 1
0
def read_med(file):
    """
    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.

    Parameters:
    -----------
    * file: The name of the disk file to read.
    """
    r = read_ascii_file(file)

    if r == None: return None

    n_detectors = r['n_detectors']
    path, fname = os.path.split(file)
    med = Med(n_detectors=n_detectors, name=fname)

    med.mca = []
    for i in range(n_detectors):
        med.mca.append(Mca())
        med.mca[i].set_rois(r['rois'][i])
        med.mca[i].set_data(r['data'][i])
        med.mca[i].set_name(fname + ':' + str(i))
    med.set_elapsed(r['elapsed'])
    med.set_calibration(r['calibration'])
    med.set_environment(r['environment'])

    return med