GithubHelp home page GithubHelp logo

gabyrod7 / amppy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from denehoffman/amppy-dep

0.0 1.0 0.0 3.55 MB

A Python wrapper for AmpTools

License: GNU General Public License v3.0

Python 97.45% Shell 0.03% Cython 2.35% C 0.16%

amppy's Introduction

AmpPy - A Python Wrapper for AmpTools

Requirements

Install

Download a wheel binary for Linux at the releases page

$ pip3 install amppy-0.0.2-cp36-cp36m-linux_x86_64.whl

While you can install AmpPy into your local python path (or use the --user tag if you don't have root permission), the recommended installation is into an isolated virtual environment to avoid dependency conflicts between other programs:

$ python3 -m venv my-amppy-venv # or whatever name you want to give it
$ source my-amppy-venv/bin/activate.csh # activation scripts for bash and fish are also located here
[my-amppy-venv] $ pip install amppy-0.0.2-cp36-cp36m-linux_x86_64.whl
[my-amppy-venv] $ source my-amppy-venv/bin/activate.csh # on the first installation, this needs to be sourced again to include the proper paths for AmpPy's scripts
[my-amppy-venv] $ ... # do your analysis
[my-amppy-venv] $ deactivate
$ ... # now that we're back out of the virtual environment, you won't have access to AmpPy commands or libraries

Usage

$ amppy
usage: amppy <command> [<args>]

Possible commands include:
    generate    Generate an AmpTools configuration file
    divide      Divide data into bins in a new fit directory
    add         Add a configuration file to an existing fit directory
    fit         Run fits using AmpTools
    bootstrap   Bootstrap existing fits using AmpTools
    plot        Plot results

See 'amppy <command> --help' to read about a specific subcommand

Typical workflow:

$ amppy generate # create a new config file, call it "etapi_D_waves.cfg" for example
$ amppy divide -o PWA_DIR --low 1.0 --high 1.8 -n 20 -d <path to data> -g <path to thrown MC> -a <path to accepted MC> ~/etapi_D_waves.cfg
$ amppy generate # maybe we want to create a config with some different waves to compare, like "etapi_S+D_waves.cfg"
$ amppy add -o PWA_DIR ~/etapi_S+D_waves.cfg
$ amppy fit Pool PWA_DIR --iterations 20 --processes 15 # amppy will give you a menu to select the config file you want to fit with
$ amppy fit Pool PWA_DIR --iterations 20 --processes 15 # so we can fit both by running it twice and selecting different configs
$ amppy bootstrap Pool PWA_DIR --iterations 20 --processes 15 # changing the command from "fit" to "bootstrap" causes amppy
$ amppy bootstrap Pool PWA_DIR --iterations 20 --processes 15 # to select the best fit, create bootstrapped config files, and run an new fit
$ amppy plot PWA -o "D_waves_only.pdf"
$ amppy plot PWA -o "S_and_D_waves.pdf"

Most of the amppy commands contain menus or command line interfaces which give the commands more functionality than is shown here. For example, the plot command allows the user to select from a number of plot types which include intensity plots and statistical plots to tell the user how well the fits converged.

From a Python script:

# example.py
from amppy.dividers import Divider_split_mass
from amppy.backends.PythonMultiprocessing import PythonMultiprocessing
from amppy.plotting.Plotter_Intensity import Plotter_Intensity
import matplotlib.backends.backend_pdf as backend_pdf

div = Divider_split_mass()
div.divide(low=1.0, high=1.8 # mass range in GeV
           nbins=20, # 20 bins
           root="~/my_pwa", # output directory
           config="~/etapi_D_waves.cfg", # AmpTools config
           data="~/data/", gen="~/thrownMC/", acc="~/acceptedMC/", bkg=None) # locations of ROOT flat trees for AmpTools
disp = PythonMultiprocessing()
disp.setup(root="~/my_pwa", config="~/etapi_D_waves.cfg",
           iterations=100, # run 100 iterations for each bin (2000 fits total)
           seed=1927428, # set a seed
           bootstrap=False, # can't bootstrap on the first fit
           verbosity=1) # verbosity (show standard loading bar)
disp.dispatch(processes=15)
plotter = Plotter_Intensity(config="~/etapi_D_waves.cfg",
                            pdf=None) # optionally, you can supply a path
plotter.plot({"acceptance_corrected": True,
              "xlabel_invmass": f"m($\eta\pi_0$) GeV/$c^2$"})
print(f"Output saved to {str(plotter.pdf_path)}")
$ python3 example.py
...
Output saved to ~/my_pwa/eta_pi_D_waves_plots.pdf

TODO

  • Add the following plotting methods:
    • a display of the complex amplitudes in a 2D scatter plot for each wave in each bin
    • add confidence intervals for bootstrapping
    • plot angular distributions for each bin and the fit projections onto the accepted MC
  • Create a divider for split_t
  • Write a generator for SDME config files
  • Write a plotting method for SDMEs
  • Write API documentation

amppy's People

Contributors

denehoffman avatar

Watchers

James Cloos avatar

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.