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

Function capability for splot tool #165

Open
acampove opened this issue Oct 9, 2024 · 0 comments
Open

Function capability for splot tool #165

acampove opened this issue Oct 9, 2024 · 0 comments

Comments

@acampove
Copy link

acampove commented Oct 9, 2024

Hi,

Thanks for your work writting the tool that calculates the sweights. However I think the user might not need the weights in an array but as a function. At the end the sWeights are just a 1D function of the mass. So what I think should happen is more like:

d_wgt = compute_sweights(model, data)

arr_wgt = d_wgt['nsig']

fun = Function(x=arr_mass, y=arr_wgt)
fun.save('swt_v1.json')

that way, if you need those weights you do:

fun = Function.load('swt_v1.json')
#For one mass value
wgt=fun(5202)
# or if you need the whole array
arr_wgt = fun([2464, 4564, 4945])

that way you would be able to keep around in disk many versions of the sweights (from different fitting models, for instance) and load them whenever you need them. I implemented a Function class in:

https://github.com/acampove/dmu/blob/main/src/dmu/stats/function.py
https://github.com/acampove/dmu/blob/main/tests/stats/test_function.py

feel free to pick up what you need from the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant