From 59b46c4e595d122b295ee73409bfd89354c6ee6d Mon Sep 17 00:00:00 2001 From: lan13005 Date: Wed, 20 Mar 2024 15:20:09 -0400 Subject: [PATCH] Update documentation --- _modules/LoadParameters.html | 29 ++-- _modules/atiSetup.html | 8 +- _modules/fit.html | 2 - _modules/plotgen_utils.html | 7 +- _sources/intro.md | 25 +--- _sources/notebooks/libraryLoading.ipynb | 4 + api/atiSetup.html | 2 +- intro.html | 38 +---- notebooks/generation.html | 52 ++----- notebooks/libraryLoading.html | 70 +++++---- notebooks/mcmc.html | 170 +++++++++++++--------- notebooks/mle.html | 57 ++------ notebooks/plotgen.html | 72 ++++------ reports/notebooks/generation.err.log | 99 +++---------- reports/notebooks/libraryLoading.err.log | 74 ---------- reports/notebooks/mcmc.err.log | 175 ++++++++++++++--------- reports/notebooks/mle.err.log | 83 ----------- reports/notebooks/plotgen.err.log | 88 ------------ searchindex.js | 2 +- 19 files changed, 352 insertions(+), 705 deletions(-) delete mode 100644 reports/notebooks/libraryLoading.err.log delete mode 100644 reports/notebooks/mle.err.log delete mode 100644 reports/notebooks/plotgen.err.log diff --git a/_modules/LoadParameters.html b/_modules/LoadParameters.html index a8b0c88..f3c05b3 100644 --- a/_modules/LoadParameters.html +++ b/_modules/LoadParameters.html @@ -369,19 +369,16 @@

Source code for LoadParameters

         self.cfg     = cfg
 
         constraintMap = cfg.constraintMap()
-        constraintIndex = {}
+        constraint_index = {}
         uniqueProdPars   = []
-        allProdPars      = set()
         i = 0
         for k, vs in constraintMap:
-            allProdPars.add(k)
-            if k not in constraintIndex and not cfg.amplitude(k).fixed():
+            if k not in constraint_index and not cfg.amplitude(k).fixed():
+                constraint_index[k] = i
                 uniqueProdPars.append(k)
-                constraintIndex[k] = i #uniqueProdPars[i]
             for v in vs:
-                if v not in constraintIndex and not cfg.amplitude(v).fixed():
-                    # str(v) needed! appears that inserting v alone will go out of scope
-                    constraintIndex[str(v)] = i #uniqueProdPars[i] 
+                if v not in constraint_index and not cfg.amplitude(v).fixed():
+                    constraint_index[v] = i
             i += 1
 
         ######## GET VALUES / REALNESS OF UNIQUE AMPLITUDES' PRODUCTION PARAMETERS ########
@@ -399,10 +396,7 @@ 

Source code for LoadParameters

 
         ####### MERGE DICTIONARIES ########
         self.params       = self.uniqueProdPars   | self.ampPars # python 3.9 - merge dictionaries
-        self.paramsIsReal = self.uniqueProdIsReal | {k: True for k in self.ampPars.keys()} # all amp params are real
-
-        ####### ADDITIONAL TRACKING #######
-        self.allProdPars = list(allProdPars)
+ self.paramsIsReal = self.uniqueProdIsReal | {k: True for k in self.ampPars.keys()} # all amp params are real
[docs] def flatten_parameters(self, params={}): ''' @@ -419,7 +413,7 @@

Source code for LoadParameters

         '''
         parameters = []
         keys       = [] # lose information on flatten, use key to keep track of provenance
-        names      = [] # track parameters in a prettier format
+        names      = [] # track parameter names, appending re/im to name if complex
         if len(params)==0:
             params = self.params
         for k, v in params.items():
@@ -428,14 +422,7 @@ 

Source code for LoadParameters

             real_value = v.real      if k in self.uniqueProdPars else v
             names.append(f'Re[{pk}]' if k in self.uniqueProdPars else pk)
             parameters.append( real_value )
-
-            # Production coefficients will have :: in their name. Normal parameters will not
-            if '::' in k:
-                keys.append(k+"_re") # MUST match notation in AmpTools' parameterManager
-            else:
-                keys.append(k)
-
-            # If parameters are complex, we will include their imaginary components
+            keys.append(k+"_re") # MUST match notation in AmpTools' parameterManager
             if not self.paramsIsReal[k]:
                 parameters.append(v.imag)
                 keys.append(k+"_im")
diff --git a/_modules/atiSetup.html b/_modules/atiSetup.html
index a77ff3c..79338be 100644
--- a/_modules/atiSetup.html
+++ b/_modules/atiSetup.html
@@ -356,8 +356,8 @@ 

Source code for atiSetup

         use_fsroot (bool): True if FSRoot library should be loaded
         use_genamp (bool): True if GenAmp library should be loaded
     '''
-    USE_MPI, USE_GPU, RANK_MPI = loadLibraries( accelerator, use_fsroot, use_genamp )
-    set_aliases( calling_globals, USE_MPI, USE_GPU )
+    USE_MPI, USE_GPU, RANK_MPI = loadLibraries(accelerator, use_fsroot, use_genamp)
+    set_aliases(calling_globals, USE_MPI)
 
     return USE_MPI, USE_GPU, RANK_MPI
@@ -403,7 +403,7 @@

Source code for atiSetup

     else: status = "OFF"
     if RANK_MPI == 0: print(f'  {status}')
-
[docs]def set_aliases( called_globals, USE_MPI, USE_GPU ): +
[docs]def set_aliases(called_globals, USE_MPI): ''' Due to MPI requiring c++ templates and the fact that all classes live under the ROOT namespace, aliasing can clean up the code significantly. A dictionary of aliases is appended to the globals() function of the calling function thereby making the aliases available in the calling function. @@ -445,8 +445,6 @@

Source code for atiSetup

         'TFile':                      ROOT.TFile,
         'AmplitudeInfo':              ROOT.AmplitudeInfo,
     }
-    if USE_GPU:
-        aliases['GPUManager'] = ROOT.GPUManager
 
     called_globals.update(aliases)
diff --git a/_modules/fit.html b/_modules/fit.html index 391a890..d0b97e9 100644 --- a/_modules/fit.html +++ b/_modules/fit.html @@ -448,10 +448,8 @@

Source code for fit

             print("ALL FITS FAILED!")
         else:
             print(f'MINIMUM LIKELHOOD FROM ITERATION {minFitTag} of {N} RANDOM PRODUCTION PARS = {minNLL}')
-            print(f'cp {fitName}_{minFitTag}.fit {fitName}.fit')
             os.system(f'cp {fitName}_{minFitTag}.fit {fitName}.fit')
             if seedfile is not None:
-                print(f'cp {seedfile}_{minFitTag}.txt {seedfile}.txt')
                 os.system(f'cp {seedfile}_{minFitTag}.txt {seedfile}.txt')
 
     return minNLL
diff --git a/_modules/plotgen_utils.html b/_modules/plotgen_utils.html index 634dda2..48d111e 100644 --- a/_modules/plotgen_utils.html +++ b/_modules/plotgen_utils.html @@ -418,8 +418,6 @@

Source code for plotgen_utils

     amp_map = {}
     if verbose: print(f' >> Plotting waveset: {waveset}')
     waves = waveset.split(';')
-    if keepAllAmps:
-        print(f' >>   Keeping all amplitudes: {amps}')
     _waves = amps if keepAllAmps else waves
     for wave in _waves:
         amp_map[wave] = -1 # Placeholder
@@ -439,10 +437,7 @@ 

Source code for plotgen_utils

         if v == -1: print(f' >> WARNING: Amplitude {k} not found in fit results. Exiting...'); exit();
 
     # Turn on only the requested amplitudes
-    if keepAllAmps:
-        for i in range(len(amps)):
-            plotGen.enableAmp(i)
-    else:
+    if not keepAllAmps:
         for i in range(len(amps)):
             plotGen.disableAmp(i)
         for i in amp_map.values():
