robintw / Py6S

A Python interface to the 6S Radiative Transfer Model
GNU Lesser General Public License v3.0
195 stars 108 forks source link

The updated S3A OLCI RSRs and new S3B OLCI RSRs #50

Closed MarcYin closed 5 years ago

MarcYin commented 5 years ago

This is proposed solution to issue #49 by adjusting the sampling to keep the max value of RSRs at the right place.

The new RSRs for S3A and S3B

image

image

Marc.

robintw commented 5 years ago

Thanks for this Marc.

A few questions/comments:

  1. What did you change in the Pleiades and RapidEye response functions? I see they've changed, but I can't see what/why.

  2. I'm intrigued as to whether the way that you've done the response functions actually works properly or not. 6S needs to take the response functions at 2.5nm intervals. You've done 2.5nm intervals, but haven't started from a 'round' 2.5nm wavelength. For example, you've started from something like 0.521um, rather than something that evenly divides by 2.5nm like 0.520 or 0.5225. Interestingly, I can't see anywhere in the documentation where 6S says it actually requires the response functions to be given starting from 'round' numbers - but all of the spectral response functions that are built-in to 6S (Landsat, AVHRR etc) start and finish at round numbers.

Now, it seems that 6S doesn't crash when given a response function which doesn't start at round numbers (as the tests pass - and one test runs a simulation with each of the PredefinedWavelengths values in turn) - but I'm concerned that it might not give the right answer. The error-handling and robustness of the underlying 6S code is fairly poor, as is the documentation, and the author is unresponsive to emails.

I'm not sure what the best thing to do here is - whether to go ahead with these new response functions and assume that everything is working correctly, or stick to the old ones, or try and do some further investigation. What do you think?

I'm trying to think of some tests that we could do to see whether it is working correctly - but we'd need to have some output of another radiative transfer model to see how they compare. Alternatively, I can try and trace the code that processes the response functions - but this is quite tricky as the 6S code is in Fortran 77 and very hard to interpret.

MarcYin commented 5 years ago

Hi,

I commented them out because if you have a check previous Travis test, they all failed at: test/test_predefined_wavelengths.py::PredefinedWavelengthTests::test_all_predefined_wavelengths FAILED [ 52%]. The shape of predefined PLEIADES and RAPIDEYE RSRs have different shape of the RSR filter and wavelengths, which causes the error of: E ParameterError: wavelength: Wavelength must be between 0.200000 and 4.000000 So the RSRs for those two sensors have to be updated as well.

After some checking of 6S code, it seems they do interpolation internal again to ensure all the wavelength are consistent to have 2.5nm step and round them to between the predefined spectral range, so even after adaption the RSRs will be again different from the one I have specified. So I have changed it has the start and end to be round at 2.5nm.

EQUIVWL.f:

    subroutine equivwl(iinf,isup,step,wlmoy)

      common /sixs_ffu/s(1501),wlinf,wlsup
      real step,wlmoy,s,wlinf,wlsup,seb,wlwave,sbor,wl,swl,coef
      integer iinf,isup,l

      seb=0.
      wlwave=0.

      do 50 l=iinf,isup
        sbor=s(l)                                                                                                                             
        if(l.eq.iinf.or.l.eq.isup) sbor=sbor*0.5
        wl=.25+(l-1)*step
        call solirr(wl,swl)
        coef=sbor*step*swl
        seb=seb+coef
        wlwave=wlwave+wl*coef
  50  continue
      wlmoy=wlwave/seb
      return
      end

The newly adapted RSRs for S3A and S3B( two bands are almost centred and one missed the centre):

image image

Marc.

robintw commented 5 years ago

That looks great - thank you!

(I missed that you'd commented out the other spectral responses - sorry. I'll try and look at them shortly and get them sorted).

In the meantime, I'll merge this - thanks for contributing!

MarcYin commented 5 years ago

Cheers,

Marc.