First of all, thank you for publishing openly the Py6S package. I really appreciate such a free, handy tool!
What I am trying to do, is to calculate atmospheric transmittance between a ground target and a remote sensing drone (at e.g. 100m altitude). While trying to calculate that I found some really strange behavior (a bug?) in Rayleigh upward transmittance result. This seems to occur when sensor altitudes is set with set_sensor_custom_altitude() instead of set_sensor_sea_level() or set_sensor_satellite_level().
To reproduce the error, I ran the 6S simulation using default Py6S parameters on sea level, on satellite level, and on 4 custom altitudes in between. This is how the result: “transmittance_rayleigh_scattering.upward” comes out:

As expected the “Sea level” (with set_sensor_sea_level()) has transmittance of 1 while the “Satellite” (with set_sensor_satellite_level()) shows about what you should expect. However, the custom altitude simulations (with set_sensor_custom_altitude()) are not in between these two! The "99km" transmittance is basically the same as the satellite, but the rest of them start to develop to wrong direction! The error is clear when noticing that the ”0.1km” curve is nowhere close to the “Sea level” curve.
I believe I am setting the altitude correctly and this is a bug in the Py6S/6S as this strange behavior happens only with “transmittance_rayleigh_scattering.upward”. When I run similar plots on transmittance_aerosol_scattering.upward and transmittance_global_gas.upward, they act as expected:

Here is my minimum python code reproducing the problem and plotting the Rayleigh figure above:
#%% Simulate atmosphere under different drone altitudes
import numpy as np
import Py6S
Wavelengths_um = np.arange(350, 1001, 50)/1000
# Altitude set to SEA LEVEL
s = Py6S.SixS()
s.altitudes = Py6S.Altitudes()
s.altitudes.set_sensor_sea_level()
s.altitudes.set_target_sea_level()
_, results_SEA = Py6S.SixSHelpers.Wavelengths.run_wavelengths(s, Wavelengths_um)
# Altitude set to 0.1km
s = Py6S.SixS()
s.altitudes = Py6S.Altitudes()
s.altitudes.set_sensor_custom_altitude(0.100)
s.altitudes.set_target_sea_level()
_, results_100m = Py6S.SixSHelpers.Wavelengths.run_wavelengths(s, Wavelengths_um)
# Altitude set to 1km
s = Py6S.SixS()
s.altitudes = Py6S.Altitudes()
s.altitudes.set_sensor_custom_altitude(1.0)
s.altitudes.set_target_sea_level()
_, results_1km = Py6S.SixSHelpers.Wavelengths.run_wavelengths(s, Wavelengths_um)
# Altitude set to 10km
s = Py6S.SixS()
s.altitudes = Py6S.Altitudes()
s.altitudes.set_sensor_custom_altitude(10.0)
s.altitudes.set_target_sea_level()
_, results_10km = Py6S.SixSHelpers.Wavelengths.run_wavelengths(s, Wavelengths_um)
# Altitude set to 100km
s = Py6S.SixS()
s.altitudes = Py6S.Altitudes()
s.altitudes.set_sensor_custom_altitude(99.0)
s.altitudes.set_target_sea_level()
_, results_99km = Py6S.SixSHelpers.Wavelengths.run_wavelengths(s, Wavelengths_um)
# Altitude set to SATELLITE
s = Py6S.SixS()
s.altitudes = Py6S.Altitudes()
s.altitudes.set_sensor_satellite_level()
s.altitudes.set_target_sea_level()
_, results_SAT = Py6S.SixSHelpers.Wavelengths.run_wavelengths(s, Wavelengths_um)
#%% Plot transmittance spectra
def transmittance_spectrum(results):
return [result.transmittance_rayleigh_scattering.upward for result in results]
import matplotlib.pyplot as plt
plt.figure()
plt.plot(Wavelengths_um, transmittance_spectrum(results_SEA), 'ko:', label='Sea level')
plt.plot(Wavelengths_um, transmittance_spectrum(results_100m), 'kx-', label='0.1km')
plt.plot(Wavelengths_um, transmittance_spectrum(results_1km), 'bx-', label='1km')
plt.plot(Wavelengths_um, transmittance_spectrum(results_10km), 'gx-', label='10km')
plt.plot(Wavelengths_um, transmittance_spectrum(results_99km), 'rx-', label='99km')
plt.plot(Wavelengths_um, transmittance_spectrum(results_SAT), 'ro:', label='Satellite')
plt.ylim([0.45, 1.05])
plt.grid()
plt.legend()
plt.xlabel('Wavelength (um)')
plt.ylabel('Rayleigh transmittance')
My Py6S version is "1.7.2_py_1" that was installed this week from conda-forge.
Am I doing something wrong or have I discovered a bug in simulation/in output of results?
Best regards
-Juha Suomalainen
--
You received this message because you are subscribed to the Google Groups "Py6S" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py6s+uns...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/py6s/0fe91f9a-8d25-43d5-bcb4-5dbad53f8e0c%40googlegroups.com.
* downward upward total *...* rayl. sca. trans. : 0.93267 0.86730 0.80890 ** aeros. sca. " : 0.89678 0.99507 0.89236 ** total sca. " : 0.83040 0.99442 0.82577 *
The total scattering row should be result of multiplication of rayleigh and aerosol rows. We can see here that this is not the case on upward and total columns. The fact that the total scattering row is different (and actually has sensible values in different altitudes!), would indicate that internally the 6S is using some other Rayleigh value than what is shown in output file. Most likely the 6S has just a bug where it retrieves wrong value for "upward Rayleigh transmittance" when writing the output.
This solves the issue for me, as I actually don't even need the Rayleigh transmittance itself for anything. I just need to have the total upward transmittance which I believe is:
transmittance_total = result.transmittance_total_scattering.upward *result.transmittance_global_gas.upward
I just got confused as the Rayleigh seemed NOT to be included the in the "transmittance_total_scattering" and thought I had to add it separately.
If you want, you could add a 2 line fix to the Py6S as it is still possible to determine the correct Rayleigh values using the total_scattering values:
result.transmittance_rayleigh_scattering.upward = result.transmittance_total_scattering.upward / result.transmittance_aerosol_scattering.upward
result.transmittance_rayleigh_scattering.total= result.transmittance_total_scattering.total/ result.transmittance_aerosol_scattering.total
Thanks!-Juha
--
You received this message because you are subscribed to the Google Groups "Py6S" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py6s+uns...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/py6s/846c1817-74b3-4499-9d2a-f80b4fa00b81%40googlegroups.com.