nucleon_elastic_ff.data.parsing

Routines for parsing information from data files and hdf addresses

nucleon_elastic_ff.data.parsing.parse_file_info(filename: str, convert_numeric: bool = True) → Dict[str, Union[int, float, str]][source]

Parses the filename and returns dict corresponding to file parameters.

Arguments
filename: str
File that starts with formfac_4D_<…>.h5 where the elipses are not optional.
convert_numeric: bool = True
Converts float & int strings to floats & ints. If false, leave them as a string.
Raises
ValueError
If one key is not specified.
nucleon_elastic_ff.data.parsing.parse_t_info(string: str) → Dict[str, int][source]

Extract t0 and tsep info from string.

The pattern matches e.g., proton_DD_dn_dn_t0_83_tsep_7_sink_mom_px0_py0_pz0. Matches _t0_[0-9]+_tsep_[\-0-9]+_. If no match is found, tries to identify t by the source location _x[0-9]+y[0-9]+z[0-9]+t[0-9]+ and sets t0 to t.

Arguments
string: str
The string to match
Returns
Dict[str, int]:
Dictionary with keys for t0 and tsep