TemporalFields class

class IMTreatment.core.temporalfields.TemporalFields[source]

Bases: IMTreatment.core.fields.Fields, IMTreatment.core.field.Field

Class representing a set of time evolving fields. All fields added to this object has to have the same axis system.

add_field(field, time=0.0, unit_times='', copy=True)[source]

Add a field to the existing fields.

Parameters:
  • field (vf.VectorField or sf.ScalarField object) – The field to add.
  • time (number) – time associated to the field.
  • unit_time (Unum object) – time unit.
augment_temporal_resolution(fact=2, inplace=False)[source]

Augment the temporal resolution using temporal interpoalation.

Parameters:
  • fact (integer) – Temporal resolution ratio.
  • inplace (bool) –

    .

axe_x
axe_y
change_unit(axe, new_unit)[source]

Change the unit of an axe.

Parameters:
  • axe (string) – ‘y’ for changing the profile y axis unit ‘x’ for changing the profile x axis unit ‘values’ for changing values unit ‘time’ for changing time unit
  • new_unit (Unum.unit object or string) – The new unit.
copy()[source]

Return a copy of the velocityfields

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

Return a croped field in respect with given intervals.

Parameters:
  • intervx (array, optional) – interval wanted along x
  • intervy (array, optional) – interval wanted along y
  • intervt (array, optional) – interval wanted along time
  • full_output (boolean, optional) – If ‘True’, cutting indices are alson returned
  • inplace (boolean, optional) – If ‘True’, fields are croped in place.
crop_masked_border(hard=False, inplace=False)[source]

Crop the masked border of the velocity fields in place.

Parameters:
  • hard (boolean, optional) – If ‘True’, partially masked border are croped as well.
  • inplace (boolean, optional) – If ‘True’, crop the F in place, else, return a croped TF.
display(compo=None, kind=None, sharecb=True, buffer_size=100, **plotargs)[source]

Create a windows to display temporals field, controlled by buttons.

Parameters:
  • compo (string) – Component to plot.
  • kind (string) – Kind of plot to use.
  • sharecb (boolean) – Do all the vector field serie has to share the same colorbar or not.
  • buffer_size (number) – Number of displays to keep in memory (faster, but use memory).
  • **plotargs (dic) – Arguments passed to the plot command.
  • control (Display) –
  • ---------------
  • display can be controlled useing the button, but also the keyboard (The) –
  • right arrow or + (space,) –
  • left arrow or - (backspace,) –
  • arrow (down) –
  • arrow
  • + enter (number) –
  • p (play the animated fields) –
  • + i (number) –
  • + t (number) –
  • q (close) –
  • s (save an image) –
display_animate(compo=None, interval=500, fields_inds=None, repeat=True, **plotargs)[source]

Display fields animated in time.

Parameters:
  • compo (string) – Composante to display
  • interval (number, optionnal) – interval between two frames in milliseconds.
  • fields_ind (array of indices) – Indices of wanted fields. by default, all the fields are displayed
  • repeat (boolean, optional) – if True, the animation is repeated infinitely.
  • arguments can be passed (scale, vmin, vmax,..) (additional) –
display_multiple(component=None, kind=None, inds=None, sharecb=False, sharex=False, sharey=False, ncol=None, nrow=None, **plotargs)[source]

Display a component of the velocity fields.

Parameters:
  • component (string, optional) – component to display
  • kind (string, optional) – Kind of display wanted.
  • fields_ind (array of indices) – Indices of fields to display.
  • samecb (boolean, optional) – If ‘True’, the same color system is used for all the fields. You have to pass ‘vmin’ and ‘vmax’, to have correct results.
  • nrow (ncol,) – Wanted number of columns and rows. If not specified, these values are computed so that ncol ~ nrow.
  • plotargs (dict, optional) – Arguments passed to the function used to display the vector field.
dt
extend(nmb_left=0, nmb_right=0, nmb_up=0, nmb_down=0, inplace=False)[source]

Add columns or lines of masked values at the fields.

Parameters:
  • nmb_**** (integers) – Number of lines/columns to add in each direction.
  • inplace (bool) – If ‘False’, return a new extended field, if ‘True’, modify the field inplace.
Returns:

Extended_field – Extended field.

Return type:

TemporalFields object, optional

get_fluctuant_fields(nmb_min_mean=1)[source]

Calculate the fluctuant fields (fields minus mean field).

Parameters:nmb_min_mean (number, optional) – Parameter for mean computation (see ‘get_mean_field’ doc).
Returns:fluct_fields – Contening fluctuant fields.
Return type:TemporalScalarFields or TemporalVectorFields object
get_interpolated_field(time)[source]

Return the interpolated field happening at the time ‘time’.

get_mean_field(nmb_min=1, dtype=None)[source]

Calculate the mean velocity field, from all the fields.

