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
Add support for group-by financial years. #1257
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1257 +/- ##
===========================================
- Coverage 93.60% 93.58% -0.03%
===========================================
Files 129 129
Lines 13145 13331 +186
===========================================
+ Hits 12305 12476 +171
- Misses 840 855 +15
Continue to review full report at Codecov.
|
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.
Looks good Toktam.
Please add a line to docs/about/whats_new.rst
describing the change and referencing this PR.
… support financial years.
datacube/virtual/transformations.py
Outdated
""" | ||
df = pd.Series(time.values) | ||
years = df.apply(lambda x: np.datetime64(str(x.to_period('Q-JUN').qyear))).values | ||
ds = xr.DataArray(years, name='time', attrs=time.attrs, coords=time.coords, dims=time.dims) |
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.
Looks good to me too.
What happens if instead of the two lines defining and modifying ds
you try to do it in one go?
ds = xr.DataArray(years, name='time', attrs=time.attrs, coords=years, dims=time.dims)
I think that should work!
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.
The coordinates should be a dictionary so something like below will work but I'm not 100% sure if the coords
can contain other variables than time which the following code will exclude:
ds = xr.DataArray(years, name='time', attrs=time.attrs, coords=({"time": years}), dims=time.dims)
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.
How about writing a test - that way we know for sure if it works the way we expect. :)
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.
Most of the existing time grouping transforms aren't covered by tests either, but they are trivial compared to this one.
…xtending the fiscal year function to support multi-input time dimensions.
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.
Looks good to me. Thanks Toktam.
Reason for this pull request
Support virtual products to group-by financial years.
Proposed changes
Added a new function to support this alongside the calendar year.
Closes #xxxx
Tests added / passed
Fully documented, including
docs/about/whats_new.rst
for all changes