diff --git a/_sources/intro.md b/_sources/intro.md
index 42e6ba0..03e4e5a 100644
--- a/_sources/intro.md
+++ b/_sources/intro.md
@@ -6,24 +6,20 @@ This repository contains Python bindings for AmpTools. Under the hood, it uses [
 
 # Installation
 
-Use `Bash` shell. 
-
 All major dependencies (ROOT, AmpTools, FSRoot) are built from source.
 
-Install AmpTools and FSRoot as a submodule:
+To install AmpTools and FSRoot as a submodule:
 
 ```shell
 git clone https://github.com/lan13005/PyAmpTools --recurse-submodules
-cd PyAmpTools
 ```
 
-Environment setup. `conda` can be very slow to resolve dependencies for ROOT. Use [Mamba](https://github.com/conda-forge/miniforge#mambaforge) or [Miniconda](https://docs.anaconda.com/free/miniconda/index.html) instead of conda for faster dependency resolution
+Environment setup. `conda` can be very slow to resolve dependencies for ROOT. I recommend [Mamba](https://github.com/conda-forge/miniforge#mambaforge)
 
 ```shell
 conda env create  # Creates environment specified by environment.yml and pyproject.toml
 conda activate PyAmpTools # activate the environment
-pip install mpi4py # MPI (if available), mamba will link it against the wrong executables. 
-# if installing mpi4py fails, see bottom of page
+pip install mpi4py # MPI (if available), mamba will link it against the wrong executables
 pre-commit install --install-hooks # (Optional) commit hooks to perform loose formatting
 ```
 
@@ -32,15 +28,13 @@ pre-commit install --install-hooks # (Optional) commit hooks to perform loose fo
 ```shell
 cd root
 # Modify build_root.sh to match your environment (gcc versions, etc))
-# if you modify the root version and use VSCode please update .vscode/settings.json file's extraPaths variable accordingly
 source build_root.sh
 ```
 
-Modify `set_environment.sh` to match you GPU environment (default: setup for JLab ifarm). Then create the necessary directory and link the environment script, allowing for `set_environment.sh` to be sourced everytime `conda activate PyAmpTools` is executed. *Note:* VSCode loads the environment but does not appear to run activate.d requiring manual activation.
+Modify `set_environment.sh` to match you GPU environment (default: setup for JLab ifarm)
 
 ```shell
-mkdir -p $CONDA_PREFIX/etc/conda/activate.d/
-ln -snfr set_environment.sh $CONDA_PREFIX/etc/conda/activate.d/
+ln -snfr set_environment.sh $CONDA_PREFIX/etc/conda/activate.d # load environment variables on conda activation
 ```
 
 Build required libraries
@@ -66,15 +60,6 @@ AmpTools and FSRoot are included as git submodules. Modified source files and ma
 
 Currently, the main scripts that perform an analysis, from simulation to fitting to plotting results, is located in `EXAMPLES/python` folder. These scripts can also be run from the commandline but its main functionality can be imported into another script (or Jupyter). Utility functions used by these scripts are located in the `utils` folder. Hopefully these scripts exposes enough functionality that adapation to other algorithms and use cases is easier.
 
-# Potential Errors
-
-## Failure to pip install mpi4py
-
-If installing `mpi4py` fails due to `error: Cannot link MPI programs` this is a common conda-forge linker issue. Try replacing the built-in linker with the system's and attempt to install `mpi4py` again.
-```shell
-rm $CONDA_PREFIX/compiler_compat/ld
-ln -s /usr/bin/ld $CONDA_PREFIX/compiler_compat/
-```
 
 ```{tableofcontents}
 ```
diff --git a/_sources/notebooks/libraryLoading.ipynb b/_sources/notebooks/libraryLoading.ipynb
index 59ec5e1..6975f46 100644
--- a/_sources/notebooks/libraryLoading.ipynb
+++ b/_sources/notebooks/libraryLoading.ipynb
@@ -97,6 +97,10 @@
    "display_name": "PyAmpTools",
    "language": "python",
    "name": "pyamptools"
+  },
+  "language_info": {
+   "name": "python",
+   "version": "3.9.18"
   }
  },
  "nbformat": 4,
diff --git a/api/atiSetup.html b/api/atiSetup.html
index 7d331bc..b545cf8 100644
--- a/api/atiSetup.html
+++ b/api/atiSetup.html
@@ -419,7 +419,7 @@ 

atiSetup

-set_aliases(called_globals, USE_MPI, USE_GPU)[source]#
+set_aliases(called_globals, USE_MPI)[source]#

Due to MPI requiring c++ templates and the fact that all classes live under the ROOT namespace, aliasing can clean up the code significantly. A dictionary of aliases is appended to the globals() function of the calling function thereby making the aliases available in the calling function.

diff --git a/intro.html b/intro.html index 9195c45..43e5ac2 100644 --- a/intro.html +++ b/intro.html @@ -380,11 +380,7 @@

Contents