CSHS-CWRA / RavenPy

A Python wrapper to setup and run the hydrologic modelling framework Raven
https://ravenpy.readthedocs.io
MIT License
26 stars 5 forks source link

No output file Hydrographs.nc when running RavenPy with pre-existing configuration files #165

Closed lcamgalindo closed 2 years ago

lcamgalindo commented 2 years ago

Description

I loaded pre-existing Raven configuration files (.rvc,. rvh, etc.) and tried to run the model using RavenPy. The model appears to run and produces the expected .csv results but also gives the following user warning:

UserWarning: No output files for *Hydrographs.nc in /notebook_dir/writable-workspace/runExRavenMod/exec.

When I tried to view the q_sim of the model, I got the following error (expected since it appears Hydrographs.nc did not write):

KeyError: 'hydrograph'

What I Did

Directory setup

image

I'm not sure if the error could be due to my forcing not being an .nc file but rather an .rvt

Code

from ravenpy.models import Raven
import os

config = [
    "JumpCk.rvc",
    "JumpCk.rvh",
    "JumpCk.rvi",
    "JumpCk.rvp",
    "JumpCk.rvt",
]

model = Raven(os.getcwd())
model.configure(config)

model("PWNAMet.rvt")

model.q_sim
huard commented 2 years ago

RavenPy was built under the assumption that all IO would be in netCDF. So the hydrograph method looks for a netCDF output file, and doesn't find it.

On the input forcing side, since you're not using RavenPy's templating mechanism, this is not an issue.

My suggestion is to tweak your RVI to request a netCDF output :WriteNetcdfFormat yes. This is our template for netCDF metadata:

    :NetCDFAttribute title Simulated river discharge
    :NetCDFAttribute history Created on {now} by Raven
    :NetCDFAttribute references  Craig, J.R., and the Raven Development Team, Raven user's and developer's manual (Version 2.8), URL: http://raven.uwaterloo.ca/ (2018).
    :NetCDFAttribute comment Raven Hydrological Framework version {raven_version}
    :NetCDFAttribute model_id {identifier}
    :NetCDFAttribute time_frequency day
    :NetCDFAttribute time_coverage_start {start_date}
    :NetCDFAttribute time_coverage_end {end_date}

I don't think you'll need that to get hydrograph to work, but in case you spot issues, that might be it.

lcamgalindo commented 2 years ago

I made the change to .rvi file and that has fixed it. I don't recall seeing this assumption listed in the documentation but I may have missed it. I will take a look at RavenPy's templates to get a better understanding of what other assumptions there are. Thanks for the help!

huard commented 2 years ago

No problem.