dleutnant / swmmr

R Interface for US EPA's SWMM
https://cran.r-project.org/package=swmmr
39 stars 15 forks source link

read_out(), actual & potential evaporation labelled wrong #111

Open schuetzpaul opened 1 year ago

schuetzpaul commented 1 year ago

When using the read_out() function to load the system variable of potential & actual evaporation, they are labelled the wrong way around.

The loaded data of actual evaporation has higher values than potential evaporation, which i) is not possible in reality and ii) also don't represent the results of the SWMM model if they get opened through the application.

potential_evap <- swmmr::read_out("00_template.out",
                                  iType = 3,
                                  vIndex = 13)

actual_evap <- swmmr::read_out("00_template.out",
                               iType = 3, 
                               vIndex = 14)
hsonne commented 1 year ago

In the C source code of the current SWMM version (https://www.epa.gov/system/files/other-files/2023-03/swmm523_engine.zip) I found the following:

enum SysFlowType {
     SYS_TEMPERATURE,                  // air temperature
     SYS_RAINFALL,                     // rainfall intensity
     SYS_SNOWDEPTH,                    // snow depth
     SYS_INFIL,                        // infil
     SYS_RUNOFF,                       // runoff flow
     SYS_DWFLOW,                       // dry weather inflow
     SYS_GWFLOW,                       // ground water inflow
     SYS_IIFLOW,                       // RDII inflow
     SYS_EXFLOW,                       // external inflow
     SYS_INFLOW,                       // total lateral inflow
     SYS_FLOODING,                     // flooding outflow
     SYS_OUTFLOW,                      // outfall outflow
     SYS_STORAGE,                      // storage volume
     SYS_EVAP,                         // evaporation
     SYS_PET};                         // potential ET

According to this, vIndex should have the following meaning:

So, you are right, 13 refers to the actual and 14 to the potential evapo(transpi)ration. I wonder why it was documented differently by @dleutnant for the read_out() function. Maybe something changed between different SWMM versions?

hsonne commented 1 year ago

By the way, you can read both variables at the same time and have them next to each other in the output:

sys_evap <- swmmr::read_out(
  "00_template.out",
  iType = 3,
  vIndex = 13:14, 
  multiColumn = TRUE
)

head(sys_evap$system_variable)
                    potential_evaporation actual_evaporation
2017-01-01 00:05:00                     0              0.447
2017-01-01 00:10:00                     0              0.447
2017-01-01 00:15:00                     0              0.447
2017-01-01 00:20:00                     0              0.447
2017-01-01 00:25:00                     0              0.447
2017-01-01 00:30:00                     0              0.447

This makes it even more clear that you are right.