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

Fix issue where wrong GCHP grid boxes were being looked up in models vs. obs plots #240

Merged
merged 8 commits into from
Jul 27, 2023

Conversation

yantosca
Copy link
Contributor

This PR fixes the models vs observations benchmark plots for GCHP. Previously, an incorrect algorithm was used to retrieve the GCHP grid box nearest to the observational site. We now use the proper algorithm from the gcpy/cstools.py module.

Before the fix, the GCHP plots showed very high concentrations at high-latitude sites like Villum Nord and Eureka. (NOTE: The green line in this plot is actually GCHP despite the label):

image

which is now corrected:

2023_07_27_13_11_39_Greenshot

yantosca added 8 commits July 25, 2023 10:31
benchmark/modules/benchmark_models_vs_obs.py
- Convert longitudes and latitudes from xarray.DataArray to
  numpy.ndarray before computing x_idx and y_idx.  This will ensure
  that x_idx and y_idx are returned as numpy.int64 values.

NOTE: There is an issue with the search algorithm for GCHP data.
We will rectify this soon.

Signed-off-by: Bob Yantosca <[email protected]>
benchmark/modules/run_1yr_fullchem_benchmark.py
- gcc_vs_gcc_models_vs_obs_dir, gchp_vs_gcc_models_vs_obs_dir,
  and gchp_vs_gchp_models_vs_obs_dir now use directory name
  "ModelVsObs" instead of "Models_vs_Observations".

Signed-off-by: Bob Yantosca <[email protected]>
gcpy/util.py
- Added utility function verify_variable_type.  This will return a
  TypeError if a variable is not of the expected type or types
  that are provided.  Useful for function argument error checking.

Signed-off-by: Bob Yantosca <[email protected]>
gcpy/util.py
- Function verify_variable_type now accepts a single type or a tuple
  of types.  These are the allowable types to be passed to isinstance.

gcpy/cstools.py
- Convert lists of types to tuples in function calls to
  verify_variable_type
- Also remove src_var argument in extract_grid function

Signed-off-by: Bob Yantosca <[email protected]>
benchmark_models_vs_obs.py
- Now use verify_variable_type to error check function arguments
- Replaced find_nearest_3d function with separate functions for
  returning the model data nearest to the observation site
  for cubed-sphere and lat-lon grids
- Updated PyDoc comments
- For cubed-sphere grids, cap the lookup latitude at +/- 89.75
  so that the a GCHP grid box can be found for a given (lon,lat)
- Cap the y-axis range at 80 ppbv
- Set y-axis tickmarks at 0, 20, 40, 60, 80 ppbv

gcpy/cstools.py
- Update PyDoc and comments with a better description of jitter_size

Signed-off-by: Bob Yantosca <[email protected]>
gcpy/grid.py
- Remove inaccurate coment in verify_variable_type

gcpy/util.py
- Add "import numpy as np" instead of just importing
  individual numpy functions

Signed-off-by: Bob Yantosca <[email protected]>
CHANGELOG.md
- Added blurb about new verify_variable_type function
- Minor edits to fix typos

Signed-off-by: Bob Yantosca <[email protected]>
@yantosca yantosca added category: Bug Something isn't working topic: Benchmark Plots and Tables Issues pertaining to generating plots/tables from benchmark output labels Jul 27, 2023
@yantosca yantosca added this to the 1.4.0 milestone Jul 27, 2023
@yantosca yantosca requested a review from msulprizio July 27, 2023 17:15
Copy link
Contributor

@msulprizio msulprizio left a comment

Choose a reason for hiding this comment

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

Looks good to merge

@yantosca yantosca merged commit 6967acc into dev Jul 27, 2023
@yantosca yantosca deleted the bugfix/model-vs-obs-plots branch July 27, 2023 18:40
@yantosca yantosca added category: Bug Fix Fixes a bug that was previously reported and removed category: Bug Something isn't working labels Aug 1, 2023
hannahnesser pushed a commit to hannahnesser/gcpy that referenced this pull request Jan 22, 2024
This merge brings PR geoschem#240 (Fix issue where wrong GCHP grid boxes
were being looked up in models vs. obs plots, by @yantosca) into
the GCPy 1.4.0 development stream.

This fixes an issue with the models vs. observations benchmark
plots where the wrong GCHP grid box was being looked up for a
given (lon, lat, alt) value.  We now use the cubed-sphere
functions in gcpy/cstools.py to do the lookup properly.

Signed-off-by: Bob Yantosca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: Bug Fix Fixes a bug that was previously reported topic: Benchmark Plots and Tables Issues pertaining to generating plots/tables from benchmark output
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants