s1tiling.libs.otbwrappers.SelectBestCoverage
- class s1tiling.libs.otbwrappers.SelectBestCoverage(cfg: Configuration)[source]
Bases:
_FileProducingStepFactory
StepFactory that helps select only one path after LIA concatenation: the one that have the best coverage of the S2 tile target.
If several concatenated products have the same coverage, the oldest one will be selected.
The coverage is extracted from
tile_coverage
step metadata.The step produced does nothing: it only only rename the selected product into the final expected name. Note: in LIA case two files will actually renamed.
Requires the following information from the metadata dictionary
acquisition_day
tile_coverage
LIA_kind
flying_unit_code
tile_name
orbit_direction
orbit
fname_fmt – optional key: lia_product
dname_fmt – optional key: lia_product
New methods & Specialized methods
__init__
Constructor
_update_filename_meta_pre_hook
Inject the
reduce_LIAs()
hook in step metadata.Instanciates the step related to the current
StepFactory
, that consumes results from the previous input steps.Methods inherited from parent
Directory used to store temporary files before they are renamed into their final version.
Most steps that produce files will expect parameters.
Duplicates, completes, and returns, the meta dictionary with specific information for the current factory regarding tasks analysis.
This specialization of
StepFactory.build_step_output_tmp_filename()
will automatically insert.tmp
before the filename extension.Abstract method used to test whether a
StepFactory
has all its external requirements fulfilled.Returns the names of typical result files in case their production is required (i.e. not in-memory processing).
Accessor to where output files will be stored in case their production is required (i.e. not in-memory processing).
Root implementation of
update_image_metadata()
that shall be specialized in every file producing Step Factory.Duplicates, completes, and returns, the meta dictionary with specific information for the current factory regarding
Step
instanciation.Attributes and properties
Property image_description, used to fill
TIFFTAG_IMAGEDESCRIPTION
Step Name property.
Property ram_per_process
- _do_create_actual_step(execution_parameters: Dict, input_step: AbstractStep, meta: Dict) AbstractStep
Generic variation point for the exact step creation. The default implementation returns a new
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()
- 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
Abstract method used to test whether a
StepFactory
has all its external requirements fulfilled. For instance,OTBStepFactory
’s will check their related OTB application can be executed.- Returns:
None
if requirements are fulfilled.- Returns:
A message indicating what is missing otherwise, and some context how to fix it.
- complete_meta(meta: Dict, all_inputs: List[Dict[str, AbstractStep]]) Dict
Duplicates, completes, and returns, the meta dictionary with specific information for the current factory regarding
Step
instanciation.
- create_step(execution_parameters: Dict, previous_steps: List[List[Dict[str, AbstractStep]]]) AbstractStep [source]
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 theinput
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 actualPipeline
.
- property image_description: str | List[str]
Property image_description, used to fill
TIFFTAG_IMAGEDESCRIPTION
- 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}'),
wheretile_name
is looked intometa
parameterNone
, in that case the result will be the same astmp_directory()
. This case will make sense for steps that don’t produce required products
- parameters(meta: Dict) List[str] | Dict[str, str | int | float | bool | List[str]]
Most steps that produce files will expect parameters.
Warning: parameters that designate output filenames are expected to use
tmp_filename()
and notout_filename()
. Indeed products are meant to be first produced with temporary names before being renamed with their final names, once the operation producing them has succeeded.Note: This method is kind-of abstract –
SelectBestCoverage
is a_FileProducingStepFactory
but, it doesn’t actualy consume parameters.
- property ram_per_process
Property ram_per_process
- 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}')
wheretile_name
is looked intometa
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 defaultout_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_filename_meta_pre_hook()
,
- update_image_metadata(meta: Dict, all_inputs: List[Dict[str, AbstractStep]]) None
Root implementation of
update_image_metadata()
that shall be specialized in every file producing Step Factory.