Giter Club home page Giter Club logo

particlephasespace's People

Contributors

ax3l avatar bwheelz36 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

particlephasespace's Issues

paper: community guidelines

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

specification

Goal

Develop a common library for dealing with phase space data which can import/export from multiple codes in an extensible manner.

phase space format

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?

functionality

  • different export options (cst, comsol, etc.)
  • filter by particles to generate electron only, proton only etc. phase spaces
  • project particles forward/back
  • basic analytics

pandas data setter doesnt work on individual columns

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:

  • create a new instance of Dataframe with the set_item method overwritten
  • document the acceptable ways to interact with PhaseSpace.

integrate units

At read in

  • update all data loaders
  • update docs for writing new data loaders

set_units

  • tbd

what direction is the beam moving in

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....

  • where possible don't make this assumption.
  • the only place it's painful is in the 'project particles' code. Even there, I think it is possible to generalise...

possible issue with `plot_transverse_trace_space_intensity`

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()

add csv exporter

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')

cannot achieve consistent read in of energy

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?

to do

  • set up doc build
  • write tests
  • set up auto testing
  • protect main branch

Expand phase space

Generate N new particles based on the existing phase space.

This will happen in two parts:

  1. Fit some function to the [x,y,z] points (maybe RBF)
  2. generate N points based on this function
  3. Fit another function to momentum as a function of spatial coordinate
  4. Interpolate the momentum at each generated location

fix this

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>__

add new data loader

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.