satpy.readers.sar_c_safe module

SAFE SAR-C reader.

This module implements a reader for Sentinel 1 SAR-C GRD (level1) SAFE format as provided by ESA. The format is comprised of a directory containing multiple files, most notably two measurement files in geotiff and a few xml files for calibration, noise and metadata.

References

class satpy.readers.sar_c_safe.AzimuthNoiseReader(root, shape)[source]

Bases: object

Class to parse and read azimuth-noise data.

The azimuth noise vector is provided as a series of blocks, each comprised of a column of data to fill the block and a start and finish column number, and a start and finish line. For example, we can see here a (fake) azimuth noise array:

[[ 1.  1.  1. nan nan nan nan nan nan nan]
 [ 1.  1.  1. nan nan nan nan nan nan nan]
 [ 2.  2.  3.  3.  3.  4.  4.  4.  4. nan]
 [ 2.  2.  3.  3.  3.  4.  4.  4.  4. nan]
 [ 2.  2.  3.  3.  3.  4.  4.  4.  4. nan]
 [ 2.  2.  5.  5.  5.  5.  6.  6.  6.  6.]
 [ 2.  2.  5.  5.  5.  5.  6.  6.  6.  6.]
 [ 2.  2.  5.  5.  5.  5.  6.  6.  6.  6.]
 [ 2.  2.  7.  7.  7.  7.  7.  8.  8.  8.]
 [ 2.  2.  7.  7.  7.  7.  7.  8.  8.  8.]]

As is shown here, the blocks may not cover the full array, and hence it has to be gap-filled with NaNs.

Set up the azimuth noise reader.

_assemble_azimuth_noise_blocks(chunks)[source]

Assemble the azimuth noise blocks into one single array.

_create_dask_slice_from_block_line(current_line, chunks)[source]

Create a dask slice from the blocks at the current line.

_create_dask_slices_from_blocks(chunks)[source]

Create full-width slices from azimuth noise blocks.

static _fill_dask_pieces(dask_pieces, shape, chunks)[source]
_find_blocks_covering_line(current_line)[source]

Find the blocks covering a given line.

_get_array_pieces_for_current_line(current_line)[source]

Get the array pieces that cover the current line.

_get_next_start_line(current_blocks, current_line)[source]
_get_padded_dask_pieces(pieces, chunks)[source]

Get the padded pieces of a slice.

_read_azimuth_noise_blocks(chunks)[source]

Read the azimuth noise blocks.

read_azimuth_noise_array(chunks=4096)[source]

Read the azimuth noise vectors.

class satpy.readers.sar_c_safe.SAFEGRD(filename, filename_info, filetype_info, calfh, noisefh, annotationfh)[source]

Bases: BaseFileHandler

Measurement file reader.

The measurement files are in geotiff format and read using rasterio. For performance reasons, the reading adapts the chunk size to match the file’s block size.

Init the grd filehandler.

_calibrate(dn, chunks, key)[source]

Calibrate the data.

_calibrate_and_denoise(data, key)[source]

Calibrate and denoise the data.

static _change_quantity(data, quantity)[source]

Change quantity to dB if needed.

_denoise(dn, chunks)[source]

Denoise the data.

_get_digital_number(data)[source]

Get the digital numbers (uncalibrated data).

_get_lonlatalts_uncached()[source]

Obtain GCPs and construct latitude and longitude arrays.

Parameters:
  • band (gdal band) – Measurement band which comes with GCP’s

  • array_shape (tuple) – The size of the data array

Returns:

A tuple with longitude and latitude arrays

Return type:

coordinates (tuple)

property end_time

Get the end time.

get_dataset(key, info)[source]

Load a dataset.

get_gcps()[source]

Read GCP from the GDAL band.

Parameters:
  • band (gdal band) – Measurement band which comes with GCP’s

  • coordinates (tuple) – A tuple with longitude and latitude arrays

Returns:

Pixel and Line indices 1d arrays gcp_coords (tuple): longitude and latitude 1d arrays

Return type:

points (tuple)

property start_time

Get the start time.

class satpy.readers.sar_c_safe.SAFEXML(filename, filename_info, filetype_info, header_file=None)[source]

Bases: BaseFileHandler

XML file reader for the SAFE format.

Init the xml filehandler.

property end_time

Get the end time.

get_metadata()[source]

Convert the xml metadata to dict.

property start_time

Get the start time.

class satpy.readers.sar_c_safe.SAFEXMLAnnotation(filename, filename_info, filetype_info, header_file=None)[source]

Bases: SAFEXML

XML file reader for the SAFE format, Annotation file.

Init the XML annotation reader.

_get_incidence_angle_uncached(chunks)[source]

Get the incidence angle array.

get_dataset(key, info, chunks=None)[source]

Load a dataset.

class satpy.readers.sar_c_safe.SAFEXMLCalibration(filename, filename_info, filetype_info, header_file=None)[source]

Bases: SAFEXML

XML file reader for the SAFE format, Calibration file.

Init the XML calibration reader.

_get_calibration_uncached(calibration, chunks=None)[source]

Get the calibration array.

_get_calibration_vector(calibration_name, chunks)[source]

Get the calibration vector.

get_calibration_constant()[source]

Load the calibration constant.

get_dataset(key, info, chunks=None)[source]

Load a dataset.

class satpy.readers.sar_c_safe.SAFEXMLNoise(filename, filename_info, filetype_info, header_file=None)[source]

Bases: SAFEXML

XML file reader for the SAFE format, Noise file.

Init the xml filehandler.

_get_noise_correction_uncached(chunks=None)[source]

Get the noise correction array.

get_dataset(key, info, chunks=None)[source]

Load a dataset.

read_legacy_noise(chunks)[source]

Read noise for legacy GRD data.

read_range_noise_array(chunks)[source]

Read the range-noise array.

class satpy.readers.sar_c_safe.XMLArray(root, list_tag, element_tag)[source]

Bases: object

A proxy for getting xml data as an array.

Set up the XML array.

_read_xml_array()[source]

Read an array from xml.

expand(shape, chunks=None)[source]

Generate the full-blown array.

get_data_items()[source]

Get the data items for this array.

interpolate_xml_array(shape, chunks)[source]

Interpolate arbitrary size dataset to a full sized grid.

class satpy.readers.sar_c_safe._AzimuthBlock(xml_element)[source]

Bases: object

Implementation of an single azimuth-noise block.

Set up the block from an XML element.

expand(chunks)[source]

Build an azimuth block from xml data.

property first_line
property first_pixel
property last_line
property last_pixel
property lines
property lut
satpy.readers.sar_c_safe._dictify(r)[source]

Convert an xml element to dict.

satpy.readers.sar_c_safe._get_calibration_name(calibration)[source]

Get the proper calibration name.

satpy.readers.sar_c_safe.dictify(r)[source]

Convert an ElementTree into a dict.

satpy.readers.sar_c_safe.interpolate_slice(slice_rows, slice_cols, interpolator)[source]

Interpolate the given slice of the larger array.

satpy.readers.sar_c_safe.interpolate_xarray(xpoints, ypoints, values, shape, blocksize=4096)[source]

Interpolate, generating a dask array.

satpy.readers.sar_c_safe.interpolate_xarray_linear(xpoints, ypoints, values, shape, chunks=4096)[source]

Interpolate linearly, generating a dask array.

satpy.readers.sar_c_safe.intp(grid_x, grid_y, interpolator)[source]

Interpolate.