<div dir="ltr">Dear list,<div>I came across another strange behaviour in i.atcorr used for Sentinel 2A data - for most of the scenes I process, the output of i.atcorr (for each band) is correct (i.e. contains values), but for several scenes, the output (for each band) contains just -nans. I thought this is caused by the input scenes, but apparently, it is rather caused by the date (line 2, first two numbers) in the 6s file. Some days in the 6s file lead to a correct result, other days in the 6s file lead to -nans.</div><div><br></div><div>Example:</div><div>date in 6s file = 08 16</div><div>i.atcorr input=S2A_20160816.B02 range=0,10000 elevation=dem_10m parameters=param_6s_20160816.txt output=S2A_20160816.B02_atcorr1<br></div><div>-> only -nans in output map<br></div><div><br></div><div><div>date in 6s file = 09 05</div><div>i.atcorr input=S2A_20160816.B02 range=0,10000 elevation=dem_10m parameters=param_6s_20160905.txt output=S2A_20160816.B02_atcorr2<br></div><div>-> values in output map</div></div><div><br></div><div><div>date in 6s file = 08 16</div><div>i.atcorr input=S2A_20160905.B02 range=0,10000 elevation=dem_10m parameters=param_6s_20160816.txt output=S2A_20160905.B02_atcorr3<br></div><div>-> only -nans in output map</div></div><div><br></div><div><div>date in 6s file = 09 05</div><div>i.atcorr input=S2A_20160905.B02 range=0,10000 elevation=dem_10m parameters=param_6s_20160905.txt output=S2A_20160905.B02_atcorr4<br></div><div>-> values in output map</div></div><div><br></div><div><div>Version:</div><div><div>g.version -g</div><div>version=7.4.0svn</div><div>date=2017</div><div>revision=r71960M</div><div>build_date=2017-12-22</div><div>build_platform=x86_64-pc-linux-gnu</div><div>build_off_t_size=8</div></div></div><div><br></div><div>I checked the verbose module output, and the only difference is (obviously) in solar zenith angle, solar azimuth angle, view zenith angle etc., but these values look correct in all cases. </div><div><br></div><div>Could this be caused by numerical instability as in the previous problem? The data (two scenes, DEM and two 6s files) can be downloaded from here, it would be great if someone could check whether the issue occurs as well.</div><div><a href="https://www.dropbox.com/sh/ntg46stpjhxyqov/AADVBHVHHI_ap1W32kqesaHna?dl=0">https://www.dropbox.com/sh/ntg46stpjhxyqov/AADVBHVHHI_ap1W32kqesaHna?dl=0</a><br></div><div><br></div><div><br></div><div>Thanks a lot.</div><div>Zofie</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 8, 2018 at 9:01 AM, Stefan Blumentrath <span dir="ltr"><<a href="mailto:Stefan.Blumentrath@nina.no" target="_blank">Stefan.Blumentrath@nina.no</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="NO-BOK" link="blue" vlink="purple">
<div class="m_9025613633707978615WordSection1">
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Hi,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">This is how you can patch i.atcorr and compile into home dir.:<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">svn checkout
<a href="https://svn.osgeo.org/grass/grass/branches/releasebranch_7_4%20grass_74" target="_blank">
https://svn.osgeo.org/grass/<wbr>grass/branches/releasebranch_<wbr>7_4 grass_74</a><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">cd grass_74<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">wget
</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><a href="https://trac.osgeo.org/grass/raw-attachment/ticket/3469/i_atcorr_double.patch" target="_blank"><span lang="EN-GB">https://trac.osgeo.org/grass/<wbr>raw-attachment/ticket/3469/i_<wbr>atcorr_double.patch</span></a></span><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">patch -p0 -i</span><span lang="EN-GB">
</span><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">i_atcorr_double.patch<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">CFLAGS=”-g -Wall -Wextra -Wpedantic -Wshadow -Wno-sign-compare -fno-common -fexceptions -Werror=implicit-function-<wbr>declaration -Wp,-D_FORTIFY_SOURCE=2 -O3 -fno-fast-math” CXXFLAGS=”-g
 -Wall -Wextra -Wpedantic -Wshadow -Wno-sign-compare -fno-common -fexceptions -Werror=implicit-function-<wbr>declaration -Wp,-D_FORTIFY_SOURCE=2 -O3 -fno-fast-math” ./configure --with-cxx --with-sqlite --with-postgres --with-postgres-includes=/usr/<wbr>include/postgresql
 --with-odbc --with-cairo --with-proj-share=/usr/local/<wbr>share/proj --with-tcltk-includes=/usr/<wbr>include/tcl8.4/ --with-freetype --with-freetype-includes=/usr/<wbr>include/freetype2 --with-fftw --with-nls --with-python --with-tiff --with-geos --enable-largefile --with-readline
 --with-blas --with-glw --with-motif --with-openmp --with-wxwidgets --with-liblas --with-netcdf --with-lapack --with-mysql-includes=/usr/<wbr>include/mysql --with-mysql --with-opencl --with-pdal --with-bzlib –prefix=~/<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">make –j 20<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">make install<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">Cheers<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">Stefan<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif"> grass-user [mailto:<a href="mailto:grass-user-bounces@lists.osgeo.org" target="_blank">grass-user-bounces@<wbr>lists.osgeo.org</a>]
