Skip to content
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

Add test suites for met2Cf.csv.R #3301

Merged
merged 30 commits into from
Jun 5, 2024
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2ce9f80
Update test.met2CF.csv.R
Sweetdevil144 May 7, 2024
3d158c8
Merge branch 'develop' of https://github.com/Sweetdevil144/pecan into…
Sweetdevil144 May 7, 2024
62ec135
Merge branch 'PecanProject:develop' into develop
Sweetdevil144 May 11, 2024
bf27687
Merge branch 'develop' of https://github.com/Sweetdevil144/pecan into…
Sweetdevil144 May 16, 2024
508aabc
Update datetime in test.met2CF.csv.R
Sweetdevil144 May 16, 2024
15f9408
Merge branch 'PecanProject:develop' into develop
Sweetdevil144 May 17, 2024
f03eff1
Merge branch 'PecanProject:develop' into develop
Sweetdevil144 May 18, 2024
55ca543
Merge branch 'PecanProject:develop' into develop
Sweetdevil144 May 20, 2024
0e8f6cf
Merge branch 'PecanProject:develop' into develop
Sweetdevil144 May 24, 2024
0268b04
Update datetime to use lubridate
Sweetdevil144 May 28, 2024
9873b97
Merge branch 'PecanProject:develop' into develop
Sweetdevil144 May 30, 2024
2298a9b
Refactor csv import format in test.met2CF.csv.R for debugging
Sweetdevil144 May 30, 2024
c59a3f2
Refactor 'format' in test.met2CF.csv.R for debugging
Sweetdevil144 May 31, 2024
b130f66
Merge branch 'PecanProject:develop' into develop
Sweetdevil144 May 31, 2024
1466683
Format Specified correctly. Initial suites prepared
Sweetdevil144 May 31, 2024
eadb6ab
Finalized Initial Test suite
Sweetdevil144 May 31, 2024
7411603
Update lat lon
Sweetdevil144 May 31, 2024
efbcba4
Update File comments
Sweetdevil144 May 31, 2024
a7d30ea
Remove temporary variabels to directly implement them within test_fun…
Sweetdevil144 May 31, 2024
3bc9df0
Update datetime format to ISO
Sweetdevil144 Jun 2, 2024
ddf362a
Update data in csv filer to match ISO standards
Sweetdevil144 Jun 2, 2024
0a71e55
Removed unrequired comments
Sweetdevil144 Jun 2, 2024
9cee97e
Remove redundant comments
Sweetdevil144 Jun 2, 2024
d714068
Directly implement PEcAn.data.atmosphere
Sweetdevil144 Jun 2, 2024
994283f
Merge branch 'develop' into develop
Sweetdevil144 Jun 4, 2024
2e5cc63
Merge branch 'PecanProject:develop' into develop
Sweetdevil144 Jun 5, 2024
634b90f
Fixed bug catching datetime_units
Sweetdevil144 Jun 5, 2024
b931da3
Remove redundant variables
Sweetdevil144 Jun 5, 2024
6ae6b4d
Update input_units in test file
Sweetdevil144 Jun 5, 2024
942b8d5
Update modules/data.atmosphere/tests/testthat/test.met2CF.csv.R
infotroph Jun 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 52 additions & 12 deletions modules/data.atmosphere/tests/testthat/test.met2CF.csv.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,56 @@
context("testing csv import using met2CF.csv")

format <- list(orig = c("Corrected.Date.Time", "Solar.Radiation..W.m2.", "Temp..C.",
"PAR_.umol_m.2_s.1.", "PAR_.mol_m.2_h.1.", "RH....", "Wind.Speed..m.s.",
"VPD", "Rain..mm."),
units = c("mdy_hm", "W m-2","celsius",
"umol m-2 s-1", "mol m-2 h-1", "%", "m s-1", "Pa","mm h-1"),
bety = c("datetime", "solar_radiation", "airT",
"PAR", NA, "relative_humidity", "Wspd", NA, "precipitation_rate"),
skip = 0,
unit.row = TRUE,
na.strings = NA)
# met2CF.csv(in.path = "data", in.file = "met2CF.csv.csv", outfolder = tempdir(),
format <- list(
header = 1,
time_zone = "GMT",
time.row = 1,
skip = 0,
unit.row = TRUE,
na.strings = NA,
vars = list(
input_name = c(
"Corrected Date/Time", "Solar Radiation (W/m2)", "Temp (C)",
"PAR_(umol_m-2_s-1)", "PAR_(mol_m-2_h-1)", "RH (%)", "Wind Speed (m/s)",
"VPD", "Rain (mm)"
),
input_units = c(
NA, "W m-2", "celsius",
"umol m-2 s-1", "mol m-2 h-1", "%", "m s-1", "Pa", "mm h-1"
),
bety_name = c(
"datetime", "solar_radiation", "airT",
"PAR", NA, "relative_humidity", "Wspd", NA, "precipitation_rate"
),
storage_type = c(
"%m/%d/%y %H:%M", NA, NA, NA, NA, NA, NA, NA, NA
)
),
lat <- 42 + 47 / 60 + 30 / 6000,
lon <- 76 + 7 / 60 + 20 / 6000
)
# met2CF.csv(in.path = "data", in.file = "met2CF.csv.csv", outfolder = tempdir(),
# format = format,
# lat = 42 + 47/60 + 30/6000,
# lon = 76 + 7/60 + 20/6000)


outfolder <- tempdir()

# Initial test suite to test the met2CF.csv function
test_that("met2CF.csv function works correctly", {
output <- PEcAn.data.atmosphere::met2CF.csv(
in.path = "data",
in.prefix = "test.met2CF.csv.csv",
outfolder = outfolder,
start_date = lubridate::ymd_hm("2013-03-01 18:00"),
end_date = lubridate::ymd_hm("2013-03-27 17:00"),
format = format,
lat = format$lat,
lon = format$lon,
overwrite = TRUE
)
nc_files <- list.files(outfolder, pattern = "\\.nc$", full.names = TRUE)

expect_true(file.exists(nc_files))
expect_true(file.size(nc_files) > 0)
expect_equal(nc_files, file.path(outfolder, "test.met2CF.2013.nc"))
})
Loading