Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide domain generator progress bar when generating hit-and-miss sample #395

Closed
redeboer opened this issue Jan 5, 2022 · 0 comments · Fixed by #396
Closed

Hide domain generator progress bar when generating hit-and-miss sample #395

redeboer opened this issue Jan 5, 2022 · 0 comments · Fixed by #396
Assignees
Labels
🐛 Bug Something isn't working
Milestone

Comments

@redeboer
Copy link
Member

redeboer commented Jan 5, 2022

When using a TFPhaseSpaceGenerator as domain_generator in IntensityDistributionGenerator, calling generate() results in several tqdm progress bars if the generated sample is generated in bunches. This is because TFPhaseSpaceGenerator uses a hit-and-miss strategy as well. It's therefore actually better to use TFWeightedPhaseSpaceGenerator, but even so, it would be nicer if the progress bar for the domain can be deactivated.

How to reproduce?

pip install -q ampform[viz]==0.12.1 tensorwaves[jax,pwa]==0.4.0
import ampform
import qrules
from ampform.dynamics.builder import create_relativistic_breit_wigner_with_ff
from tensorwaves.data import (
    IntensityDistributionGenerator,
    TFPhaseSpaceGenerator,
    TFUniformRealNumberGenerator,
)
from tensorwaves.data.transform import SympyDataTransformer
from tensorwaves.function.sympy import create_parametrized_function

reaction = qrules.generate_transitions(
    initial_state="J/psi(1S)",
    final_state=["gamma", "pi0", "pi0"],
    allowed_intermediate_particles=["f(0)"],
    allowed_interaction_types=["strong", "EM"],
)

builder = ampform.get_builder(reaction)
resonances = reaction.get_intermediate_particles()
for p in resonances:
    builder.set_dynamics(p.name, create_relativistic_breit_wigner_with_ff)
model = builder.formulate()

intensity = create_parametrized_function(
    model.expression.doit(),
    parameters=model.parameter_defaults,
    backend="jax",
)
helicity_transformer = SympyDataTransformer.from_sympy(
    model.kinematic_variables, backend="jax"
)

phsp_generator = TFPhaseSpaceGenerator(
    initial_state_mass=reaction.initial_state[-1].mass,
    final_state_masses={i: p.mass for i, p in reaction.final_state.items()},
)
data_generator = IntensityDistributionGenerator(
    function=intensity,
    domain_generator=phsp_generator,
    domain_transformer=helicity_transformer,
)
rng = TFUniformRealNumberGenerator(seed=0)
phsp_momenta = phsp_generator.generate(1_000_000, rng)
data_momenta = data_generator.generate(100_000, rng)

image

@redeboer redeboer added the 🐛 Bug Something isn't working label Jan 5, 2022
@redeboer redeboer added this to the 0.4.1 milestone Jan 5, 2022
@redeboer redeboer self-assigned this Jan 5, 2022
@redeboer redeboer changed the title Hide phase space generator progress bar when generating hit-and-miss sample Hide domain generator progress bar when generating hit-and-miss sample Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
Status: Released
Development

Successfully merging a pull request may close this issue.

1 participant