<b>On Behalf Of </b>Žofie Cimburová<br>
<b>Sent:</b> mandag 18. desember 2017 16.14<br>
<b>To:</b> Moritz Lennert <<a href="mailto:mlennert@club.worldonline.be" target="_blank">mlennert@club.worldonline.be</a>><br>
<b>Cc:</b> GRASS user list <<a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a>><span class=""><br>
<b>Subject:</b> Re: [GRASS-user] i.atcorr with Sentinel2<u></u><u></u></span></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">Dear Moritz,<u></u><u></u></p>
</div><div><div class="h5">
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">According to <a href="https://earth.esa.int/web/sentinel/user-guides/sentinel-2-msi/product-types" target="_blank">https://earth.esa.int/web/<wbr>sentinel/user-guides/sentinel-<wbr>2-msi/product-types</a> , the L1C product I am using already is in top of atmosphere
 reflectance, so this should not be the problem (?). <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I tried running i.atcorr both with and without the -r flag.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Zofie<u></u><u></u></p>
</div>
</div></div></div><div><div class="h5">
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Mon, Dec 18, 2017 at 3:35 PM, Moritz Lennert <<a href="mailto:mlennert@club.worldonline.be" target="_blank">mlennert@club.worldonline.be</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal">On 18/12/17 13:14, Žofie Cimburová wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal">Hi all,<br>
Now the 6S parameters are complete, but the output map contains only NULLs, no matter what combinations of input parameters and flags I use. Have anyone encountered the same issue? (Info below.)<u></u><u></u></p>
</blockquote>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
In the i.atcorr man page it says:<br>
<br>
"If flag -r is used, the input raster data are treated as reflectance. Otherwise, the input raster data are treated as radiance values"<br>
<br>
IIUC, your data is still in DN. You might want to try to transform this into radiance values before sending it into i.atcorr.<br>
<br>
Moritz<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal"><br>
Thanks again.<br>
Zofie<br>
<br>
------------------------------<wbr>----------<br>
Version:<br>
g.version -g<br>
version=7.4.0RC1<br>
date=2017<br>
revision=exported<br>
build_date=2017-11-18<br>
build_platform=x86_64-pc-<wbr>linux-gnu<br>
build_off_t_size=8<br>
<br>
------------------------------<wbr>----------<br>
Region:<br>
g.region -p<br>
projection: 1 (UTM)<br>
zone:       33<br>
datum:      etrs89<br>
ellipsoid:  grs80<br>
north:      6653695<br>
south:      6643685<br>
west:       256495<br>
east:       266505<br>
nsres:      10<br>
ewres:      10<br>
rows:       1001<br>
cols:       1001<br>
cells:      1002001<br>
<br>
------------------------------<wbr>----------<br>
Input data: Sentinel2 L1C product B02 (tried with B01 too)<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><a href="http://r.info" target="_blank">r.info</a> <<a href="http://r.info" target="_blank">http://r.info</a>> map=test_B02@p_<wbr>Sentinel4Nature_S2_Oslo<br>
  +---------------------------<wbr>------------------------------<wbr>-------------------+<br>
  | Map:      test_B02@p_Sentinel4Nat  Date: Wed Dec  6 12:06:39 2017<br>
  | Mapset:   p_Sentinel4Nature_S2_Oslo      Login of Creator: stefan.blumentr<br>
  | Location: ETRS_33N<br>
  | DataBase: /data/grass<br>
  | Title:    S2A_OPER_PRD_MSIL1C_PDMC_<wbr>20160907T044118_R008_<wbr>V20160905T104022_2<br>
  | Timestamp: none<br>
  |---------------------------<wbr>------------------------------<wbr>-------------------|<br>
  |<br>
  |   Type of Map:  raster               Number of Categories: 0<br>
  |   Data Type:    CELL<br>
  |   Rows:         1001<br>
  |   Columns:      1001<br>
  |   Total Cells:  1002001<br>
  |        Projection: UTM (zone 33)<br>
  |            N:    6653695    S:    6643685   Res:    10<br>
  |            E:     266505    W:     256495   Res:    10<br>
  |   Range of data:    min = 1  max = 28000<br>
  |<br>
  |   Data Description:<br>
  |    generated by r.in.gdal<br>
  +---------------------------<wbr>------------------------------<wbr>-------------------+<br>
