pytac.load_csv#

Module to load the elements of the machine from csv files.

The csv files are stored in one directory with specified names:

  • elements.csv

  • devices.csv

  • families.csv

  • unitconv.csv

  • uc_poly_data.csv

  • uc_pchip_data.csv

Members

available_ringmodes

Return the possible ringmodes based on the subdirectories and files in the given directory.

csv_loader

load

Load the elements of a lattice from a directory.

load_pchip_unitconv

Load pchip unit conversions from a csv file.

load_poly_unitconv

Load polynomial unit conversions from a csv file.

load_unitconv

Load the unit conversion objects from a file.

resolve_unitconv

Create a unit conversion object based on the dictionary of parameters passed.

pytac.load_csv.load_poly_unitconv(filepath: Path) dict[int, PolyUnitConv][source]#

Load polynomial unit conversions from a csv file.

Parameters:

filepath – The file from which to load.

Returns:

A dictionary of the unit conversions.

Return type:

dict

pytac.load_csv.load_pchip_unitconv(filepath: Path) dict[int, PchipUnitConv][source]#

Load pchip unit conversions from a csv file.

Parameters:

filename – The file from which to load.

Returns:

A dictionary of the unit conversions.

Return type:

dict

pytac.load_csv.resolve_unitconv(uc_params: dict, unitconvs: dict, polyconv_file: Path, pchipconv_file: Path) UnitConv[source]#

Create a unit conversion object based on the dictionary of parameters passed.

Parameters:
  • uc_params (Dict) – A dictionary of parameters specifying the unit conversion object’s properties.

  • unitconvs (Dict) – A dictionary of all loaded unit conversion objects.

  • polyconv_file (Path) – The path to the .csv file from which all PolyUnitConv objects are loaded.

  • pchipconv_file (Path) – The path to the .csv file from which all PchipUnitConv objects are loaded.

Returns:

The unit conversion object as specified by uc_params.

Return type:

UnitConv

Raises:

UnitsException – if the “uc_id” given in uc_params isn’t in the unitconvs Dict.

pytac.load_csv.load_unitconv(mode_dir: Path, lattice: Lattice) None[source]#

Load the unit conversion objects from a file.

Parameters:
  • mode_dir – Path to directory containing CSV files.

  • lattice – The lattice object that will be used.

pytac.load_csv.load(mode, control_system=None, directory=None, symmetry=None) EpicsLattice[source]#

Load the elements of a lattice from a directory.

Parameters:
  • mode (str) – The name of the mode to be loaded.

  • control_system (ControlSystem) – The control system to be used. If none is provided an EpicsControlSystem will be created.

  • directory (str) – Directory where to load the files from. If no directory is given the data directory at the root of the repository is used.

  • symmetry (int) – The symmetry of the lattice (the number of cells).

Returns:

The lattice containing all elements.

Return type:

Lattice

Raises:

ControlSystemException – if the default control system, cothread, is not installed.

pytac.load_csv.available_ringmodes(directory=None) set[str][source]#

Return the possible ringmodes based on the subdirectories and files in the given directory.

Note

It is not guaranteed that the modes returned will be able to be successfully loaded due to errors, missing data, etc. I.e., any mode that can be loaded will always be returned, but modes that can’t be loaded might also sometimes be returned.

Parameters:

directory (str) – The data directory to check inside. If no directory is given the default data directory location is used.

Returns:

A set of possible ringmodes.

Return type:

set[str]

Raises:

OSError – if no ringmodes can be found in the specified directory.