Parameters:
  • nmb_min (integer, optional) – Minimum number of values used to make a mean. else, the value is masked
  • dtype (type) – Specify the output values type (default to the same one as fields).
get_recurrence_map(norm=2, verbose=False, bandwidth=None, normalized=False)[source]

Return the recurrence map associated with the 2-norm.

Returns:rec_map – .
Return type:sf.ScalarField object
get_spatial_spectrum(component, direction, intervx=None, intervy=None, intervtime=None, welch_seglen=None, scaling='base', fill='linear')[source]

Return a spatial spectrum. If more than one time are specified, spectrums are averaged.

Parameters:
  • component (string) – Should be an attribute name of the stored fields.
  • direction (string) – Direction in which perform the spectrum (‘x’ or ‘y’).
  • and intervy (intervx) – To chose the zone where to calculate the spectrum. If not specified, the biggest possible interval is choosen.
  • intervtime (2x1 array, optional) – Interval of time on which averaged the spectrum.
  • welch_seglen (integer, optional) – If specified, welch’s method is used (dividing signal into overlapping segments, and averaging periodogram) with the given segments length (in number of points).
  • scaling (string, optional) – If ‘base’ (default), result are in component unit. If ‘spectrum’, the power spectrum is returned (in unit^2). If ‘density’, the power spectral density is returned (in unit^2/(1/unit_axe))
  • fill (string or float) – Specifies the way to treat missing values. A value for value filling. A string (‘linear’, ‘nearest’ or ‘cubic’) for interpolation.

Notes

If there is missing values on the field, ‘fill’ is used to linearly interpolate the missing values (can impact the spectrum).

get_spectrum_map(comp, welch_seglen=None, nmb_pic=1, spec_smooth=None, verbose=True)[source]

Return the temporal spectrum map.

Parameters:
  • comp (string) – Component to get the spectrum from.
  • welch_seglen (integer) –

    .

  • nmb_pic (integer) – Number of succesive spectrum pic to detect
  • spec_smooth (number) –

    .

  • verbose (bool) –

    .

Returns:

  • map_freq_sf – .
  • map_freq_quality_sf – .

get_temporal_spectrum(component, pt, ind=False, wanted_times=None, welch_seglen=None, scaling='base', fill='linear', mask_error=True, detrend='constant')[source]

Return a Profile object, with the temporal spectrum of ‘component’ on the point ‘pt’.

Parameters:
  • component (string) –

    .

  • pt (2x1 array of numbers) –

    .

  • ind (boolean) – If true, ‘pt’ is read as indices, else, ‘pt’ is read as coordinates.
  • wanted_times (2x1 array, optional) – Time interval in which compute spectrum (default is all).
  • welch_seglen (integer, optional) – If specified, welch’s method is used (dividing signal into overlapping segments, and averaging periodogram) with the given segments length (in number of points).
  • scaling (string, optional) – If ‘base’ (default), result are in component unit. If ‘spectrum’, the power spectrum is returned (in unit^2). If ‘density’, the power spectral density is returned (in unit^2/Hz)
  • fill (string or float) – Specifies the way to treat missing values. A value for value filling. A string (‘linear’, ‘nearest’, ‘zero’, ‘slinear’, ‘quadratic, ‘cubic’ where ‘slinear’, ‘quadratic’ and ‘cubic’ refer to a spline interpolation of first, second or third order) for interpolation.
  • mask_error (boolean) – If ‘False’, instead of raising an error when masked value appear on time profile, ‘(None, None)’ is returned.
  • detrend (string, optional) – Method used to detrend the profile. Can be ‘none’, ‘constant’ (default) or ‘linear’.
Returns:

magn_prof – Magnitude spectrum.

Return type:

prof.Profile object

get_temporal_spectrum_over_area(component, intervx, intervy, ind=False, welch_seglen=None, scaling='base', fill='linear', detrend='constant')[source]

Return a prof.Profile object, contening a mean spectrum of the given component, on all the points included in the given intervals.

Parameters:
  • component (string) – Scalar component (‘Vx’, ‘Vy’, ‘magnitude’, …).
  • intervy (intervx,) – Defining the square on which averaging the spectrum. (in axes values)
  • ind (boolean) – If true, ‘pt’ is read as indices, else, ‘pt’ is read as coordinates.
  • welch_seglen (integer, optional) – If specified, welch’s method is used (dividing signal into overlapping segments, and averaging periodogram) with the given segments length (in number of points).
  • scaling (string, optional) – If ‘base’ (default), result are in component unit. If ‘spectrum’, the power spectrum is returned (in unit^2). If ‘density’, the power spectral density is returned (in unit^2/Hz)
  • fill (string or float) – Specifies the way to treat missing values. A value for value filling. A string (‘linear’, ‘nearest’, ‘zero’, ‘slinear’, ‘quadratic, ‘cubic’ where ‘slinear’, ‘quadratic’ and ‘cubic’ refer to a spline interpolation of first, second or third order) for interpolation.
  • detrend (string, optional) – Method used to detrend the profile. Can be ‘none’, ‘constant’ (default) or ‘linear’.