<br>
------------------------------<wbr>----------<br>
6s file:<br>
25- geometrical conditions=Sentinel-2A<br>
9 5 10.6728 10.73413 59.90647- month day hh.ddd longitude latitude<br>
4 - atmospheric model=subarctic summer<br>
3- aerosol model=urban<br>
50- visibility [km] (aerosol model concentration) (this is estimated, I also tried with AOD specified)<br>
-0.055- mean target elevation above sea level [km]<br>
-1000- sensor height<br>
166- Sentinel2A Blue band B2 (440nm - 535nm)<br>
<br>
------------------------------<wbr>----------<br>
Command:<br>
i.atcorr input=test_B02@p_<wbr>Sentinel4Nature_S2_Oslo range=1,28000 elevation=dem_10m_25833@p_<wbr>Sentinel4Nature_S2_Oslo parameters=/home/<a href="http://NINA.NO/zofie.cimburova/Sentinel4Nature/DATA/6s.txt" target="_blank">NINA.NO/<wbr>zofie.cimburova/<wbr>Sentinel4Nature/DATA/6s.txt</a>
 <<a href="http://NINA.NO/zofie.cimburova/Sentinel4Nature/DATA/6s.txt" target="_blank">http://NINA.NO/zofie.<wbr>cimburova/Sentinel4Nature/<wbr>DATA/6s.txt</a>> output=test_B02_atcorr<br>
 >Atmospheric correction...<br>
 >Atmospheric correction complete.<br>
