-
Notifications
You must be signed in to change notification settings - Fork 298
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
Refactor all indices to one module. #285
Conversation
This won't work in general. Although all of our current indices are difference ratios, most indices are not: https://www.indexdatabase.de/db/i.php We could have a single difference ratio index to represent all, but I'm not sure how much of an advantage that will give us. @isaaccorley thoughts? |
That is my thought; one module for all difference indices and then we can add more specific ones as needed. Keeps it clean. |
This won't work in general because our current indices are all normalized difference indices but many indices have more than 2 bands, can be normalized in different ways, or some indices can be a function of other indices. The other reasoning for keeping a separate class per index is that we were including the correct DOI for each index. There seems to some confusion in the community on the original publication source of certain spectral indices and this would help these papers be cited properly. The refactor plan was to break out the Edit: although I do think the tests could be refactored some as they are repetitive. |
I'm not sure I understand the significance of the "normalized" part. These indices are all just a function of some number of bands. In fact, our indices modules could take advantage of the fact that the RasterDatasets know which bands are which.
I think we can keep the DOIs around easily by making say We should definitely have https://www.indexdatabase.de/db/i.php in the documentation. |
👆 I am still unfamiliar with the TorchGeo API (working on it!), but my suggestion was going to be to used NamedTensors (or the RasterDataset implementation equivalent) to make a difference index factory, essentially. |
No worries, our API is constantly evolving anyway, thanks for all the fresh ideas! |
Okay, so how does everyone feel about a parent |
Good by me. So that looks like a super + subclasses? |
I would call it |
3b19124
to
ce6ebb2
Compare
@isaaccorley our "Indices" tutorial still uses |
* Add compute index helper function + refactor * Generalize all indices to one function * Refactor indices to one module * Fix init imports * Add docstrings * Fix transform test * update to inherit from parent index class * add nbr index * forgot self in method * mypy and dim fixes * update expected tensor in test * Update indices.py * Black * Update indices.py * Black again Co-authored-by: isaaccorley <22203655+isaaccorley@users.noreply.github.com> Co-authored-by: Caleb Robinson <calebrob6@gmail.com>
All the indices currently included are just ratios of sums. The helper functions also depend on the user knowing what the index of the relevant bands are to begin with.
Since this knowledge of the underlying index is already required, it's cleaner to have one generalized module for difference indices.