dodal.devices.util.lookup_tables_apple2#

Classes

EnergyCoverage

EnergyCoverageEntry

Create a new model by parsing and validating input data from keyword arguments.

EnergyMinMax

Create a new model by parsing and validating input data from keyword arguments.

EnergyMotorLookup

Handles lookup tables for Apple2 ID, converting energy and polarisation to gap and phase.

GapPhaseLookupTables

Create a new model by parsing and validating input data from keyword arguments.

LookupTable

LookupTableConfig

Create a new model by parsing and validating input data from keyword arguments.

LookupTableEntries

Create a new model by parsing and validating input data from keyword arguments.

Apple2 lookup table utilities and CSV converter.

This module provides helpers to read, validate and convert Apple2 insertion-device lookup tables (energy -> gap/phase polynomials) from CSV sources into an in-memory dictionary format used by the Apple2 controllers.

Data format produced The lookup-table dictionary created by convert_csv_to_lookup() follows this structure:

{
“POL_MODE”: {
“energies”: {
“<min_energy>”: {

“low”: <float>, “high”: <float>, “poly”: <numpy.poly1d>

}, “limit”: {

“minimum”: <float>, “maximum”: <float>

}

},

}

Functions

convert_csv_to_lookup(file_contents, lut_config)

Convert CSV content into the Apple2 lookup-table dictionary.

generate_lookup_table(pol, min_energy, ...)

generate_lookup_table_entry(min_energy, ...)

get_poly(energy, pol, lookup_table)

Return the numpy.poly1d polynomial applicable for the given energy and polarisation.

make_phase_tables(pols, min_energies, ...)

Generate a dictionary containing multiple lookuptable entries for provided polarisations.

read_file_and_skip(file[, skip_line_start_with])

Yield non-comment lines from the CSV content string.

dodal.devices.util.lookup_tables_apple2.convert_csv_to_lookup(file_contents: str, lut_config: LookupTableConfig, skip_line_start_with: str = '#') LookupTable[source]#

Convert CSV content into the Apple2 lookup-table dictionary.

Return type:

LookupTable

Parameters:#

file_contents:

The CSV file contents as string.

lut_config:

The configuration that how to process the file_contents into a LookupTable.

skip_line_start_with

Lines beginning with this prefix are skipped (default “#”).

Returns:#

: LookupTable

param file_contents:

type file_contents:

str

param lut_config:

type lut_config:

LookupTableConfig

param skip_line_start_with:

type skip_line_start_with:

str, default: "#"

dodal.devices.util.lookup_tables_apple2.read_file_and_skip(file: str, skip_line_start_with: str = '#') Generator[str][source]#

Yield non-comment lines from the CSV content string.

Parameters:
  • file (str)

  • skip_line_start_with (str, default: "#")

Return type:

Generator[str]

dodal.devices.util.lookup_tables_apple2.get_poly(energy: float, pol: Pol, lookup_table: LookupTable) poly1d[source]#

Return the numpy.poly1d polynomial applicable for the given energy and polarisation.

Return type:

poly1d

Parameters:#

energy:

Energy value in the same units used to create the lookup table.

pol:

Polarisation mode (Pol enum).

lookup_table:

The converted lookup table dictionary for either ‘gap’ or ‘phase’.

param energy:

type energy:

float

param pol:

type pol:

Pol

param lookup_table:

type lookup_table:

LookupTable

dodal.devices.util.lookup_tables_apple2.generate_lookup_table_entry(min_energy: float, max_energy: float, poly1d_param: list[float]) LookupTableEntries[source]#
Parameters:
Return type:

LookupTableEntries

dodal.devices.util.lookup_tables_apple2.generate_lookup_table(pol: Pol, min_energy: float, max_energy: float, poly1d_param: list[float]) LookupTable[source]#
Parameters:
Return type:

LookupTable

dodal.devices.util.lookup_tables_apple2.make_phase_tables(pols: list[Pol], min_energies: list[float], max_energies: list[float], poly1d_params: list[list[float]]) LookupTable[source]#

Generate a dictionary containing multiple lookuptable entries for provided polarisations.

Parameters:
Return type:

LookupTable