satpy.composites package¶
Submodules¶
satpy.composites.abi module¶
Composite classes for the AHI instrument.
-
class
satpy.composites.abi.
SimulatedGreen
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶ Bases:
satpy.composites.GenericCompositor
A single-band dataset resembles a Green (0.55 µm).
satpy.composites.ahi module¶
Composite classes for the AHI instrument.
-
class
satpy.composites.ahi.
GreenCorrector
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶ Bases:
satpy.composites.GenericCompositor
Corrector of the AHI green band to compensate for the deficit of chlorophyl signal.
satpy.composites.cloud_products module¶
Compositors for cloud products.
-
class
satpy.composites.cloud_products.
CloudTopHeightCompositor
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶ Bases:
satpy.composites.ColormapCompositor
Colorize with a palette, put cloud-free pixels as black.
-
static
build_colormap
(palette, info)¶ Create the colormap from the raw_palette and the valid_range.
-
static
satpy.composites.crefl_utils module¶
Shared utilities for correcting reflectance data using the ‘crefl’ algorithm.
Original code written by Ralph Kuehn with modifications by David Hoese and Martin Raspaud. Ralph’s code was originally based on the C crefl code distributed for VIIRS and MODIS.
-
satpy.composites.crefl_utils.
G_calc
(zenith, a_coeff)¶
-
satpy.composites.crefl_utils.
atm_variables_finder
(mus, muv, phi, height, tau, tO3, tH2O, taustep4sphalb, tO2=1.0)¶
-
satpy.composites.crefl_utils.
chand
(phi, muv, mus, taur)¶
-
satpy.composites.crefl_utils.
csalbr
(tau)¶
-
satpy.composites.crefl_utils.
find_coefficient_index
(sensor, wavelength_range, resolution=0)¶ Return index in to coefficient arrays for this band’s wavelength.
This function search through the COEFF_INDEX_MAP dictionary and finds the first key where the nominal wavelength of wavelength_range falls between the minimum wavelength and maximum wavelength of the key. wavelength_range can also be the standard name of the band. For example, “M05” for VIIRS or “1” for MODIS.
Parameters: - sensor – sensor of band to be corrected
- wavelength_range – 3-element tuple of (min wavelength, nominal wavelength, max wavelength)
- resolution – resolution of the band to be corrected
Returns: index in to coefficient arrays like aH2O, aO3, etc. None is returned if no matching wavelength is found
-
satpy.composites.crefl_utils.
get_atm_variables
(mus, muv, phi, height, ah2o, bh2o, ao3, tau)¶
-
satpy.composites.crefl_utils.
get_atm_variables_abi
(mus, muv, phi, height, G_O3, G_H2O, G_O2, ah2o, ao2, ao3, tau)¶
-
satpy.composites.crefl_utils.
get_coefficients
(sensor, wavelength_range, resolution=0)¶ Parameters: - sensor – sensor of the band to be corrected
- wavelength_range – 3-element tuple of (min wavelength, nominal wavelength, max wavelength)
- resolution – resolution of the band to be corrected
Returns: aH2O, bH2O, aO3, taur0 coefficient values
-
satpy.composites.crefl_utils.
run_crefl
(refl, coeffs, lon, lat, sensor_azimuth, sensor_zenith, solar_azimuth, solar_zenith, avg_elevation=None, percent=False, use_abi=False)¶ Run main crefl algorithm.
All input parameters are per-pixel values meaning they are the same size and shape as the input reflectance data, unless otherwise stated.
Parameters: - reflectance_bands – tuple of reflectance band arrays
- coefficients – tuple of coefficients for each band (see get_coefficients)
- lon – input swath longitude array
- lat – input swath latitude array
- sensor_azimuth – input swath sensor azimuth angle array
- sensor_zenith – input swath sensor zenith angle array
- solar_azimuth – input swath solar azimuth angle array
- solar_zenith – input swath solar zenith angle array
- avg_elevation – average elevation (usually pre-calculated and stored in CMGDEM.hdf)
- percent – True if input reflectances are on a 0-100 scale instead of 0-1 scale (default: False)
satpy.composites.sar module¶
Composite classes for the VIIRS instrument.
-
class
satpy.composites.sar.
SARIce
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶ Bases:
satpy.composites.GenericCompositor
The SAR Ice composite.
-
class
satpy.composites.sar.
SARQuickLook
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶ Bases:
satpy.composites.GenericCompositor
The SAR QuickLook composite.
-
class
satpy.composites.sar.
SARRGB
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶ Bases:
satpy.composites.GenericCompositor
The SAR RGB composite.
-
satpy.composites.sar.
overlay
(top, bottom)¶ Blending two layers.
from: https://docs.gimp.org/en/gimp-concepts-layer-modes.html
satpy.composites.viirs module¶
Composite classes for the VIIRS instrument.
-
class
satpy.composites.viirs.
AdaptiveDNB
(*args, **kwargs)¶ Bases:
satpy.composites.viirs.HistogramDNB
Adaptive histogram equalized DNB composite.
The logic for this code was taken from Polar2Grid and was originally developed by Eva Schiffer (SSEC).
This composite separates the DNB data in to 3 main regions: Day, Night, and Mixed. Each region is equalized separately to bring out the most information from the region due to the high dynamic range of the DNB data. Optionally, the mixed region can be separated in to multiple smaller regions by using the mixed_degree_step keyword.
Initialize the compositor with values from the user or from the configuration file.
Adaptive histogram equalization and regular histogram equalization can be configured independently for each region: day, night, or mixed. A region can be set to use adaptive equalization “always”, or “never”, or only when there are multiple regions in a single scene “multiple” via the adaptive_X keyword arguments (see below).
Parameters: - adaptive_day – one of (“always”, “multiple”, “never”) meaning when adaptive equalization is used.
- adaptive_mixed – one of (“always”, “multiple”, “never”) meaning when adaptive equalization is used.
- adaptive_night – one of (“always”, “multiple”, “never”) meaning when adaptive equalization is used.
-
class
satpy.composites.viirs.
ERFDNB
(*args, **kwargs)¶ Bases:
satpy.composites.CompositeBase
Equalized DNB composite using the error function (erf).
The logic for this code was taken from Polar2Grid and was originally developed by Curtis Seaman and Steve Miller. The original code was written in IDL and is included as comments in the code below.
-
class
satpy.composites.viirs.
HistogramDNB
(*args, **kwargs)¶ Bases:
satpy.composites.CompositeBase
Histogram equalized DNB composite.
The logic for this code was taken from Polar2Grid and was originally developed by Eva Schiffer (SSEC).
This composite separates the DNB data in to 3 main regions: Day, Night, and Mixed. Each region is equalized separately to bring out the most information from the region due to the high dynamic range of the DNB data. Optionally, the mixed region can be separated in to multiple smaller regions by using the mixed_degree_step keyword.
Initialize the compositor with values from the user or from the configuration file.
Parameters: - high_angle_cutoff – solar zenith angle threshold in degrees, values above this are considered “night”
- low_angle_cutoff – solar zenith angle threshold in degrees, values below this are considered “day”
- mixed_degree_step – Step interval to separate “mixed” region in to multiple parts by default does whole mixed region
-
class
satpy.composites.viirs.
NCCZinke
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶ Bases:
satpy.composites.CompositeBase
Equalized DNB composite using the Zinke algorithm [1].
References
[1] Stephan Zinke (2017), A simplified high and near-constant contrast approach for the display of VIIRS day/night band imagery DOI:10.1080/01431161.2017.1338838 -
gain_factor
(theta)¶
-
-
class
satpy.composites.viirs.
ReflectanceCorrector
(*args, **kwargs)¶ Bases:
satpy.composites.CompositeBase
CREFL modifier
Uses a python rewrite of the C CREFL code written for VIIRS and MODIS.
Initialize the compositor with values from the user or from the configuration file.
If dem_filename can’t be found or opened then correction is done assuming TOA or sealevel options.
Parameters: - dem_filename – path to the ancillary ‘averaged heights’ file default: CMGDEM.hdf environment override: os.path.join(<SATPY_ANCPATH>, <CREFL_ANCFILENAME>)
- dem_sds – variable name to load from the ancillary file
-
get_angles
(vis)¶
-
class
satpy.composites.viirs.
SnowAge
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶ Bases:
satpy.composites.GenericCompositor
Create RGB snow product.
Product is based on method presented at the second CSPP/IMAPP users’ meeting at Eumetsat in Darmstadt on 14-16 April 2015
# Bernard Bellec snow Look-Up Tables V 1.0 (c) Meteo-France # These Look-up Tables allow you to create the RGB snow product # for SUOMI-NPP VIIRS Imager according to the algorithm # presented at the second CSPP/IMAPP users’ meeting at Eumetsat # in Darmstadt on 14-16 April 2015 # The algorithm and the product are described in this # presentation : # http://www.ssec.wisc.edu/meetings/cspp/2015/Agenda%20PDF/Wednesday/Roquet_snow_product_cspp2015.pdf # For further information you may contact # Bernard Bellec at Bernard.Bellec@meteo.fr # or # Pascale Roquet at Pascale.Roquet@meteo.fr
-
class
satpy.composites.viirs.
VIIRSFog
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶
-
satpy.composites.viirs.
histogram_equalization
(data, mask_to_equalize, number_of_bins=1000, std_mult_cutoff=4.0, do_zerotoone_normalization=True, valid_data_mask=None, clip_limit=None, slope_limit=None, do_log_scale=False, log_offset=None, local_radius_px=None, out=None)¶ Perform a histogram equalization on the data selected by mask_to_equalize. The data will be separated into number_of_bins levels for equalization and outliers beyond +/- std_mult_cutoff*std will be ignored.
If do_zerotoone_normalization is True the data selected by mask_to_equalize will be returned in the 0 to 1 range. Otherwise the data selected by mask_to_equalize will be returned in the 0 to number_of_bins range.
Note: the data will be changed in place.
-
satpy.composites.viirs.
local_histogram_equalization
(data, mask_to_equalize, valid_data_mask=None, number_of_bins=1000, std_mult_cutoff=3.0, do_zerotoone_normalization=True, local_radius_px=300, clip_limit=60.0, slope_limit=3.0, do_log_scale=True, log_offset=1e-05, out=None)¶ Equalize the provided data (in the mask_to_equalize) using adaptive histogram equalization.
tiles of width/height (2 * local_radius_px + 1) will be calculated and results for each pixel will be bilinerarly interpolated from the nearest 4 tiles when pixels fall near the edge of the image (there is no adjacent tile) the resultant interpolated sum from the available tiles will be multipled to account for the weight of any missing tiles:
pixel total interpolated value = pixel available interpolated value / (1 - missing interpolation weight)
if
do_zerotoone_normalization
is True the data will be scaled so that all data in the mask_to_equalize falls between 0 and 1; otherwise the data in mask_to_equalize will all fall between 0 and number_of_binsReturns: The equalized data
-
satpy.composites.viirs.
make_day_night_masks
(solarZenithAngle, good_mask, highAngleCutoff, lowAngleCutoff, stepsDegrees=None)¶ given information on the solarZenithAngle for each point, generate masks defining where the day, night, and mixed regions are
optionally provide the highAngleCutoff and lowAngleCutoff that define the limits of the terminator region (if no cutoffs are given the DEFAULT_HIGH_ANGLE and DEFAULT_LOW_ANGLE will be used)
optionally provide the stepsDegrees that define how many degrees each “mixed” mask in the terminator region should be (if no stepsDegrees is given, the whole terminator region will be one mask)
Module contents¶
Base classes for composite objects.
-
class
satpy.composites.
Airmass
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶
-
class
satpy.composites.
BWCompositor
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶
-
class
satpy.composites.
CO2Corrector
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶
-
class
satpy.composites.
CloudCompositor
(transition_min=258.15, transition_max=298.15, transition_gamma=3.0, **kwargs)¶ Bases:
satpy.composites.GenericCompositor
Collect custom configuration values.
Parameters: - transition_min (float) – Values below or equal to this are clouds -> opaque white
- transition_max (float) – Values above this are cloud free -> transparent
- transition_gamma (float) – Gamma correction to apply at the end
-
class
satpy.composites.
ColorizeCompositor
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶ Bases:
satpy.composites.ColormapCompositor
A compositor colorizing the data, interpolating the palette colors when needed.
-
class
satpy.composites.
ColormapCompositor
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶ Bases:
satpy.composites.GenericCompositor
A compositor that uses colormaps.
-
static
build_colormap
(palette, dtype, info)¶ Create the colormap from the raw_palette and the valid_range.
-
static
-
class
satpy.composites.
CompositeBase
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶ Bases:
satpy.dataset.MetadataObject
-
apply_modifier_info
(origin, destination)¶
-
check_areas
(data_arrays)¶
-
-
class
satpy.composites.
CompositorLoader
(ppp_config_dir='/build/satpy-0.11.1/satpy/etc')¶ Bases:
object
Read composites using the configuration files on disk.
-
get_compositor
(key, sensor_names)¶
-
get_modifier
(key, sensor_names)¶
-
load_compositors
(sensor_names)¶ Load all compositor configs for the provided sensors.
Parameters: sensor_names (list of strings) – Sensor names that have matching sensor_name.yaml
config files.Returns: Where comps is a dictionary: sensor_name -> composite ID -> compositor objectAnd mods is a dictionary:
sensor_name -> modifier name -> (modifier class, modifiers options)Note that these dictionaries are copies of those cached in this object.
Return type: (comps, mods)
-
load_sensor_composites
(sensor_name)¶ Load all compositor configs for the provided sensor.
-
-
class
satpy.composites.
Convection
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶
-
class
satpy.composites.
DayNightCompositor
(lim_low=85.0, lim_high=95.0, **kwargs)¶ Bases:
satpy.composites.GenericCompositor
A compositor that blends a day data with night data.
Collect custom configuration values.
Parameters: - lim_low (float) – lower limit of Sun zenith angle for the blending of the given channels
- lim_high (float) – upper limit of Sun zenith angle for the blending of the given channels
-
class
satpy.composites.
DifferenceCompositor
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶
-
class
satpy.composites.
Dust
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶
-
class
satpy.composites.
EffectiveSolarPathLengthCorrector
(correction_limit=88.0, **kwargs)¶ Bases:
satpy.composites.SunZenithCorrectorBase
Special sun zenith correction with the method proposed by Li and Shibata.
(2006): https://doi.org/10.1175/JAS3682.1
In addition to adjusting the provided reflectances by the cosine of the solar zenith angle, this modifier forces all reflectances beyond a solar zenith angle of max_sza to 0 to reduce noise in the final data. It also gradually reduces the amount of correction done between
correction_limit
andmax_sza
. Ifmax_sza
isNone
then a constant correction is applied to zenith angles beyondcorrection_limit
.To set
max_sza
toNone
in a YAML configuration file use:effective_solar_pathlength_corrected: compositor: !!python/name:satpy.composites.EffectiveSolarPathLengthCorrector max_sza: !!null optional_prerequisites: - solar_zenith_angle
Collect custom configuration values.
Parameters: - correction_limit (float) – Maximum solar zenith angle to apply the correction in degrees. Pixels beyond this limit have a constant correction applied. Default 88.
- max_sza (float) – Maximum solar zenith angle in degrees that is considered valid and correctable. Default 95.0.
-
class
satpy.composites.
FillingCompositor
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶ Bases:
satpy.composites.GenericCompositor
Make a regular RGB, filling the RGB bands with the first provided dataset’s values.
-
class
satpy.composites.
GenericCompositor
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶ Bases:
satpy.composites.CompositeBase
-
modes
= {1: 'L', 2: 'LA', 3: 'RGB', 4: 'RGBA'}¶
-
-
exception
satpy.composites.
IncompatibleAreas
¶ Bases:
Exception
Error raised upon compositing things of different shapes.
-
exception
satpy.composites.
IncompatibleTimes
¶ Bases:
Exception
Error raised upon compositing things from different times.
-
class
satpy.composites.
LuminanceSharpeningCompositor
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶
-
class
satpy.composites.
NIREmissivePartFromReflectance
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶
-
class
satpy.composites.
NIRReflectance
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶
-
class
satpy.composites.
PSPAtmosphericalCorrection
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶
-
class
satpy.composites.
PSPRayleighReflectance
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶ Bases:
satpy.composites.CompositeBase
-
get_angles
(vis)¶
-
-
class
satpy.composites.
PaletteCompositor
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶ Bases:
satpy.composites.ColormapCompositor
A compositor colorizing the data, not interpolating the palette colors.
-
class
satpy.composites.
RGBCompositor
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶
-
class
satpy.composites.
RatioSharpenedRGB
(*args, **kwargs)¶ Bases:
satpy.composites.GenericCompositor
Sharpen RGB bands with ratio of a high resolution band to a lower resolution version.
Any pixels where the ratio is computed to be negative or infinity, it is reset to 1. Additionally, the ratio is limited to 1.5 on the high end to avoid high changes due to small discrepancies in instrument detector footprint. Note that the input data to this compositor must already be resampled so all data arrays are the same shape.
Example
R_lo - 1000m resolution - shape=(2000, 2000) G - 1000m resolution - shape=(2000, 2000) B - 1000m resolution - shape=(2000, 2000) R_hi - 500m resolution - shape=(4000, 4000)
ratio = R_hi / R_lo new_R = R_hi new_G = G * ratio new_B = B * ratio
-
class
satpy.composites.
RealisticColors
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶
-
class
satpy.composites.
SandwichCompositor
(name, prerequisites=None, optional_prerequisites=None, **kwargs)¶
-
class
satpy.composites.
SelfSharpenedRGB
(*args, **kwargs)¶ Bases:
satpy.composites.RatioSharpenedRGB
Sharpen RGB with ratio of a band with a strided-version of itself.
Example
R - 500m resolution - shape=(4000, 4000) G - 1000m resolution - shape=(2000, 2000) B - 1000m resolution - shape=(2000, 2000)
ratio = R / four_element_average(R) new_R = R new_G = G * ratio new_B = B * ratio
-
static
four_element_average_dask
(d)¶ Average every 4 elements (2x2) in a 2D array
-
static
-
class
satpy.composites.
SunZenithCorrector
(correction_limit=88.0, **kwargs)¶ Bases:
satpy.composites.SunZenithCorrectorBase
Standard sun zenith correction using
1 / cos(sunz)
.In addition to adjusting the provided reflectances by the cosine of the solar zenith angle, this modifier forces all reflectances beyond a solar zenith angle of
max_sza
to 0. It also gradually reduces the amount of correction done betweencorrection_limit
andmax_sza
. Ifmax_sza
isNone
then a constant correction is applied to zenith angles beyondcorrection_limit
.To set
max_sza
toNone
in a YAML configuration file use:sunz_corrected: compositor: !!python/name:satpy.composites.SunZenithCorrector max_sza: !!null optional_prerequisites: - solar_zenith_angle
Collect custom configuration values.
Parameters: - correction_limit (float) – Maximum solar zenith angle to apply the correction in degrees. Pixels beyond this limit have a constant correction applied. Default 88.
- max_sza (float) – Maximum solar zenith angle in degrees that is considered valid and correctable. Default 95.0.
-
class
satpy.composites.
SunZenithCorrectorBase
(max_sza=95.0, **kwargs)¶ Bases:
satpy.composites.CompositeBase
Base class for sun zenith correction.
Collect custom configuration values.
Parameters: max_sza (float) – Maximum solar zenith angle in degrees that is considered valid and correctable. Default 95.0. -
coszen
= <WeakValueDictionary>¶
-
-
satpy.composites.
add_bands
(data, bands)¶ Add bands so that they match bands
-
satpy.composites.
check_times
(projectables)¶
-
satpy.composites.
enhance2dataset
(dset)¶ Apply enhancements to dataset dset and return the resulting data array of the image.
-
satpy.composites.
sub_arrays
(proj1, proj2)¶ Substract two DataArrays and combine their attrs.
-
satpy.composites.
zero_missing_data
(data1, data2)¶ Replace NaN values with zeros in data1 if the data is valid in data2.