[GRASS-dev] compile 6S library in GRASS

Moritz Lennert mlennert at club.worldonline.be
Thu Jun 28 01:26:05 PDT 2018


On 27/06/18 15:40, Roberto Marzocchi wrote:
> 
> 
> Il giorno mer 27 giu 2018 alle ore 15:25 Markus Metz 
> <markus.metz.giswork at gmail.com <mailto:markus.metz.giswork at gmail.com>> 
> ha scritto:
> 
> 
> 
>     On Wed, Jun 27, 2018 at 3:06 PM, Roberta Fagandini
>     <robifagandini at gmail.com <mailto:robifagandini at gmail.com>> wrote:
>      >
>      >
>      >
>      > 2018-06-27 14:24 GMT+02:00 Markus Metz
>     <markus.metz.giswork at gmail.com <mailto:markus.metz.giswork at gmail.com>>:
>      >>
>      >>
>      >>
>      >> On Wed, Jun 27, 2018 at 2:16 PM, Roberta Fagandini
>     <robifagandini at gmail.com <mailto:robifagandini at gmail.com>> wrote:
>      >> >
>      >> > I'm trying to create an automatic procedure to retrieve all
>     the input parameters for the control file of i.atcorr.
>      >> > I need py6S because I want to automatically read and compute
>     AOT at 550nm from an AERONET file.
>      >>
>      >> With AOT you mean aerosol optical thickness right? This is user
>     input to i.atcorr. There are various sources for AOT at 550nm, e.g.
>     MODIS.
>      >
>      >
>      > Right!
>      >
>      >>
>      >>
>      >>
>      >>
>      >> Anyway, it is probably much easier to to write your own routine
>     to read the AERONET file and get the corresponding formula for AOT
>     than to fight with 51821 lines of Fortran source code that is
>     numerically unstable. Maybe I can help with getting AOT at 550nm
>     from an AERONET file avoiding the Fortran version of 6S.
>      >
>      >
>      > Ok but I'm not able to create this kind of routine on my own. If
>     someone, more expert than me, can help me in translating the 6S/Py6S
>     functions I can go on in this way otherwise for me it's easier to
>     use the fortran source code.
> 
>     Apparently the AERONET data are simple CSV files. You can import
>     them with r.in.xyz <http://r.in.xyz> or v.in.ascii.
> 
>     Still, I think it is up to the user to decide on the source of AOT
>     values. AERONET is one of many possible sources.
> 
> 
> Ok but I know that Roberta  want try to simplify the procedure for 
> atmospheric correction. In particular she would like to add an option 
> (not the only one) to read automatically the AOT at the wave length of 
> 550 nm from the AERONET file.
> 
> The steps to do this IMHO are:
> 
> 1) read the file (using GRASS or maybe better Python)
> 
> 2) a formula to calculate the AOT550
> 
> Unfortunately I have no idea about the 2nd point :-(

I'm not sure either, what exactly the necessary calculations are.

Superficially reading through the relevant class in Py6S [1], I 
understasnd that it does two things:

1) Get the value of AOT550
2) Create a continuous profile by interpolating values

If all you need is 1), then all they do (see _get_aot() method at the 
end) is to read all the AOT_* columns and chose the value of the line 
with the timestamp closest to the one asked for and the wavelength 
closest to 550.

As the code is GPL you could probably just extract the necessary parts 
and integrate them into your code. The only thing I'm not to sure about 
is their use of pandas which creates yet again another dependency which 
I don't really think necessary and desirable.

It should be enough to extract from the file the date and time (or maybe 
easier to work with: year and the Julian day) and all AOT_* columns, 
parse the AOT_* columns for their wavelength value and then identify the 
value which has closes time and wavelength to the time requested and 550nm.

Moritz




[1] https://github.com/robintw/Py6S/blob/master/Py6S/SixSHelpers/aeronet.py


More information about the grass-dev mailing list