-
Notifications
You must be signed in to change notification settings - Fork 62
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
Saving new measurement #147
Comments
Hi, can you try whether it works when you use |
If I run flavio.measurements.read_file('/path/to/flavio/data/measurements_test.yml') It outputs a list with the name of the observable as only item ['observable'] |
Right, that's the return value, but it also instantiates all the You can pass the list of names to |
Ok, but then how can I edit/update the measured Likelihood for the relevant observable with the values I want to assign? i.e. how can I edit the dictionary and dump it back to the file like in: flavio.measurements.read_file('/path/to/flavio/data/load_measurements_to_edit.yml') #this instantiate the measurements
dict['values'][0]['value']['y']=np.exp(logL) #this step would be what I'd need
flavio.measurements.write_file('/path/to/flavio/data/dump_for_edited_measurements.yml', dict) |
Ah OK, you want to edit the YAML before instantiating the [Measurement.from_yaml_dict(dict, pname='observables') for m in measurements] |
I suspect you were missing the |
(Arguably, this is not an elegant implementation. It would make more sense to make |
Thanks. So what I now do is: #get the measurement to edit
with open('/path/to/flavio/data/measurements_test.yml') as file:
test = yaml.load(file, Loader=yaml.FullLoader)
#edit the likelihood y
test2=copy.deepcopy(test)
test2['observable']['values'][0]['value']['y']=np.exp(logL)
#create a measurement list with the edited yaml dict
from flavio.classes import Measurement
measurements = [Measurement.from_yaml_dict(test2, pname='observables')] And I obtain KeyError: 'constraints' I attach for clarity the LHCb RK Example:
experiment: LHCb
values:
- name: <Rmue>(B+->Kll)
q2min: 1.1
q2max: 6.0
value:
distribution: numerical
x: [0.5 , 1.5] #dummy values
y: [1.0 , 1.0] |
Ah OK. This module is a mess. The reason is that the YAML serialization/deserialization was added at a later point and the |
It's ok and actually with a simple edit I could make it work. For now I just dump the modified measurement with yaml and edited this line https://github.com/flav-io/flavio/blob/master/flavio/measurements.py#L14 to: measurements = yaml.load(obj, Loader=yaml.Loader) And it works just fine. Thank you! |
Yes, good point! I think in general loading and saving of measurements can be improved and I will keep this issue open as a reminder for that. |
Dear mantainers,
Apologies in advance if what I'm about to ask is detailed in some guide but I couldn't find it anywhere. I would like to create a new measurement instance modifying one of the existing ones in flavio. For example, for the relevant observables I want to create an arbitrary Likelihood:
Then from the file
measurements_test.yml
that contains a dictionary that is the copy of the observable I want to edit I do:When I want to save I do:
And I obtain a key error
What am I missing in the definition of the measurement instance with these steps?
Thanks
The text was updated successfully, but these errors were encountered: