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

HiTRes Inversion Options #1

Merged
merged 82 commits into from
Mar 3, 2023
Merged

HiTRes Inversion Options #1

merged 82 commits into from
Mar 3, 2023

Conversation

hanchawn
Copy link
Contributor

@hanchawn hanchawn commented Apr 7, 2022

Description:

  • Add HiTRes options to hbmcmc set up to allow for creating mf timeseries using the HiTRes procedures
  • Add edits to name to filter files imported for the date (avoid importing all matching files and then cropping data) and make some processes faster e.g. option to create timeseries in fp_sensitivity so timeseries_HiTRes doesn't need to be run both there and in footprints_data_merge
  • Add overwrite and uncertainty options to flux.write

resolves issues #124 & #126

Type of Change:
[ ] Bug fix
[X] New feature
[ ] Code-breaking change

Checklist:
[ ] Code documentation has been updated if needed
[ ] If new tests are needed, they have been added
[X] All tests pass
[X] No merge conflicts
[X] /CHANGELOG.md has been updated if change is significant

hanchawn and others added 30 commits September 27, 2021 09:32
Former-commit-id: 524a305f1ef056fe4c3cf35e3448cc9bbc2d83dd
Former-commit-id: 5fb9af139f2ccbf4456310bec3cfc1c394f5ca7d
… and then filters out nans

Former-commit-id: f8c10d14bd19cdc7d27df1e8dba8025fa30a690b
…tion

Former-commit-id: 4bcea91defcb8ee22b8751248a6edce5397d0e34
Former-commit-id: 631950cf3c895f09883a0cf53a92412ea8cc1c24
…te docstrings

Former-commit-id: f3c90bd82ee15c6b49471ff70db24c2560d15314
Former-commit-id: c6643f80a149c87cc7a7b5d91737e9f1920db65e
Former-commit-id: ed627fbb17262fb3ec531e008f76333a3d0fb18e
Former-commit-id: c3dcd444f43274c95e373913c5b52a6b3b6f69b1
Former-commit-id: eb3002b5b40191792e5bb69b4528a09b81876e85
Former-commit-id: 16d65e0c15dfb3e85482d62cb2f0a0b281d2e794
…idusing too much memory

Former-commit-id: 364589fc2e9f03760c946b88151db4ac80da2ba1
…ementation Error

Former-commit-id: 74f4a969d8f36b18a304d0fe2cdb09cef5bcc47a
Former-commit-id: c4ce8a647bb261234a61f53b21f2e6e743eceed8
Former-commit-id: 55f5e1f86884a72fd98fff75615faed5b4566837
…ng timeseries_HiTRes twice if both are needed

Former-commit-id: 20239b5ed277cd9340185d03e2e207a6b5b48fad
Former-commit-id: 478b28e1bf671d2a69589cd377d9b895474be9c3
…c_sensitivity

Former-commit-id: c3dbde41bc5b9a8da6f6db8e863e125041dfae47
Former-commit-id: 54231427e57e1dd2dbe4b3daf2072fbe5e50dc9f
…metres

Former-commit-id: 6bca8d9bd83937e02b35263d306704e1db242622
Former-commit-id: c82380d405b3a539b02733ca7a15c65fcb8debb4
…tasets

Former-commit-id: d68bd5630b911b08abb2d8b16d148b7f5deb7e9c
Former-commit-id: 034688e7f621e6bf95d9b2d2b704396c1dc1c1e4
Former-commit-id: 70b593cd09f815665b938642981ceb816fb1fc9b
Former-commit-id: 15bbfd42ebc93425773a82d2238fad7e92d42c92
Former-commit-id: 0ba832bbdd493e487a3773632777a8fea7ef03c8
…sensitivity

Former-commit-id: 6135421929a10633b3dc1bf05fe74c6ab7827226
Former-commit-id: 5331d20abcf7836c9f3030cb6ea78bbeea122f01
Former-commit-id: d5616288860496c459aa1c5ba2c58b2f18239144
Former-commit-id: e8b6316aed360a4aa5068f61d1d7fbee1baa8996
@hanchawn
Copy link
Contributor Author

hanchawn commented Apr 25, 2022

