Close field

../../../../_images/thumbnail3.png

Description

The close field operation consists of a dilate treatment followed by an erosion treatment

Parameters

  • base: Base

    The input base

  • variables: list(str)

    The list of variables to close

  • passes: int, default = 1

    The number of times the dilate and erosion treatments are applied to the base

  • memory_mode: bool, default = False

    If True, the modifications are done directly on the input base to limit memory usage. If False, a new base is created.

Preconditions

Same as the dilate and erosion treatments.

Postconditions

Same as the dilate and erosion treatments.

Usage

import antares
treatment = antares.Treatment('closefield')
treatment['base'] = base
treatment['variables'] = ['var1', 'var2']
treatment['passes'] = 2
open_base = treatment.execute()

or

import antares
open_base = antares.treatment.CloseField(
              base = base,
              variables = ['var1', 'var2'],
              passes = 2,)

Example

The following example shows the effect of closing a field for 1 pass and 2 passes.

import os
import antares

# Prepare output folder
output_folder = os.path.join("OUTPUT", "TreatmentClose")
os.makedirs(output_folder, exist_ok=True)

# Read example base
base = antares.io.Read(
    filename='../data/AMR/amr_example.h5',
    format='hdf_antares',)


# Apply close field treatment
close_base_1_pass = antares.treatment.CloseField(
    base=base,
    variables=['metric'],
    passes=1)

close_base_2_passes = antares.treatment.CloseField(
    base=base,
    variables=['metric'],
    passes=2)



# Dump bases
antares.io.Dump(
    base=close_base_1_pass,
    filename='close_base_1_pass',
    folder=output_folder,
    format='hdf_antares',)

antares.io.Dump(
    base=close_base_2_passes,
    filename='close_base_2_passes',
    folder=output_folder,
    format='hdf_antares',)
../../../../_images/input.png

Close field after 1 pass

../../../../_images/close_1_pass.png

Close field after 2 passes

../../../../_images/close_2_passes.png