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

Load data summary #7

Open
coolalexzb opened this issue Jun 9, 2020 · 4 comments
Open

Load data summary #7

coolalexzb opened this issue Jun 9, 2020 · 4 comments
Assignees
Labels
question Further information is requested research Experimental or investiagation

Comments

@coolalexzb
Copy link
Contributor

coolalexzb commented Jun 9, 2020

Currently, I want to make a summary of loading data. This is important to complete an automatic process.

Situation 1: background + signal (BkgOnly.json + patchset.json)
e.g. BkgOnly.json + patchset.json

    patchset = pyhf.PatchSet(json.loads('patchset.json'))
    workspace = pyhf.workspace.Workspace(json.loads('BkgOnly.json'))
    model = workspace.model(
        measurement_name=None,
        patches=patchset[model_point],
        modifier_settings={
            "normsys": {"interpcode": "code4"},
            "histosys": {"interpcode": "code4p"},
        },
    )

Situation 2: workspace.json
e.g. HVTWZ_3500.json

    workspace = pyhf.workspace.Workspace(json.loads('HVTWZ_3500.json'))
    model = workspace.model()

Situation 3: BkgOnly.json

    workspace = pyhf.workspace.Workspace(json.loads('BkgOnly.json'))
    model = workspace.model()

If there is any problem over the examples I wrote or any situations I ignored, feel free to add notes here. Thank you!

@matthewfeickert
Copy link
Member

matthewfeickert commented Jun 9, 2020

All that is needed to create a model is a valid spec (c.f. pyhf.pdf.Model API) and a valid spec is anything that passes pyhf inspect. So while using pyhf.workspace.Workspace is a very natural and normal way for us to do things it is not explicitly required.

For further reference, the pyhf model JSON Schema is linked to in the first reference in the Likelihood Specifiaction bibliography (v1.0.0 of the schema that is).

pyhf.workspace.Workspace doesn't accept a file path though, so all the examples above that pass in a string aren't valid.

@matthewfeickert matthewfeickert added question Further information is requested research Experimental or investiagation labels Jun 9, 2020
@coolalexzb
Copy link
Contributor Author

coolalexzb commented Jun 9, 2020

Oh, I made an error in Situation 2 and 3. The input should be a Json type. I have modified them

@coolalexzb
Copy link
Contributor Author

coolalexzb commented Jun 9, 2020

If we initialize workspace in the way like situation 2 and 3 (we don't have a patchset.json in these situations), can we get data by workspace.data(model) successfully in further steps? Is there any situation that I did not take into consideration? @matthewfeickert

@matthewfeickert
Copy link
Member

If we initialize workspace in the way like situation 2 and 3 (we don't have a patchset.json in these situations), can we get data by workspace.data(model) successfully in further steps?

The patchset just gives the signal contribution to the statistical model. The data (observations + auxiliary data) are not part of the model and so pyhf.workspace.Workspace.data() doesn't care if the model object does or doesn't have a signal component.

This is maybe made a bit more clear by just looking at the source for pyhf.workspace.Workspace.data which is very short.

Is there any situation that I did not take into consideration?

I think this is fine. 👍 There are other ways to make models, but for what we're doing this covers all the cases we care about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested research Experimental or investiagation
Projects
None yet
Development

No branches or pull requests

2 participants