-
Notifications
You must be signed in to change notification settings - Fork 308
Remove conversion and checkTemp helpers per TODO #3853
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
Open
Thomas-Sedhom
wants to merge
3
commits into
PecanProject:develop
Choose a base branch
from
Thomas-Sedhom:refactor/ed2-inline-conversion-checktemp
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't write this comment (that was probably @serbinsh years ago), but I recommend against it -- inline ifelse statements get messy fast and don't show intent as well as named helpers.
But while I'm looking at it, a higher-level fix that would eliminate the need for these operations would be to set all the missing values in
outto literal NAs instead of -999. Then numeric conversions can be done on whole columns without worrying about disturbing the missing value flags, and the ncdf4 library will handle them automatically.This suggestion does assume
outis only written to netcdf and not passed to any other processes that need the missing values to be -999, so someone who knows the ED model should weigh in on whether that's true. Even if it does get passed elsewhere, it may still be cleaner overall to convert the NAs once at the end rather than work around them when converting each column.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a closer look at the data flow in
model2netcdf.ED2.R. From what I found, the out object built byread_T_files() / read_E_files()is mainly used as an intermediate step before writing toNetCDF, and I did not find any internal code path in this repo where it is passed to otherEDprocessing that specifically depends on -999.I also noticed that the
E-filepath already seems to rely on NA internally in some places and still writesNetCDFvariables withmissval = -999, so your suggestion looks reasonable to me. The main remaining concern seems to be whether changingread_T_files()output from -999 to NA would affect any external callers, since these helper functions are exported. If that concern is not important, I agree that using NA internally and only handling missing values at theNetCDFboundary would likely be cleaner.