OpenCDSS / cdss-app-statedmi-main

StateDMI main application, tests, and documentation
GNU General Public License v3.0
1 stars 0 forks source link

SetCropPatternTSFromList not reading from .csv #107

Open macphersonbr opened 2 years ago

macphersonbr commented 2 years ago

This issue is in StateDMI 5.1.0.dev but does not appear in 5.00.03dev (so was introduced somewhere between these versions). When creating a .cds file, the command SetCropPatternTSFromList is not reading the acreage from the .csv provided. Files attached to test. Command file is \Crops\sj2020.cds.stateDMI. Using HydroBase_CO_20210322.

sj2020_StateDMI_Issue28.zip

smalers commented 2 years ago

Several changes have occurred to the command over time in response to testing. I believe what is going on is that the MancosStructures_StateMod.csv file specifies the crops types including the .TR21. However, the crop types from HydroBase do not include this extension. Therefore, what happens is the HydroBase value 51.7 in 1993 and 58.8 in 2005, 2010, and 2015 are read using GRASS_PASTURE. Then, the list file has 74.94156744 for GRASS_PASTURE.TR21, which is considered a different crop because of the TR21 at the end of the crop type. Fill commands fills 51.7 back in time. Therefore the 1909 value is 51.7 plus 74.94156744, which is 126.6. And, 2005 is 58.8 + 74.94156744 = 133.7. The commands translate the crop type without TR21 to add TR21 later in the command file, which adds the values to result in a single value.

The fix is to remove the TR21 from the csv file, or move the command later in the workflow so that crop types with the extension are manipulated. I don't think the current software needs to be changed.

I'll wait on comments from Brian to close this. I'm not sure that any warning can be put in place since the current software is doing what is asked.

Also, it is helpful to insert a StartLog command as the first command so that a log file is created. I usually name the log file as the same as the command file with .log at the end.