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

weather data use during simulations is corrupted #93

Closed
dschlaep opened this issue Dec 12, 2017 · 1 comment · Fixed by DrylandEcology/SOILWAT2#108
Closed

weather data use during simulations is corrupted #93

dschlaep opened this issue Dec 12, 2017 · 1 comment · Fixed by DrylandEcology/SOILWAT2#108

Comments

@dschlaep
Copy link
Member

Commit DrylandEcology/SOILWAT2@85d2836 screwed up the weather data access during simulations.

library("rSOILWAT2")
path_demo <- system.file("extdata", "example1", package = "rSOILWAT2")
sw_in2 <- sw_inputDataFromFiles(dir = path_demo, files.in = "files.in")

The weather data are identical and present

> sw_in2@weatherHistory[[1]]@data[1:3, ]
     DOY Tmax_C Tmin_C PPT_cm
[1,]   1  -0.52 -15.67   0.22
[2,]   2  -2.06  -7.86   0.72
[3,]   3  -4.04 -14.47   0.22

Output with commit DrylandEcology/SOILWAT2@85d2836

> sw_out2 <- sw_exec(inputData = sw_in2)
WARNING: weath.1980 : Missing max temp on doy=1.
WARNING: weath.1980 : Missing min temp on doy=1.
WARNING: weath.1980 : Missing PPT on doy=1.
WARNING: weath.1980 : Missing max temp on doy=2.

Output with commit DrylandEcology/SOILWAT2@35c924a

> sw_out2 <- sw_exec(inputData = sw_in2)
> sw_out2@TEMP@Year[1:3, ]
      Year    max_C     min_C    avg_C surfaceTemp_C
 [1,] 1980 13.12448 -4.074754 4.524863             0
 [2,] 1981 14.21397 -3.032931 5.590521             0
 [3,] 1982 11.50699 -5.125288 3.190849             0
...
@dschlaep dschlaep added this to the master milestone Dec 12, 2017
@dschlaep dschlaep self-assigned this Dec 12, 2017
@dschlaep
Copy link
Member Author

The problem lies in the function onSet_WTH_DATA. Eliminating the compile warnings exposed problems in the code, here testing an unused variable for a 'missing' value -- and always finding it 'missing because unused.

The question remains why this was not picked up by unit tests.

dschlaep added a commit to DrylandEcology/SOILWAT2 that referenced this issue Dec 13, 2017
dschlaep added a commit that referenced this issue Dec 13, 2017
- addressing #93
- unit tests that check that simulation output is not all 0

> rSOILWAT2 annual aggregation:
....12.34.56...........78.9a........bc.de....fg.......hi.jk..........lm.
...no...........pq.rs........tu.vw....xy.......zA.........

Failed ----------------------------------------------------------------
1. Failure: Simulate and aggregate (@test_exec_and_aggregate.R#61) ----
sum(x1@Day[, -(1:2)]) > 0 isn't true.
test-data Ex1 - slot TEMP

2. Failure: Simulate and aggregate (@test_exec_and_aggregate.R#62) ----
sum(x1@Year[, -1]) > 0 isn't true.
test-data Ex1 - slot TEMP
...
dschlaep added a commit that referenced this issue Dec 13, 2017
- close #93

- patch version bump
- example/test-data updated

- unit tests pass
> rSOILWAT2 annual aggregation:
........................................................................
..........................................................
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant