-
Notifications
You must be signed in to change notification settings - Fork 25
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
Stacking along bands #19
Conversation
Thanks @jsignell! This looks really cool. Ping @matthewhanson and @scottyhq for some inital thoughts on the functionality here. |
intake_stac/catalog.py
Outdated
if item['path_as_pattern'] != pattern: | ||
raise ValueError( | ||
'Band stacking failed because band url did not ' | ||
'generalize') |
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.
this error could also use a test.
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.
This one is harder to test because usually hrefs contain the band key in the url at a predictable location, but this is testing for the case where the key is not at a fixed place in the url. I would have to write a whole new broken catalog to test for that.
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.
I did improve the wording though to hopefully make it clearer what is going on.
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 great. Just a few nits about tests/errors. I really want @matthewhanson and @scottyhq to take a look here to get their take on the api.
This is great, thanks for getting the ball rolling @jsignell ! I hope to have more time in the coming months to dive into intake-stac more. A few thoughts come to mind quickly looking this over. Each STAC Item can have different band keys. I think we'll have to enumerate them when loading a Catalog to validate the inputs to Also, what should we do if two bands are requested that have different pixel postings (aka resolution)? throw an error or resample to a common grid? In the example above the posting is encoded in the name for Sentinel-2 Items, but not for Landsat8, so you'd need to either read the file metadata or have a lookup table:
|
Right the user would explicitly pass a list of the band keys. I guess if they don't pass such a list we could stack all the bands. Would that be useful?
Right now we generate a sparse grid, but not sure if that is smart or not. It is at least correct. But maybe the user would expect some warning instead? That would be harder to implement, but I guess that is the type of metadata that STAC encapsulates, so maybe not impossible. |
Thanks for this @jsignell , overall the functionality looks good, a couple notes:
One approach could be to validate that the total size in pixels of stacked bands are equal in both dimensions. This is mostly guaranteed to catch most of the problem cases above, however it also means retrieving header information from the assets in order to validate. A simpler easier approach might be just to check the resolution of the bands that are stacked (from the "eo:bands" property) and only allow equal res bands to be stacked. For now especially I think the responsibility for ensuring assets are stackable is up to the user, and we shouldn't worry too much about including a lot of validation.
In the next few weeks some of my other project work will be winding down and I'll finally get a chance to spend more time on this and will start playing with this library. Drew here at E84 is also working on the API interface (#11) |
I added the ability to stack using
I have implemented that, but with a
I don't quite follow what that would look like and I haven't seen an example in the test catalogs. Could you point me to one? |
Does this look ready for merge or are there more cases that I need to consider? |
This looks good to me. WRT to assets with multiple bands, I actually don't think there's an example catalog with assets that contain multiple bands. However, there is the potential that an asset could be a datafile containing multiple bands. I think we can push that feature until there's catalogs that require it. |
Oh there is one more thing @jsignell , can you update the target branch to be |
Ok I changed the target branch to develop. Looks like I don't have the rights to restart the travis job. Someone else might want to do that to check that it works as expected with the change in target branch. |
First pass at implementing stacking. This PR does the stacking over the band dimension. I think that creating a dataset from the different bands is probably straightforward enough after you have the xarray objects. See the example notebook to try it out. Works like:
Some notes:
Closes #12