Field class

class PyFields.core.field.Field(axis_x, axis_y, unit_x='', unit_y='')[source]

Bases: object

axis_x
axis_y
change_unit(axis, new_unit)[source]

Put a field axis in the wanted unit. Change the axis value in agreement with the new unit.

Parameters:
  • axis (string in ['x', 'y']) – Axis to change the unit for.
  • new_unit (Unum.unit object or string) – New unit.

Note

To associate a completely different unit to an axis (e.g. ‘m’ to ‘s’), use ‘Field.axis_x = “s”’.

copy()[source]

Return a copy of the Field object.

crop(intervx=None, intervy=None, full_output=False, ind=False, inplace=False)[source]

Crop the field.

Parameters:
  • intervx (array, optional) – Wanted interval along x.
  • intervy (array, optional) – Wanted interval along y.
  • full_output (boolean, optional) – If ‘True’, cutting indices are also returned
  • ind (boolean, optional) – If ‘True’, intervals are understood as indices along axis. If ‘False’ (default), intervals are understood in axis units.
  • inplace (boolean, optional) – If ‘True’, the field is croped in place, else (default), a copy is returned.
dx
dy
extend(nmb_left=0, nmb_right=0, nmb_up=0, nmb_down=0, inplace=False)[source]

Add columns and/or lines of masked values to the field.

Parameters:
  • nmb_right, nmb_up, nmb_down (nmb_left,) – Number of lines/columns to add in each direction.
  • inplace (bool) – If ‘True’, extend the field in place, else (default), return an extended copy of the field.
Returns:

Extended_field – Extended field.

Return type:

Field object

Note

If the axis values are not equally spaced, a linear extrapolation is used to obtain the new axis values.

get_indice_on_axis(direction, value, kind='bounds')[source]

Return, on the given axis, the indices of the positions surrounding the given value.

Parameters:
  • direction (string in ['x', 'y']) – Axis choice.
  • value (number) –
  • kind (string, optional) – If ‘bounds’ (default), return the bounding indices. if ‘nearest’, return the nearest indice if ‘decimal’, return a decimal indice (interpolated)
Returns:

interval – Bounding, nearest or decimal indice.

Return type:

2x1 array of integer or integer

rotate(angle, inplace=False)[source]

Rotate the field.

Parameters:
  • angle (integer) – Angle in degrees (signe in trigonometric convention). In order to preserve the orthogonal grid, only multiples of 90° are accepted.
  • inplace (boolean, optional) – If True, the field is rotated in place, else (default), a rotated copy is returned.
Returns:

rotated_field – Rotated field.

Return type:

Field object

scale(scalex=None, scaley=None, inplace=False, output_reverse=False)[source]

Scale the Field.

Parameters:
  • scaley (scalex,) – Scale to apply on the associated axis
  • inplace (boolean, optional) – If True, scale the field in place, else (default) return a scaled copy.
set_origin(x=None, y=None)[source]

Modify the axis in order to place the origin at the given point (x, y).

Parameters:y (x,) – Position of the new origin.
shape
unit_x
unit_y