Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make a script analysing pulse energy distribution #14

Open
samoylv opened this issue Oct 24, 2014 · 3 comments
Open

make a script analysing pulse energy distribution #14

samoylv opened this issue Oct 24, 2014 · 3 comments

Comments

@samoylv
Copy link
Owner

samoylv commented Oct 24, 2014

the script read every FELsource_out.h5 file in a folder and fill a vector with values of calculated total pulse energy

total_pulse_energy = <put formula here>

output: a text file with header and values (in J) and a histogram for pulses energy distribution

Questions:

  1. what is most effective way to read wave field data, get intensity,
  2. shouldn't we include the script in WPG library?
@samoylv
Copy link
Owner Author

samoylv commented Nov 6, 2014

could you help me with proper piece of code for h5-file access, i.e.

  • read data/arrEhor in a loop for every file in the dir, for every file
  • calculate wf_intensity[idx] = wf.get_intensity(polarization='horizontal')
  • plot histogram of wf_intensity[idx]

@buzmakov
Copy link
Collaborator

buzmakov commented Nov 7, 2014

import os
import sys
import glob
import pylab as plt
sys.path.insert(0,os.path.join('..','WPG'))

from wpg import Wavefront

#get list of all files by mask (without recursive directory discovering)
wavefront_files = glob.glob('simulation_test/FELsource/*.h5') 
print wavefront_files

for wavefront_file in wavefront_files:
    print wavefront_file
    w = Wavefront()
    w.load_hdf5(wavefront_file)

    #load data/arrEhor
    data_hor = w.data.arrEhor
    print data_hor.shape

    intensity = w.get_intensity().flat
    #filter intensity to remove near zero values
    intensity = intensity[intensity>1e10]

    plt.hist(intensity, bins=100)

@samoylv
Copy link
Owner Author

samoylv commented Nov 8, 2014

thanks!

On Fri, Nov 7, 2014 at 9:36 AM, Alexey Buzmakov [email protected]
wrote:

import osimport sysimport globimport pylab as plt
sys.path.insert(0,os.path.join('..','WPG'))
from wpg import Wavefront
#get list of all files by mask (without recursive directory discovering)
wavefront_files = glob.glob('simulation_test/FELsource/*.h5') print wavefront_files
for wavefront_file in wavefront_files:
print wavefront_file
w = Wavefront()
w.load_hdf5(wavefront_file)

#load data/arrEhor
data_hor = w.data.arrEhor
print data_hor.shape

intensity = w.get_intensity().flat
#filter intensity to remove near zero values
intensity = intensity[intensity>1e10]

plt.hist(intensity, bins=100)

Reply to this email directly or view it on GitHub
#14 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants