HARPgroup / cbp_wsm

1 stars 0 forks source link

recalibrate southern rivers with NLDAS2 met #40

Open rburghol opened 2 years ago

rburghol commented 2 years ago

Overview

Functions

Basic Procedure

Test Cases

Detailed Modifications/Investigations

Steps Followed

cbp copy_params.csh p532cal_062211 p532sova_2021
cbp copy_PWATER_params.csh p532cal_062211 p532sova_2021
# created by RWB to duplicate a scenario
cbp copy_river_scenario_params.csh p532cal_062211 p532sova_2021
cbp make_land_directories.csh p532sova_2021
cbp make_river_directories.csh p532sova_2021
# copy calib allows this scenario to be the "calibscen" argument
# so, if we run PWATER_opt* with 2nd argument as p532sova_hydro 
# we must first have run a copy_calib for that name
cbp copy_calib.csh p532hydro p532sova_hydro 
# created by RWB to duplicate a scenario
# only do this once.
# cbp copy_land_control.csh p532cal_062211 p532sova_2021
# cbp copy_river_control.csh p532cal_062211 p532sova_2021
# then edit the con files to have correct dates, etc.

#Test the model:
cbp run_all.csh p532sova_cal OR2_8130_7900
# Recalibrate:
cbp compile_PWATER_opt.csh p532sova_hydro
cbp run_PWATER_optimization.csh p532sova_2021 p532sova_hydro OR2_8130_7900
rburghol commented 2 years ago

Debugging error:

problem opening file:
../../../config/control/river/.con

-postproc/river/stats/main.f

# load some standard path variables
. hspf_config
cd $CBP_SRC
nano postproc/river/stats/main.f
# recompile
./comp_rstats.csh
cd $CBP_BIN/calibration/PWATER
./run_postproc_flow_calib.csh p532sova_2021 p532sova_2021 MN0_8300_0001
rburghol commented 2 years ago

Tried to expand the parms read in the river basin to run only 1 watershed from a custom seglist echo p532sova_hydro p532sova_2021 MN0 | $CBP_ROOT/code/bin/calib_iter_PWATER_params_p532sova_hydro.exe

MOdify steps:

nano /opt/model/p53/p532c-sova/code/src/calibration_utils/change_param/calib_iter/PWATER/main.f
# recompile
./comp_rstats.csh'
cd $CBP_BIN/calibration/PWATER
./compile_PWATER_opt.csh p532sova_hydro
# test
./test_adjust.csh p532sova_2021 p532sova_hydro MN0_8300_0001

Changed:

      basin = calscen(:lencalscen)//'_'//module

to:

      read(*,*,IOSTAT=arginfo) calscen,rscen,basin
      if (arginfo < 0) then
        basin = calscen(:lencalscen)//'_'//module
        print*,'Basin auto:',basin
      else
        print*,'Basin arg:',basin
      end if
rburghol commented 2 years ago

Working on adapting scripts to recalibrate a single basin only, versus a custom list of all.

# edit this code 
cd $CBP_SRC
nano /opt/model/p53/p532c-sova/code/src/calibration_utils/change_param/calib_iter/PWATER/main.f
./comp_rstats.csh
cd $CBP_BIN/calibration/PWATER/ 
# create the custom copy of the adjust params script
./compile_PWATER_opt.csh p532sova_hydro    
# run the final param adjust step (since we've already successfully mae through an iteration)
 echo p532sova_hydro p532sova_2021 MN0_8300_0001 | $CBP_ROOT/code/bin/calib_iter_PWATER_params_p532sova_hydro.exe

Fails on "orphans" list, in function getorphans() in nano ./calibration_utils/change_param/calib_iter/PWATER/getall.f cp /opt/model/p53/p532c-sova/config/control/calib/PWATER/p532hydro/p532hydro_orphans.csv /opt/model/p53/p532c-sova/config/control/calib/PWATER/p532sova_hydro/p532sova_hydro_orphans.csv

rburghol commented 2 years ago
 DEBUG: getRstats() reading statline MN0_8300_0001,   0.045,   1.053,   0.980,   0.715,   1.319,   0.404,   0.288,   0.826,   0.961,   1.060,  -0.215,  -0.130,   1.035,   1.162,  46.328,  43.923,
 DEBUG: getRstats() reading statline again with nr =         8300
 DEBUG: getRstats() uniquindex(nr) =            1
 DEBUG: getRstats() returned from read(Tbias...)
 DEBUG: getRstats() facLandEvap() Wstat(1):    1.05299997
 DEBUG: returned getRstats
 all accounting
 A51800
rburghol commented 2 years ago

Because of above https://github.com/HARPgroup/cbp_wsm/issues/40#issuecomment-1024615552 bad string handling of river segment in stats file must be problem.

cd $CBP_SRC
 nano ./postproc/postutils/sumstats/main.f
 ./comp_rstats.csh
cd $CBP_BIN/calibration/PWATER

nano ./postproc/postutils/sumstats/make1type.f

***   This file "11" must be opened somewhere else? looking for
***   list of river segments? must find file 11!
*** File 11 is the bias file.
        read(11,'(a200)',end=222) longline
        ns = ns + 1
***   Check here
      do i=1,len(longline)
***     now we go through and extract each river seg, which are
***     delimited by slashes '/', stash in segments
        if (longline(i:i).eq.'/') segment(ns)=longline(i+1:i+13)
rburghol commented 2 years ago

debug param adjust error

rburghol commented 2 years ago

Create new calibration holder:

cbp copy_params.csh p532sova_2021 p532sova_cal
cbp copy_PWATER_params.csh p532sova_2021 p532sova_cal
# created by RWB to duplicate a scenario
cbp copy_river_scenario_params.csh p532cal_062211 p532sova_cal
cbp make_land_directories.csh p532sova_cal
cbp make_river_directories.csh p532sova_cal
cbp copy_calib.csh p532hydro p532sova_cal
# created by RWB to duplicate a scenario
cbp copy_land_control.csh p532sova_2021 p532sova_cal
cbp copy_river_control.csh p532sova_2021 p532sova_cal
# edit land and river con files (see below)
fgrep OR1_8280_8020 output/river/summary/p532sova_cal_sum_stats_*
#Test the model:
cbp run_all.csh p532sova_cal OR2_8130_7900
# Recalibrate:
cbp compile_PWATER_opt.csh p532sova_hydro
cbp run_PWATER_optimization.csh p532sova_cal p532sova_hydro OR2_8130_7900
# follow the recalibration for a single segment:
fgrep OR1_8280_8020 output/river/summary/p532sova_cal_sum_stats_*

Edit land control nano config/control/land/p532sova_cal.con

PARAMETERS
p532sova_cal
END PARAMETERS
...
CALIBSCEN
p532sova_cal
END CALIBSCEN

Edit river control nano config/control/river/p532sova_cal.con

PARAMETERS
p532sova_cal
END PARAMETERS
...
CALIBSCEN
p532sova_cal
END CALIBSCEN
rburghol commented 2 years ago

This changes params, but makes things worse and worse (instead of better): cbp run_PWATER_optimization.csh p532sova_cal p532sova_cal OR2_8130_7900

rburghol commented 2 years ago

Run a full basin to see if this eliminates calibration divergence (instead of convergence)

# reset the params
cbp copy_PWATER_params.csh p532sova_2021 p532sova_cal
# run the calibration 
cbp run_PWATER_optimization.csh p532sova_cal p532sova_cal OR7_8490_0000