示例#1
0
    def __init__(self, folder_path, memory_limit = 1, header_lines_pcfslog = 5):

        tic = timing.time()
        # property
        self.cross_corr_interferogram = None
        self.auto_corr_sum_interferogram = None
        self.tau = None
        self.PCFS_interferogram = None
        self.blinking_corrected_PCFS_interferogram = None
        self.spectral_correlation = {}
        self.Fourier = {}
        self.memory_limit = memory_limit

        # extract files information
        self.path_str = folder_path
        self.PCFS_ID = os.path.split(folder_path)[1] # extract the folder name, i.e., 'DotA'
        os.chdir(folder_path)
        file_pos = glob.glob('*.pos')
        if len(file_pos) == 0:
            print('.pos file not found!')
        self.file_pos = file_pos[0] # with extension

        file_pcfslog = glob.glob('*.pcfslog')
        if len(file_pcfslog) == 0:
            print('.pcfslog file not found!')
        self.file_pcfslog = file_pcfslog[0] # with extension

        self.file_stream = [f.replace('.stream', '') for f in glob.glob('*.stream')] # without extension



        # read in the position file as array
        self.get_file_photons() # get all the photons files in the current directory
        self.stage_positions = np.loadtxt(self.file_pos)
        # read in the metadata of the .pcfslog file and store it as property
        with open(self.file_pcfslog) as f:
            lines_skip_header = f.readlines()[header_lines_pcfslog:]
        self.pcfslog = {}
        for lines in lines_skip_header:
            lines_split = lines.split('=')
            if len(lines_split) == 2:
                self.pcfslog[lines_split[0]] = float(lines_split[1])

        #create photons object for the photon stream at each interferometer path length difference.
        self.photons = {}
        for f in self.file_stream:
            self.photons[f] = ph.photons(f+'.stream', self.memory_limit)

        toc= timing.time()
        print('Total time elapsed to create PCFS class is %4f s' % (toc - tic))
示例#2
0
文件: oneton.py 项目: jiangsbu/oneton
    def __init__(self):

        self.debug = 0

        # initialize external classes. Note self.Photons initialized below
        self.traj = trajectory.trajectory()
        self.Range = Range.Range()
        self.cerenkov = cerenkov.cerenkov()
        self.ParticleProperties = ParticleProperties.ParticleProperties()

        # defaults for definition of detector
        self.detectorName = None
        self.pawDir = None
        self.Detector = None
        self.PMTradius = None
        self.dEdx = None
        self.ScintYield = None
        self.generationLog = None
                

        # for defining cosmic ray hodoscope external to vessel
        c = 1.
        self.HodoWidth = c
        self.Hodoscope = [-c/2., c/2, -c/2, c/2] # x1,y1 , x2,y2 = edges of hodoscope


        self.ior = 1.33  # index of refraction


        #self.wlRange = [300., 600. ] # range of wavelengths for cerenkov light relevant for bialkalai pmt (nm)
        self.wlRange = [250., 700. ] # wider range of wavelengths for cerenkov light relevant for bialkalai pmt (nm)

        self.hc = 2.*math.pi*197.326972 # eV*nm or MeV*fm
        self.Photons = photons.photons(wl1=self.wlRange[0], wl2=self.wlRange[1] )

        self.downward = [0., 0., -1.] # unit vector pointing down
        self.upward   = [0., 0.,  1.] # unit vector pointing up
        self.twopi = 2.*math.pi
        self.options = {'Cerenkov':0, 'Scint':1}

        self.me = self.ParticleProperties.getMass('electron')
        self.betaSpec = {}
        self.betaBins = 10000

        self.savedEvents = {}
        self.savedEventKeys = {}


        return
示例#3
0
'''
Example code for PCFS data analysis.
'''

import photons as ph

if __name__ == '__main__':
    file = 'ExampleT2.stream'
    example_photons = ph.photons(file)  # create photons class
    example_photons.get_photon_records()  # create .photons

    # all functions can be used...
示例#4
0
文件: water.py 项目: davidjaffe/water
    for l in csv.reader(csvfile):
        if len(headers)==0:
            headers = l
            for h in headers: data[h] = []
        else:
            for h,x in zip(headers,l):
                data[h].append(float(x))
                ymin = min(ymin,float(x))
                if h=='Wavelength':
                    wavelength.append(float(x))
                    

ymin = 1.001*ymin # no zeros
                    
gU = graphUtils.graphUtils()
ph = photons.photons()
pmp = ProcessMaterialProperty.ProcessMaterialProperty()

tmg = TMultiGraph()
tmg.SetName('tmg')
tmg.SetTitle('#splitline{Absorbance in 10cm cell}{Adjusted to be non-zero}')
amg = TMultiGraph()
amg.SetName('amg')
amg.SetTitle('Attenuation length (cm)')
bmg = TMultiGraph()
bmg.SetName('bmg')
bmg.SetTitle('#splitline{Effective effy for}{100cm path length}')
cmg = TMultiGraph()
cmg.SetName('cmg')
cmg.SetTitle('Attenuation in 100cm')
dmg = TMultiGraph()
示例#5
0
文件: ct_detect.py 项目: ds-k/east-ct
def ct_detect(p, coeffs, depth, mas=10000):
    """ct_detect returns detector photons for given material depths.
    y = ct_detect(p, coeffs, depth, mas) takes a source energy
    distribution photons (energies), a set of material linear attenuation
    coefficients coeffs (materials, energies), and a set of material depths
    in depth (materials, samples) and returns the detections at each sample
    in y (samples).

    mas defines the current-time-product which affects the noise distribution
    for the linear attenuation"""

    # check p for number of energies
    if type(p) != np.ndarray:
        p = np.array([p])
    if p.ndim > 1:
        raise ValueError('input p has more than one dimension')
    energies = len(p)

    # check coeffs is of (materials, energies)
    if type(coeffs) != np.ndarray:
        coeffs = np.array([coeffs]).reshape((1, 1))
    elif coeffs.ndim == 1:
        coeffs = coeffs.reshape((1, len(coeffs)))
    elif coeffs.ndim != 2:
        raise ValueError('input coeffs has more than two dimensions')
    if coeffs.shape[1] != energies:
        raise ValueError(
            'input coeffs has different number of energies to input p')
    materials = coeffs.shape[0]

    # check depth is of (materials, samples)
    if type(depth) != np.ndarray:
        depth = np.array([depth]).reshape((1, 1))
    elif depth.ndim == 1:
        if materials is 1:
            depth = depth.reshape(1, len(depth))
        else:
            depth = depth.reshape(len(depth), 1)
    elif depth.ndim != 2:
        raise ValueError('input depth has more than two dimensions')
    if depth.shape[0] != materials:
        raise ValueError(
            'input depth has different number of materials to input coeffs')
    samples = depth.shape[1]

    # extend source photon array so it covers all samples
    detector_photons = np.zeros([energies, samples])
    for e in range(energies):
        detector_photons[e] = p[e]

    # calculate array of residual mev x samples for each material in turn
    for m in range(materials):
        detector_photons = photons(detector_photons, coeffs[m], depth[m])

    # sum this over energies
    detector_photons = np.sum(detector_photons, axis=0)

    # model noise

    # minimum detection is one photon
    detector_photons = np.clip(detector_photons, 1, None)

    return detector_photons