-
Notifications
You must be signed in to change notification settings - Fork 239
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
Bugfixes for model2netcdf.ED2()
#2985
Conversation
@dlebauer, I'd like to look at the resulting .nc files with you and figure out if they're correct before merging this PR. |
.nc outputs don't have PFT as a dimension for variables that probably should have that dimension, but I think this is a separate issue for a different PR, so this PR is ready now. |
Move ED2 internal data to unexported sysdata.rda
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.
Wow. Nice work!!! 👏🏻👏🏻👏🏻👏🏻
Thanks for taking the time to understand and improve how these functions work and to re-enable and add tests!
all test / check errors are 'Error: These files have changed since checkout. Check for out-of-sync autogenerated files, or for untracked files written inside the working tree' TODO
|
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.
@Aariq Sorry again for my long delay in reviewing -- As long as I typed them already, I'm posting the incomplete comments that I started before this was merged but then failed to post in time for them to be useful to you 😬
None of my comments are showstoppers, and in fact as I type this I realize my proposed dir.create
additions in the tests aren't strictly needed because the unzip
below them does the directory creation for us.
test_that("Met conversion runs without error", { | ||
outdir <- tempfile() #creates a directory |
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.
tempfile gives a name but doesn't actually create a file there!
outdir <- tempfile() #creates a directory | |
outdir <- tempfile() | |
dir.create(outdir, showWarnings = FALSE) |
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.
Looks like getting files and directories mixed up. Might be:
outfile <- tempfile()
file.create(outfile, showWarnings = FALSE)
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.
the intention here was to create a directory and I was instructed (by someone, forgot who) to use tempfile()
to do this. I think a better way is probably to use a sub-directory in tempdir()
. Might change it in the next PR.
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.
the good thing is that you are guaranteed this way to have a unique tempfolder, while if you create it you need to keep track how often this function has been called to make sure the folder you create is unique.
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.
It is unique to the R session, but doesn't change between calls
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.
@Aariq I think I'm the one who said to use tempfile(), which does default to being inside the session temp directory... the gotcha is that what it returns is "here's a path that will be unique if you create a file-or-directory there" rather than a path it has created.
The other, maybe bigger gotcha is that tempdir()
and tempfile()
are such similarly named functions that do such completely different things. That's one of my top nominees for items that should be in the Inferno but aren't yet.
context("check output from model2netcdf.ED2") | ||
library(stringr) | ||
#set up tempdir | ||
outdir <- tempfile() |
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.
outdir <- tempfile() | |
outdir <- tempfile() | |
dir.create(outdir, showWarnings = FALSE) |
Description
Went down a bit of a rabbit hole on this one...
Fixes several bugs related to
model2netcdf.ED2()
. The end goal is to fix #2974, but ended up having to deal with other issues along the way.PEcAn.utils::mstmipvar()
where there were nonePEcAn.utils::mstmipvar()
mstmipvar()
to NULL instead of NA (why this is a good practice: https://stackoverflow.com/a/29620701). This is to fixPEcAn.utils::mstmipvar()
condition has length > 1 error #2981settings
argument in test/testthat/datamodel2netcdf.ED2()
only reading one PFT (model2netcdf.ED2()
only converts data for first PFT #2974) (and adds tests)pfts
and the change to using thesettings$pfts
list was never completed.pftmapping
dataset withusethis::use_data()
and documented it. Surprised that it still gives a "global variables" type warning without explicitly assigning it 🤷♂️usethis::use_data_raw()
to set up infrastructure to keep pftmapping.csv and convert to package dataset.Motivation and Context
model2netcdf.ED2()
was brokenReview Time Estimate
Types of changes
Unsure if new
NULL
defaults formstmipvar
args will cause problems anywhere elseChecklist:
Should I add a NEWS file to PEcAn.ED2?
Should I increment the version of PEcAn.ED2?