UnwrapLine¶
Description¶
Unwrap a one-dimensional set of points in the space to get a one-dimensional continuous set of points in space.
Parameters¶
- base:
Base
The input base.
- base:
- sorting_variable:
str
, default= None The name of the variable used to sort the points.
If specified, the sorting method will sort the data following the increasing order of the variable values.
If not given, it will unwrap the input dataset using the connectivity and the criterion of proximity between the endpoints of the disconnected closed curves. In this case, the coordinates key has to be used.
- sorting_variable:
- coordinates:
list(str)
, default= global_var.coordinates The variable names that define the set of coordinates. It is used only when there are more than one endpoint in the connectivity (curves not connected) to find the closest segment to continue with to travel along the line.
- coordinates:
- memory_mode:
bool
, default= False If True, the input base is deleted on the fly to limit memory usage.
- memory_mode:
Preconditions¶
The input base must contain a one-dimensional set of points in the instants.
Postconditions¶
With the sorting_variable parameter:
If the sorting variable is not in the shared, the shared variables will be ordered using the first instant ordering.
Only variables that have the same location as the sorting variable are taken into account. The resulting base will only contain these variables.
The element connectivity is lost.
Without the sorting_variable parameter:
Unwrapping without sorting_variable only works for ‘node’ variables
If the input dataset represents closed curves, one point will be duplicated for each closed curve. So, the output dataset may contain more points than the input dataset.
The coordinates parameter is only needed if the curve contains more than one endpoint (it is composed of multiple separated curves) so the curve can be unwrapped using proximity criteria to find the next curve. Note that no node will be removed even if they are at a null distance of each other (if you want to do so look at the merge treatment which contains a duplicate removal functionality)
Example¶
import antares
myt = antares.Treatment('unwrapline')
myt['base'] = base
myt['sorting_variable'] = 'theta'
unwrapped = myt.execute()
Main functions¶
Example¶
"""
This example illustrates how to use the unwrap line treatment.
"""
import os
import antares
if not os.path.isdir('OUTPUT'):
os.makedirs('OUTPUT')
# ------------------
# Reading the files
# ------------------
reader = antares.Reader('bin_tp')
reader['filename'] = os.path.join('..', 'data', 'ROTOR37', 'GENERIC',
'flow_<zone>_ite0.dat')
ini_base = reader.read()
ini_base.set_computer_model('internal')
# -------------------
# Cutting
# -------------------
# 2 cuts are done on a initial 3D dataset to create a 1D line.
cut1 = antares.Treatment('cut')
cut1['base'] = ini_base
cut1['type'] = 'cylinder'
cut1['origin'] = [0., 0., 0.]
cut1['radius'] = 180.
cut1['axis'] = 'x'
result = cut1.execute()
cut2 = antares.Treatment('cut')
cut2['base'] = result
cut2['type'] = 'plane'
cut2['origin'] = [62., 0., 0.]
cut2['normal'] = [1., 0., 0.]
result = cut2.execute()
# -------------------------------------
# Merge the multi-element line in one
# -------------------------------------
merge = antares.Treatment('merge')
merge['base'] = result
result = merge.execute()
# plot result to show that the multi-zone structure is not practical
result.compute('theta')
plot1 = antares.Treatment('plot')
plot1['base'] = result[:, :, ('theta', 'rovx')]
plot1.execute()
# prompt the user
# (allows to pause the script to visualize the plot)
input('press enter to see the result after unwrapping the line')
# ----------------------------
# Unwrap the line and Plot
# ----------------------------
unwrap = antares.Treatment('unwrapline')
unwrap['base'] = result
unwrap['sorting_variable'] = 'theta'
result = unwrap.execute()
plot2 = antares.Treatment('plot')
plot2['base'] = result[:, :, ('theta', 'rovx')]
plot2.execute()
# prompt the user
input('press enter to quit')
w = antares.Writer('column')
w['filename'] = os.path.join('OUTPUT', 'ex_unwrap.dat')
w['base'] = result[:, :, ('theta', 'rovx')]
w.dump()