Repository navigation
Write the PCRaster header in the time series outputs - #349
Merged
Merged
Conversation
The station time series were written with noHeader=True, a form PCRaster documents as incompatible with its own tools, so every reader had to guess the station ids from the column position. The writer now keeps the PCRaster header (title, number of columns, timestep line, one line per station id) and tss2csv reads it before converting: a file without the header, with a truncated header, or whose column count or ids differ from the configured stations is refused naming both sides, and only the data rows are converted, so the CSV tables are byte for byte the same.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #349 +/- ##
==========================================
+ Coverage 92.58% 92.64% +0.05%
==========================================
Files 60 60
Lines 3953 3985 +32
Branches 497 502 +5
==========================================
+ Hits 3660 3692 +32
Misses 236 236
Partials 57 57 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Path.read_text accepts the newline argument only from Python 3.13 on; the test compared the exact CRLF text the CSV writer emits and failed to collect its argument on 3.12. Read the file through an explicit open with newline="" instead.
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.
Checklist
Description
noHeader=Falsein theTimeoutputTimeserieswriter): the title linetimeseries scalar, the number of columns, thetimestepline and one line per station id, followed by the data rows. A kept.tssfile is therefore readable by PCRaster's own tools, Aguila included.tss2csvreads that header before converting: a file without it (a first line that is not a title, a second line that is not a positive integer) is refused with a message saying the model writes headed files; a header that stops short of its announced column count, announces a column count different from the configured station ids, or lists other ids, is refused naming both sides. Only the data rows are converted, so the CSV tables are unchanged.tss_*.csvbefore and after the change compare equal withcmp, and the previous converter applied to the headed files with their header stripped produces the same bytes as the new converter on the headed files.tss2csvfixture writes the headed form; the refusals (no header, non-integer or non-positive count, truncated header, other ids, other count, zero-byte source); the CSV text of a headed file equals the one of the previous form; a run keepingPCRasterTSSleaves a.tsswhose header istimeseries scalar,3,timestep,1,2for the synthetic dataset; the converted table is exactly the column line plus one row per step..tssoutputs and the derivation of the CSV; changelog entry under Changed.Related Issue
Motivation and context
How has this been tested
python -m pytest -q -p no:cacheprovider --ignore=tests/integration/doc -n 2: 1011 passed, 1 skipped (Linux, Python 3.13, PCRaster 4.4.2); no.tssfile is part of the goldens and the CSV goldens are byte-identical.uvx ruff@0.16.4 format --check .anduvx ruff@0.16.4 check .: clean.sphinx-build -W -b html doc/sourcewith the documentation's Python 3.13 environment: no warnings.Screenshots