Returns:

magn_prof – Averaged magnitude spectrum.

Return type:

prof.Profile object

get_time_profile(component, pt, wanted_times=None, ind=False)[source]

Return a profile contening the time evolution of the given component.

Parameters:
  • component (string) – Should be an attribute name of the stored fields.
  • pt (2x1 array of numbers, or pts.Points object) – Wanted position for the time profile, in axis units.
  • wanted_times (2x1 array of numbers) – Time interval in which getting profile (default is all).
  • ind (boolean, optional) – If ‘True’, values are undersood as indices.
Returns:

profile

Return type:

prof.Profile object

inject_time_profile(comp, pt, prof, ind=False)[source]

Overwrite the value at the given points with data from the time profile.

Parameters:
  • comp (string) – Should be an attribute name of the stored fields.
  • pt (2x1 array of numbers, or pts.Points object) – Wanted position for the time profile, in axis units.
  • prof (Profile object) – Profile used to overwrite data at point
  • ind (boolean, optional) – If ‘True’, values are understood as indices.
make_evenly_spaced(interp='linear', res=1)[source]

Use interpolation to make the fields evenly spaced

Parameters:
  • interp ({‘linear’, ‘cubic’, ‘quintic’}, optional) – The kind of spline interpolation to use. Default is ‘linear’.
  • res (number) – Resolution of the resulting field. A value of 1 meaning a spatial resolution equal to the smallest space along the two axis for the initial field.
mask
mask_as_sf
mask_cum
mask_cum_as_sf
mirroring(direction, position, inds_to_mirror='all', mir_coef=1.0, inplace=False, interp=None, value=[0, 0])[source]

Return the fields with additional mirrored values.

Parameters:
  • direction (integer) – Axe on which place the symetry plane (1 for x and 2 for y)
  • position (number) – Position of the symetry plane along the given axe
  • inds_to_mirror (integer) – Number of vector rows to symetrize (default is all)
  • mir_coef (number or 2x1 array, optional) – Optional coefficient(s) applied only to the mirrored values. It can be an array first value is for ‘comp_x’ and second one to ‘comp_y’ (for vector fields)
  • inplace (boolean, optional) –

    .

  • interp (string, optional) – If specified, method used to fill the gap near the symetry plane by interpoaltion. ‘value’ : fill with the given value, ‘nearest’ : fill with the nearest value, ‘linear’ (default): fill using linear interpolation (Delaunay triangulation), ‘cubic’ : fill using cubic interpolation (Delaunay triangulation)
  • value (array, optional) – Value at the symetry plane, in case of interpolation
record_animation(anim, filepath, kind='gif', fps=30, dpi=100, bitrate=50, imagemagick_path=None)[source]

Record an animation in a gif file. You must create an animation (using ‘display_animate’ for example) before calling this method. You may have to specify the path to imagemagick in orfer to use it.

reduce_spatial_resolution(fact, inplace=False, verbose=False)[source]

Reduce the spatial resolution of the fields by a factor ‘fact’

Parameters:
  • fact (int) – Reducing factor.
  • inplace (boolean, optional) –

    .

reduce_temporal_resolution(nmb_in_interval, mean=True, inplace=False)[source]

Return a TemporalVelocityFields, contening one field for each ‘nmb_in_interval’ field in the initial TFVS.

Parameters:
  • nmb_in_interval (integer) – Length of the interval. (one field is kept for each ‘nmb_in_interval fields)
  • mean (boolean, optional) – If ‘True’, the resulting fields are average over the interval. Else, fields are taken directly.
  • inplace (boolean, optional) –
Returns:

TVFS

Return type:

TemporalVelocityFields

remove_fields(fieldnumbers)[source]

Remove field(s) of the existing fields.

Parameters:fieldnumber (integer or list of integers) – Velocity field(s) number(s) to remove.
remove_weird_fields(std_coef=3.29, treatment='interpolate', inplace=False)[source]

Look at the time evolution of spatial mean magnitude to identify and replace weird fields.

Parameters:
  • std_coef (number) – Fields associated with mean magnitude outside the interval [mean - std_coef*std, mean - std_coef*std] are treated as weird fields. Default value of ‘3.29’ corespond for a 99.9% interval.
  • treatment (string in ['remove', 'interpolate']) – Type of treatment for the weird fields (default is ‘interpolate’)
  • inplace (bool) –

    .

Returns:

tf – treated temporal field

Return type:

TemporalField

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

Scale the Fields.

Parameters:
  • scaley, scalev (scalex,) – Scale for the axis and the values.
  • inplace (boolean) –

    .

set_origin(x=None, y=None)[source]

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

Parameters:
  • x (number) –
  • y (number) –
times
unit_times
unit_values
unit_x
unit_y