Point Probe

Description

Extract data values from a given input Base at specified point locations.

The probe values are computed at the user-defined point positions by interpolating into the input data. The interpolation can be linear or 0-order based on the closest points.

Parameters

  • base: Base

    Sample probes in this input base.

  • coordinates: list(str)

    The variable names that define the set of coordinates. The coordinates must always be located at nodes whatever the value of location.

  • location: str in LOCATIONS, default= ‘node’

    Location of values that are concerned by the search. If location is ‘node’, then the probe value will be computed with variables located at ‘node’.

  • points: list(tuple)

    List of point coordinates.

  • interpolation: str in [‘closest’, ‘linear’], default= closest

    Type of interpolation to apply to the input values to get the probe value.

  • axis: str or None, default= None

    Name of the rotation axis. Must be in coordinates. If None, then no rotation will be performed on the zones to find the probe location.

  • angle_name: str, default= None

    Name of the rotation angle that is a key in the dictionary Zone.attrs.

  • vectors: tuple/list(tuple(str)), default= []

    Coordinate names of vectors that need to be rotated.

  • one_zone_per_probe: bool, default= True

    If True, each valid point probe gives one Zone, else all probes are set in a single Zone. This option is not applied with interpolation = “closest” and location = “node”. The value False should be used for single-zone input base.

Preconditions

The underlying mesh must be time-independent (non-deformable and non-moving mesh).

If the zones have to be rotated, then the input zones must contain a key named as the value given by the parameter angle_name in Zone.attrs.

Postconditions

The output Base object contains as many zones as probe points if they are all detected. Undetected probe points are ignored. See also one_zone_per_probe.

The name of an output zone is <name of the input zone>_x_y_z with (x,y,z) the coordinates of the probe. If the zone has been rotated N times, then the name of an output zone is <name of the input zone>_<’DUP%02d’%N>_x_y_z.

If location is ‘node’ and interpolation is ‘closest’, then the probe value will be the node value of the nearest mesh point. The process is implemented in python and the probe coordinates will be found from the input mesh and available in the output base.

If location is ‘cell’ and interpolation is ‘closest’, then the probe value will be the cell value of the mesh element in which the probe is located. The process uses the VTK library and the probe coordinates will not be available in the output base. To get the coordinates in the output, you may use the following instruction before calling the treatment:

base.node_to_cell(coordinates)

If location is ‘node’ and interpolation is ‘linear’, then the probe value will be the value interpolated from the vertices of the mesh element in which the probe is located. The process uses the VTK library and the probe coordinates will come from the user-defined probes and will be available in the output base.

If one_zone_per_probe is False, then the array ‘valid_interpolation’ is set in the instant of the zone. This boolean array tells if a given point could have been interpolated. This should be used for single-zone input base.

Example

import antares
myt = antares.Treatment('pointprobe')
myt['base'] = base
myt['points'] = [(-20., 160., 0.), (110, 160., 0.)]
myt['location'] = 'node'
myt['interpolation'] = 'linear'
probes_base = myt.execute()

Main functions

class antares.treatment.TreatmentPointProbe.TreatmentPointProbe
execute()

Probe the data from the base.

Returns:

The base containing the values of the given points.

Return type:

Base

Example

"""
This example illustrates how use the pointprobe treatment.

Compare with probe.py
"""
import os
if not os.path.isdir('OUTPUT'):
    os.makedirs('OUTPUT')

import numpy as np

from antares import Reader, Treatment

# ----------------------------------------------
# Reading the files and topological information
# ----------------------------------------------
reader = Reader('bin_tp')
reader['filename'] = os.path.join('..', 'data', 'ROTOR37', 'GENERIC', 'flow_<zone>_ite0.dat')
reader['zone_prefix'] = 'Block'
base = reader.read()

# -----------------------------
# Retrieve the probes family
# -----------------------------
treatment = Treatment('pointprobe')
treatment['base'] = base
treatment['points'] = [(-20., 160., 0.), (110, 160., 0.)]
treatment['location'] = 'node'
treatment['interpolation'] = 'closest'
probes = treatment.execute()

print(probes)
# >>>  Base object
#      - zones : ['Block0002_-20.0_160.0_0.0', 'Block0000_110_160.0_0.0']

for zonen, zone in probes.items():
    print('Probe {}'.format(zonen))
    for inst in zone.values():
        for varn, var in inst.items():
            print('Variable {}: {}'.format(varn[0], np.squeeze(var)))