Giter Club home page Giter Club logo

appletree's People

Contributors

dachengx avatar faroutylq avatar hoetzsch avatar joranangevaare avatar mhliu0001 avatar pre-commit-ci[bot] avatar zihaoxu98 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

appletree's Issues

More test called

Current test coverage is only ~80%(look at Pull Request Test Coverage Report for more information), we should add more tests on all the features.

Hard to debug config file loading

When loading the config file, sometimes it loads NoneType and it's hard to know which file failed.
``File` ~/appletree/appletree/utils.py:88, in load_json(file_name)
85 @export
86 def load_json(file_name: str):
87 """Load data from json file."""
---> 88 with open(get_file_path(file_name), 'r') as file:
89 data = json.load(file)
90 return data

TypeError: expected str, bytes or os.PathLike object, not NoneType
``

My temporary fix is to make it print all names in
`@export
class Map(Config):
"""Map is a special config which takes input file"""

def build(self):
    """Cache the map to jnp.array"""

    
    if self.name in _cached_configs:
        print('want to get:',self.name)
        file_path = _cached_configs[self.name]
        
    else:
        file_path = get_file_path(self.get_default())
        _cached_configs.update({self.name: file_path})

`
But there might be better ways to print what didn't load.

S2 simulation

We should separate S2 correction map when simulating S2 PE and doing corrections. The former should use true XY and the later should use reconstructed XY.

Also we should consider again the implementation of extraction efficiency XY map in appletree.

Inconsistent coverage using two half gaussian

If some parameter with asymmetric error bars, it will be interpreted as a distribution that pastes two half gaussians together, with their sigmas being plus and minus error bars.

However, this does not conserve the coverage, meaning that the coverage will no longer be 68%.

Show_config() does not respect the overwritten plugins

In components, the simulation tree is deduced based on the order of registration, i.e. later registered plugins have higher priority if two plugins simulate the same feature.

However, when using component.show_config(), it will show all the configs from all plugins even if some of them are overwritten by other plugins.

Wrong `static_argnums` in `negative_binomial` in release v0.3.2

When I downloaded the latest release of appletree and tried to import, I encountered an error:

Python 3.10.14 (main, Mar 21 2024, 16:24:04) [GCC 11.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.24.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import appletree
Using Normal as an approximation of Binomial
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[1], line 1
----> 1 import appletree

File ~/anaconda3/envs/xenon_apt/lib/python3.10/site-packages/appletree/__init__.py:18
     14 from .interpolation import *
     16 from .config import *
---> 18 from .parameter import *
     20 from .randgen import *
     22 from .share import *

File ~/anaconda3/envs/xenon_apt/lib/python3.10/site-packages/appletree/parameter.py:6
      2 import json
      4 import numpy as np
----> 6 from appletree.randgen import TwoHalfNorm
      7 from appletree.utils import errors_to_two_half_norm_sigmas
     10 class Parameter:

File ~/anaconda3/envs/xenon_apt/lib/python3.10/site-packages/appletree/randgen.py:281
    275         ret = vmap(lambda *x: dispatch(*x))(seed, p, n)
    276     return key, jnp.reshape(ret, shape)
    279 @export
    280 @partial(jit, static_argnums=(3, 4))
--> 281 def negative_binomial(key, p, n, shape=()):
    282     """Negative binomial distribution random sampler. Using Gamma–Poisson mixture.
    283 
    284     Args:
   (...)
    297 
    298     """
    300     key, lam = gamma(key, n, p / (1 - p), shape)

File ~/anaconda3/envs/xenon_apt/lib/python3.10/site-packages/jax/_src/api.py:281, in jit(fun, in_shardings, out_shardings, static_argnums, static_argnames, donate_argnums, donate_argnames, keep_unused, device, backend, inline, abstracted_axes)
    142 def jit(
    143   fun: Callable,
    144   in_shardings=sharding_impls.UNSPECIFIED,
   (...)
    154   abstracted_axes: Any | None = None,
    155 ) -> pjit.JitWrapped:
    156   """Sets up ``fun`` for just-in-time compilation with XLA.
    157 
    158   Args:
   (...)
    279     Array([   0,    1,  256, 6561], dtype=int32)
    280   """
--> 281   return pjit.make_jit(
    282         fun, in_shardings, out_shardings, donate_argnums, donate_argnames,
    283         static_argnums, static_argnames, device, backend, abstracted_axes,
    284         keep_unused, inline, use_resource_env=False)

File ~/anaconda3/envs/xenon_apt/lib/python3.10/site-packages/jax/_src/pjit.py:500, in make_jit(fun, in_shardings, out_shardings, donate_argnums, donate_argnames, static_argnums, static_argnames, device, backend, abstracted_axes, keep_unused, inline, use_resource_env)
    491 def make_jit(fun: Callable, in_shardings: Any, out_shardings: Any,
    492              donate_argnums: int | Sequence[int] | None,
    493              donate_argnames: str | Iterable[str] | None,
   (...)
    497              abstracted_axes: Any | None, keep_unused: bool,
    498              inline: bool, use_resource_env: bool) -> Any:
    499   """jit() and pjit() are thin wrappers around this function."""
--> 500   jit_info = _parse_jit_arguments(
    501         fun, in_shardings, out_shardings, donate_argnums, donate_argnames,
    502         static_argnums, static_argnames, device, backend, abstracted_axes,
    503         keep_unused, inline, use_resource_env)
    504   return _make_jit_wrapper(jit_info)

File ~/anaconda3/envs/xenon_apt/lib/python3.10/site-packages/jax/_src/pjit.py:420, in _parse_jit_arguments(fun, in_shardings, out_shardings, donate_argnums, donate_argnames, static_argnums, static_argnames, device, backend, abstracted_axes, keep_unused, inline, use_resource_env)
    417 fun_sourceinfo = api_util.fun_sourceinfo(fun)
    418 fun_signature = api_util.fun_signature(fun)
--> 420 donate_argnums, donate_argnames, static_argnums, static_argnames = resolve_argnums(
    421     fun, fun_signature, donate_argnums, donate_argnames, static_argnums,
    422     static_argnames)
    424 has_explicit_sharding = _pjit_explicit_sharding(
    425     in_shardings, out_shardings, device, backend)
    427 return PjitInfo(
    428       fun=fun,
    429       fun_sourceinfo=fun_sourceinfo,
   (...)
    445       has_explicit_sharding=has_explicit_sharding,
    446       use_resource_env=use_resource_env)

File ~/anaconda3/envs/xenon_apt/lib/python3.10/site-packages/jax/_src/api_util.py:540, in resolve_argnums(fun, signature, donate_argnums, donate_argnames, static_argnums, static_argnames)
    536 donate_argnums, donate_argnames = infer_argnums_and_argnames(
    537     signature, donate_argnums, donate_argnames)
    539 # Validation
--> 540 _validate_argnums(signature, static_argnums, "static_argnums")
    541 _validate_argnames(signature, static_argnames, "static_argnames")
    542 _validate_argnums(signature, donate_argnums, "donate_argnums")

File ~/anaconda3/envs/xenon_apt/lib/python3.10/site-packages/jax/_src/api_util.py:170, in _validate_argnums(sig, argnums, argnums_name)
    167     return
    169 if argnums and (-min(argnums) > n_pos_args or max(argnums) >= n_pos_args):
--> 170   raise ValueError(f"Jitted function has {argnums_name}={argnums}, "
    171                    f"but only accepts {n_pos_args} positional arguments.")

ValueError: Jitted function has static_argnums=(3, 4), but only accepts 4 positional arguments.

This was introduced in PR #145 and fixed in PR #148. We might need to release one more time.

Lineage and version control

We should track the simulation results with the version of the package, configuration files, and input files(maps, corrections, and calibration data). Maybe follow the scenario in strax to use the lineage and hash.

Multiple scatter modeling

In neutron calibration, multi-scatter S2s might be merged together. We need to recurrent the workflow in BBF.

Missing cut acceptance

Not sure why but the cut acceptance is not implemented in the appletree default ER model.

Implement NEST as emission model

NEST "is an unprecedentedly comprehensive, accurate, and precise simulation of the excitation, ionization, and corresponding scintillation and electroluminescence processes in liquid noble elements". For purpose of comparison, we might want to add such a NEST model in the simulation.

Document system

We should add a helpful document including a tutorial, workflow, and configuration guide.

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.