Closed kelleythompson closed 2 years ago
A new matlab script named StateTLgains.m was developed and added to the github matlab folder. This script runs the StateTL exe using a "StateTL -e" command line argument for every year in the multiyrlist in the control file to calculate and store hourly gains & losses for every year. The gain/loss amounts for each year are saved into a file named StateTL_data_gainsyr.mat (this includes both the subreach gagediffportion variable and the reach based gagedifflast variable). The StateTLgains reads these data and calculates the median hourly gain/loss/error for all the years and saves that as the binary file StateTL_data_gains.mat. For calibration, the StateTL script can then use the fixed/constant hourly gains/losses from this binary file within the simulation. It will average (or median) the hourly values based on the calibavggainloss method and gainsavgwindowdays parameters set in the control file (these are set to 'movingmedian' with a 30 day window which seemed to work well in initial testing. )
The use of the fixed/constant gains & losses can be managed with the control file in the following ways:
Currently, just one fixed/constant gains/loss/error (gagediffportion and gagedifflast) timeseries is established for use in the simulation runs. However, a future improvement might be to establish several timeseries based on if the year is wet, dry, or average. This could currently be implemented easily similar to the wet/dry/average that is used to fill Qnode; but that wet,dry,avg can currently vary through the year based on the gage flow and it might be best to fix one single year type for use for the whole year.
The gains datafile will need to be rebuilt if there are changes to the river network etc. Although the files can be rebuilt using the StateTLgains script - the rebuilding was also added to the StateTL -r command that is typically used to rebuild all datafiles. With the StateTL -r command, StateTL actually calls the StateTLgains compiled exe which in turn calls new instances of the StateTL script to rebuild the datafiles.
Added option so that gains/losses used in calibration are zero. To do this, the following options in the control file would be used:
calibavggainloss='zero'; (this is the new option) calibconstantgains=1; (same as to use averaged gains etc)
Added option to use constant/fixed gains/losses using original (ie Livingston) parameters for calibration year. Therefore, the gains/losses used in calibration are fixed and won't change based on changing calibration parameters but will hopefully be suited for the year that is being calibrated (ie if it is a wet/dry year and given return operations etc that happened). Gains/losses were previously calculated for every year in the multiyrlist using the StateTLgains.m script to use with the calibconstantgains=1 option. The same/resulting StateTL_data_gainsyr.mat is required in the StateTLdata folder. This option uses those annual gain/losses but averages as specified over the specified period. To do this, the following options in the control file would be used:
calibavggainloss='movingmedian'; calibconstantgains=2; (this is the new option)
Previously, during calibration the riverloop was rerun and gains/losses recalculated given the changed calibration parameters; then the gains/losses were averaged over some moving window for use in the actual simulation (had been using moving centered median over 14 days). However, it was decided that perhaps the gains and losses should be made entirely independent of the calibration. Therefore, an option was added to fix the gains/losses so they don't change between calibration runs.