Helper methods¶
The SixSHelpers module contains a number of helper functions that improve the ease-of-use of Py6S. These include functions to set 6S parameters from various external data sources, as well as functions to make it easy to produce wavelength and BRDF plots from 6S runs.
Running for many wavelengths¶
The Wavelengths class contains functions to run 6S over a number of wavelength ranges.
For example, the following code runs 6S simulations across the Visible-Near Infrared wavelength range and plots the results, producing the output shown below:
from Py6S import *
s = SixS()
s.aero_profile = AeroProfile.PredefinedType(AeroProfile.Maritime)
wavelengths, values = SixSHelpers.Wavelengths.run_vnir(s, output_name='pixel_radiance')
SixSHelpers.Wavelengths.plot_wavelengths(wavelengths, values, 'Pixel Radiance (W/m^2)')

A similar function exist to run across the whole 6S wavelength range (run_whole_range()
), and arbritary lists of wavelengths can be run using the run_wavelengths()
function. For example, you can manually specify a number of wavelengths to run for:
wv, res = SixSHelpers.Wavelengths.run_wavelengths(s, [0.46, 0.67, 0.98], output_name='apparent_radiance')
If you want to run user-specific ranges of wavelengths then you can use the handy numpy functions arange and linspace to generate the lists of wavelengths for you. For example:
# Run the model between 0.5 and 0.7um with a step of 0.001um (1nm)
wv, res = SixSHelpers.Wavelengths.run_wavelengths(s, np.arange(0.5, 0.7, 0.001), output_name='apparent_radiance')
# Run the model at 50 equally-spaced wavelengths in the range 0.9-1.5um
wv, res = SixSHelpers.Wavelengths.run_wavelengths(s, np.linspace(0.9, 1.5, 50), output_name='apparent_radiance')
Functions also exist to run for all bands of the various sensors supported in 6S (for example, run_landsat_tm()
, run_modis()
and run_aatsr()
). It should be noted that for these functions, bands which are outside of the 6S wavelength range (0.2-4.0um), such as the Landsat thermal band, will not be simulated. The example below shows the creation of a plot for the Landsat ETM bands:
from Py6S import *
s = SixS()
s.aero_profile = AeroProfile.PredefinedType(AeroProfile.Maritime)
wavelengths, values = SixSHelpers.Wavelengths.run_landsat_etm(s, output_name='pixel_reflectance')
SixSHelpers.Wavelengths.plot_wavelengths(wavelengths, values, 'Pixel Reflectance')

The supported sensors are:
- Landsat MSS, TM and ETM
- SPOT HRV1, HRV2 and Vegetation
- MERIS
- MODIS
- POLDER
- SeaWiFS
- AATSR
- ASTER
- VIIRS
- ER2 MODIS Airborne Simulator (MAS)
- ALI
- GLI
-
class
Py6S.SixSHelpers.
Wavelengths
[source]¶ Helper functions for running the 6S model for a range of wavelengths, and plotting the result
-
classmethod
run_wavelengths
(s, wavelengths, output_name=None, n=None, verbose=False)[source]¶ Runs the given SixS parameterisation for each of the wavelengths given, optionally extracting a specific output.
This function is used by all of the other wavelengths running functions, such as :method:`run_vnir`, and thus any arguments that are passed to this function can also be passed to these other functions.
The calls to 6S for each wavelength will be run in parallel, making this function far faster than simply running a for loop over each wavelength.
Arguments:
s
– ASixS
instance with the parameters set as requiredwavelengths
– An iterable containing the wavelengths to iterate overoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
n
– (Optional) The number of threads to run in parallel. This defaults to the number of CPU cores in your system, and is unlikely to need changing.verbose
– (Optional) Print wavelengths as Py6S is running (default=False)
Return value:
A tuple containing the wavelengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.Example usage:
# Run for all wavelengths from 0.4 to 0.5 micrometers, with a spacing of 1nm, returns SixS.Outputs instances wavelengths, results = SixSHelpers.PredefinedWavelengths.run_wavelengths(s, np.arange(0.400, 0.500, 0.001)) # Run for all wavelengths from 0.4 to 0.5 micrometers, with a spacing of 1nm, returns a list of pixel radiance values wavelengths, results = SixSHelpers.PredefinedWavelengths.run_wavelengths(s, np.arange(0.400, 0.500, 0.001), output_name='pixel_radiance') # Run for the first three Landsat TM bands wavelengths, results = SixSHelpers.PredefinedWavelengths.run_wavelengths(s, [PredefinedWavelengths.LANDSAT_TM_B1, PredefinedWavelengths.LANDSAT_TM_B2, PredefinedWavelengths.LANDSAT_TM_B3)
-
classmethod
run_vnir
(s, spacing=0.005, **kwargs)[source]¶ Runs the given SixS parameterisation for wavelengths over the Visible-Near Infrared range, optionally extracting a specific output.
By default, the given model is run for wavelengths from 0.4-1.4um, with a spacing of 5nm.
Arguments:
s
– ASixS
instance with the parameters set as requiredspacing
– (Optional) The spacing to use between each wavelength, in um. Eg. a spacing of 0.001 is a spacing of 1nm.output_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the wavelengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.Example usage:
# Run for the VNIR wavelengths, with the default spacing (5nm), returning SixS.Outputs instances wavelengths, results = SixSHelpers.PredefinedWavelengths.run_vnir(s) # Run for the VNIR wavelengths, with a spacing of 10nm, returning pixel reflectance values wavelengths, results = SixSHelpers.PredefinedWavelengths.run_vnir(s, spacing=0.010, output_name='pixel_reflectance')
-
classmethod
run_whole_range
(s, spacing=0.01, **kwargs)[source]¶ Runs the given SixS parameterisation for the entire wavelength range of the 6S model, optionally extracting a specific output.
By default, the given model is run for wavelengths from 0.2-4.0um, with a spacing of 10nm.
Arguments:
s
– ASixS
instance with the parameters set as requiredspacing
– (Optional) The spacing to use between each wavelength, in um. Eg. a spacing of 0.001 is a spacing of 1nm.output_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the wavelengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.Example usage:
# Run for the VNIR wavelengths, with the default spacing (5nm), returning SixS.Outputs instances wavelengths, results = SixSHelpers.PredefinedWavelengths.run_vnir(s) # Run for the VNIR wavelengths, with a spacing of 10nm, returning pixel reflectance values wavelengths, results = SixSHelpers.PredefinedWavelengths.run_vnir(s, spacing=0.010, output_name='pixel_reflectance')
-
classmethod
to_centre_wavelengths
(item)[source]¶ Get centre wavelengths for a sensor from a list of the wavelength tuples.
This is calculated simple as minwv+((maxwv-minwv)/2) and is the CENTER wavelength (that is the wavelength in the middle of the range) not necessarily the peak wavelength.
-
classmethod
run_landsat_tm
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the Landsat TM bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_landsat_oli
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the Landsat TM bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_landsat_etm
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the Landsat ETM bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_landsat_mss
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the Landsat MSS bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_s2a_msi
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the Sentinel2/MSI bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_s2b_msi
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the Sentinel2/MSI bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_s3a_olci
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the Sentinel3/OLCI bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_s3a_slstr
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the Sentinel3/SLSTR bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_s3b_olci
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the Sentinel3/OLCI bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_s3b_slstr
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the Sentinel3/SLSTR bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_meris
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the MERIS bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_modis
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the MODIS bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_aqua
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the MODIS bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_terra
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the MODIS bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_spot_hrv
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the SPOT HRV (both 1 and 2, as the only bands specified are the same for both) bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_spot_vgt
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the SPOT Vegetation bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_probav_1
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the Proba-V left camera bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_probav_2
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the Proba-V middle camera bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_probav_3
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the Proba-V right camera bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_polder
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the POLDER bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_seawifs
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the SeaWiFS bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_aatsr
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the AATSR bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_aster
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the ASTER bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_viirs
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the VIIRS bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_er2_mas
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the ER2 MODIS Airborne Simulator (MAS) bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_ali
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the ALI bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
run_gli
(s, **kwargs)[source]¶ Runs the given SixS parameterisation for all of the GLI bands within the 6S band range, optionally extracting a specific output.
Arguments:
s
– ASixS
instance with the parameters set as requiredoutput_name
– (Optional) The output to extract froms.outputs
, as a string that could be placed afters.outputs.
, for examplepixel_reflectance
Return value:
A tuple containing the centre wavlengths used for the run and the results of the simulations. The results will be a list of
SixS.Outputs
instances ifoutput_name
is not set, or a list of values of the selected output ifoutput_name
is set.
-
classmethod
extract_output
(results, output_name)[source]¶ Extracts data for one particular SixS output from a list of SixS.Outputs instances.
Basically just a wrapper around a list comprehension.
Arguments:
results
– A list ofSixS.Outputs
instancesoutput_name
– The name of the output to extract. This should be a string containing whatever is put after the s.outputs when printing the output, for example ‘pixel_reflectance’.
-
classmethod
plot_wavelengths
(wavelengths, values, y_axis_label)[source]¶ Plot the given wavelengths and values, such as those produced by the other functions in this class.
Arguments:
wavelengths
– A list of wavelengths (in um)values
– A corresponding list of values at the wavelengths abovey_axis_label
– A string containing tha axis label to use for the Y axis
Example usage:
SixSHelpers.PredefinedWavelengths.plot_wavelengths(wavelengths, values, 'Pixel Radiance ($W/m^2$)')
-
classmethod
Running for many angles¶
The Angles class contains functions to run 6S over a number of different angles, which are particularly useful when dealing with surfaces with a modelled-BRDF.
For example, the following code runs 6S simulations for many view zenith and azimuth angles and plots a polar contour plot of the resulting reflectance distribution. The output is shown below:
s = SixS()
s.ground_reflectance = GroundReflectance.HomogeneousRoujean(0.037, 0.0, 0.133)
s.geometry.solar_z = 30
s.geometry.solar_a = 0
SixSHelpers.Angles.run_and_plot_360(s, 'view', 'pixel_reflectance')

