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

Convert H2OLNZ units to ppm by volume #874

Merged
merged 3 commits into from
Oct 25, 2024
Merged

Convert H2OLNZ units to ppm by volume #874

merged 3 commits into from
Oct 25, 2024

Conversation

chengzhuzhang
Copy link
Contributor

Description

Resolve comments #868 (comment)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

If applicable:

  • New and existing unit tests pass with my changes (locally and CI/CD build)
  • I have added tests that prove my fix is effective or that my feature works
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have noted that this is a breaking change for a major release (fix or feature that would cause existing functionality to not work as expected)

@chengzhuzhang chengzhuzhang changed the title H2OLNZ units ppm by volume Convert H2OLNZ units to ppm by volume Oct 23, 2024
@chengzhuzhang chengzhuzhang requested a review from tangq October 23, 2024 21:53
@chengzhuzhang
Copy link
Contributor Author

@tangq this PR converts units from g/kg to ppm by volume for both Q and H2OLNZ as requested. Note that H2OLNZ had already brought to g/kg before the units change happening in zonal_mean_2d_driver.py. The results can be view here. Could you please review the code change and the results? Thanks!

Copy link

@tangq tangq left a comment

Choose a reason for hiding this comment

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

The changes Look good to me. Thanks, @chengzhuzhang

@chengzhuzhang
Copy link
Contributor Author

Thank you @tangq

@chengzhuzhang chengzhuzhang merged commit 4cda0a8 into main Oct 25, 2024
4 checks passed
@chengzhuzhang chengzhuzhang deleted the h2olnz_units_ppm branch October 25, 2024 21:19
@tomvothecoder tomvothecoder mentioned this pull request Jan 10, 2025
19 tasks
tomvothecoder added a commit that referenced this pull request Jan 10, 2025
tomvothecoder added a commit that referenced this pull request Jan 15, 2025
**Bug Fixes:**  
- Fixed incorrect logic in `cf_units.Unit` that replaced `genutil.udunits`, which previously caused incorrect results.  

**Performance Improvements:**  
- Improved subsetting logic by performing a time slice before loading time series datasets into memory, enhancing performance by reducing the size of the datasets
- Optimized variable derivation by subsetting and loading datasets into memory with `.load(scheduler="sync")` first, as the `convert_units()` function requires in-memory access for `cf_units.Unit` operations -- affected `MERRA2` datasets
- Addressed an issue with single-point time dimensions in climatology datasets (e.g., OMI-MLS). xCDAT now squeezes the time dimension to remove time coordinates and bounds before loading the dataset, avoiding errors like "Non-integer years and months are ambiguous and not currently supported." -- affected `OMI-MLS` datasets
- Update `_get_slice_from_time_bounds()` to load time bounds into memory if they already exist using `.load(scheduler="sync")` to avoid hanging -- affected `streamflow` datasets
- Add missed unit conversion for `H2OLNZ` via #874 to address large differences
  - Related code: https://github.com/E3SM-Project/e3sm_diags/blame/ca41b0e5d913610c88410928951f1ed11c75663f/e3sm_diags/driver/zonal_mean_2d_driver.py#L166-L171

**Testing:**
- Performed regression testing with v2 and v3 data. Results check-out, but a closer look will be done after v3.0.0rc1 release.

---------

Co-authored-by: tomvothecoder <tomvothecoder@gmail.com>
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