Seeking Help on Generating WRF-Hydro Streamflow Nudging Input Files with R

43 views
Skip to first unread message

zed li

unread,
May 9, 2025, 9:46:11 AMMay 9
to wrf-hydro_users

Dear WRF-Hydro Users,

Hello everyone, I'm currently working on the Streamflow Nudging Data Assimilation of WRF-Hydro. I'm having trouble generating the input files. I need to use rwrfhydro to create nudgingTimeSliceObs and nudgingParams.nc, but I'm quite unfamiliar with R language. Is there an R script that I can modify and run? Is there an R script for generating nudgingTimeSliceObs files? My observed traffic data is in tabular form, with one column for time and one column for traffic .And I found an R script on the forum to generate nudgingParams.nc, thanks to Mr. Arezoo for providing the script. The link is as follows (https://groups.google.com/a/ucar.edu/g/wrf-hydro_users/c/E-UqPduOdTM/m/xLdr0ZG5AAAJ), but I encountered problems when running it:[1] "vobjtovarid4: **** WARNING **** I was asked to get a varid for dimension named stationIdStrLen BUT this dimension HAS NO DIMVAR! Code will probably fail at this point"

[1] "vobjtovarid4: **** WARNING **** I was asked to get a varid for dimension named stationIdInd BUT this dimension HAS NO DIMVAR! Code will probably fail at this point" [1] "vobjtovarid4: **** WARNING **** I was asked to get a varid for dimension named threshInd BUT this dimension HAS NO DIMVAR! Code will probably fail at this point" [1] "vobjtovarid4: **** WARNING **** I was asked to get a varid for dimension named monthInd BUT this dimension HAS NO DIMVAR! Code will probably fail at this point" [1] "vobjtovarid4: **** WARNING **** I was asked to get a varid for dimension named threshCatInd BUT this dimension HAS NO DIMVAR! Code will probably fail at this point"

char stationId(stationIdInd,stationIdStrLen) (Chunking: [15,1]),Is this a mistake?Thank you all! Looking forward to your reply!

zed li

Arezoo RafieeiNasab

unread,
May 9, 2025, 12:48:56 PMMay 9
to wrf-hyd...@ucar.edu
Hi Zed, 

Let's do this step by step. Were you able to generate the nudgingParm.nc file?

Thanks!
Arezoo

--
You received this message because you are subscribed to the Google Groups "wrf-hydro_users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wrf-hydro_use...@ucar.edu.
To view this discussion visit https://groups.google.com/a/ucar.edu/d/msgid/wrf-hydro_users/f2b9959e-0bc8-4264-953c-ece9ffc094dcn%40ucar.edu.


--
Arezoo Rafieei Nasab, Ph.D.
NCAR/RAL Project Scientist II
office: 303-497-2888

zed li

unread,
May 10, 2025, 4:23:25 AMMay 10
to wrf-hydro_users, Arezoo RafieeiNasab
Hi  Arezoo,
I generated the nudgingParm.nc file, but the warning messages when running the script have me concerned.I have attached the Route_Link.nc and nudgingParm.nc files. 
Thanks!
zed
nudgingParams.nc
Route_Link.nc

Arezoo RafieeiNasab

unread,
May 10, 2025, 2:24:18 PMMay 10
to zed li, wrf-hydro_users
Hi Zed, 

I also get the warning messages, but the file gets generated and they look fine for me. If you see all the fields then you should be fine. And the stationIds are set to be 15 characters, this is based on the initial intent of the nudging which is for assimilating USGS streamflow observation and the name of the stations are always less than 15, mostly either 8 character or 15 character. That is why the length of the stationId variable is 15 characters. 

Now to the next, are you able to create time slices, or that is giving you problems? Time slices are not tied directly to the nudging param file, and therefore it could have more or less gauges than what is in the nudgingParam.nc file. If you have gauges that are not in the nudgingParam.nc file, then it ignores them in the assimilation procedure. Do you have a script to create the nudging time slices? If not, pass me your observations file and I will pass you a working script in R. 

Thanks!
Arezoo

zed li

