bwheelz36 / particlephasespace Goto Github PK
View Code? Open in Web Editor NEWImport, analysis, and export of particle phase space data
Home Page: https://bwheelz36.github.io/ParticlePhaseSpace/
License: GNU General Public License v3.0
Import, analysis, and export of particle phase space data
Home Page: https://bwheelz36.github.io/ParticlePhaseSpace/
License: GNU General Public License v3.0
Community guidelines
There should be clear guidelines for third-parties wishing to:
Contribute to the software
Report issues or problems with the software
Seek support
Can already be done by simply manipuldating the pandas dataframe inside PhaseSpace, but could make this more streamlined/automated...
Develop a common library for dealing with phase space data which can import/export from multiple codes in an extensible manner.
I'm thinking of using pandas with the below columns.
one potential limitation is that pandas is not good at handling data larger than available memory...
x
y
z
px
py
pz
t
particle_type (use geant)
weight
anything else?
as per leo's code in https://github.com/lesnat/p2sat
as also noted here when an individual column of a data frame is called the setter method is never activated.
This is very annoying. It would appear the options are:
At read in
set_units
A lot of the plotting functions assume we have a phase space scored on a plane moving primarily in the z direction.
there is no reason to suppose this is always the case.
so what can we do about this....
compare the below two cases.
it seems like the bounds are not being properly used to form the image?
PS.plot_transverse_trace_space_intensity(xlim=[-1,1], ylim=[-.004, .004], plot_twiss_ellipse=False)
PS.plot_transverse_trace_space_intensity()
in cases where pz <<< P, it seems that due to machine precision error pz can end up being NaN.
To fix this, we can detect such cases and set pz = 0 with a warning.
class CSV_Exporter(_DataExportersBase):
'''
Export data to a csv format, in particular one which can be read by p2sat read text
# weight x (um) y (um) z (um) px (MeV/c) py (MeV/c) pz (MeV/c) t (fs)
'''
def _define_required_columns(self):
self._required_columns = ['x', 'y', 'z', 'px', 'py', 'pz', 'time', 'weight']
def _export_data(self):
data_string = ['weight', 'x [um]', 'y [um]', 'z [um]', 'px [MeV/c]', 'py [MeV/c]', 'pz [MeV/c]', 'time [fs]']
self._PS.ps_data[data_string].to_csv(self._output_location / self._output_name, index=False, header=False)
def _set_expected_units(self):
self._expected_units = ParticlePhaseSpaceUnits()('p2_sat_UHI')
now, I think that my basic moment to energy formalism is correct.
I also know it worked for the previous SLAC data.
so this implies that actually the momentum calculations are incorrect?
Generate N new particles based on the existing phase space.
This will happen in two parts:
when a user manually changes the public attribute, to the private aspects get updated?
this was only intended as an example not something that should be in the main code base
operations you make - following any edits to the underling data, you should manually reset_phase_space, because you have quite likely invalidated any previously calculated quantities. reset_phase_space <https://bwheelz36.github.io/ParticlePhaseSpace/code_docs.html#ParticlePhaseSpace._ParticlePhaseSpace.PhaseSpace.reset_phase_space>
__
would not be uncommon to want to work with radial position...
class Load_p2sat_txt(_DataLoadersBase):
"""
Adapted from the `p2sat <https://github.com/lesnat/p2sat/blob/master/p2sat/datasets/_LoadPhaseSpace.py>`_
'txt' loader.
- Note: One difference is that this implementation has a hard coded seperation value ","
"""
def _check_input_data(self):
if not Path(self._input_data).is_file():
raise FileNotFoundError(f'input data file {self._import_data()} does not exist')
if not self._particle_type:
raise Exception('particle_type must be specified when readin p2sat_txt data')
def _import_data(self):
# Initialize data lists
w = []
x, y, z = [], [], []
px, py, pz = [], [], []
t = []
# Open file
with open(self._input_data, 'r') as f:
# Loop over lines
for line in f.readlines():
# If current line is not a comment, save data
if line[0] != "#":
data = line.split(",")
w.append(float(data[0]))
x.append(float(data[1]))
y.append(float(data[2]))
z.append(float(data[3]))
px.append(float(data[4]))
py.append(float(data[5]))
pz.append(float(data[6]))
t.append(float(data[7]))
self.data[self._columns['x']] = x
self.data[self._columns['y']] = y
self.data[self._columns['z']] = z
self.data[self._columns['time']] = t
self.data[self._columns['weight']] = w
self.data[self._columns['particle id']] = np.arange(self.data.shape[0])
self.data[self._columns['particle type']] = particle_cfg.particle_properties[self._particle_type]['pdg_code']
self.data[self._columns['px']] = px
self.data[self._columns['py']] = py
self.data[self._columns['pz']] = pz
it is the opposite to the topas definition ,as described here
at the moment it operates in place.
it should probably at least have the option to return a new object instead.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.