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

make_paris_outputs fails for hfo1234yf #179

Open
joe-pitt opened this issue Jun 26, 2024 · 1 comment
Open

make_paris_outputs fails for hfo1234yf #179

joe-pitt opened this issue Jun 26, 2024 · 1 comment
Assignees
Labels

Comments

@joe-pitt
Copy link
Contributor

Describe the bug
make_paris_outputs fails for inversion runs that used species-specific hfo1234yf fps. It works fine for hfo1234yf runs that used inert footprints, and it also works fine for runs using species-specific fps for hcfo1233zde. I have put the relevant runs on BP1 in the following directory: /group/chem/acrg/joe_hfo_output/24.06.1

To Reproduce
python ~/acrg/acrg/paris_formatting/make_paris_outputs.py \
-s hfo1234yf \
-r /group/chem/acrg/joe_hfo_output/24.06.1/pop_base \
-t RHIME_NAME_EUROPE_POPULATION_hfo1234yf_yearly \
-c /group/chem/acrg/PARIS_results_sharing/country_masks/country_EUROPE_EEZ_PARIS_gapfilled.nc \
-p "4h" \
-o /group/chem/acrg/joe_hfo_output/24.06.1 \
--pol-obs

Output
Traceback (most recent call last):
File "/user/home/zh21490/acrg/acrg/paris_formatting/make_paris_outputs.py", line 401, in
emissions, concentrations = main(
^^^^^
File "/user/home/zh21490/acrg/acrg/paris_formatting/make_paris_outputs.py", line 271, in main
country_output = make_country_output(species, inv_outs, countries, report_mode=report_em_mode)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/user/home/zh21490/acrg/acrg/paris_formatting/make_paris_outputs.py", line 93, in make_country_output
countries.get_country_trace(species, inv_out).expand_dims({"time": [time_func(inv_out)]})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/user/home/zh21490/acrg/acrg/paris_formatting/countries.py", line 140, in get_country_trace
x_to_country_mat = self.get_x_to_country_mat(inv_out)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/user/home/zh21490/acrg/acrg/paris_formatting/countries.py", line 94, in get_x_to_country_mat
result = sparse_xr_dot(self.matrix, self.area_grid * inv_out.flux * inv_out.basis)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
File "/user/home/zh21490/.conda/envs/openghg_dev_env/lib/python3.12/site-packages/xarray/core/_typed_ops.py", line 252, in mul
return self._binary_op(other, operator.mul)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/user/home/zh21490/.conda/envs/openghg_dev_env/lib/python3.12/site-packages/xarray/core/dataarray.py", line 4720, in _binary_op
self, other = align(self, other, join=align_type, copy=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/user/home/zh21490/.conda/envs/openghg_dev_env/lib/python3.12/site-packages/xarray/core/alignment.py", line 882, in align
aligner.align()
File "/user/home/zh21490/.conda/envs/openghg_dev_env/lib/python3.12/site-packages/xarray/core/alignment.py", line 582, in align
self.reindex_all()
File "/user/home/zh21490/.conda/envs/openghg_dev_env/lib/python3.12/site-packages/xarray/core/alignment.py", line 557, in reindex_all
self.results = tuple(
^^^^^^
File "/user/home/zh21490/.conda/envs/openghg_dev_env/lib/python3.12/site-packages/xarray/core/alignment.py", line 558, in
self._reindex_one(obj, matching_indexes)
File "/user/home/zh21490/.conda/envs/openghg_dev_env/lib/python3.12/site-packages/xarray/core/alignment.py", line 546, in _reindex_one
return obj._reindex_callback(
^^^^^^^^^^^^^^^^^^^^^^
File "/user/home/zh21490/.conda/envs/openghg_dev_env/lib/python3.12/site-packages/xarray/core/dataarray.py", line 1890, in _reindex_callback
reindexed = ds._reindex_callback(
^^^^^^^^^^^^^^^^^^^^^
File "/user/home/zh21490/.conda/envs/openghg_dev_env/lib/python3.12/site-packages/xarray/core/dataset.py", line 3478, in _reindex_callback
reindexed_vars = alignment.reindex_variables(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/user/home/zh21490/.conda/envs/openghg_dev_env/lib/python3.12/site-packages/xarray/core/alignment.py", line 86, in reindex_variables
new_var = var[indxr]
~~~^^^^^^^
File "/user/home/zh21490/.conda/envs/openghg_dev_env/lib/python3.12/site-packages/xarray/core/variable.py", line 800, in getitem
data = indexing.apply_indexer(indexable, indexer)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/user/home/zh21490/.conda/envs/openghg_dev_env/lib/python3.12/site-packages/xarray/core/indexing.py", line 1024, in apply_indexer
return indexable.oindex[indexer]
~~~~~~~~~~~~~~~~^^^^^^^^^
File "/user/home/zh21490/.conda/envs/openghg_dev_env/lib/python3.12/site-packages/xarray/core/indexing.py", line 366, in getitem
return self.getter(key)
^^^^^^^^^^^^^^^^
File "/user/home/zh21490/.conda/envs/openghg_dev_env/lib/python3.12/site-packages/xarray/core/indexing.py", line 1501, in _oindex_get
return self.array[key]
~~~~~~~~~~^^^^^
File "/user/home/zh21490/.conda/envs/openghg_dev_env/lib/python3.12/site-packages/sparse/_coo/indexing.py", line 74, in getitem
mask, adv_idx = _mask(x.coords, index, x.shape)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/user/home/zh21490/.conda/envs/openghg_dev_env/lib/python3.12/site-packages/sparse/_coo/indexing.py", line 152, in _mask
raise IndexError("Only one-dimensional iterable indices supported.")
IndexError: Only one-dimensional iterable indices supported.

@joe-pitt
Copy link
Contributor Author

From discussion with Brendan: basis functions in the inversion output are aligned with the footprint, whereas the flux is not. So we need to align the flux with the basis functions in make_paris_outputs before multiplying them

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

No branches or pull requests

2 participants