nucleon_elastic_ff.data.scripts.tslice

Script for time slicing correlator data

nucleon_elastic_ff.data.scripts.tslice.get_t_slices(t0: int, tsep: int, nt: int) → Tuple[List[int], numpy.ndarray][source]

Returns range [t0, t0 + tsep + step] where step is defined by sign of tsep.

List elements are counted modulo the maximal time extend nt. This function returns the new indices and the factor associated with the indices. E.g., entries which hop the boundaries are multiplied by minus one.

Arguments
t0: int
Start index for slicing.
tsep: int
Seperation for slicing.
nt: int
Maximum time slice.
nucleon_elastic_ff.data.scripts.tslice.slice_file(file_address_in: str, file_address_out: str, overwrite: bool = False, tslice_fact: Optional[float] = None, dset_patterns: List[str] = ('local_current', ), boundary_sign_flip: bool = False)[source]

Reads input file and writes time-sliced data to output file.

This methods scans all datasets within the file. If a data set has “local_current” in its name it is sliced in its time components. The slicing info is inferred by the group name (see parse_t_info) and cut according using slice_array. Also the slicing meta info is stored in the resulting output file in the meta attribute of local_current.

Arguments
file_address_in: str
Address of the to be scanned and sliced HDF5 file.
file_address_out: str
Address of the output HDF5 file.
overwrite: bool = False
Overwrite existing sliced file.
tslice_fact: Optional[float] = None
User interface for controlling factor for determening sclicing size. E.g., if a a file has NT = 48 and tslice_fact is 0.5, only time slices from 0 to 23 are exported to the output file. Note that the source location is shifted before slicing.
dset_patterns: List[str] = (“local_current”,),
Pattern dsets must matched in order to be sliced.
boundary_sign_flip: bool = False
Applies minus sign to correlator if hopping over temporal boundaries after tslicing (in any direction).
Raises
ValueError:
If tslice_fact is not None but one is able to parse tsep information from the file string. This is a safeguard against accidentally slicing files which shall not be sliced.
nucleon_elastic_ff.data.scripts.tslice.tslice(root: str, name_input: str = 'formfac_4D', name_output: str = 'formfac_4D_tslice', overwrite: bool = False, tslice_fact: Optional[float] = None, dset_patterns: List[str] = ('local_current', ), boundary_sign_flip: bool = False)[source]

Recursively scans dir for files, slices in time and shifts in all directions.

The input files must be h5 files (ending with “.h5”) and must have name_input in their file name. Files which have name_output as name are excluded. Also, this routine ignores exporting to files which already exist. Once all files are fixed, this routine calls slice_file on each file.

Arguments
root: str
The directory to look for files.
name_input: str = “formfac_4D”
Files must match this pattern to be submitted for slicing.
name_output: str = “formfac_4D_tslice”
Files must not match this pattern to be submitted for slicing. Also the sliced output files will have the input name replaced by the output name. This also includes directory names.
overwrite: bool = False
Overwrite existing sliced files.
tslice_fact: Optional[float] = None
User interface for controlling factor for determening sclicing size. E.g., if a a file has NT = 48 and tslice_fact is 0.5, only time slices from 0 to 23 are exported to the output file. Note that the source location is shifted before slicing.
dset_patterns: List[str] = (“local_current”,),
Pattern dsets must matched in order to be sliced.
boundary_sign_flip: bool = False
Applies minus sign to correlator if hopping over temporal boundaries after tslicing (in any direction).
Raises
ValueError:
If tslice_fact is not None but one is able to parse tsep information from the file string. This is a safeguard against accidentally slicing files which shall not be sliced.