command line mode for github version

Technical questions about ACOLITE
Post Reply
tsm00
Posts: 8
Joined: Wed Feb 01, 2017 4:23 pm
Location: Florida

command line mode for github version

Post by tsm00 »

Happy New Year Quinten,

I've decided to start afresh with many things in life in this new year and am looking for the feeling like a new born baby.

As part of this rebirth, I've downloaded the github version of acolite, and its seems to have installed and I can run it from the command line with the gui.

But I'd like to run it from a cronjob as part of an automated script, which I've done for the binary 2019 release.

I'm unsure how to call the github version from a shell script - can you advise? I've previously used a parameter file as input as well.

Many thankens,
Tim
tsm00
Posts: 8
Joined: Wed Feb 01, 2017 4:23 pm
Location: Florida

Re: command line mode for github version

Post by tsm00 »

Ok - I see it runs in command line mode, but how/where do I point to my Earth user creds...I've set my information in acolite_config.txt, but not sure how this is read by the launch_acolite.py

thanks!
quinten
Posts: 1019
Joined: Tue Mar 03, 2015 8:13 am

Re: command line mode for github version

Post by quinten »

Hi Tim

Good to hear about your rebirth! If this year is anything like the last, spending it as a baby may not be the worst...

You can put the EarthData credentials in acolite_config.txt or in the settings file you use. You can check whether they are actually used if you are getting successfully downloaded files in the subfolders of data/MET.

If you want to further integrate the processing in an automated script you can call Python directly in the shell script, e.g.:

Code: Select all

python /path/to/acolite/launch_acolite.py --cli --settings /path/to/settings --image /path/to/image
Alternatively you could also directly run ACOLITE in a Python script. If ACOLITE is not in your Python path you'll have to add it in your Python script. In this example my ACOLITE GitHub clone is in my home directory (~) in the git directory:

Code: Select all

## Python import example
import sys, os
user_home = os.path.expanduser("~")
sys.path.append(user_home+'/git/acolite')
import acolite as ac
Once you have imported ACOLITE you can directly run processing:

Code: Select all

## Python processing example
inputfile = '/path/to/bundle'
output = '/path/to/output'

## read default settings
settings = ac.acolite.acolite_settings(None)
## settings can be modified here
settings['s2_target_res'] = 60
settings['l2r_export_geotiff'] = True
#settings['limit'] = [S,W,N,E]

## or you can read custom settings
#settings = ac.acolite.acolite_settings('/path/to/settings')

## whether to merge adjacent scenes for your ROI
merge_tiles=False

## run the processing
ac.acolite.acolite_run(inputfile=inputfile, output=output, settings=settings, merge_tiles= merge_tiles)
Hope this helps!

Quinten
tsm00
Posts: 8
Joined: Wed Feb 01, 2017 4:23 pm
Location: Florida

Re: command line mode for github version

Post by tsm00 »

Hi Quinten,

Thanks for the info - I think that did trick. I guess there is only a line print if there was an error, because I don't see anything now printed to the screen regarding the ancillary download. Well, no news is good news, as they say...whoever 'they' are.

But this clears it up!

Thanks very much!

tim
quinten
Posts: 1019
Joined: Tue Mar 03, 2015 8:13 am

Re: command line mode for github version

Post by quinten »

Hi Tim

Glad it clears things up! Strange that you are getting no outputs in the terminal - are you piping or redirecting the stdout?

Quinten
tsm00
Posts: 8
Joined: Wed Feb 01, 2017 4:23 pm
Location: Florida

Re: command line mode for github version

Post by tsm00 »

Hi Quinten,

No, I am not redirecting any outputs.

Should I be seeing a line print if the program is downloading the ancillary files, regardless of whether it is successful or not?

Thanks,
Tim
quinten
Posts: 1019
Joined: Tue Mar 03, 2015 8:13 am

Re: command line mode for github version

Post by quinten »

Hi Tim

Ow - I need to brush up on my comprehensive reading, did read over the "regarding the ancillary download" part... I thought you had no ACOLITE printouts at all. I think no news is good news in this case. You can also check the header of the L2R.nc output files to check whether non-default values were used, e.g. in a terminal:

Code: Select all

file='/path/to/your/L2R.nc'
ncdump -h $file | grep uoz
ncdump -h $file | grep uwv
ncdump -h $file | grep pressure
Quinten
Post Reply