Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#3482 closed enhancement (fixed)

i.atcorr: Add Sentinel-2B

Reported by: sbl Owned by: sbl
Priority: normal Milestone: 7.4.1
Component: Imagery Version: svn-trunk
Keywords: i.atcorr Cc: grass-dev@…
CPU: All Platform: All

Description

Currently, only Sentinel-2A is implemented in i.atcorr: https://lists.osgeo.org/pipermail/grass-user/2018-January/077668.html Sentinel-2B should be added as well.

Attachments (2)

i_atcorr_create_iwave_py.diff (2.4 KB ) - added by sbl 6 years ago.
create_iwave.py maintenance
i.atcorr_trunk_S2B.diff (351.7 KB ) - added by sbl 6 years ago.
Add Sentinel-2B to i.atcorr; update Sentinel-2A curves v3

Download all attachments as: .zip

Change History (16)

comment:1 by sbl, 6 years ago

Please find attached a first attempt for a diff that adds Sentinel-2B to i.atcorr and updates create_iwave.py as discussed on ML (above).

If you can confirm that my edits of create_iwave.py are OK, I will also update Sentinel-2A curves (in a separate ticket.

Please let me know if you prefer the contribution in another form (e.g. a diff per file...).

in reply to:  1 comment:2 by mmetz, 6 years ago

Replying to sbl:

Please find attached a first attempt for a diff that adds Sentinel-2B to i.atcorr and updates create_iwave.py as discussed on ML (above).

If you can confirm that my edits of create_iwave.py are OK, I will also update Sentinel-2A curves (in a separate ticket.

Please let me know if you prefer the contribution in another form (e.g. a diff per file...).

One diff for create_iwave.py and another diff for adding Sentinel-2B would be better because these are two different issues.

Unfortunately, the changes to create_iwave.py did not work out: the created cpp template is wrong because response values start with -1 and all the leading and trailing zeroes are still in there. Please don't modify interpolate_band().

For example, the cpp template for Sentinel 2A band 1 should be

    /* SR_AV_B1 of sentinel_2A_msi */
    static const float sr1[11] = {
		.0153, .2766, .5116, .6004, .6992, .8274, .9939, .9815,
		.9567, .5561, .0518
    };

comment:3 by SBL, 6 years ago

Ah, OK. Now I got it (I think). Will fix that ASAP.

by sbl, 6 years ago

create_iwave.py maintenance

comment:4 by sbl, 6 years ago

OK, just added a second try.

Now:

  • No Data is replaced by 0
  • all leading and trailing zeros are filtered out (replaced by -1 in read_input() and then removed by interpolate_band())
  • interpolate_band() remains unchanged
  • changes in write_cpp() only add informative messages for wavelength range, where spectral response is > 0.1 (this differs from exact / total ranges in the cpp template.

Output for Band 1 for example now looks like this:

    /* SR_AV_B1 of sentinel_2B_msi */
    static const float sr1[18] = {
		.0068, .0054, .0071, .0053, .0006, .0042, .0026, .0088,
		.1887, .7887, .8814, .9260, .9504, .9843, .9764, .9390,
		.8090, .2076
    };

Wavelength ranges in the cpp template look like this:

    static const float wli[13] = {0.411, 0.438, 0.536, 0.646, 0.694, 0.730, 0.766, 0.774, 0.848, 0.930, 1.339, 1.538, 2.065};
    static const float wls[13] = {0.456, 0.532, 0.582, 0.685, 0.714, 0.748, 0.794, 0.907, 0.880, 0.957, 1.415, 1.679, 2.303};

Hope that is more like you meant!?

comment:5 by sbl, 6 years ago

And now there are also the additions for S2B support. (Description of the patch above is incorrect . create_iwave.py is actually excluded from the patch).

Ready to update S2A as well, if the changes above are OK.

For the record, (latest) response curves fetched from: https://sentinels.copernicus.eu/documents/247904/685211/S2-SRF_COPE-GSEG-EOPG-TN-15-0007_3.0.xlsx

in reply to:  4 comment:6 by mmetz, 6 years ago

Replying to sbl:

OK, just added a second try.

Now:

  • No Data is replaced by 0
  • all leading and trailing zeros are filtered out (replaced by -1 in read_input() and then removed by interpolate_band())
  • interpolate_band() remains unchanged
  • changes in write_cpp() only add informative messages for wavelength range, where spectral response is > 0.1 (this differs from exact / total ranges in the cpp template.

Output for Band 1 for example now looks like this:

    /* SR_AV_B1 of sentinel_2B_msi */
    static const float sr1[18] = {
		.0068, .0054, .0071, .0053, .0006, .0042, .0026, .0088,
		.1887, .7887, .8814, .9260, .9504, .9843, .9764, .9390,
		.8090, .2076
    };

Wavelength ranges in the cpp template look like this:

    static const float wli[13] = {0.411, 0.438, 0.536, 0.646, 0.694, 0.730, 0.766, 0.774, 0.848, 0.930, 1.339, 1.538, 2.065};
    static const float wls[13] = {0.456, 0.532, 0.582, 0.685, 0.714, 0.748, 0.794, 0.907, 0.880, 0.957, 1.415, 1.679, 2.303};

Nice!

Hope that is more like you meant!?

Yes, exactly. There is however a problem with interpolate_band(): it is not enough to interpolate at 2.5 nm steps, the resultant wavelengths must also be exact multiples of 2.5 nm. IOW, the resultant wavelength resolution must be 2.5 nm, aligned to the extents 250 - 4000 nm as expected in iwave.cpp. I have changed create_iwave.py in trunk r72118 accordingly, with your changes adapted.

in reply to:  5 comment:7 by mmetz, 6 years ago

Replying to sbl:

And now there are also the additions for S2B support. (Description of the patch above is incorrect . create_iwave.py is actually excluded from the patch).

Ready to update S2A as well, if the changes above are OK.

The new S2B support looks fine. I recommend to re-create

void IWave::sentinel2b(int iwa)

in iwave.cpp to get the new interpolated values. Then S2A can be updated as well.

Actually, all sensors for which a csv file is available should be updated. For example, have a look at new cpp templates created for rapideye and worldview2 compared to current iwave.cpp.

comment:8 by sbl, 6 years ago

Great! Thanks again!

Will update S2B curves and then have look at the other sensors where we have csv files (starting with S2A)... Will add another task ticket for those updates...

BTW, what response peaks should I use for reporting wavelength in the manual? "Response peaks from input file" or "Response peaks from interpolation to 2.5 nm steps"? create_iwave.py prints out both. I assume, peaks from interpolation is what you had in mind, right?

in reply to:  8 comment:9 by mmetz, 6 years ago

Replying to sbl:

Great! Thanks again!

Will update S2B curves and then have look at the other sensors where we have csv files (starting with S2A)... Will add another task ticket for those updates...

Makes sense.

BTW, what response peaks should I use for reporting wavelength in the manual? "Response peaks from input file" or "Response peaks from interpolation to 2.5 nm steps"? create_iwave.py prints out both. I assume, peaks from interpolation is what you had in mind, right?

The "Response peaks from interpolation to 2.5 nm steps" should go into the manual because i.atcorr uses these interpolated values. The "Response peaks from input file" are added for reference to check if the interpolation produced reasonable results.

by sbl, 6 years ago

Attachment: i.atcorr_trunk_S2B.diff added

Add Sentinel-2B to i.atcorr; update Sentinel-2A curves v3

comment:10 by neteler, 6 years ago

Cc: grass-dev@… added

Please keep grass-dev@… in cc when editing tickets!

comment:11 by martinl, 6 years ago

Milestone: 7.5.07.6.0

Milestone renamed

comment:12 by mmetz, 6 years ago

Resolution: fixed
Status: assignedclosed

Sentinel-2B has been added to i.atcorr in trunk r72127,8.

in reply to:  12 comment:13 by neteler, 6 years ago

Replying to mmetz:

Sentinel-2B has been added to i.atcorr in trunk r72127,8.

For the record: it includes the update of the Sentinel-2A curves as well.

comment:14 by neteler, 6 years ago

Milestone: 7.6.07.4.1

I made a full sync to trunk in relbranch74 (r72557) since otherwise i.atcorr could not be maintained any more (too many differences). Now all in sync again, will be available in 7.4.1.

Note: See TracTickets for help on using tickets.