Window

Window Class.

class antares.api.Window.Window(window=None, inherit_computer=None)

Window class.

Methods

add_computer_function(new_func)

Set a new function.

clear()

compute(var_name[, location, reset, store])

Compute a given variable on the whole zone.

compute_bounding_box(coordinates)

Compute the bounding box of the zone with respect to the coordinates.

compute_coordinate_system([ttype, ...])

Compute a new coordinate system in the Datasets.

copy()

delete_variables(list_vars[, location])

Delete variables in the dataset.

deserialized(pickable_window)

Build a pickable representation of the window.

dimension()

Dimension of the Dataset.

duplicate_variables(list_vars, list_newvars)

Duplicate variables in the dataset.

fromkeys(iterable[, value])

get(k[,d])

get_ghost_cells()

Return the ghost_cells table.

get_location(location, new_dataset)

Return a copy of the Datasets containing only the variables located in the original Datasets at the specified location.

get_shape()

Get the shape of the dataset.

is_structured()

Tell whether the zone is a structured mesh or not.

items()

keys()

Return keys as a list and not KeysView nor dict_keys.

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()

as a 2-tuple; but raise KeyError if D is empty.

rel_to_abs([coordinates, conservative_vars, ...])

Transform conservative variables from relative frame to absolute frame by looping on all instants using the Instant.rel_to_abs() method.

rename_variables(list_vars, list_newvars[, ...])

Rename variables in the dataset.

serialized([data])

Build a pickable representation of the window.

set_computer_model(modeling[, ...])

Set a computer modeling for the zone.

set_formula(formula)

Set a formula for the dataset (Zone or Boundary).

set_formula_from_attrs(name)

Set a formula from a name in the dataset attribute.

setdefault(k[,d])

update([E, ]**F)

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values()

Attributes

add_computer_function(new_func)

Set a new function.

The computer will receive a new function associated to its current modeling.

clear() None.  Remove all items from D.
compute(var_name, location=None, reset=False, store=True)

Compute a given variable on the whole zone.

This variable is computed on all instants of the zone.

Use the Instant.compute() method.

Parameters:
  • var_name (str) – The name of the variable to compute.

  • location (str in LOCATIONS) – The location of the variable. If None, the default location is assumed.

  • reset (bool) – Remove temporary fields stored in the equation manager.

  • store (bool) – Store temporary fields in the equation manager.

compute_bounding_box(coordinates)

Compute the bounding box of the zone with respect to the coordinates.

Parameters:

coordinates (list(str)) – list of variable names

Returns:

the bounding box

Return type:

dictionary with key: variable names, value: list with min and max values

compute_coordinate_system(ttype='cartesian2cylindrical', remove_current=False, current_coord_sys=['x', 'y', 'z'], new_coord_sys=['x', 'r', 'theta'], origin=[0.0, 0.0, 0.0])

Compute a new coordinate system in the Datasets.

Parameters:
  • ttype (str in ['cartesian2cylindrical', 'cylindrical2cartesian']) – type of transformation

  • remove_current (bool) – remove current coordinate system after transformation

  • current_coord_sys (list of 3 str) – names of the current coordinates

  • new_coord_sys (list of 3 str) – names of the new coordinates

  • origin (list of 3 float) – position of the origin

Warning

‘cylindrical2cartesian’ not implemented

for ‘ttype’=’cartesian2cylindrical’, in ‘new_coord_sys’, the first coordinate is the axial direction, the second the radial one, and the third the azimuthal one (by default (x, r, \(\theta\)))

The first coordinate name in ‘new_coord_sys’ must also be into ‘current_coord_sys’.

copy()
delete_variables(list_vars, location=None)

Delete variables in the dataset.

Parameters:
  • list_vars (list(str)) – list of variables to delete

  • location (str in LOCATIONS or ‘None’) – if None, delete the variables at the all locations

equivalent to del zone[:, :, list_vars] which uses del with zone slicing instead.

classmethod deserialized(pickable_window)

Build a pickable representation of the window.

dimension()

Dimension of the Dataset.

Returns:

dimension of the Datasets

Return type:

int

duplicate_variables(list_vars, list_newvars, location=None)

Duplicate variables in the dataset.