unread,
May 10, 2025, 11:35:38 PMMay 10
to wrf-hydro_users, Arezoo RafieeiNasab, wrf-hydro_users, zed li
Hi  Arezoo,
Thank you for your reply.I do not have the R script for creating the nudging time slices. I have attached part of my observed flow data, with the flow rate in cubic meters per second.

Thanks!
zed
obs.xlsx

Arezoo RafieeiNasab

unread,
May 11, 2025, 2:03:12 AMMay 11
to zed li, wrf-hydro_users
Hi Zed, 

Which one of the following is the streamflow measurement?

tunxi yuetan xiuning

Thanks!
Arezoo

zed li

unread,
May 11, 2025, 6:45:08 AMMay 11
to wrf-hydro_users, Arezoo RafieeiNasab, wrf-hydro_users, zed li

Hi Arezoo,

All three (Tunxi, Yuetan, and Xiuning) are streamflow measurement stations. However, Tunxi is the target station for forecasting, while Yuetan and Xiuning are upstream stations used as input data for Nudging Data Assimilation .

Thanks!

zed

Arezoo RafieeiNasab

unread,
May 12, 2025, 12:44:43 AMMay 12
to zed li, wrf-hydro_users
To clarify, you want to assimilate all the three stations? And could you share the Routelink file with me? The name of the stations in the nudging file should match what is used in the Routelink file. 
Thanks!
Arezoo

zed li

unread,
May 12, 2025, 3:43:46 AMMay 12
to wrf-hydro_users, Arezoo RafieeiNasab, wrf-hydro_users, zed li
Hi  Arezoo,
Yes, I want to assimilate all three stations. I have just come across Streamflow Nudging Data Assimilation. I think assimilating information from more observation stations can lead to better assimilation results. This is just practice for now. In the future, the number of assimilated sites may be increased or decreased.I will attach the Route_Link.nc file as well as the csv file of the forecast stations used to generate this file.
Thanks!
zed 
yuetan.csv
Route_Link.nc

Arezoo RafieeiNasab

unread,
May 12, 2025, 3:10:22 PMMay 12
to zed li, wrf-hydro_users
Hi Zed, 

The below script will re-organize the data you provided, and then use an existing function in the rwrfhydro R library (https://github.com/NCAR/rwrfhydro) to write the time slices. Hopefully, you would be able to install rwrfhydro easily, it used to be installed very easily in the past, but I am aware the new versions of the R are giving users problems in installation due to library conflicts. In that case we could pull the function of interest out and use it outside the rwrfhydro. 

Also, time slices are pretty simple netcdf file, and you could generate them in your languages of your choice. I am attaching also a sample timeSlice that was generated from this script in case you would like to develop your own script. 

I hope this will be helpful!
Arezoo
for_zed_create_time_slices.R
2024-06-17_03_00_00.15min.usgsTimeSlice.ncdf

zed li

unread,
May 13, 2025, 9:31:12 AMMay 13
to wrf-hydro_users, Arezoo RafieeiNasab, wrf-hydro_users, zed li
Hi Arezoo,
Thank you for providing the script. I have successfully run it. Installing the R package 'rwrfhydro' indeed took me a lot of time. Previously, the installation went smoothly on Windows, but the filenames generated by the script were invalid on Windows, forcing me to install 'rwrfhydro' on Linux instead. Installing the dependencies was quite complicated, but everything finally works as expected. The files generated by the script you provided are good.Thank you again for your help!
zed

Arezoo RafieeiNasab

unread,
May 13, 2025, 12:15:55 PMMay 13
to zed li, wrf-hydro_users
Hi Zed, 

I am glad Zed that you were able to install rwrfhydro, with older versions of R this was a smooth process, but we are not maintaining rwrfhydro currently and there has not been any work to make it up to date. However, I am glad you were able to install and use the script. 
Let me know how the testing goes. I have used the streamflow nudging only with the National Water Model which has a UMD (spatial weight file). I would be curious to know whether it works for other configurations. 

Have a wonderful day!
Arezoo
Reply all
Reply to author
Forward
0 new messages