s1tiling.libs.otbwrappers.SARDEMProjection

class s1tiling.libs.otbwrappers.SARDEMProjection(cfg: Configuration)[source]

Bases: OTBStepFactory

Factory that prepares steps that run SARDEMProjection as described in Normals computation documentation.

SARDEMProjection application puts a DEM file into SAR geometry and estimates two additional coordinates. For each point of the DEM input four components are calculated: C (colunm into SAR image), L (line into SAR image), Z and Y. XYZ cartesian components into projection are also computed for our needs.

Requires the following information from the configuration object:

  • ram_per_process

  • dem_db_filepath – to fill-up image metadata

  • dem_field_ids – to fill-up image metadata

  • dem_main_field_id – to fill-up image metadata

  • tmp_dir – useless in the in-memory nomical case

  • fname_fmt – optional key: s1_on_dem, useless in the in-memory nominal case

Requires the following information from the metadata dictionary

  • basename

  • input filename

  • output filename

  • nodata – optional

It also requires $OTB_GEOID_FILE to be set in order to ignore any DEM information already registered in dask worker (through OrthoRectification for instance) and only use the Geoid.

New methods & Specialized methods

__init__

Constructor.

_update_filename_meta_pre_hook

Injects the reduce_inputs_insar() hook in step metadata, and provide names clear from polar related information.

add_image_metadata

Post-application hook used to complete GDAL metadata.

complete_meta

  • Complete meta information with hook for updating image metadata

parameters

Returns the parameters to use with SARDEMProjection OTB application to project S1 geometry onto DEM tiles.

requirement_context

Return the requirement context that permits to fix missing requirements.

update_image_metadata

Set SARDEMProjection related information that'll get carried around.

Methods inherited from parent

output_directory

Accessor to where output files will be stored in case their production is required (i.e. not in-memory processing).

create_step

Instanciates the step related to the current StepFactory, that consumes results from the previous input steps.

update_filename_meta

Duplicates, completes, and returns, the meta dictionary with specific information for the current factory regarding tasks analysis.

tmp_directory

Directory used to store temporary files before they are renamed into their final version.

build_step_output_filename

Returns the names of typical result files in case their production is required (i.e. not in-memory processing).

set_output_pixel_type

Permits to have steps force the output pixel data.

build_step_output_tmp_filename

This specialization of StepFactory.build_step_output_tmp_filename() will automatically insert .tmp before the filename extension.

check_requirements

This specialization of check_requirements() checks whether the related OTB application can correctly be executed from S1Tiling.

Attributes and properties

appname

OTB Application property.

image_description

Property image_description, used to fill TIFFTAG_IMAGEDESCRIPTION

name

Step Name property.

param_in

Name of the "in" parameter used by the OTB Application.

param_out

Name of the "out" parameter used by the OTB Application.

ram_per_process

Property ram_per_process

_do_create_actual_step(execution_parameters: Dict, input_step: AbstractStep, meta: Dict) AbstractStep

Instanciates the step related to the current StepFactory, that consumes results from the previous input step.

  1. We expect the step metadata and the GDAL image metadata to have been updated.

1. Steps that wrap an OTB application will instanciate this application object, and:

  • either pipe the new application to the one from the input step if it wasn’t a first step

  • or fill in the “in” parameter of the application with the out_filename() of the input step.

1-bis. in case the new step isn’t related to an OTB application, nothing specific is done, we’ll just return an AbstractStep

_update_filename_meta_post_hook(meta: Dict) None

Hook meant to be overridden to fix product metadata by overriding their default definition.

Called from update_filename_meta()

add_image_metadata(meta: Dict, app) None[source]

Post-application hook used to complete GDAL metadata.

As update_image_metadata() is not designed to access OTB application information (directiontoscandeml…), we need this extra hook to fetch and propagate the PRJ information.

property appname: str

OTB Application property.

build_step_output_filename(meta: Dict) str | List[str]

Returns the names of typical result files in case their production is required (i.e. not in-memory processing).

