Skip to content

Commit

Permalink
Functionality for gauge-evaluate only option
Browse files Browse the repository at this point in the history
Made changes to the streamflow obs convertor to allow
for evaluate only option for gauges that are not desired
(i.e., gauges user didn't select but are part of the USGS network
in the domain)
  • Loading branch information
mgharamti committed Oct 26, 2023
1 parent 8161725 commit 76a3bf7
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions models/wrf_hydro/create_identity_streamflow_obs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ program create_identity_streamflow_obs
integer, parameter :: NUM_COPIES = 1 ! number of copies in sequence
integer, parameter :: NUM_QC = 1 ! number of QC entries
real(r8), parameter :: MIN_OBS_ERR_STD = 0.1_r8 ! m^3/sec
real(r8), parameter :: MAX_OBS_ERR_STD = 100000.0_r8
real(r8), parameter :: MAX_OBS_ERR_STD = 1000000.0_r8
real(r8), parameter :: NORMAL_FLOW = 10.0_r8
real(r8), parameter :: contract = 0.001_r8

Expand Down Expand Up @@ -104,7 +104,7 @@ program create_identity_streamflow_obs
real(r8), allocatable :: discharge(:)

character(len=IDLength), allocatable :: desired_gages(:)
integer :: n_wanted_gages
integer :: n_wanted_gages, n_desired_gages
real(r8) :: oerr, qc
integer :: oday, osec
type(obs_type) :: obs
Expand Down Expand Up @@ -209,9 +209,18 @@ program create_identity_streamflow_obs
call init_obs(obs, num_copies=NUM_COPIES, num_qc=NUM_QC)
call init_obs(prev_obs, num_copies=NUM_COPIES, num_qc=NUM_QC)

n_wanted_gages = set_desired_gages(gages_list_file)
! MEG 6/29/23 [Commented out set_desired_gages(gages_list_file)]
! Collect all the gauges:
! - desired ones will have the provided obs_err_sd
! - remaining gauges are dummy with very large obs_err_sd

n_desired_gages = set_desired_gages(gages_list_file)
n_wanted_gages = 0 !set_desired_gages(gages_list_file)
call find_textfile_dims(input_files, nfiles)

print *, gages_list_file
print *, 'n_wanted_gages: ', n_wanted_gages

num_new_obs = estimate_total_obs_count(input_files, nfiles)

inquire(file=output_file, exist=file_exist)
Expand Down Expand Up @@ -316,12 +325,21 @@ program create_identity_streamflow_obs
if (indx == 0) cycle OBSLOOP

! relate the physical location to the dart state vector index
dart_index = linkloc_to_dart(lat(indx), lon(indx))
dart_index = linkloc_to_dart(lat(indx), lon(indx))

! desired gauges get the provided obs_err
! remaining ones are for verification purposes
if (ANY(desired_gages == station_strings(n))) then
oerr = max(discharge(n)*obs_fraction_for_error, MIN_OBS_ERR_STD)
else
oerr = MAX_OBS_ERR_STD
endif

! MEG: 6/29/23 [Commented out, oerr is conditionally computed now]
! oerr is the observation error standard deviation in this application.
! The observation error variance encoded in the observation file
! will be oerr*oerr
oerr = max(discharge(n)*obs_fraction_for_error, MIN_OBS_ERR_STD)
!oerr = max(discharge(n)*obs_fraction_for_error, MIN_OBS_ERR_STD)

! MEG: A fix to not crush the ensemble in a no-flood period (stagnant water).
!if ( discharge(n) < NORMAL_FLOW ) then
Expand Down

0 comments on commit 76a3bf7

Please sign in to comment.