Conversation
bpbond
reviewed
Dec 31, 2025
Member
bpbond
left a comment
There was a problem hiding this comment.
Question -- do we want to be constantly changing the precision of the stream?
| if (!core->outputEnabled(c->getComponentName())) | ||
| return; | ||
| streamsize oldPrecision = csvFile.precision(4); | ||
| csvFile.precision(15); |
Member
There was a problem hiding this comment.
Why do this at all here? Should we simply set the precision we want when the stream is opened and leave it?
Contributor
Author
There was a problem hiding this comment.
oh good point! so would that be in the main.cpp file? where the stream is opened? Or part of the CSVOutputStreamVisitor constructor?
Contributor
Author
|
@bpbond does this look correct? |
bpbond
approved these changes
Jan 16, 2026
Draft
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.
This PR addresses a rounding issue that is only relevant to the CSV output stream & addresses an inline TODO item related to the csvouput stream visitor.
The Problem
While working on #795, I realized that there were some numerical differences between Hector results written out by the CSV output stream visitor vs. fetched via R.
When we compare the numerical results from hector output via R vs. csv outputter the overall summary table absolute error (this is across multiple scenarios & variables)
Of the 80 variables considered 57 of them had a MAE > 1E-6
Looking at the variable with the largest error, DO ocean C, while the relative MAE of 4.999791. A visual comparison of DO ocean C reveals a step like behavior in the csv result which seems odd and is most likely due to rounding.
Same data but different perspective.
the solution
It turns out the csvFile has a default precision level of 6 whereas typical C++ double precision is 16. Since R was pulling directly from the C++ precision level we needed to make sure that the csvFile was using the same precision level.
After changing the precision level of the csvFile the MAE between R and the csv output the MAE is now 1.035752e-13. Which is much better! And now no longer see the step behavior we were seeing before.