This specialization uses gen_output_filename naming policy parameter to build the output filename. See the Available naming policies.

build_step_output_tmp_filename(meta: Dict) str | List[str]

This specialization of StepFactory.build_step_output_tmp_filename() will automatically insert .tmp before the filename extension.

check_requirements() Tuple[str, str] | None

This specialization of check_requirements() checks whether the related OTB application can correctly be executed from S1Tiling.

Returns:

A pair of the message indicating what is required, and some context how to fix it – by default: install OTB!

Returns:

None otherwise.

complete_meta(meta: Dict, all_inputs: List[Dict[str, AbstractStep]]) Dict[source]
  • Complete meta information with hook for updating image metadata w/ directiontoscandemc, directiontoscandeml and gain.

  • Computes dem information and add them to the meta structure, to be used later to fill-in the image metadata.

create_step(execution_parameters: Dict, previous_steps: List[List[Dict[str, AbstractStep]]]) AbstractStep

Instanciates the step related to the current StepFactory, that consumes results from the previous input steps.

1. This methods starts by updating metadata information through: complete_meta() on the input metadatas.

2. Then it updates the GDAL image metadata information that will need to be written in the pipeline output image through update_image_metadata().

3. Eventually the actual step creation method is executed according to the exact kind of step factory (ExecutableStepFactory, AnyProducerStepFactory, OTBStepFactory) through the variation point _do_create_actual_step().

While this method is not meant to be overridden, for simplity it will be in Store factory.

Note: it’s possible to override this method to return no step (None). In that case, no OTB Application would be registered in the actual Pipeline.

property image_description: str

Property image_description, used to fill TIFFTAG_IMAGEDESCRIPTION

property name: str

Step Name property.

output_directory(meta: Dict) str

Accessor to where output files will be stored in case their production is required (i.e. not in-memory processing)

This property is built from gen_output_dir construction parameter. Typical values for the parameter are:

  • os.path.join(cfg.output_preprocess, '{tile_name}'), where tile_name is looked into meta parameter

  • None, in that case the result will be the same as tmp_directory(). This case will make sense for steps that don’t produce required products

property param_in: str

Name of the “in” parameter used by the OTB Application. Default is likely to be “in”, while some applications use “io.in”, often “il” for list of files…

property param_out: str

Name of the “out” parameter used by the OTB Application. Default is likely to be “out”, whie some applications use “io.out”.

parameters(meta: Dict) Dict[str, str | int | float | bool | List[str]][source]

Returns the parameters to use with SARDEMProjection OTB application to project S1 geometry onto DEM tiles.

property ram_per_process

Property ram_per_process

requirement_context() str[source]

Return the requirement context that permits to fix missing requirements. SARDEMProjection2 comes from normlim_sigma0.

set_output_pixel_type(app, meta: Dict) None

Permits to have steps force the output pixel data.

tmp_directory(meta) str

Directory used to store temporary files before they are renamed into their final version.

This property is built from gen_tmp_dir construction parameter. Typical values for the parameter are:

  • os.path.join(cfg.tmpdir, 'S1')

  • os.path.join(cfg.tmpdir, 'S2', '{tile_name}') where tile_name is looked into meta parameter

update_filename_meta(meta: Dict) Dict

Duplicates, completes, and returns, the meta dictionary with specific information for the current factory regarding tasks analysis.

This method is used:

  • while analysing the dependencies to build the task graph – in this use case the relevant information are the file names and paths.

  • and indirectly before instanciating a new Step

Other metadata not filled here:

  • get_task_name() which is deduced from out_filename by default

  • out_extended_filename_complement()

It’s possible to inject some other metadata (that could be used from _get_canonical_input() for instance) thanks to _update_filename_meta_pre_hook().

This method is not meant to be overridden. Instead it implements the template method design pattern, and expects the customization to be done through the specialization of the hooks:

update_image_metadata(meta: Dict, all_inputs: List[Dict[str, AbstractStep]]) None[source]

Set SARDEMProjection related information that’ll get carried around.