Skip to content
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

Bug fix on GCM clearsky ratio #249

Merged
merged 4 commits into from
Dec 13, 2024
Merged

Bug fix on GCM clearsky ratio #249

merged 4 commits into from
Dec 13, 2024

Conversation

grantbuster
Copy link
Member

@bnb32, possibly a bit premature as i haven't tested thoroughly yet, but since kestrel is down and i know you're bored i thought i'd submit this for review now.

Main fix is that da.repeat does not do what we think it does for multi year solar timeseries (see lines referenced below). We need to stack multiple years of the NSRDB clearsky ghi but da.repeat does [1, 2, 3] -> [1, 1, 2, 2, 3, 3] so you get one giant annual cycle which results in a lot of ratio=1 values at the edges. Leap days also matter... if we do nyears*366 for nyears>10 we end up with a growing shift in the later years. This matters a lot for the 40-year record we analyze for bias correction.

main...gb/csratio#diff-d97151971c312b63001f37eafc4f5fac2020d7b0a7421d7b3e4adfa1bf7d1cebR223-R229

@grantbuster grantbuster requested a review from bnb32 December 12, 2024 17:04

cs_ghi = cs_ghi[..., : len(self.rasterizer.time_index)]
cs_ghi = da.concatenate(multi_year, axis=-1)
cs_ghi = cs_ghi[..., :len(self.rasterizer.time_index)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe this would be cleaner if we just matched the doy in cs_ghi.time with the doy in self.rasterizer.time_index for each element?

Copy link
Member Author

@grantbuster grantbuster Dec 13, 2024

Choose a reason for hiding this comment

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

Very good call. Check this out. Will want to test on large timeseries once kestrel is back up but i think this should work!

2d33c8b#diff-d97151971c312b63001f37eafc4f5fac2020d7b0a7421d7b3e4adfa1bf7d1cebR218-R222

Copy link
Collaborator

@bnb32 bnb32 Dec 13, 2024

Choose a reason for hiding this comment

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

Yeah that looks great! Little nitpick 'time' -> Dimension.TIME. I don't think pd.to_datetime() is needed here either, but doesn't matter

cs_ghi['time'] = pd.to_datetime(cs_ghi['time']).strftime('%m.%d')

Copy link
Member Author

Choose a reason for hiding this comment

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

hmmm maybe im misunderstanding but i dont see the benefit of storing the index up at line 207 vs. pulling it at 220 and converting to month-day. I kind of like having everything contained in these few lines that reindex the ti. I should def be using Dimension.TIME though. will push that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, disregard that initial message. At first glance I thought there was some extra unneeded conversion happening. Edited to clarify.

Copy link
Member Author

Choose a reason for hiding this comment

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

Gotcha! I think I saw the time index is stored as a numpy array so needed the to datetime. doesnt hurt anyway.

… lots of variability with such small test sample
@grantbuster
Copy link
Member Author

Just verified this functionality on kestrel with a 10 year timeseries, everything works as expected, merging.

@grantbuster grantbuster merged commit 94eebae into main Dec 13, 2024
12 checks passed
@grantbuster grantbuster deleted the gb/csratio branch December 13, 2024 19:22
github-actions bot pushed a commit that referenced this pull request Dec 13, 2024
Bug fix on GCM clearsky ratio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants