Skip to content

Deflate#87

Closed
huard wants to merge 17 commits intomainfrom
deflate
Closed

Deflate#87
huard wants to merge 17 commits intomainfrom
deflate

Conversation

@huard
Copy link
Copy Markdown
Collaborator

@huard huard commented Apr 2, 2026

Pull Request Checklist:

  • This PR addresses an already opened issue (for bug fixes / features)
  • Tests for the changes have been added (for bug fixes / features)
    • (If applicable) Documentation has been added / updated (for bug fixes / features)

What kind of change does this PR introduce?

  • Compresses NetCDF standard and custom outputs using the deflate filter.
  • Chunks NetCDF standard and custom outputs, optimizing for time series analysis (one chunk covers the entire time series).

Compression is particularly useful with simulations that do not include q_obs. Without compression, we still need to store the full array of NaNs.

Does this PR introduce a breaking change?

Should not, but I'm going to run more tests.

Note that this PR is based off v4.12 because the main does not compile on my end, nor on the CI. This PR should not be merged before main is merged into this branch.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR targets issue #86 by adding NetCDF-4 deflate compression and explicit chunking to reduce standard output file sizes and improve time-series access patterns.

Changes:

  • Add zlib/deflate compression and chunking to standard NetCDF outputs (notably 2D time×basin variables) and to custom NetCDF outputs.
  • Change the standard-output NetCDF time dimension from NC_UNLIMITED to a fixed length derived from Options.duration/Options.timestep.
  • Introduce NetCDF compression/chunking constants in RavenInclude.h and some related formatting-only cleanups.

Reviewed changes

Copilot reviewed 5 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/StandardOutput.cpp Adds deflate + chunking and makes standard-output time dimension fixed; updates NetCDFAddMetadata2D to apply compression/chunking.
src/CustomOutput.cpp Adds deflate + chunking to custom NetCDF variables and introduces ComputeNumTimeSteps() to size time.
src/CustomOutput.h Declares ComputeNumTimeSteps().
src/RavenInclude.h Adds NETCDF_DEFLATE_LEVEL and NETCDF_CHUNKSIZE_MB constants.
src/Makefile Forces NetCDF compilation/linking on by default.
src/Reservoir.cpp / src/Reservoir.h Whitespace/formatting-only changes.
src/ParsePropertyFile.cpp Whitespace-only changes.
src/ChannelXSect.cpp Comment whitespace-only change.
src/Assimilate.cpp Whitespace-only change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/StandardOutput.cpp Outdated
Comment thread src/CustomOutput.cpp Outdated
Comment thread src/CustomOutput.cpp Outdated
Comment thread src/CustomOutput.cpp Outdated
Comment thread src/Makefile Outdated
Comment thread src/StandardOutput.cpp
@huard
Copy link
Copy Markdown
Collaborator Author

huard commented Apr 9, 2026

Tested against the RavenPy test suite and no error. Bonus, the outputs from the test take half the disk space.

@analytophile
Copy link
Copy Markdown
Collaborator

@huard showing off my github ignorance today - I thought I had merged the main into deflate but I still see recent changes in main not included in the 'Files changed'. It seems like it only merged the conflicts I approved but not the unconflicted changes?? Can you tell me how to do this? There was a separate button for the other pull requests that made this easy, but not here...?

Copy link
Copy Markdown
Collaborator

@analytophile analytophile left a comment

Choose a reason for hiding this comment

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

not sure why my merge with main didn't take, but it is still holding onto these features of the previous branch as if they were additions in deflate

Comment thread src/Assimilate.cpp
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should revert to main

Comment thread src/ChannelXSect.cpp
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

revert to main

Comment thread src/Model.cpp
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should revert to main

Comment thread src/Model.h
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

revert to main

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

revert to main

Comment thread src/Reservoir.cpp
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

revert to main

Comment thread src/Reservoir.h
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

revert to main

Comment thread src/StandardOutput.cpp
for (int p = 0; p < _nSubBasins; p++) {
if((_pSubBasins[p]->IsGauged()) && (_pSubBasins[p]->IsEnabled())){
if (Options.assim_method==DA_ECCC){ASSIM<<","<<_aDAQadjust[p]<<" ";}
else {ASSIM<<","<<_aDAscale [p]<<" ";}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

delete

Comment thread src/SubBasin.cpp

if(!overriding)
{
for(int n=0;n<_nQlatHist;n++) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

delete

Comment thread src/SubBasin.h
void SetGauged (const bool isgauged);
void Disable ();
void Enable ();
double ScaleAllFlows (const double &scale_factor, const bool scale_last, const double &tstep, const double &t);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

delete

@huard
Copy link
Copy Markdown
Collaborator Author

huard commented Apr 10, 2026

What happened is that I merged main, then reverted that merge because I couldn't compiile. I'll try to make a clean branch and open a new PR.

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.

Compress (deflate) netCDF outputs

3 participants