Skip to content

add cloudy flag to ghi and nighttime to power variables#382

Merged
alorenzo175 merged 10 commits intoSolarArbiter:masterfrom
alorenzo175:morevalid
Apr 3, 2020
Merged

add cloudy flag to ghi and nighttime to power variables#382
alorenzo175 merged 10 commits intoSolarArbiter:masterfrom
alorenzo175:morevalid

Conversation

@alorenzo175
Copy link
Contributor

@alorenzo175 alorenzo175 commented Apr 2, 2020

@alorenzo175 alorenzo175 added enhancement New feature or request validation Issue pertains to data validation labels Apr 2, 2020
@alorenzo175 alorenzo175 added this to the 1.0 beta 5 milestone Apr 2, 2020
@alorenzo175
Copy link
Contributor Author

I've modified the validation.validator.detect_clearsky_ghi to raise warnings instead of errors and default to flagging a time as cloudy if the pvlib detect clearsky can't run. This produces a validation like
image

I think this is probably the right approach, but wanted to get some feedback @wholmgren @cwhanse

Copy link
Member

@wholmgren wholmgren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The results look good to me. When does the pvlib function fail with our data?

Comment on lines 65 to 66
cloudy_flag = validator.detect_clearsky_ghi(values, clearsky['ghi'],
_return_mask=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought you'd want a try/except here instead of a warning in the function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went back and forth on this. That is one option, but the rest of the functions in validator.py will not raise an error unless an invalid parameter for the algorith is chosen vs invalid data.

Also, it's much easier to return a series of 0 in the function and have those converted to the flag vs having to pull in logic from quality_mapping.py to figure out what the flag should be in the except

@alorenzo175
Copy link
Contributor Author

The results look good to me. When does the pvlib function fail with our data?

It will fail with too little data or uneven timestamps or long interval lengths

@cwhanse
Copy link
Contributor

cwhanse commented Apr 2, 2020

It will fail with too little data or uneven timestamps or long interval lengths

Or missing timestamps. pvlib #507

@cwhanse
Copy link
Contributor

cwhanse commented Apr 2, 2020

I've modified the validation.validator.detect_clearsky_ghi to raise warnings instead of errors and default to flagging a time as cloudy if the pvlib detect clearsky can't run. This produces a validation like

I think this is probably the right approach, but wanted to get some feedback @wholmgren @cwhanse

The label "cloudy" could be misleading, as it's either not clear, or indeterminate. Maybe reverse that part of the plot and color times labeled as Clear?

I do think that most of the validation shouldn't apply to night times.

@alorenzo175
Copy link
Contributor Author

The label "cloudy" could be misleading, as it's either not clear, or indeterminate. Maybe reverse that part of the plot and color times labeled as Clear?

An added benefit of inverting to a Clear or Cloud Free flag is that the default behavior of excluding positive quality flags from reports for these periods makes more sense. I.e. exclude the periods of clearsky from a GHI report vs excluding the cloudy periods.

This is only ok to switch the flag name in qualitymapping.py without
making a new version because the flag has not been implemented yet in
production data.
@alorenzo175
Copy link
Contributor Author

Ok, I've switched to Cloud Free and only flagging times that the detect clearsky algorithm flags as clear.

image

We can change from CLOUD FREE, but I thought it was more clear when we already have CLEARSKY EXCEEDED

@wholmgren
Copy link
Member

Hm I would have thought that consistency with the existing CLEARSKY EXCEEDED would be a reason to call this flag CLEAR or CLEARSKY.

@alorenzo175
Copy link
Contributor Author

fair, CLEAR is too ambiguous, but CLEARSKY is ok

@alorenzo175 alorenzo175 requested a review from wholmgren April 2, 2020 22:06
Copy link
Member

@wholmgren wholmgren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comments. didn't look carefully at the tests

`validator.check_ghi_limits_QCRad`,
`validator.check_ghi_clearsky`
`validator.check_ghi_clearsky`,
`validator.detect_clearsky_ghi`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a big deal, but I believe in numpydoc format the tuple is implied by multiple return values, so proper format would be

Returns
-------
timestamp_flag
    bitmask from `validator.check_timestamp_spacing`
night_flag
    bitmask from `validator.check_irradiance_day_night`

etc

vol. 9, no. 4, pp. 998-1005, July 2019. doi: 10.1109/JPHOTOV.2019.2914444
"""
if len(ghi) < 2:
return pd.Series(0, index=ghi.index)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RuntimeWarning here too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request validation Issue pertains to data validation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add NIGHTTIME validation for power variables add detect_clearsky_ghi to ghi validation

3 participants