Error reading forecast points csv in WRF preprocessing

22 views
Skip to first unread message

Erin Dougherty

unread,
Jul 19, 2022, 3:47:23 PM7/19/22
to wrf-hydro_users
Hi there, 

I am using the WRF Hydro preprocessing tools with Python (from here) and for some reason, it cannot read in the forecast points csv file properly. I can run the pre-processing tool fine without the forecast points csv file but I would really like to include the forecast points in my simulation. 

Here is the error I receive upon running Build_Routing_Stack.py:

 # Forecast point processing

  File "/Users/doughert/Documents/WRF-H/preprocess_new/wrf_hydro_gis_preprocessor/wrfhydro_gis/wrfhydro_functions.py", line 2282, in forecast_points

    ds = CSV_to_SHP(in_csv, DriverName='MEMORY', xVar='LON', yVar='LAT', idVar='FID', toProj=WKT)  # In-memory features

  File "/Users/doughert/Documents/WRF-H/preprocess_new/wrf_hydro_gis_preprocessor/wrfhydro_gis/wrfhydro_functions.py", line 2245, in CSV_to_SHP

    feature.SetField(idVar, row[idVar])

ValueError: no field of name FID

This error does not make sense to me since the FID is a header in the file. I get the same issue if I switch around the column order too. Do you know why this is happening?

Thanks, 

Erin

IA_MO_gages.csv

Matthew Casali

unread,
Jul 19, 2022, 4:23:54 PM7/19/22
to wrf-hyd...@ucar.edu
Hi Erin,

I took a look at your CSV and noticed that there are some invisible characters added to your 'FID' column. They are '\xef\xbb\xbf', which is a byte order mark for UTF-8. They can be added unintentionally by text editors. These characters are being read by the Python code, causing the ValueError. I removed the characters and made you a new CSV. Hopefully this one works for you. Please let me know if you have any questions. Thanks,

Matt Casali, GISP
Associate Scientist
National Center for Atmospheric Research
P.O. Box 3000 Boulder, CO  80307-3000
Tel: 303-497-1709

--
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 on the web visit https://groups.google.com/a/ucar.edu/d/msgid/wrf-hydro_users/22df11bf-76c5-4d2f-b545-e180ab235496n%40ucar.edu.


--
Matt Casali, GISP
Associate Scientist
National Center for Atmospheric Research
P.O. Box 3000 Boulder, CO  80307-3000
Tel: 303-497-1709
IA_MO_gages_new.csv

Erin Dougherty

unread,
Jul 19, 2022, 4:30:42 PM7/19/22
to wrf-hyd...@ucar.edu
Hi Matt, 

Thanks for the quick response! I appreciate your help in finding those UTF characters and sending me a new CSV. I will try running the code with the updated CSV now. 

Thank you! 
- Erin

You received this message because you are subscribed to a topic in the Google Groups "wrf-hydro_users" group.
To unsubscribe from this topic, visit https://groups.google.com/a/ucar.edu/d/topic/wrf-hydro_users/WZzoWlKkk4E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wrf-hydro_use...@ucar.edu.
To view this discussion on the web visit https://groups.google.com/a/ucar.edu/d/msgid/wrf-hydro_users/CANnd00W2i5gRFX0XOwJbfDM6Yx3AM18TMeQ2M8p-F3%3Drs9fimw%40mail.gmail.com.

Erin Dougherty

unread,
Jul 19, 2022, 4:49:29 PM7/19/22
to wrf-hyd...@ucar.edu
It worked! Thanks again! 

Matthew Casali

unread,
Jul 19, 2022, 5:04:07 PM7/19/22
to wrf-hyd...@ucar.edu
Reply all
Reply to author
Forward
0 new messages