aPriori.Scalar¶
- class aPriori.Scalar(shape, value=None, path='')¶
A class representing a 3D scalar field.
Attributes:¶
- __scalar_dimensionint
The dimension of the scalar field.
- test_phasebool
A flag indicating whether the test phase is active.
- VALID_DIMENSIONSlist
A list of valid dimensions for the scalar field.
Methods:¶
- __init__(shape, value=None, path=ââ):
Initializes a Scalar object.
- value
Getter and setter for the value attribute.
- shape
Getter and setter for the shape attribute.
- path
Getter and setter for the path attribute.
- Nx
Getter and setter for the Nx attribute.
- Ny
Getter and setter for the Ny attribute.
- Nz
Getter and setter for the Nz attribute.
- file_name
Getter and setter for the file_name attribute.
- file_id
Getter and setter for the file_id attribute.
- filter_size
Getter and setter for the filter_size attribute.
- _3d
Getter for the 3D reshaped scalar field.
- is_light_mode():
Checks if the scalar field is in light mode.
- reshape_3d():
Reshapes the scalar field to 3D.
- reshape_column():
Reshapes the scalar field to a column vector.
- reshape_line():
Reshapes the scalar field to a row vector.
- cut(n_cut=1, mode=âequalâ):
Cuts the scalar field.
- filter_gauss(delta, n_cut=0, mute=False):
Filters the scalar field with a Gaussian function.
- plot_x_midplane(mesh, title=ââ, colormap=âviridisâ, vmin=None, vmax=None)
Plots the x midplane of a 3D field.
- plot_y_midplane(mesh, title=ââ, colormap=âviridisâ, vmin=None, vmax=None)
Plots the y midplane of a 3D field.
- plot_z_midplane(mesh, title=ââ, colormap=âviridisâ, vmin=None, vmax=None)
Plots the z midplane of a 3D field.
- test_phase = True¶
- VALID_DIMENSIONS = [3, 1]¶
- property shape¶
- property value¶
- property path¶
- property Nx¶
- property Ny¶
- property Nz¶
- property file_name¶
- property file_id¶
- property filter_size¶
- property x_midplane¶
- property y_midplane¶
- property z_midplane¶
- is_light_mode()¶
Checks if the scalar field is in light mode, that is when only the path is specified without specifying the value as an array.
Returns:¶
: bool
True if the scalar field is in light mode, False otherwise.
Raises:¶
- ValueError
If neither the value nor the path is specified.
- lenght()¶
- reshape_3d()¶
Reshapes the scalar field to 3D.
Returns:¶
: array-like
The scalar field reshaped to 3D.
- reshape_column()¶
Reshapes the scalar field to a column vector.
Returns:¶
: array-like
The scalar field reshaped to a column vector.
- reshape_line()¶
Reshapes the scalar field to a row vector.
Returns:¶
: array-like
The scalar field reshaped to a row vector.
- cut(n_cut=1, mode='equal')¶
Cuts the scalar field.
- n_cutint or tuple, optional
The number of samples to cut at the extrema. If mode is âequalâ, n_cut is an integer specifying the number of samples to cut from each side. If mode is âxyzâ, n_cut is a tuple specifying the number of samples to cut for each dimension. Default is 1.
- mode{âequalâ, âxyzâ}, optional
The mode of cutting. âequalâ cuts the same number of samples from each side, âxyzâ allows specifying the number of samples to cut for each dimension. Default is âequalâ.
- array-like
The cut scalar field.
>>> # Example of cutting a scalar field >>> field = Scalar(shape=[10, 10, 10], value=np.random.rand(10, 10, 10)) >>> # Cut the field with equal number of samples removed from each side >>> cut_field_equal = field.cut(n_cut=2, mode='equal') >>> print("Cut field with equal mode:") >>> print(cut_field_equal) >>> # Cut the field with specified number of samples removed for each dimension >>> cut_field_xyz = field.cut(n_cut=(1, 2, 3), mode='xyz') >>> print("
- Cut field with xyz mode:â)
>>> print(cut_field_xyz)
- filter_gauss(delta, n_cut=0, mute=False)¶
Filters the scalar field with a Gaussian function. The variance sigma is considered equal to:
sigma = sqrt(1/12*delta**2)
where delta is the filter size (in this case specified as the number of cells and not in meters)
Parameters:¶
- deltafloat
The amplitude of the Gaussian filter.
- n_cutint, optional
The number of samples to cut at the extrema. Default is 0.
- mutebool, optional
A flag indicating whether to mute the output. Default is False.
Returns:¶
: array-like
The filtered scalar field.
- plot_x_midplane(mesh, title='', colormap='viridis', vmin=None, vmax=None)¶
Plots the x midplane of a 3D field.
Description:¶
This method plots the x midplane of a 3D field using the provided mesh. It uses the midpoint of the x-axis to generate a 2D plot of the field values at that plane.
Parameters:¶
- meshobject
The mesh object containing the coordinates.
- titlestr, optional
The title of the plot. Default is an empty string.
- colormapstr, optional
The colormap to use for the plot. Default is âviridisâ.
- vminfloat, optional
The minimum value for the color scale. Default is None.
- vmaxfloat, optional
The maximum value for the color scale. Default is None.
Returns:¶
: None
- plot_y_midplane(mesh, title='', colormap='viridis', vmin=None, vmax=None)¶
Plots the y midplane of a 3D field.
Description:¶
This method plots the y midplane of a 3D field using the provided mesh. It uses the midpoint of the x-axis to generate a 2D plot of the field values at that plane.
Parameters:¶
- meshobject
The mesh object containing the coordinates.
- titlestr, optional
The title of the plot. Default is an empty string.
- colormapstr, optional
The colormap to use for the plot. Default is âviridisâ.
- vminfloat, optional
The minimum value for the color scale. Default is None.
- vmaxfloat, optional
The maximum value for the color scale. Default is None.
Returns:¶
: None
- plot_z_midplane(mesh, title='', colormap='viridis', vmin=None, vmax=None)¶
Plots the x midplane of a 3D field.
Description:¶
This method plots the x midplane of a 3D field using the provided mesh. It uses the midpoint of the x-axis to generate a 2D plot of the field values at that plane.
Parameters:¶
- meshobject
The mesh object containing the coordinates.
- titlestr, optional
The title of the plot. Default is an empty string.
- colormapstr, optional
The colormap to use for the plot. Default is âviridisâ.
- vminfloat, optional
The minimum value for the color scale. Default is None.
- vmaxfloat, optional
The maximum value for the color scale. Default is None.
Returns:¶
: None