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:
objectParameters used to calculate a
TableResultncolsandnrowsmust be coprime factors ofprime_num- prime_root: int¶
A primitive root of
prime_numused to calculate the sequence
- property high_frequency: int¶
The highest diffusion frequency possible with the specified
well_widthandspeed_of_sound
- validate() None[source]¶
Validate the parameters
- Raises
ValidationError – If any parameters are invalid
- calculate() prdtools.table.TableResult[source]¶
Calculate the
well height tableand return it as aTableResult
- class prdtools.table.TableResult(parameters: prdtools.table.TableParameters, data: TableArray)[source]¶
Bases:
objectA calculated table result
- parameters: prdtools.table.TableParameters¶
The
TableParametersused 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
datarounded 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
TableParametersinstance
- get_well_counts() Dict[int, int][source]¶
Count the total number of each unique well height in
well_heightsReturns the result as a dict of
{well_height: count}
- to_csv(separator: Optional[str] = ',', offset: Optional[int] = 0) str[source]¶
Format the
well_heightsarray as a multiline string of comma-separated valuesThe offset argument will be added to the
well_heightsbefore 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_heightsarray as an rST tableThe offset argument will be added to the
well_heightsbefore 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
TableParametersThe 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
TableParametersThe 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:
ValueErrorRaised by
TableParametersif any parameter values are invalid
- prdtools.table.TableArray¶
A structured array of type
TABLE_DTYPEalias 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 sequenceindices – The index of the primes value within the sequence
wells – The physical well height calculated from primes and the design wavelength