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

terra-based reading/writing of netcdf files #156

Merged
merged 17 commits into from
Jan 12, 2024
Merged

terra-based reading/writing of netcdf files #156

merged 17 commits into from
Jan 12, 2024

Conversation

pfuehrlich-pik
Copy link
Contributor

@pfuehrlich-pik pfuehrlich-pik commented Aug 14, 2023

The existing read/write support for netcdf based on ncdf4 and raster was not quite working as discussed on mattermost. With this PR nc files are written and read using terra.

The author of raster and terra recommends to not use the netcdf writing feature of raster, see here.

@mscrawford
Copy link

In testing this, I wrote a magclass object with 12 subdimensions until 2100. In a .mz format, this was around 36 mb. The write function worked, but produced a 227 mb sized .nc file (which I could interact with in Panoply fine, it seemed). However, this extremely large file breaks the readMagpieNC function (it hangs).

I can do some more tests when I have more time, but are .nc files usually 9x larger than their .mz equivalents? Even the uncompressed (.m) magpie file is only ~50 mb.

@pfuehrlich-pik pfuehrlich-pik marked this pull request as ready for review January 11, 2024 15:05
@pfuehrlich-pik
Copy link
Contributor Author

@tscheypidi Please have a look, this may fix the CRAN windows problem. @dklein-pik had the same problem locally

Copy link
Member

@dklein-pik dklein-pik left a comment

Choose a reason for hiding this comment

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

With these changes test-readwritemagpie.R:87:3, which previously failed on my Windows computer, works again.

Copy link
Member

@tscheypidi tscheypidi 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, thanks!

@pfuehrlich-pik pfuehrlich-pik merged commit d18b8fd into pik-piam:master Jan 12, 2024
2 of 3 checks passed
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.

4 participants