-
Notifications
You must be signed in to change notification settings - Fork 311
Replace manual unit conversions with ud_convert() for consistency across models #3719
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
Merged
Merged
Changes from 53 commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
5599e09
Replace manual unit conversions with ud_convert()
ayushman1210 2fc0106
Update models/stics/R/met2model.STICS.R
ayushman1210 c425ca7
Update models/sipnet/R/write_restart.SIPNET.R
ayushman1210 747277a
Merge branch 'develop' into fix
ayushman1210 c29e56f
fixes done as per maintainer suggestion
ayushman1210 a2d79d5
Merge branch 'fix' of https://github.com/ayushman1210/pecan into fix
ayushman1210 8e2b0a4
Merge branch 'develop' into fix
ayushman1210 aa8f2d4
Update models/dalec/R/model2netcdf.DALEC.R
ayushman1210 e6ad156
Update models/dalec/R/model2netcdf.DALEC.R
ayushman1210 0c2bb74
Update models/gday/R/model2netcdf.GDAY.R
ayushman1210 1aeddf7
Update tests/testthat/test_model_conversions.R
ayushman1210 570b899
Update tests/testthat/test_model_conversions.R
ayushman1210 9970af2
Update tests/testthat/test_model_conversions.R
ayushman1210 476de3d
Update tests/testthat/test_model_conversions.R
ayushman1210 2fdc5d9
Merge branch 'develop' into fix
infotroph 46773d1
Merge branch 'develop' into fix
ayushman1210 20bd418
changes as suggested by the maintainer
ayushman1210 adecf54
suggested changes
ayushman1210 6ecf394
Merge branch 'develop' into fix
ayushman1210 10950c9
Merge branch 'develop' into fix
ayushman1210 a21b66f
Merge branch 'develop' into fix
ayushman1210 a7d584a
Merge branch 'develop' into fix
ayushman1210 f78452c
Merge branch 'develop' into fix
ayushman1210 c7786e6
Merge branch 'develop' into fix
ayushman1210 c84dc76
Merge branch 'develop' into fix
ayushman1210 3b1d45d
Merge branch 'develop' into fix
infotroph ae48649
Update models/fates/R/write.configs.FATES.R
ayushman1210 4d9ca18
Update models/fates/R/write.configs.FATES.R
ayushman1210 b63051f
Update models/sipnet/R/model2netcdf.SIPNET.R
ayushman1210 014e58f
Update models/fates/R/write.configs.FATES.R
ayushman1210 d0f49ee
Update models/fates/R/write.configs.FATES.R
ayushman1210 73db407
Merge branch 'develop' into fix
ayushman1210 785d156
removed testthat.R updated model2netcdf.SIPNET.R updated model2netcdf…
ayushman1210 de366f6
Fix: Skip Docker push on forks to avoid ghcr.io authentication errors
ayushman1210 ec3c96c
Add GDAY unit conversion tests and clean up redundant test files
ayushman1210 6ac287a
Add unit tests for SIPNET model2netcdf unit conversion changes
ayushman1210 136db35
Clarify GDAY unit conversion: daily Mg/ha/day not per-year
ayushman1210 05f6735
Merge branch 'develop' into fix
ayushman1210 174728b
Update models/sipnet/tests/testthat/test.model2netcdf.SIPNET.R
ayushman1210 bef3eb8
Address maintainer feedback: revert workflow changes, fix GDAY refere…
ayushman1210 12539c6
Update SIPNET test to exercise model2netcdf.SIPNET() directly, addres…
ayushman1210 cfa5d1d
Update GDAY test to exercise model2netcdf.GDAY() directly, addressing…
ayushman1210 4d2a612
Fix undefined THA_2_KG_M2 in GDAY model2netcdf by using ud_convert
ayushman1210 b8d8130
Fix GDAY unit conversion test to use manual calculation instead of pr…
ayushman1210 4427363
fixed the ci-failure
ayushman1210 4ba11dc
Merge branch 'develop' into fix
ayushman1210 b982d92
Merge branch 'develop' into fix
ayushman1210 df85039
Update models/gday/tests/testthat/test.model2netcdf.GDAY.R
ayushman1210 d7b2434
Update models/gday/R/model2netcdf.GDAY.R
ayushman1210 110ffef
Update models/gday/R/model2netcdf.GDAY.R
ayushman1210 dbeaf47
Merge branch 'develop' into fix
ayushman1210 3502db0
Standardize unit conversions and fix tests for PR #3719
ayushman1210 d7e5ef3
Add TODO comment for woodCreation in SIPNET
ayushman1210 eab202c
Update models/sipnet/R/model2netcdf.SIPNET.R
infotroph 68421f3
update deps
infotroph da2fab8
Merge branch 'develop' into fix
ayushman1210 bdd4a76
hack around test failure until full V2 support replaces this
infotroph b280b19
more conditionals
infotroph b972c26
Merge branch 'develop' into fix
infotroph 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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # GDAY output | ||
| year,day,auto_resp,hetero_resp,gpp,nep,npp,stem,branch,soilc,lai,et,transpiration | ||
| 2004,1,0.01,0.02,0.05,-0.03,0.03,100,50,200,2,0.5,0.3 | ||
| 2004,2,0.01,0.02,0.05,-0.03,0.03,100,50,200,2,0.5,0.3 | ||
| 2004,3,0.01,0.02,0.05,-0.03,0.03,100,50,200,2,0.5,0.3 | ||
| 2004,4,0.01,0.02,0.05,-0.03,0.03,100,50,200,2,0.5,0.3 | ||
| 2004,5,0.01,0.02,0.05,-0.03,0.03,100,50,200,2,0.5,0.3 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| ##' Test for GDAY model2netcdf unit conversions | ||
| ##' | ||
| ##' This test verifies that the unit conversions in model2netcdf.GDAY are correct. | ||
| ##' | ||
| ##' Reference: https://github.com/PecanProject/pecan/pull/3719 | ||
| ##' GDAY outputs daily values in Mg/ha/day, which should be converted to kg/m2/s | ||
| ##' | ||
| ##' Conversion factors: | ||
| ##' 1 Mg/ha = 0.1 kg/m2 (area conversion) | ||
| ##' 1 day = 86400 seconds | ||
| ##' Therefore: 1 Mg/ha/day = 0.1 / 86400 kg/m2/s = 1.157e-6 kg/m2/s | ||
|
|
||
| context("GDAY model2netcdf unit conversions") | ||
|
|
||
| test_that("model2netcdf.GDAY runs without error and produces netCDF", { | ||
| outdir <- withr::local_tempdir() | ||
| file.copy("data/gday_out.csv", outdir) | ||
|
|
||
| # Run the function | ||
| expect_silent( | ||
| model2netcdf.GDAY( | ||
| outdir = outdir, | ||
| sitelat = 40, | ||
| sitelon = -88, | ||
| start_date = "2004-01-01", | ||
| end_date = "2004-12-31" | ||
| ) | ||
| ) | ||
|
|
||
| # Check that netCDF file is created | ||
| nc_file <- file.path(outdir, "2004.nc") | ||
| expect_true(file.exists(nc_file)) | ||
|
|
||
| # Check that we can read the output | ||
| output <- PEcAn.utils::read.output( | ||
| ncfiles = nc_file, | ||
| variables = c("GPP", "AbvGrndWood"), | ||
| dataframe = TRUE, | ||
| verbose = FALSE, | ||
| print_summary = FALSE | ||
| ) | ||
| # GPP should be in kg/m2/s (converted from Mg/ha/day) | ||
| secs_day <- 86400 | ||
| kg_Mg <- 1000 | ||
| m2_ha <- 10000 | ||
| gday2pecan <- kg_Mg/m2_ha/secs_day | ||
| expect_equal(nrow(output), 5) | ||
| expect_equal(output$GPP, rep(0.5, 5) * gday2pecan, tolerance = 1e-6) | ||
|
|
||
| # AbvGrndWood is a stock (Mg/ha), not a flux (Mg/ha/day). | ||
| # Conversion: 1 Mg/ha = 0.1 kg/m2 | ||
| stock_conv <- 0.1 | ||
| expect_equal(output$AbvGrndWood, rep(150, 5) * stock_conv, tolerance = 1e-6) | ||
| }) | ||
|
ayushman1210 marked this conversation as resolved.
|
||
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.