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

Daily TI Model and W5E5 daily data #1769

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

gampnico
Copy link
Contributor

@gampnico gampnico commented Apr 3, 2025

This PR adds support for data at daily resolution and a daily temperature index model (#1750).

Changes

Adds:

  • Daily temperature model which uses W5E5 data at daily resolution.
  • Shop function to download and process W5E5 data at daily resolution via process_w5e5_data or process_gswp3_w5e5_data_daily. This creates climate_historical_daily.
  • Support for leap years.
  • Hydro/calendar date conversions with cftime - this is faster and handles arrays.

Refactors:

  • MassBalanceModel, MonthlyTIModel. My strategy has been to refactor their methods into smaller ones, and overload with DailyTI's methods. This may need to change when implementing surface tracking, but it'll reduce merge conflicts downstream.
  • Construction of valid URLs in conftest.patch_data_urls.
  • Minor optimisations (duplicate code, performance).
  • Tests (Refactor the test suite to use pytest instead of UnitTest #791)

Points for discussion

Storing a daily variant mb_calib.json will be trickier to implement - a few flowline functions in OGGM use a hardcoded file path e.g. when merging glaciers. Currently this prevents TestInitPresentDayFlowline.test_present_time_glacier_massbalance from passing with daily data without overwriting mb_calib, so I've marked this test as xfail. This is partly related to #1677.

Should there be a separate default mb_calib available for daily data instead of expecting the user to calibrate their model? Is it worth the effort/bandwidth?

shop.w5e5.GSWP3_W5E5_SERVER and conftest.patch_data_urls link to ~dtcg on the cluster for W5E5 data. Should this instead link to an OGGM equivalent?

The upscale_factor in massbalance-sandbox can be deprecated, as DailyTI no longer relies on monthly_melt_f. I have kept it as a fallback in case a calibration method does not account for leap years.

There is a negligible discrepancy O(-15) between the annual smb calculated from get_specific_mb and get_specific_mb_daily. I think this is just because of when means/sums are taken, which cause different floating point errors.

I've added some type aliases to the autodoc configuration in docs/conf.py. This imports the module under the hood, so it may be faster/safer to build docs without this.

Refs: #844, #950, #1349, #1574, #1750

  • Tests added/passed - one test marked as xfail
  • Fully documented
  • Entry in whats-new.rst

Adds the DailyTIModel from OGGM/massbalance-sandbox.
Relies on subclass' methods instead of if statements in parent.
No breaking changes!

The output from DailyTIModel is slightly different as it switches to the
Julian year for calculating melt_f (mean percentage difference -0.23%).
Some tests are skipped as daily data is not yet implemented into
ref_mb_data.
Links ``process_w5e5_data`` to ``process_gswp3_w5e5_data_daily`` to
preserve workflow for other daily resolution datasets. Data is currently
pulled from ~dtcg until it is available on OGGM.

Refactors:
  - Duplicated code
  - URL checking in conftest
Removes:
 - Unused gradient computations, unused imports.

Refs: OGGM#1750
Adds support for converting between hydro/julian date arrays and vice
versa, used for daily W5E5 data.

Refs: OGGM#844, OGGM#1349
Fixes missing ``climate_historical_daily`` file and monthly data passed
to daily model.
Removes support for hydroyear conversion as data now follow Julian
calendar.

Adds tests for W5E5 shop.

Bugs: Some statistical functions do not yet support daily data.
Adds daily specific mass balance to output via ``get_specific_mb_daily``.

Daily MB is not fully integrated with the rest of OGGM, nor with leap years.

Bug: ``get_annual_mb`` and hence ``get_specific_mb`` skips the last month of
data.
Fixes bug where the last month of data was not downloaded from the shop, which
then affected annual mass balance calculations.
Fixes bug where get_annual_mb and get_daily_mb would not return the same
annual mass balance.

Refactors some vectorisations for performance.
Refactors ``get_specific_mb`` functions as the upper bound of the stack is
always known. Performance is ~2x faster.
No need for recursion as bounds are known. Performance is 2x faster.
Refactors method and variable names for readability.

Fixes typos in docstrings which caused formatting to fail.
Begins deprecating the ``upscale_factor`` to automatically account for
leap years.

Refactors for legibility: methods primarily rely on inheritance.

Fixes:
  - references pointing to DailySfcTIModel in a different branch.
  - leap years not accounted for in tests.

Refs: OGGM#1750
Fixes gswp3-w5e5 url and associated tests pointing to w5e5 data.

Refactors some docstrings and tests.
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.

1 participant