Parameters:
  • list_vars (list(str)) – list of variables to duplicate

  • list_newvars (list(str)) – list of new variable names

  • location (str in LOCATIONS) – if different from None, change only the variables at the location specified

Duplication is performed element-wise.

classmethod fromkeys(iterable, value=None)
get(k[, d]) D[k] if k in D, else d.  d defaults to None.
get_ghost_cells()

Return the ghost_cells table.

Returns:

a list containing a dictionary for each index with two keys: ‘min’ and ‘max’.

Each key corresponds to the boundary min or max of that index. As we are in Windows (or in a Boundary), return a default result as if this was a zone without any boundaries defined

The values are lists containing as many elements as the number of boundaries. For each boundary a list of two elements is given:

  • the first is the slicing of the present block node array corresponding to this boundary

  • the second is:

    • if the boundary is a join: (donor zone name, node array slicing of the donor boundary, trirac)

    • else: None

get_location(location, new_dataset)

Return a copy of the Datasets containing only the variables located in the original Datasets at the specified location.

Parameters:
  • location (string in LOCATIONS) – location to extract

  • new_dataset (Datasets) – The dataset that will contain the variables located at the given location.

Returns:

the Datasets with only specified location variables

Return type:

Datasets or None

get_shape()

Get the shape of the dataset.

The shape is the shape of the node values, either taken from the shared instant, or taken from the first instant.

Returns:

the shape

Return type:

tuple

is_structured()

Tell whether the zone is a structured mesh or not.

Note

all instants are supposed to be of the same kind.

Return type:

bool

items() a set-like object providing a view on D's items
keys()

Return keys as a list and not KeysView nor dict_keys.

pop(k[, d]) v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() (k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

rel_to_abs(coordinates=None, conservative_vars=None, omega='in_attr', angle='in_attr')

Transform conservative variables from relative frame to absolute frame by looping on all instants using the Instant.rel_to_abs() method.

Parameters:
  • coordinates (list(str)) – list of coordinates names

  • conservative_vars (list(str)) – list of conservative variables names in the following order: density, momentum along the x-axis; momentum along the y-axis, momentum along the z-axis and total energy per unit of volume

  • omega (float) – angular speed of the current base. If in_attr use the omega stored in the attrs, necessary if different angular speeds in the base (for example one angular speed per superblock)

  • angle (float) – angular deviation of the current base. If in_attr use the angle stored in the attrs, necessary if different angular deviations in the base (for example one angular deviation per superblock and per instant)

Note

may be moved elsewhere in future releases

Warning

the angular speed must be perpendicular to the x-axis

rename_variables(list_vars, list_newvars, location=None)

Rename variables in the dataset.

Parameters:
  • list_vars (list(str)) – list of variables to rename

  • list_newvars (list(str)) – list of new variable names

  • location (str in LOCATIONS) – if different from None, change only the variables at the location specified

Replacement is performed element-wise.

serialized(data=True)

Build a pickable representation of the window.

set_computer_model(modeling, species_database=None, addons=None)

Set a computer modeling for the zone.

See antares.api.Instant.Instant.set_computer_model().

set_formula(formula)

Set a formula for the dataset (Zone or Boundary).

See antares.api.Instant.Instant.set_formula()

set_formula_from_attrs(name)

Set a formula from a name in the dataset attribute.

The computer will receive a new formula associated to its current modeling. This formula is included in the zone attribute with the key name.

setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D
update([E, ]**F) None.  Update D from mapping/iterable E and F.

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values() an object providing a view on D's values
property attrs

Dictionary antares.core.AttrsManagement.AttrsManagement containing the attributes of the Datasets.

container

Attribute (of type CustomDict) containing all kind of data associated to the Window, and not constrained to the shape. These data are ignored during a family slicing. optional.

property shared

Attribute (of type Instant) containing variables shared for all the Instants contained in the Datasets.

property slicing

Slicing gives the window location in the block.

This attribute is used to slice numpy arrays. Then, it has the following types depending on the mesh structures.

Type:

tuple(slice) or list or ndarray, compulsory

  • for unstructured grids: list of indices that gives the points (node values) that belong to this boundary

  • for structured grids: tuple of slice objects. The slices (start, stop, step) accept only None for the step value. It contains the topological information (six integers in 3D, four in 2D).

zone_name

Name of the Zone in which the slicing should be applied.

Type:

str, compulsory