cct-datascience / ed2-mandifore

PEcAn.ED2 runs using MANDIFORE site, patch, cohort, and met data
0 stars 1 forks source link

debug model2netcdf.ED2() #39

Closed Aariq closed 1 year ago

Aariq commented 1 year ago

For some reason model2netcdf.ED2() fails for the prairie run at site 1123 for ensemble member 1 at 2003.

> model2netcdf.ED2(
       # .x,
       outdirs[[1]],
       29.365195,
       -82.810137,
       '2002-06-01',
       '2012-06-30',
       c(
         SetariaWT = 1L,
         sentinel_ebifarm.c3grass = 5L,
         sentinel_ebifarm.c4grass = 16L,
         ebifarm.forb = 12L
       ),
       process_partial = TRUE
     )

2023-03-20 14:57:05 INFO   [model2netcdf.ED2] : 
   ----- Processing year: 2002 
2023-03-20 14:57:05 INFO   [read_E_files] : 
   *** Reading -E- file *** 
2023-03-20 14:57:15 INFO   [model2netcdf.ED2] : 
   *** Writing netCDF file *** 
2023-03-20 14:57:15 INFO   [model2netcdf.ED2] : 
   ----- Processing year: 2003 
2023-03-20 14:57:15 INFO   [read_E_files] : 
   *** Reading -E- file *** 
2023-03-20 14:57:25 INFO   [model2netcdf.ED2] : 
   *** Writing netCDF file *** 
Error in ncdf4::ncvar_put(nc = nc, varid = varid, vals = vals, start = start,  : 
  ncvar_put: error: you asked to write 48 values, but the passed data array only has 44 entries!
In addition: Warning message:
Returning more (or less) than 1 row per `summarise()` group was deprecated in dplyr 1.1.0.
ℹ Please use `reframe()` instead.
ℹ When switching from `summarise()` to `reframe()`, remember that `reframe()` always returns an ungrouped
  data frame and adjust accordingly.
ℹ The deprecated feature was likely used in the PEcAn.ED2 package.
  Please report the issue to the authors.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated. 
Aariq commented 1 year ago

Similar error with ensemble 2 but at year 2010:

Error in ncdf4::ncvar_put(nc = nc, varid = varid, vals = vals, start = start,  : 
  ncvar_put: error: you asked to write 48 values, but the passed data array only has 44 entries!
In addition: Warning messages:
1: There were 6 warnings in `dplyr::summarize()`.
The first warning was:
ℹ In argument: `dplyr::across(dplyr::everything(), function(.x) matrix(.x, ncol = n_pft))`.
Caused by warning in `matrix()`:
! data length [46] is not a sub-multiple or multiple of the number of rows [12]

So something to do with matrix().

Aariq commented 1 year ago

Looks like sometimes not all PFTs end up in the output, an assumption I had made. 2003-08-01 through 2008-11-01 only have 3 PFTs after going through extract_E_file()

Aariq commented 1 year ago

PR: https://github.com/PecanProject/pecan/pull/3140

Aariq commented 1 year ago

Apparently https://github.com/PecanProject/pecan/pull/3140 didn't fix it entirely. Now getting a similar error in 2002 for ensemble number 6:

   ----- Processing year: 2002 
2023-03-21 09:06:09 INFO   [read_E_files] : 
   *** Reading -E- file *** 
2023-03-21 09:06:12 INFO   [model2netcdf.ED2] : 
   *** Writing netCDF file *** 
Error in ncdf4::ncvar_put(nc = nc, varid = varid, vals = vals, start = start,  : 
  ncvar_put: error: you asked to write 48 values, but the passed data array only has 36 entries!
Calls: model2netcdf.ED2 ... var_put -> <Anonymous> -> withVisible -> <Anonymous>
Execution halted
ERROR IN model2netcdf.ED2

Also in ENS 10 in 2001, ENS 20 in 2002,