prdtools.table
¶
- class prdtools.table.TableParameters(ncols: int, nrows: int, prime_num: int, prime_root: int, design_freq: int, well_width: Optional[float] = 3.81, speed_of_sound: Optional[int] = 343)[source]¶
Bases:
object
Parameters used to calculate a
TableResult
ncols
andnrows
must be coprime factors ofprime_num
- prime_root: int¶
A primitive root of
prime_num
used to calculate the sequence
- property high_frequency: int¶
The highest diffusion frequency possible with the specified
well_width
andspeed_of_sound
- validate() None [source]¶
Validate the parameters
- Raises
ValidationError – If any parameters are invalid
- calculate() prdtools.table.TableResult [source]¶
Calculate the
well height table
and return it as aTableResult
- class prdtools.table.TableResult(parameters: prdtools.table.TableParameters, data: TableArray)[source]¶
Bases:
object
A calculated table result
- parameters: prdtools.table.TableParameters¶
The
TableParameters
used to generate the result
- data: TableArray¶
The result array calculated by
well_height_table()
- well_heights: numpy.ndarray[Any, numpy.dtype[int]]¶
The well heights in
data
rounded to the nearest centimeter
- classmethod from_parameters(parameters: prdtools.table.TableParameters) prdtools.table.TableResult [source]¶
Calculate the result from the given
TableParameters
- classmethod from_kwargs(**kwargs) prdtools.table.TableResult [source]¶
Calculate the result using parameter values as keyword arguments
The keyword arguments given must include all necessary values to create a
TableParameters
instance
- get_well_counts() Dict[int, int] [source]¶
Count the total number of each unique well height in
well_heights
Returns the result as a dict of
{well_height: count}
- to_csv(separator: Optional[str] = ',', offset: Optional[int] = 0) str [source]¶
Format the
well_heights
array as a multiline string of comma-separated valuesThe offset argument will be added to the
well_heights
before output. For well heights of0
, there would be no block attached to the diffusor in that position. If (for aesthetic reasons) this is undesirable, an offset of1
(for example) could be applied to all wells.
- to_rst(offset: Optional[int] = 0) str [source]¶
Format the
well_heights
array as an rST tableThe offset argument will be added to the
well_heights
before output. For well heights of0
, there would be no block attached to the diffusor in that position. If (for aesthetic reasons) this is undesirable, an offset of1
(for example) could be applied to all wells.
- prdtools.table.well_height_table(parameters: prdtools.table.TableParameters) TableArray [source]¶
Calculate the well heights in centimeters for the given
TableParameters
The returned array will be of shape
(nrows, ncols)
- prdtools.table.prime_root_table(parameters: prdtools.table.TableParameters) TableArray [source]¶
Calculate well indices and prime elements for the given
TableParameters
The returned array will be of shape
(nrows, ncols)
- prdtools.table.build_diag_indices(nrows: int, ncols: int) Tuple[numpy.ndarray[Any, numpy.dtype[int]], numpy.ndarray[Any, numpy.dtype[int]]] [source]¶
Create indices for all diagonals of a 2-d array of shape
(nrows, ncols)
The results may be used to directly index an array of shape
(nrows, ncols)
along the diagonals.
- exception prdtools.table.ValidationError(msg, *fields)[source]¶
Bases:
ValueError
Raised by
TableParameters
if any parameter values are invalid
- prdtools.table.TableArray¶
A structured array of type
TABLE_DTYPE
alias of
numpy.ndarray
- prdtools.table.TABLE_DTYPE = dtype([('primes', '<i8'), ('indices', '<i8'), ('wells', '<f8')])¶
A structured data type for table results
- Parameters
primes – Value from the
prime root sequence
indices – The index of the primes value within the sequence
wells – The physical well height calculated from primes and the design wavelength