satpy.utils module
Module defining various utilities.
- satpy.utils.atmospheric_path_length_correction(data, cos_zen, limit=88.0, max_sza=95.0)[source]
Perform Sun zenith angle correction.
This function uses the correction method proposed by Li and Shibata (2006): https://doi.org/10.1175/JAS3682.1
The correction is limited to
limitdegrees (default: 88.0 degrees). For larger zenith angles, the correction is the same as at thelimitifmax_szais None. The default behavior is to gradually reduce the correction pastlimitdegrees up tomax_szawhere the correction becomes 0. Bothdataandcos_zenshould be 2D arrays of the same shape.
- satpy.utils.check_satpy(readers=None, writers=None, extras=None)[source]
Check the satpy readers and writers for correct installation.
- Parameters
readers (list or None) – Limit readers checked to those specified
writers (list or None) – Limit writers checked to those specified
extras (list or None) – Limit extras checked to those specified
- Returns: bool
True if all specified features were successfully loaded.
- satpy.utils.debug(deprecation_warnings=True)[source]
Context manager to temporarily set debugging on.
Example:
>>> with satpy.utils.debug(): ... code_here()
- Parameters
deprecation_warnings (Optional[bool]) – Switch on deprecation warnings. Defaults to True.
- satpy.utils.debug_off()[source]
Turn debugging logging off.
This disables both debugging logging and the global visibility of deprecation warnings.
- satpy.utils.debug_on(deprecation_warnings=True)[source]
Turn debugging logging on.
Sets up a StreamHandler to to sys.stderr at debug level for all loggers, such that all debug messages (and log messages with higher severity) are logged to the standard error stream.
By default, since Satpy 0.26, this also enables the global visibility of deprecation warnings. This can be suppressed by passing a false value.
- Parameters
deprecation_warnings (Optional[bool]) – Switch on deprecation warnings. Defaults to True.
- Returns
None
- satpy.utils.get_satpos(dataset)[source]
Get satellite position from dataset attributes.
Preferences are:
Longitude & Latitude: Nadir, actual, nominal, projection
Altitude: Actual, nominal, projection
A warning is issued when projection values have to be used because nothing else is available.
- Returns
Geodetic longitude, latitude, altitude
- satpy.utils.proj_units_to_meters(proj_str)[source]
Convert projection units from kilometers to meters.
- satpy.utils.sunzen_corr_cos(data, cos_zen, limit=88.0, max_sza=95.0)[source]
Perform Sun zenith angle correction.
The correction is based on the provided cosine of the zenith angle (
cos_zen). The correction is limited tolimitdegrees (default: 88.0 degrees). For larger zenith angles, the correction is the same as at thelimitifmax_szais None. The default behavior is to gradually reduce the correction pastlimitdegrees up tomax_szawhere the correction becomes 0. Bothdataandcos_zenshould be 2D arrays of the same shape.
- satpy.utils.unify_chunks(*data_arrays: xarray.core.dataarray.DataArray) list[xarray.core.dataarray.DataArray][source]
Run
xarray.unify_chunks()if input dimensions are all the same size.This is mostly used in
satpy.composites.CompositeBaseto safe guard against runningdask.array.core.map_blocks()with arrays of different chunk sizes. Doing so can cause unexpected results or errors. However, xarray’sunify_chunkswill raise an exception if dimensions of the provided DataArrays are different sizes. This is a common case for Satpy. For example, the “bands” dimension may be 1 (L), 2 (LA), 3 (RGB), or 4 (RGBA) for most compositor operations that combine other composites together.