In terms of the inversion, the HiTRes specific processes are only used in the set up i.e. where it calls footprints_data_merge & fp_sensitivity - although I agree that the test coverage for the HiTRes part of name.py is not great
I thought that the existing hbmcmc tests would cover the rest as it's not HiTRes specific
The current tests pass for the changes I made to name.py, including a test for name.timeseries_HiTRes (but it doesn't test the other HiTRes parts of name.py)

adjust the start datetime for name.flux_for_HiTRes to only import the required hours back, rather than a whole extra month
add tests for importing HiTRes footprints, and for name.flux_for_HiTRes
initally import data from year before start if start month=1 and HiTRes=True, and then slice to required time range
@hanchawn hanchawn marked this pull request as draft April 25, 2022 15:53
allow for flexible options of H_backwhen importing fluxes
@rt17603
Copy link
Member

rt17603 commented Apr 26, 2022

In terms of the inversion, the HiTRes specific processes are only used in the set up i.e. where it calls footprints_data_merge & fp_sensitivity - although I agree that the test coverage for the HiTRes part of name.py is not great I thought that the existing hbmcmc tests would cover the rest as it's not HiTRes specific The current tests pass for the changes I made to name.py, including a test for name.timeseries_HiTRes (but it doesn't test the other HiTRes parts of name.py)

Ok, but given that this PR is to integrate the HiTRes options into the hbmcmc code it would be useful to have even a very simple example which demonstrates that integration works. Even if we're happy each individual part works it's nice to know that the steps can and do work together.

hanchawn added 7 commits May 4, 2022 09:45
split HiTRes tests out where there were multiple asserts in 1 test to ensure all sserts are run if any fail
   test that using HiTRes fp with constant flux gives the same as integrated fp with constant flux
   this should allow for easier testing
@hanchawn hanchawn force-pushed the apo_inversion branch 2 times, most recently from dd46c68 to a403282 Compare February 28, 2023 15:56
@hanchawn hanchawn marked this pull request as ready for review March 1, 2023 15:07
@hanchawn
Copy link
Contributor Author

hanchawn commented Mar 1, 2023

I haven't added this test as I'm not sure how to write a test to run an inversion without it being very inefficient - from what I could see of the current hbmcmc tests they mostly use a toy model which doesn't use fpdm inputs (I could be wrong though).

It would be good to have this merged in so that we could add a version number to the APO paper, I can add an issue that some version of the test should be added later.

There are 4 tests failing but these are also failing in develop

to integrated and HiTRes footprints \
{integrated:path1, HiTRes:path2}")
return None
fp_directory = join(data_path, 'LPDM/fp_NAME/') if fp_directory is None else fp_directory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on previous code - is it no longer expected that fp_directory will be a dictionary for 'HiTRes' option?

Copy link
Contributor Author

@hanchawn hanchawn Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never used a dictionary for it as the HiTRes footprints are stored in the same area as the integrated ones now, do you think it would be better to change the code to make that an option again, or just take out reference to is being a dictionary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of the code would need changing to use a dictionary for it, and I don't think you'd often have a reason for importing both so I think it would be best just to change the documentation
(The way the footprints are processed now means that the HiTRes code now only needs the HiTRes ones)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the question is around backwards compatibility - thinking about it I think the dictionary option was because we used to have to use separate integrated and HiTRes files. If it's not too much work if may be good to allow it to be included as an option? Otherwise, maybe you could just add a comment to say this mode is no longer supported.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah ok I think that's fine - seems like a thing to add to the change log just so we know when the change happened.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good

@rt17603
Copy link
Member

rt17603 commented Mar 2, 2023

I've reviewed this as much as I can given the time constraints and I think this looks really good overall.

You're correct that there are currently failing tests in develop anyway so these aren't being influenced by your changes. I think you're right it's best to get this in but as you say if an issue could be added to say that this needs to be tested that would be very helpful. At the very least were there some examples of how this can be run with example inputs etc.?

As a group we also should really think about getting this integrated into the openghg-inversions repository but that's a future problem and better to get this integrated for now.

@hanchawn
Copy link
Contributor Author

hanchawn commented Mar 2, 2023

Thank you Rachel, I appreciate it's a big PR so you'e done a thorough job in the circumstances!

I never got to the point of running a HiTRes inversion so I don't have example runs of that, but my APO models rely on some of the other changes to run.

Eric has added the HiTRes option to the openghg-inversions code, and is going to make any other changes that need to go in for that.

@hanchawn hanchawn merged commit bfeb92c into develop Mar 3, 2023
@hanchawn hanchawn deleted the apo_inversion branch March 3, 2023 10:51
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