[GRASS-dev] new addon on the way

Hi everybody,

I have very slowly started to develop a toolset to search, download and import Landsat data based on landsatxplore python library [0]. I went for landsatxplore library because among the other options, it was the most active in terms of development, i.e., commits in the repo. Currently, I’m working in my repo [1], but hopefully, once it’s done and reviewed by you, it can be moved to addons.

The toolset attempts to be similar to i.modis and i.sentinel, but it is pretty raw right now. I have started with i.landsat.download and the basic functionality is there (details in the html). I recycled and adapted parts of i.sentinel.download to read the settings file and get the region extent. Next step is to draft i.landsat.import. Then, I’ll be working on writing (a bit) better code. Is it recommended to create classes?

Since I’m not a programmer, this is quite a challenge for me, hence I appreciate your patience, help and suggestions, either by this means or in the repo itself.

Thanks much in advance!
Vero

[0] https://github.com/yannforget/landsatxplore
[1] https://github.com/veroandreo/i.landsat

Ciao Vero,

Nice! Looking forward to testing those modules.

Your draft for i.landsat.download looks already quite good.

Cheers

Stefan

···

Hi everybody,

I have very slowly started to develop a toolset to search, download and import Landsat data based on landsatxplore python library [0]. I went for landsatxplore library because among the other options, it was the most active in terms of development, i.e., commits in the repo. Currently, I’m working in my repo [1], but hopefully, once it’s done and reviewed by you, it can be moved to addons.

The toolset attempts to be similar to i.modis and i.sentinel, but it is pretty raw right now. I have started with i.landsat.download and the basic functionality is there (details in the html). I recycled and adapted parts of i.sentinel.download to read the settings file and get the region extent. Next step is to draft i.landsat.import. Then, I’ll be working on writing (a bit) better code. Is it recommended to create classes?

Since I’m not a programmer, this is quite a challenge for me, hence I appreciate your patience, help and suggestions, either by this means or in the repo itself.

Thanks much in advance!

Vero

[0] https://github.com/yannforget/landsatxplore

[1] https://github.com/veroandreo/i.landsat

On Mon, Nov 16, 2020 at 8:09 AM Veronica Andreo <veroandreo@gmail.com> wrote:

Then, I’ll be working on writing (a bit) better code. Is it recommended to create classes?

Hi Vero,

Classes can be sometimes useful for writing things like scripts and GRASS modules, but usually in these cases, just writing functions instead of having everything in one long function does what you need which is understandable and maintainable code.

A class could be useful to carry some state through your code gluing most related variables and functions together like this:

p = Process(some, vars, always, needed)

result1 = p.phase_one_of_processing(some, other, vars)
result2 = p.another_phase_of_processing(result1, and, even, more, vars)

However, that’s nothing you can’t do well with just functions or functions and a class which has only data attributes, but no functions. Sometimes, it is a matter of taste. Sometimes, you may see that the functions are somehow not quite fitting to do what you need to do and that’s where classes might come in.

With your current code, I would just run Pylint on in with default settings and try to make it as happy as possible. Pylint usually forces me to split big chunks of code into smaller documented functions with more clear inputs and outputs. You can also run Black on it and forget about details of formatting. I didn’t really look into the logic of your code, but I think your code looks good and readable, so you don’t have much to worry about even when you start applying some strict tools such as Pylint.

HTH,
Vaclav