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

Paris formatting #161

Merged
merged 59 commits into from
Apr 11, 2024
Merged

Paris formatting #161

merged 59 commits into from
Apr 11, 2024

Conversation

brendan-m-murphy
Copy link
Contributor

@brendan-m-murphy brendan-m-murphy commented Jan 10, 2024

Pull Request Template: delete as needed and mark appropriate check boxes [ ] with an x

Description:
Script to create PARIS outputs.

This script requires a venv with openghg_inversions installed, as well as the sparse package (which can be installed using pip install sparse).

Run using (for instance):

python make_paris_outputs.py -s "sf6" -r "/home/brendan/Documents/inversions/plotting/sf6_best" -c "/home/brendan/Documents/inversions/openghg_inversions/countries" -m 0.1 -o "/home/brendan/Documents/paris_formatting_test"

It is assumed that the -c argument (for "country_files_path") points to a directory containing country_EUROPE.nc and country-ukmo_EUROPE.nc. This could be changed in the future, but in addition to specifying the country map, we also need to specify which countries we want to use, so passing these as arguments would be unwieldy.

Type of Change:

[ ] Bug fix

[ ] New feature

[ ] Code-breaking change

Checklist:

[ ] Code documentation has been updated if needed

[ ] If new tests are needed, they have been added

[ ] All tests pass

[ ] No merge conflicts

[ ] /CHANGELOG.md has been updated if change is significant

Other Comments:

Any additional comments to reviewers not accounted for above

brendan-m-murphy and others added 30 commits January 9, 2024 16:18
…anges for which ukmo mask countries are used
...still needs to be turned into a script... currently only
works on my local machine
Previous regex didn't allow underscores in variable names.
This version uses the variable names "x", "bc", "sigma", "mu_bc", and
"y", and allows passing in a dimension string or tuple for each random
variable ("x", "bc", "sigma")
This class (~InversionOutput~) takes the current (v0.1) RHIME outputs from
openghg_inversions and creates: a posterior trace, PyMC model,
and contains other info needed for creating PARIS outputs (e.g. basis
functions).

There is a function to "clean" the raw RHIME dataset, and this is incorporated
into ~InversionOutput~ via a class method.

There are functions to sample predictive distributions and to output the
traces as a dataset with dimensions: site, time, draw, nx, nbc,
nsigma_site, nsigma_time.
This class creates a country matrix and optionally restricts it to a
selected list of countries. Its main purpose is to provide a method
to create country traces from an InversionOutput object.

Country objects can be merged, allowing the use of multiple country
files.

Note: the __init__ method requires a dataset, not a file path, so the
country files need to be loaded separately.
brendan-m-murphy and others added 28 commits February 14, 2024 12:43
units can be specified as pandas period string
to seconds since 1 Jan 1970 instead of days
..instead of all files found
...and added option to run without computing concentration
The species for the country outputs was accidentally
hard coded to "sf6". I fixed this bug, and converted country
total units to kg/yr from g/yr.

The outputs now match what HBMCMC outputs.
This will let us use the EEZ file if we want.
report mode by passing `--mode` flag on command line
need to try/except for bc prior
we still want to use "mode" for country totals and emissions
in flux and country totals
… the template: PARIS_Lagrangian_inversion_concentration_EUROPE.cdl
We were assuming that the basis region numbers would always start
at 0, but this is only true because we subtract 1 from the basis
functions before saving the output in openghg_inversions.

There isn't really a reason to modify the basis functions before
outputting them, so if we change this in inversions, our assumption
would be wrong.

This change will avoid this potential problem.
@brendan-m-murphy brendan-m-murphy merged commit 205de07 into develop Apr 11, 2024
0 of 2 checks passed
@hdelongueville hdelongueville deleted the paris_formatting branch August 28, 2024 14:45
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

Successfully merging this pull request may close these issues.

2 participants