GispoCoding / eis_toolkit

Python library for mineral prospectivity mapping
https://eis-he.eu/
European Union Public License 1.2
26 stars 8 forks source link

293 add smoothingfilter cli functions #307

Closed msorvoja closed 8 months ago

msorvoja commented 10 months ago

Adds cli functions for the filter tools. There is a problem with Lee enhanced, frost and kuan filters which I was unable to solve, hence the draft PR. Could you @msmiyels look into it as you have implemented these tools? Those three filter function all give SystemError: <built-in function len> returned a result with an exception set with the same data (small_raster.tif in tests/data/remote) as the tests for these tools use.

msmiyels commented 10 months ago

Servus Mika,

thank you for integrating this into the CLI. I never came across this type of error ๐Ÿ™„ and to be honest, currently have no capacity to dive in.

I would probably need to test this out by myself, so is there a doc containing info how to test the CLL implementation or could you provide me a short how to for replicating this on my end?

Take your time on this one, since I assume that I cannot check it out prior to week 8. So if you have other functions to implement, I recommend to focus on these and do not wait for my reply the next couple of days.

Just for clarifiying my understanding, the Conda fails in the PR:

ERROR tests/checks/check_raster_grids_test.py
ERROR tests/conversions/csv_to_geodataframe_test.py
ERROR tests/conversions/raster_to_dataframe_test.py

refer to other files/functions than the filters. That's probably not the issue, right?

Cheers,

Michael

msorvoja commented 9 months ago

Hello Michael,

Thank you for looking into this! I'm not sure how familiar you are with these CLI functions so here are (hopefully sufficient) instructions to get you started:

You need a virtual environment into which you install eis_toolkit. Inside container,

poetry build

builds the .whl file inside dist folder. Activate the venv if not already and install the wheel

pip install eis_toolkit-0.1.0-py3-none-any.whl --force-reinstall

Note, that every time you create a new CLI function or make any modifications to the existing ones, you need to rebuild the wheel and install it.

Now with

eis --help

you should be able to see all the cli functions available. To get help with any of the CLI functions, just type

eis function-name-here-cli --help

To test, e.g., the Frost filter with the default parameters, type

eis frost-filter-cli --input-raster small_raster.tif --output-raster test.tif

This should give you the same error as it gives to me.

The Conda fails shouldn't be related to this as they seem to happen in other PRs as well. @nmaarnio is looking into it.

-Mika

nmaarnio commented 9 months ago

Hi,

If you are using Poetry (or Docker) environment, you don't actually need to create any additional venv. Just run

poetry run eis frost-filter-cli --input-raster small_raster.tif --output-raster test.tif etc.

I tried to solve this quickly, but with no success. I could run the notebook without any issues, but the CLI functions give the same error Mika pointed out. It would still probably be worth test this with different Scipy version, although it puzzles me that the functions run in notebooks/scripts with the current version...

msmiyels commented 9 months ago

Ahoi, Iโ€˜m currently on my way back from traveling and will check that out asap. But Iโ€˜ll probably be only 1-2 days in the office this week.

Cheers, Michael

msmiyels commented 9 months ago

Ahoi @nmaarnio, @msorvoja,

checked this one out today. There were some minor inconsistencies in the respective call- and private function definitions โœ๏ธ , which obviously caused these errors ๐Ÿ›‘ for the kuan, frost and lee-enhanced filters. Also updated the CLIfile to be consistent with the changes. Please check that out on your machines ๐Ÿงช and give it a go if okay ๐Ÿš€

Cheers and a nice weekend ๐Ÿ˜„ Michael