-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved error codes for irradproc, solar_resource_data #1219
Conversation
errorcodes for irrad.calc, test on pvwattsv8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mjprilliman Thanks for tackling this. I'll look over and revise the text of the messages. I think the variable name "errorCode" is misleading. Not sure if it's worth the effort to change, but something like "error_message" would make it clearer that it's a text message and not a numeric code.
@mjprilliman I'm using PVWatts to test this in the SAM UI because it is the only model that calls irradproc's getErrorCode(). When I use this weather file with invalid time zone data, SAM crashes: |
Sorry Paul, there was an extra callout to code that was in the util::format call in pvwattsv8 that I had been using for troubleshooting. That meant it was trying to format a error code as a string, a string as a integer, and so on. The most recent push should fix that, and rename the errorCode references to errorMessage. |
@mjprilliman This is working now in PVWatts, thanks for the fix. I would like to be able to use formatted strings like this to include useful data in the error messages:
But this doesn't work because |
Paul, I tested it out and something like this should work:
Not a very elegant example but it reports out this: |
@mjprilliman |
checks for solar_resource_data where required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we looking for consistent behavior between cmods for this? For example, cmod_irradproc will throw an error for elevation < 0, but pvwattsv8 will just silently set it to zero and run just fine. Is that expected for optional variables?
For elevation specifically, I was moving away from error messages or text warnings for the changed value and leaning on the elevation output in the results spelling things out. This avoids breaking things like the CSP weather file reader that looks for warning messages whether they throw an error or not. Happy to figure out a workaround, and will take a look at cmod_irradproc.cpp |
Overall this is a big improvement and the error messages work well for irradiance, time, and albedo. The highlighted values from hour 2 all should generate warnings or errors, but PVWattsv8 runs just fine with them: Do we want to fix these as a part of this PR, another issue, or are these unimportant? |
Tdew will throw an error if the heat transfer temperature model is chosen. The other place it is used is the POA decomposition, would need to check error handling there. Pressure and Tamb are treated as optional inputs to irrad same as elevation, so they get rewritten as 1013.25 mbar and 15 degC if the values are not valid (isnan check for each, > 800 mbar for pres). But Tamb should likely throw an error from the thermal model. Wind speed should likely have a positive sanity check and an upper bound in the thermal models. I vote for making a new issue for improving error messages and handling at the thermal model level. |
I agree with making a new issue for better error checking in the PV models for weather data elements that depend on options. Note that the "Weather Data Elements" topic in Help attempts to document when different weather data elements are required for all performance models: https://samrepo.nrelcloud.org/help/weather_data_elements.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving the code here. Filed #1226 for additional improvements after the release.
-Fixes #973
-Add output errorcodes from irrad::check(), not just codes
-Add checks for solar_resource_data, including header information such as elev, lat, lon, tz
-Tested on pvwattsv8, feedback needed before propagating across irrad and solar_resource_data instances
@cpaulgilman review needed on language of error messages
@brtietz review needed on functionality