Error: cannot load sen2mosaic.* modules in command line scripts

Issue #3 new
Charlotte Wilczok created an issue

Dear Sam!

I would really like to use your set of tools, installation was successful, unfortunately now I am stuck with using the command line scripts. Starting with the first step to download S2 images using (conda environment is activated) the command line script download.py, the terminal is responding with the following error statement:

File "/home/charlotte/sen2mosaic/cli/download.py", line 7, in <module>
    import sen2mosaic.download
ModuleNotFoundError: No module named 'sen2mosaic.download'

I am not an advanced python user, so maybe the trick is easy, but it seems as python cannot locate the corresponding *.py scripts that is stored in my directory /home/charlotte/sen2mosaic/sen2mosaic? Do I have to define the PATH somewhere?

Thank you very much in advance for your feedback.

Best, Charlotte

Comments (3)

  1. Samuel Bowers repo owner

    Hi Charlotte,

    Your diagnosis is correct, python can’t locate the .py scripts. You might be able to remedy this by defining the PATH in your .bashrc, although this shouldn’t be necessary. I think it’s most likely that something’s gone wrong in installation, and re-running the setup.py file will probably fix things.

    My best guess is that you either accidentally omitted the installation step:

    cd /home/charlotte/sen2mosaic
    python setup.py install
    

    Or that you ran the installation from outside your conda environment. This can be fixed with:

    conda activate conda_enviroment_name
    cd /home/charlotte/sen2mosaic
    python setup.py install
    

    To test if this has worked, try re-running the command line scripts (e.g. python ~/sen2mosaic/cli/download.py --help) and see if any errors are returned.

    If this doesn’t work do let me know, it might indicate a more serious problem somewhere.

    Cheers,

    Sam

  2. Charlotte Wilczok reporter

    Dear Sam,

    thank you very much for your fast replay and the hints! Finally, it worked out when I set-up a complete new VM Ubuntu 18.04. and started from scratch! In the end I think I’ve made the mistake to not activate the conda environment.

    Still, the shortcuts for the command lines I was not able to set up properly but I have managed to run the entire process by calling the python script giving the path to their directory.

    I generated a composite from 2 S2 tiles, the result is unfortunately not the best one, still a lot of clouds and some other artifacts (as for instance the stripe where both tiles have been mosaiced or patchy pattern reminding on haze) remain. I guess it is due to the non-availability of appropriate S2 data, rather than a problem of the algorithm? Study area = South-West Region, Cameroon, around Mt. Cameroon.

    What is your opinion?

    Cheers,

    Charlotte

  3. Samuel Bowers repo owner

    Hi Charlotte,

    SW Cameroon is going to be a really tough place to get a clean composite image, I’m not totally surprised that outputs aren’t looking great first go! I wrote this with the dry tropics in mind, we don’t have to worry about cloud quite to the same degree there.

    Three things worth a go:

    i) Add in more scenes if you can (more images = greater chance of capturing cloud free pixels), and perhaps limit to the least cloudy images (you can see cloud cover in the Sentinel-2 metadata files, less than 30% is what I use, maybe <10% would be better for the wet tropics). If any image is causing particular problems, try removing it and re-generating the composite.

    ii) It might be worth a go using the --improve_mask flag (python …/sen2mosaic/mosaic.py -i), this adds a buffer around clouds which could give you a cleaner output (albeit with possible nodata around persistent cloud).

    iii) Try a different percentile value (perhaps --pc 10 or --pc 50). You might need to tune this value to exclude clouds/cloud shadows.

    A final, possibly less helpful suggestion, would be to give this a go on Google Earth Engine. It’s a powerful way to quickly pilot test multiple compositing methods, if the above suggestions don’t give you a clean output image it might be that a different algorithm would be your best option.

    Lots of people have had problems with that shortcut! I’ve been thinking about removing it, your approach is certainly a valid one.

    Sam

  4. Log in to comment