Bgc riverinput from file#615
Open
ubbu36 wants to merge 28 commits into
Open
Conversation
This reverts commit 3965516.
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Codecov Report❌ Patch coverage is @@ Coverage Diff @@
## main #615 +/- ##
==========================================
+ Coverage 86.27% 89.03% +2.75%
==========================================
Files 28 28
Lines 6171 6692 +521
Branches 1101 1178 +77
==========================================
+ Hits 5324 5958 +634
+ Misses 564 415 -149
- Partials 283 319 +36
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 10 files with indirect coverage changes 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds RIVR2O-based river BGC forcing to
RiverForcing, alongside the existing Dai/Trenberth discharge workflow. River mouths can receive spatially and temporally varying carbon and nutrient export from annual RIVR2O files, while discharge can remain a repeating monthly climatology when Dai data are missing.Also moves MARBL river tracer defaults from hardcoded values to
river_tracer_defaults.nc(32 MARBL tracers plustempandsalt, 34 total), downloaded via the sameriver_datapooch registry as Dai discharge.Refactors river BGC so
RiverForcingis data-source agnostic: RIVR2O export conversion, MARBL tracer mapping, and gap-filling are handled by BGC dataset classes and a shared merge utility, not hardcoded in the forcing orchestrator.Motivation
Users should be able to use observationally constrained global river BGC export (RIVR2O) instead of uniform default concentrations, including the common case of repeating seasonal discharge (Dai climatology) combined with year-to-year BGC variation from RIVR2O annual files.
River BGC products are patchy by nature. This PR separates discharge (
source→ Dai) from BGC (bgc_source), and uses an explicit fill policy for tracers the dynamic source does not provide, rather than bespoke merge logic insideRiverForcing.Key changes
RiverForcing (orchestration)
bgc_sourceoptions:CONSTANTS(default) orRIVR2O(requirespath).bgc_source["fill"](default{"name": "CONSTANTS"}) supplies scalar concentrations for tracers missing from the dynamic source or non-finite at a given(river_time, nriver)._apply_bgc_tracers()callsforcing_concentrations()on the configured dataset, then merges with fill viafill_river_bgc_concentrations().RiverForcingno longer contains RIVR2O unit conversion, stoichiometry, or MARBL tracer name logic.requires_calendar_discharge_time), expandsriver_timeto a monthly calendar axis;river_volumerepeats by month while BGC varies by year viaabs_time.discharge_climatologydataset attribute for plotting and time-axis behavior.BGC dataset layer (
river_datasets.py)RiverBGCDatasetprotocol:forcing_concentrations()andrequires_calendar_discharge_time.RiverTracerDefaultsDataset: loads recommended defaults from NetCDF; implementsforcing_concentrations()for constant fields.Rivr2oRiverBGCDataset: owns RIVR2O I/O, DIC-cell sampling, discharge partitioning, export→concentration conversion, and MARBL tracer combinations viaforcing_concentrations().fill_river_bgc_concentrations(): generic merge of dynamic(river_time, nriver)arrays with scalar fill values.Rivr2oRiverBGCDataset (RIVR2O product)
rivr2o_riverinputs_*.ncfiles.discharge_partition_weightssplits export among rivers sharing a cell in proportion to discharge, normalized overriver_timeso co-located rivers get similar concentrations.Tracer defaults and downloads
get_tracer_defaults()reads recommended values fromriver_tracer_defaults.nc.download_river_tracer_defaults()aligned with other downloads: registered on theriver_datapooch object (same pattern asdownload_river_data()), no separate pooch registry or bundled fallback.Docs and tests
docs/river_forcing.ipynbwith RIVR2O examples andbgc_source["fill"]documentation.docs/methods.mdRiver Forcing section for optional BGC and fill.fill_river_bgc_concentrations, RIVR2O dataset logic,RiverForcingBGC sources, tracer defaults, and validation snapshots (river_forcing_with_bgc,river_forcing_no_climatology).docs/releases.md.pre-commit run --all-files.