Here methods for data processing are provided, which mostly serve the purpose to export data in such a way that it is easy to display in LaTeX using PGFplots and TikZ.

class camiba.data.Decoder(*, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None)[source]

This class can be used to correctly decode integers in json files to Python integers right upon parsing of the json file.

>>> json.load('file.json', cls=camiba.data.Decoder)
decode(s)[source]

Return the Python representation of s (a str instance containing a JSON document).

camiba.data.csv_to_dict(p)[source]
Read from CSV to a Dictionary

This routine reads in a csv file and returns a dictionary with column headers as keys and columns as numpy arrays.

Parameters:

p : string

path to read from

Returns:

dict

the content of the csv as a dictionary of numpy ndarrays

camiba.data.dict_to_csv(d, p)[source]
Write a Dictionary to CSV

This routine takes a dictionary and uses the keys to use as header for the values writen column wise into a csv file, where we assume that the values are numpy arrays of the same length

Parameters:

d : dict

dictionary of data to write

p : string

path to write to

camiba.data.dict_to_tex(in_dict, out_path, verbose=False)[source]
Save Dictionary to TeX Makros

This function takes a path to a JSON file and outputs a file of TeX makros to make the values in the JSON file available to TeX. It may be very useful if one would like to run simulations parametrized by an external file and automatically include the used values in tex.

If one had a dictionary looking like:

>>> {
>>>     "measurementDataPath": "museData.mat",
>>>     "measurementDataName": "data",
>>>     "dictionaryDataPath": "dictData%(d).mat",
>>>     "dictionaryDataName": "data",
>>>     "dataShift": [0,0,0],
>>>     "dataStride": [1,1,1],
>>>     "recoParams": {
>>>         "numK": 50
>>>     },
>>>     "outputPath": "../data/",
>>>     "logPath": "reconstruct.log"
>>> }

then issuing

>>> dict_to_tex(dictionary.json, dictionary.tex)

would result in the file config.tex looking like:

\newcommand{\measurementDataPath}{museData.mat}
\newcommand{\measurementDataName}{data}
\newcommand{\dictionaryDataName}{data}
\newcommand{\dataShift1}{0}
\newcommand{\dataShift2}{0}
\newcommand{\dataShift3}{0}
\newcommand{\dataStride1}{1}
\newcommand{\dataStride2}{1}
\newcommand{\dataStride3}{1}
\newcommand{\recoParamsnumK}{50}
\newcommand{\outputPath}{../data/}
\newcommand{\logPath}{reconstruct.log}
Parameters:

in_dict : dict

the dictionary to export

out_path : str

path to the tex file that will be created

camiba.data.json_to_tex(in_path, out_path, verbose=False)[source]
Save Dictionary to TeX Makros

This function takes a path to a JSON file and outputs a file of TeX makros to make the values in the JSON file available to TeX. It may be very useful if one would like to run simulations parametrized by an external file and automatically include the used values in tex.

If one had a file config.json looking like:

>>> {
>>>     "measurementDataPath": "museData.mat",
>>>     "measurementDataName": "data",
>>>     "dictionaryDataPath": "dictData%(d).mat",
>>>     "dictionaryDataName": "data",
>>>     "dataShift": [0,0,0],
>>>     "dataStride": [1,1,1],
>>>     "recoParams": {
>>>         "numK": 50
>>>     },
>>>     "outputPath": "../data/",
>>>     "logPath": "reconstruct.log"
>>> }

then issuing

>>> json_to_tex(config.json, config.tex)

would result in the file config.tex looking like:

\newcommand{\measurementDataPath}{museData.mat}
\newcommand{\measurementDataName}{data}
\newcommand{\dictionaryDataName}{data}
\newcommand{\dataShift1}{0}
\newcommand{\dataShift2}{0}
\newcommand{\dataShift3}{0}
\newcommand{\dataStride1}{1}
\newcommand{\dataStride2}{1}
\newcommand{\dataStride3}{1}
\newcommand{\recoParamsnumK}{50}
\newcommand{\outputPath}{../data/}
\newcommand{\logPath}{reconstruct.log}
Parameters:

in_path : str

path to the json file

out_path : str

path to the tex file that will be created

camiba.data.mat_to_heat(d, x, y, p)[source]
Convert 2D Array to a heatmap

This function takes a 2D ndarray and writes the data to disk such that it can be plotted as a 2D heatmap in pgfplots.

Parameters:

d : ndarray

the array to plot

x : ndarray

x-axis range

y : ndarray

y-axis range

p : string

path to save to

camiba.data.save_params(dct_vars, str_p)[source]
Save Dictionary of Parameters to Disk

This routine allows to store names and their values in a file, which can be read from LaTeX to dynamically update parameter values of simulations in a paper

Parameters:

dct_vars : dict

dictionary of parameter values

str_p : string

path to save the file to