<br>
(I am not sure about the range parameter, tried with 0,255 too. The DEM contains no NULLs. Also tried running with -r and -a flags.)<br>
<br>
------------------------------<wbr>----------<br>
Output:<br>
<a href="http://r.info" target="_blank">r.info</a> <<a href="http://r.info" target="_blank">http://r.info</a>> map=test_B02_atcorr@p_<wbr>Sentinel4Nature_S2_Oslo<br>
  +---------------------------<wbr>------------------------------<wbr>-------------------+<br>
  | Map:      test_B02_atcorr@p_Sentinel4N  Date: Mon Dec 18 13:10:14 2017<br>
  | Mapset:   p_Sentinel4Nature_S2_Oslo      Login of Creator: zofie.cimburova<br>
  | Location: ETRS_33N<br>
  | DataBase: /data/grass<br>
  | Title:    test_B02_atcorr2<br>
  | Timestamp: none<br>
  |---------------------------<wbr>------------------------------<wbr>-------------------|<br>
  |<br>
  |   Type of Map:  raster               Number of Categories: 0<br>
  |   Data Type:    FCELL<br>
  |   Rows:         1001<br>
  |   Columns:      1001<br>
  |   Total Cells:  1002001<br>
  |        Projection: UTM (zone 33)<br>
  |            N:    6653695    S:    6643685   Res:    10<br>
  |            E:     266505    W:     256495   Res:    10<br>
  |   Range of data:    min = -nan  max = -nan<br>
  |<br>
  |   Data Description:<br>
  |    generated by i.atcorr<br>
  |<br>
  |   Comments:<br>
  |    i.atcorr input="test_B02@p_<wbr>Sentinel4Nature_S2_Oslo" range=1,28\<br>
  |    000 elevation="dem_10m_25833@p_<wbr>Sentinel4Nature_S2_Oslo" para\<br>
  |    meters="/home/<a href="http://NINA.NO/zofie.cimburova/Sentinel4Nature/DATA/6s.txt" target="_blank">NINA.NO/zofie.<wbr>cimburova/Sentinel4Nature/<wbr>DATA/6s.txt</a> <<a href="http://NINA.NO/zofie.cimburova/Sentinel4Nature/DATA/6s.txt" target="_blank">http://NINA.NO/zofie.<wbr>cimburova/Sentinel4Nature/<wbr>DATA/6s.txt</a>>"
 o\<br>
  |    utput="test_B02_atcorr2" rescale=0,255<br>
  |<br>
  +---------------------------<wbr>------------------------------<wbr>-------------------+<br>
<br>
<br>
<br>
On Fri, Dec 15, 2017 at 5:12 PM, Žofie Cimburová <<a href="mailto:zoficimburova@gmail.com" target="_blank">zoficimburova@gmail.com</a> <mailto:<a href="mailto:zoficimburova@gmail.com" target="_blank">zoficimburova@gmail.<wbr>com</a>>> wrote:<br>
<br>
    Dear Markus,<br>
    thanks for your reply, this is exactly what I need to know!<br>
<br>
    Best, Zofie<br>
<br>
    On Fri, Dec 15, 2017 at 5:09 PM, Markus Neteler <<a href="mailto:neteler@osgeo.org" target="_blank">neteler@osgeo.org</a><br>
    <mailto:<a href="mailto:neteler@osgeo.org" target="_blank">neteler@osgeo.org</a>>> wrote:<br>
<br>
<br>
        On Dec 15, 2017 3:54 PM, "Žofie Cimburová"<br>
        <<a href="mailto:zoficimburova@gmail.com" target="_blank">zoficimburova@gmail.com</a> <mailto:<a href="mailto:zoficimburova@gmail.com" target="_blank">zoficimburova@gmail.<wbr>com</a>>> wrote:<br>
        ><br>
        > Dear all,<br>
        > I am trying to use i.atcorr (GRASS 7.4) to apply atmospheric corrections for Sentinel 2 data. The documentation provides a great help, but there are two points I am not sure about -         ><br>
        > - I don't need the atmospheric correction to be applied to the whole scene, so I only imported a small clip of the scene to GRASS. What longitude and latitude shall I then specify in the 6S parameters?<br>
<br>
        I'd use the center coordinates of the clipped area.<br>
<br>
        > Or is it necessary to apply the corrections to the entire scene?<br>
<br>
        No since it is a pixel based algorithm.<br>
<br>
        > - How can I estimate the value of visibility (aerosol model concentration)?
<br>
        There are AERONET data online somewhere which might be the best<br>
        choice.<br>
<br>
        Markus<br>
<br>
<br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
grass-user mailing list<br>
<a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/grass-user</a><u></u><u></u></p>
</blockquote>
<p class="MsoNormal" style="margin-bottom:12.0pt"><u></u> <u></u></p>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div></div></div>
</div>

</blockquote></div><br></div>