Problem using C2RCC atmospheric correction

Hi
I am using the dedicated SNAP resampler for Sentinel-2 images (called “S2Resamp”) to run C2RCC (I am attaching the xml file I am running on a linux command line. It works, but there are two disadvantages:

  1. This resampler does not allow the subsampling of an image, and I have to process the whole tile.
  2. It only processes the first 6 bands. However, I have seen in published articles that C2RCC gives output on other bands as well, for example B7 (783 nm).

I was wondering if you know how to fix this 2nd problem, that would allow me to process more bands (beyond the first 6 bands).

Thank you for your time. The xml file that I am using is the followingS2_resamp_c2rcc_20m.xml (1.9 KB)

With the S2 resampler you can down-sample to 60m. Which is kind of subsampling for the 10- and 20-meter bands. The S2resampler was developed for accurate results because it considered the view geometry data.
If you want to go to a lower resolution, you can use the generic resampler. If you want to subset your data, you can use the Subset operation.

There should not only be 6 Bands, the C2RCC generates output spectra using the bands “B1”, “B2”, “B3”, “B4”, “B5”, “B6”, “B7” and “B8A”.

Dear Peters
I have a new xml file (attached) where I am using the generic resampler and subset operators, however, when I run it with gpt using the following command

gpt /home/dmantsis/Run_c2rcc_10m_v2.xml -f NetCDF4-CF -q 4 -c 10G -x -t /home/dmantsis/Result.nc

it always gives me an error (Error: [NodeId: c2rcc] Source must be a resampled S2 MSI L1C product). This does not make any sense, because the c2rcc is geting a resampled S2 MSI L1C product. I was wondering if you could take a look at the attached xml file. Maybe I am doing something wrong and someone with a great experience like you could spot it right away. Thank you for your time Run_c2rcc_10m_v2.xml (3.1 KB)

Have you tried to run it in th GUI beforehand?
I tried to do something similar with one of my images, and the C2RCC cannot handle only the few bands you extracted.

Dear Dr Ruescas
Initially I tried this with the GUI. First I was running the graph (that included only the Read, Write, Resampler and Subset operators). The graph was running correctly in gpt and was producing two output files. One *.data and one *.dim file/folders. The problem was when I was trying to run the 2nd step (C2RCC) and I was getting the error (Error: [NodeId: c2rcc] Source must be a resampled S2 MSI L1C product).

Also, I saw that you eddited your previous response while I was writing my response. Can you explain what you did and what you got as an output, and whether you have any suggestions to fix the problem.

Thank you

The displayed message is not good. You should not limit the input bands so much.
The C2RCC needs all 13 reflectance bands and the bands
sun_zenith, sun_azimuth, view_zenith_mean, view_azimuth_mean

1 Like

The error is related to the lack of bands, the resample is fine. I tried both cases and only when you have all bands, tha last step (c2rcc) is done.

Hi
Let me ask a question to make sure I understand what exactly you are suggesting. Are you suggesting to include all 13 bands in the xml operator where in my case i only have 7 bands, or you are referring to something else? And did you run the xml file I have attached above on the command line OR did you run your own xml file with the settings you mention?

Also, dear Peters, how do you include the sun_zenith, sun_azimuth,… and the others in the xml file?
Thank you

First thing you have to do, before using GPT, is to see if your chain works in the GUI. I applied the chain processing manually. You can also check if it works in the Graph Builder before using the gpt option. What Marco is telling you is that you do not have to subset by bands if you want to use C2RCC because you need other auxiliary data that is included in the file, and by selecting only a few bands, you get rid of that other info too. You can still subset by region, but forget about the bands.

In your xml you should remove two parameters
from the subset operator.
image
The sourceBands and also the region.
When deleting sourceBands all bands will be available to the C2RCC operator not only the ones which are listed.
The region parameter can be confusing when at the same time the geoRegion is provided.
The C2RCC operator gives precedence to the geoRegion, but for making the xml easier to understand it is better to provide only one of those parameters.

Hi
First of all, thank you. Deleting the two parameters Marko suggested (region and SourceBands) from the xml file worked, and I have successfully run the code and it produced output only for the lake of interest. I need to ask however a few clarification questions:

  1. I am interested in the Remote sensing reflectance and for that I am looking at the normalized water leaving reflectance (which I divide with 3.14 to get the Rrs). This parameter is still only given for the first 6 bands. How can we fix this? Or maybe I am looking at the wrong parameters, and maybe I should be looking at the Angular dependent remote sensing reflectance, which is given for the first 8 bands? Please let me know which is correct.

  2. If I don’t want to delete the sourceBands parameter from the Subset operator in the xml file, can I alternatively just include all 13 bands B1, B2, …B12 in the sourceBands parameter? Is this going to lead to the same result?

Thank you

Yes, you are right, for the normalised rhow there are only 6 bands. The neural net calculates only those 6.
There is also an explanation for this that I was told. But I forgot it. Sorry.
For the normal rhow you get all 8 bands.

If you add all necessary bands to the sourceBands parameter, it should work too.
<sourceBands>B1,B2,B3,B4,B5,B6,B7,B8,B8A,B9,B10,B11,B12,sun_zenith, sun_azimuth, view_zenith_mean, view_azimuth_mean</sourceBands>

Dear Peters
I was wondering if I could ask 3 last and simple questions.

  1. How do you activate the normal rhow (not normalized)? I am not getting it in the output. Is it simple as (outputRhow) true (/outputRhow)?
  2. What does the parameter (outputAsRrs) do?
  3. Is it possible to get a Rrs for land and water?

Thank you very much for your help

I apologize because my initial message this morning was problematic, but I made some edits.
Thank you

The normalized rhow are always written, but you have set the outputAsRrs option to true. That’s why they are shown as rrs in your result.
I think this answeres the first two question.

Regarding the third question, yes you can. But you shouldn’t do it.
You can remove the valid-pixel expression B8 > 0 && B8 < 0.1 or set it to true. Then all pixels are processed and you will get a result for land pixels. But the neural nets which are used are trained for water and not for land. So the results will not be good.

Thank you, you are awesome

Dear Peters
I tried to run C2RCC with both options “false” and “true” for OutputAsRrs and the output was the same. So, I got a little confused how to get the water leaving reflectance for bands B1,…, B7, B8A. In both cases I only got the angular Rrs for 8 bands and the normalized rhow for 6 bands. Is there something I am missing?
Thank you

The rhow are the defaults. If I just run the C2RCC without changing any parameter, I get them as you can see in the screenshot.

I provide you the parameter section in text form:

<parameters>
    <validPixelExpression>B8 > 0 && B8 < 0.1</validPixelExpression>
    <salinity>35.0</salinity>
    <temperature>15.0</temperature>
    <ozone>330.0</ozone>
    <press>1000.0</press>
    <elevation>0.0</elevation>
    <TSMfac>1.72</TSMfac>
    <TSMexp>3.1</TSMexp>
    <CHLexp>1.04</CHLexp>
    <CHLfac>21.0</CHLfac>
    <thresholdRtosaOOS>0.05</thresholdRtosaOOS>
    <thresholdAcReflecOos>0.1</thresholdAcReflecOos>
    <thresholdCloudTDown865>0.955</thresholdCloudTDown865>
    <netSet>C2RCC-Nets</netSet>
    <outputAsRrs>false</outputAsRrs>
    <deriveRwFromPathAndTransmittance>false</deriveRwFromPathAndTransmittance>
    <outputRtoa>true</outputRtoa>
    <outputRtosaGc>false</outputRtosaGc>
    <outputRtosaGcAann>false</outputRtosaGcAann>
    <outputRpath>false</outputRpath>
    <outputTdown>false</outputTdown>
    <outputTup>false</outputTup>
    <outputAcReflectance>true</outputAcReflectance>
    <outputRhown>true</outputRhown>
    <outputOos>false</outputOos>
    <outputKd>true</outputKd>
    <outputUncertainties>true</outputUncertainties>
</parameters>

Ok I think I understand what is happening. I am also getting the rhow in 8 bands. The long name though is “atmospherically corrected angular dependent water leaving reflectance”. I am confused by the “angular dependent” part.

  1. What does that mean?
  2. And can I just divide this with 3.14 and get the Rrs that I could directly compare to Rrs from other Atmospheric Correction algorithms like Acolite?

Thank you

The rrs value you get when enabling outputAsRrs is the value rhow divided by PI. This safe you the manual step of dividing the value by PI.
Angular dependent does mean that it is normalized. Normalized means the values are as they would have been observed in the nadir of the sensor. The view angle is corrected. It’s also known as a BRDF correction.