-
class
Py6S.SixSHelpers.
Angles
[source]¶ -
classmethod
run360
(s, solar_or_view, na=36, nz=10, output_name=None, n=None)[source]¶ Runs Py6S for lots of angles to produce a polar contour plot.
The calls to 6S for each angle will be run in parallel, making this function far faster than simply running a for loop over all of the angles.
Arguments:
s
– ASixS
instance configured with all of the parameters you want to run the simulation withsolar_or_view
– Set to'solar'
if you want to iterate over the solar zenith/azimuth angles or'view'
if you want to iterate over the view zenith/azimuth anglesoutput_name
– (Optional) The name of the output from the 6S simulation to plot. This should be a string containing exactly what you would put afters.outputs
to print the output. For example pixel_reflectance.na
– (Optional) The number of azimuth angles to iterate over to generate the data for the plot (defaults to 36, giving data every 10 degrees)nz
– (Optional) The number of zenith angles to iterate over to generate the data for the plot (defaults to 10, giving data every 10 degrees)n
– (Optional) The number of threads to run in parallel. This defaults to the number of CPU cores in your system, and is unlikely to need changing.
For example:
s = SixS() s.ground_reflectance = GroundReflectance.HomogeneousWalthall(0.48, 0.50, 2.95, 0.6) s.geometry.solar_z = 30 s.geometry.solar_a = 0 data = SixSHelpers.Angles.run360(s, 'view', output_name='pixel_reflectance')
-
classmethod
plot360
(data, output_name=None, show_sun=True, **kwargs)[source]¶ Plot the data returned from
run360()
as a polar contour plot, selecting an output if required.Arguments:
data
– The return value fromrun360()
output_name
– (Optional) The output name to extract (eg. “pixel_reflectance”) if the given data is provided as instances of the Outputs classshow_sun
– (Optional) Whether to show the location of the sun on the resulting polar plot.colorbarlabel
– (Optional) The label to use on the color bar shown with the plot
-
classmethod
run_and_plot_360
(s, solar_or_view, output_name, show_sun=True, na=36, nz=10, colorbarlabel=None)[source]¶ Runs Py6S for lots of angles to produce a polar contour plot.
Arguments:
s
– ASixS
instance configured with all of the parameters you want to run the simulation withsolar_or_view
– Set to'solar'
if you want to iterate over the solar zenith/azimuth angles or'view'
if you want to iterate over the view zenith/azimuth anglesoutput_name
– The name of the output from SixS to plot. This should be a string containing exactly what you would put afters.outputs
to print the output. For example pixel_reflectance.show_sun
– (Optional) Whether to place a marker showing the location of the sun on the contour plot (defaults to True, has no effect whensolar_or_view
set to'solar'
.)na
– (Optional) The number of azimuth angles to iterate over to generate the data for the plot (defaults to 36, giving data every 10 degrees)nz
– (Optional) The number of zenith angles to iterate over to generate the data for the plot (defaults to 10, giving data every 10 degrees)colorbarlabel
– (Optional) The label to use on the color bar shown with the plot
For example:
s = SixS() s.ground_reflectance = GroundReflectance.HomogeneousWalthall(0.48, 0.50, 2.95, 0.6) s.geometry.solar_z = 30 s.geometry.solar_a = 0 SixSHelpers.Angles.run_and_plot_360(s, 'view', 'pixel_reflectance')
-
classmethod
extract_output
(results, output_name)[source]¶ Extracts data for one particular SixS output from a list of SixS.Outputs instances.
Basically just a wrapper around a list comprehension.
Arguments:
results
– A list ofSixS.Outputs
instancesoutput_name
– The name of the output to extract. This should be a string containing whatever is put after the s.outputs when printing the output, for example ‘pixel_reflectance’.
-
classmethod
plot_polar_contour
(values, azimuths, zeniths, filled=True, colorbarlabel='', figsize=None)[source]¶ Plot a polar contour plot, with 0 degrees at the North.
Arguments:
values
– A list (or other iterable - eg. a NumPy array) of the values to plot on the contour plot (the z values)azimuths
– A list of azimuths (in degrees)zeniths
– A list of zeniths (that is, radii)filled
– (Optional) Whether to plot a filled contour plot, or just the contours (defaults to filled)yaxislabel
– (Optional) The label to use for the colorbarcolorbarlabel
– (Optional) The label to use on the color bar shown with the plot
The shapes of these lists are important, and are designed for a particular use case (but should be more generally useful). The values list should be len(azimuths) * len(zeniths) long with data for the first azimuth for all the zeniths, then the second azimuth for all the zeniths etc.
This is designed to work nicely with data that is produced using a loop as follows:
values = [] for azimuth in azimuths: for zenith in zeniths: # Do something and get a result values.append(result)
After that code the azimuths, zeniths and values lists will be ready to be passed into this function.
-
classmethod
run_principal_plane
(s, output_name=None, n=None)[source]¶ Runs the given 6S simulation to get the outputs for the solar principal plane.
This function runs the simulation for all zenith angles in the azimuthal line of the sun. For example, if the solar azimuth is 90 degrees, this function will run simulations for:
Azimuth Zenith 90 85 90 80 90 75 90 70 90 65 90 60 90 55 ... .. 90 0 270 5 270 10 270 15 ... .. 270 80 270 85
The calls to 6S for each angle will be run in parallel, making this function far faster than simply running a for loop over each angle.
Arguments:
s
– ASixS
instance configured with all of the parameters you want to run the simulation withoutput_name
– (Optional) The output name to extract (eg. “pixel_reflectance”) if the given data is provided as instances of the Outputs classn
– (Optional) The number of threads to run in parallel. This defaults to the number of CPU cores in your system, and is unlikely to need changing.
Return values:
A tuple containing zenith angles and the corresponding values or Outputs instances (depending on the arguments given). The zenith angles returned have been modified so that the zenith angles on the ‘sun-side’ are positive, and those on the other side (ie. past the vertical) are negative, for ease of plotting.
-
plot_principal_plane
(values, y_axis_label)[source]¶ Plot the results from a principal plane simulation (eg. a run of
run_principal_plane()
).Arguments:
zeniths
– A list of view zenith angles in degreesvalues
– A list of simulated values for each of these anglesy_axis_label
– A string to use as the label for the y axis
-
classmethod
Importing atmospheric profiles from radiosonde data¶
6S is provided with a number of pre-defined atmospheric profiles, such as Midlatitude Summer, Tropical and Subarctic Winter. However, it also possible to parameterise 6S using data acquired from radiosonde (weather balloon) measurements.
The main function in this class (import_uow_radiosonde_data()
) imports radiosonde data from the University of Wyoming’s radiosonde data website to 6S, allowing accurate parameterisation based on real-world measurements.
-
class
Py6S.SixSHelpers.
Radiosonde
[source]¶ -
classmethod
import_uow_radiosonde_data
(url, base_profile)[source]¶ Imports radiosonde data from the University of Wyoming website (http://weather.uwyo.edu/upperair/sounding.html) for use in Py6S.
Arguments:
url
– The URL of the sounding results page on the UoW websitebase_profile
– One of the predefined Atmospheric Profiles to use for any parts of the profile which the radiosonde data does not cover (>40km normally)
Return value:
A value suitable for assigning to
s.atmos_profile
, wheres
is aSixS
instance.How to use:
Go to http://weather.uwyo.edu/upperair/sounding.html and use the interface to select the sounding that you want. Ensure that the From and To date/times are the same, so that only one sounding is retrieved.
Copy the URL of the page displaying the sounding. It will look something like http://weather.uwyo.edu/cgi-bin/sounding?region=europe&TYPE=TEXT%3ALIST&YEAR=2012&MONTH=02&FROM=2712&TO=2712&STNM=03808
Call this function with the URL as the first argument, and one of the predefined atmospheric profiles (eg.
AtmosProfile.MidlatitudeSummer
orAtmosProfile.Tropical
) as the second argument, and store the result in the atmos_profile attribute of a SixS instance. For example:s.atmos_profile = SixSHelpers.Radiosonde.import_uow_radiosonde_data("http://weather.uwyo.edu/cgi-bin/sounding?region=europe&TYPE=TEXT%3ALIST&YEAR=2012&MONTH=02&FROM=2712&TO=2712&STNM=03808", AtmosProfile.MidlatitudeWinter)
The water density, pressure and temperature values from the radiosonde sounding will be interpolated to the 6S atmospheric grid and used for the 6S parameterisation. As radiosonde data tends to end at an altitude of around 30-40km, the data from the selected base profile is used above that height. Ozone data is not imported from the radiosonde data, as most radiosondes do not collect ozone density measurements, so the entire profile is taken from the base profile selected.
-
classmethod
Importing aerosol data from AERONET data¶
6S also has a number of pre-defined aerosol profiles, such as Maritime and Urban, as well as a number of methods for setting aerosol particle distributions based on theoretical distributions. However, the AERONET network (http://aeronet.gsfc.nasa.gov/) stores and processes sun photometer data from many stations around the world which allow the more accurate parameterisation of aerosols in 6S.
The main function in this class (import_aeronet_data()
) imports data from an AERONET CSV file and sets the aero_profile
and aot550
parameters of the 6S model accordingly.
-
class
Py6S.SixSHelpers.
Aeronet
[source]¶ Contains functions for importing AERONET measurements to set the 6S aerosol profile.
-
classmethod
import_aeronet_data
(s, filename, time)[source]¶ Imports data from an AERONET data file to a given SixS object.
This requires a valid AERONET data file and the pandas package (see http://pandas.pydata.org/ for installation instructions).
The type of AERONET file required is a Combined file for All Points (Level 1.5 or 2.0)
To download a file like this:
- Go to http://aeronet.gsfc.nasa.gov/cgi-bin/webtool_opera_v2_inv
- Choose the site you want to get data from
- Tick the box near the bottom labelled as “Combined file (all products without phase functions)”
- Choose either Level 1.5 or Level 2.0 data. Level 1.5 data is unscreened, so contains far more data meaning it is more likely for you to find data near your specified time.
- Choose All Points under Data Format
- Download the file
- Unzip
- Pass the filename to this function
Arguments:
s
– ASixS
instance whose parameters you would like to set with AERONET datafilename
– The filename of the AERONET file described abovetime
– The date and time of the simulation you want to run, used to choose the AERONET data which is closest in time. Provide this as a string in almost any format, and Python will interpret it. For example,"12/03/2010 15:39"
. When dates are ambiguous, the parsing routine will favour DD/MM/YY rather than MM/DD/YY.
Return value:
The function will return
s
with theaero_profile
andaot550
fields filled in from the AERONET data.Notes:
Beware, this function makes a number of assumptions and performs a number of possibly-inaccurate steps.
1. The refractive indices for aerosols are only provided in AERONET data at a few wavelengths, but 6S requires them at 20 wavelengths. Thus, the refractive indices are extrapolated outside of their original range, to provide the necessary data. This is generally not a wonderful idea, but it is the only way to be able to use the data within 6S. In many cases the refractive indices seem to change very little - but please do check this yourself!
2. The AERONET AOT measurement at the wavelength closest to 550nm (the wavelength required for the AOT specification in 6S) is used. This varies depending on the AERONET site, but may be 50-100nm (or more) away from 550nm. In future versions this code will interpolate the AOT at 550nm using the Angstrom coefficent.
-
classmethod
Importing ground reflectance spectra from spectral libraries¶
These functions allow you to import spectra from two widely-used spectral libraries: the USGS Spectral Library and the ASTER Spectral Library and use the spectra to define the ground reflectance of a 6S model run.
-
class
Py6S.SixSHelpers.
Spectra
[source]¶ Class allowing the import of spectral libraries from various sources
-
classmethod
import_from_usgs
(loc)[source]¶ NOT WORKING AT THE MOMENT - USGS have changed the format of their spectra.
Imports a spectral library from the USGS Spectral Library (available at http://speclab.cr.usgs.gov/spectral.lib06/).
Arguments:
loc
– Location of the data to import.
Returns:
An
ndarray
with two columns: wavelength (um) and reflectance (fraction)Example usage:
from Py6S import * s = SixS() s.wavelength = Wavelength(0.500) s.ground_reflectance = GroundReflectance.HomogeneousLambertian(Spectra.import_from_usgs("http://speclab.cr.usgs.gov/spectral.lib06/ds231/ASCII/V/russianolive.dw92-4.30728.asc")) s.run() # Bear in mind this will produce a result for a single Wavelength # To see what the whole spectrum will look like after atmospheric # radiative transfer has taken place you must run for multiple wavelengths # For example wavelengths, reflectances = SixSHelpers.Wavelengths.run_vnir(s, output_name="apparent_radiance")
-
classmethod
import_from_aster
(loc)[source]¶ Imports a spectral library from the ASTER Spectral Library (http://speclib.jpl.nasa.gov/)
Arguments:
loc
– Location of the data to import. Must be a local file path - URLs do not work currently due to SSL errors at the remote end
Returns:
An
ndarray
with two columns: wavelength (um) and reflectance (fraction)Example usage:
from Py6S import * s = SixS() s.ground_reflectance = GroundReflectance.HomogeneousLambertian(Spectra.import_from_aster("http://speclib.jpl.nasa.gov/speclibdata/jhu.becknic.vegetation.trees.conifers.solid.conifer.spectrum.txt")) s.run() # Bear in mind this will produce a result for a single Wavelength # To see what the whole spectrum will look like after atmospheric # radiative transfer has taken place you must run for multiple wavelengths # For example wavelengths, reflectances = SixSHelpers.Wavelengths.run_vnir(s, output_name="apparent_radiance")
-
classmethod