fix(writers): accept fmt as an alias for to_netcdf format - #3453
fix(writers): accept fmt as an alias for to_netcdf format#3453Manny7717 wants to merge 1 commit into
Conversation
save_datasets() forwarded the fmt kwarg straight into xarray's Dataset.to_netcdf(), which does not accept it (TypeError: got an unexpected keyword argument 'fmt'). Accept fmt as an alias for xarray's format kwarg, mapping the common 'nc' shorthand to 'NETCDF4'. Closes pytroll#2685
|
I'm confused by this pull request and even @mraspaud's original issue. Where is the https://docs.xarray.dev/en/latest/generated/xarray.Dataset.to_netcdf.html#xarray.Dataset.to_netcdf Because in the issue Martin was passing Regardless, why does Satpy need to use CC @pnuu @mraspaud @gerritholl and maybe @sfinkens (I think you did CF writer stuff?) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3453 +/- ##
==========================================
- Coverage 96.34% 96.33% -0.02%
==========================================
Files 465 465
Lines 59151 59153 +2
==========================================
- Hits 56990 56983 -7
- Misses 2161 2170 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
The original original issue was in Trollflow2, where we pass the format among Some relevant points in Trollflow2:
I actually don't follow anymore what's happening in the Trollflow2 code, and one of my goals with the Claude subscription would be to simplify it as much as possible. Remove all in-place product list operations and such. |
What
Fixes #2685:
save_datasets(writer='cf', fmt='nc', ...)raisedTypeError: Dataset.to_netcdf() got an unexpected keyword argument 'fmt'. Thefmtkwarg was forwarded verbatim into xarray'sDataset.to_netcdf(), which expectsformat, notfmt.Change
CFWriter.save_datasetsnow popsfmtfrom the forwarded kwargs and passes it through asformat, mapping the common'nc'shorthand to'NETCDF4'. Passing bothfmtandformatwith different values raises a clear error.Tests
test_save_array_fmt_nc_alias: saves withfmt='nc'and verifies the file round-trips. Fails on the previous implementation (TypeError; verified) and passes with the fix.test_cf.py: 32 passed. ruff clean.