openghg / openghg_inversions

University of Bristol Atmospheric Chemistry Research Group RHIME Inversion code (with openghg dependency)
MIT License
5 stars 0 forks source link

Iss52 test get data separately #73

Closed brendan-m-murphy closed 4 months ago

brendan-m-murphy commented 4 months ago

This addresses issue #52 by adding tests for data_processing_surface_notracer, and refactoring the inversion tests to run from reloaded merged data, rather than calling data_processing_surface_notracer.

Changes include:

  1. Creating fixtures to avoid copying the same dictionary into many test functions

  2. Three tests for merged data were added:

    1. Get merged data using data_processing_surface_notracer and compare the result to the results of this function from v0.1 of main on 9 Feb 2024

      1. Create merged data and save, then reload and compare merged data with reloaded merged data.

      2. Create merged data and compare with pickled data frozen from main v0.1 created on 9 Feb 2024

  3. Existing tests for inversion now run from merged data, and a new test was added for the case where reload_merged_data is True, but the merged data can't be found.

  4. Further tests to check that sites are dropped, but fp_all is created if some data is found, and that a SearchError is raised if all sites are dropped.

I also added an option to fixedbasisMCMC to specify the merged data file name, to simplify testing. This might be useful more generally (alternatively, I can remove it and change the test merged data file name).

Note: at some point, some of these tests are likely to fail because a package update might make it impossible to open the pickled merged data that is used for testing. If we move to using netCDF for storing merged data, this issue will go away.