Comments (6)
- I like this idea! But I don't want to leave it as default since the idea of these indices is that people should use the value that they need for their application (even if they don't provide the parameters). I will probably add an
use_default
argument to the computation. I will add this to animprovement Issue
soon :) - Fair enough! :) I will also add it soon!
Thanks a lot, @remi-braun!
from spyndex.
And it would be equally awesome to avoid throwing a too generic Exception
if the value is missing.
Maybe a ValueError
(or a custom exception) should replace it? 😅
from spyndex.
Hi @remi-braun,
Actually, the constant objects have default values :) please see the Constant docs. Nevertheless, this is an overall default (e.g., the most common default value of L is 1, but for SAVI is 0.5, so the user must decide).
About the Exception, could you be more specific? At the moment spyndex
notifies the user that the value is missing. Or do you mean just changing the Exception type?
Exception example (as it is right now):
import spyndex
spyndex.indices.SAVI.compute()
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
[<ipython-input-5-bffea78d37b9>](https://localhost:8080/#) in <module>
----> 1 spyndex.indices.SAVI.compute()
2 frames
[/usr/local/lib/python3.7/dist-packages/spyndex/axioms.py](https://localhost:8080/#) in compute(self, params, **kwargs)
155 parameters = params
156
--> 157 return computeIndex(self.short_name, parameters)
158
159
[/usr/local/lib/python3.7/dist-packages/spyndex/spyndex.py](https://localhost:8080/#) in computeIndex(index, params, online, returnOrigin, coordinate, **kwargs)
219 raise Exception(f"{idx} is not a valid Spectral Index!")
220 else:
--> 221 _check_params(idx, params, indices)
222 result.append(eval(indices[idx]["formula"], {}, params))
223
[/usr/local/lib/python3.7/dist-packages/spyndex/utils.py](https://localhost:8080/#) in _check_params(index, params, indices)
73 if band not in list(params.keys()):
74 raise Exception(
---> 75 f"'{band}' is missing in the parameters for {index} computation!"
76 )
Exception: 'L' is missing in the parameters for SAVI computation!
from spyndex.
1️⃣ I tried to compute a SAVI index without providing the L constant and it threw me the Exception
you linked. It would be very neat that instead a SAVI index is computed with the default L value (relative to the asked index, 0.5 in this case) 😉
2️⃣ Yes, I am writing about the Exception
class, it is too generic to throw it as the try except
cannot be specific after that (except Exception
is way too generic). Throwing a Value Error
would be more appropriate, or even better, a custom Spyndex Exception that would allow me to catch this exception properly 👍
from spyndex.
Thanks a lot 😉
As promised, I am trying to use spyndex in the EOReader lib, this may lead to several issues and questions, please be patient with me haha 🙏
from spyndex.
Haha sure!
from spyndex.
Related Issues (20)
- Add `kwargs` to `computeIndex` and `computeKernel` HOT 1
- Can't load the package in google colab HOT 2
- [Suggestion] Pin requirement versions (specifically python-box)
- QST: Maturity level of spyndex HOT 2
- Something wrong with NDWI HOT 2
- QST: Compute custom spectral indices HOT 4
- Extras require for `spyndex` HOT 3
- spyndex.plot.heatmap not working HOT 1
- `spyndex` breaks with `earthengine-api==0.1.365` HOT 1
- migrate from setup.py to pyproject.toml HOT 1
- Error while running the toy example HOT 1
- Separate bands and constants in `SpectralIndex` objects HOT 1
- Support index-specific constant defaults HOT 1
- issue in calculating some of the vegetation indices HOT 7
- `globals` to `locals` HOT 1
- Missing gamma parameter for ARVI index. HOT 2
- `online` argument is not working HOT 1
- Add `omega` HOT 1
- Add `SpectralIndex` class HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spyndex.