Coder Social home page Coder Social logo

Comments (6)

davemlz avatar davemlz commented on May 24, 2024 1
  1. 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 an improvement Issue soon :)
  2. Fair enough! :) I will also add it soon!

Thanks a lot, @remi-braun!

from spyndex.

remi-braun avatar remi-braun commented on May 24, 2024

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.

davemlz avatar davemlz commented on May 24, 2024

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.

remi-braun avatar remi-braun commented on May 24, 2024

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.

remi-braun avatar remi-braun commented on May 24, 2024

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.

davemlz avatar davemlz commented on May 24, 2024

Haha sure!

from spyndex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.