fIO - File Input/Output
@author: Fraser M. Callaghan
Input / Output functions
- ngawari.fIO.remove_symbols(text: str) str[source]
Remove symbols from the given text.
- Parameters:
text (str) – The input text to process.
- Returns:
The text with symbols removed.
- Return type:
str
- ngawari.fIO.remove_not_allowed(text: str, allowed_characters: str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0cßöüäéèà') str[source]
Remove characters that are not in the allowed set.
- Parameters:
text (str) – The input text to process.
allowed_characters (str) – The set of characters to keep (default is all printable characters and some special (DE, FR) characters).
- Returns:
The text with disallowed characters removed.
- Return type:
str
- ngawari.fIO.countFilesInDir(dirName: str) int[source]
Count the number of files in a directory.
- Parameters:
dirName (str) – The path to the directory.
- Returns:
The number of files in the directory.
- Return type:
int
- ngawari.fIO.getAllFilesUnderDir(dirName: str) List[str][source]
Get all file paths under a directory.
- Parameters:
dirName (str) – The path to the directory.
- Returns:
A list of full file paths.
- Return type:
List[str]
- ngawari.fIO.parseFileToTagsDictionary(fileName: str, equator: str = '=', commentor: str = '#', SPACE_REPLACE: bool = True) Dict[str, str][source]
Parse a file to a dictionary of tags.
- Parameters:
fileName (str) – The name of the file to parse.
equator (str, optional) – The character used to separate keys and values. Defaults to ‘=’.
commentor (str, optional) – The character used to denote comments. Defaults to ‘#’.
SPACE_REPLACE (bool, optional) – Whether to replace spaces in keys with underscores. Defaults to True.
- Returns:
A dictionary containing the parsed tags and values.
- Return type:
dict
Notes
If the file ends with ‘.json’, it will be parsed as a JSON file instead.
Comments at the beginning of the file are stored under the ‘header’ key.
Subsequent comments are stored as ‘comment0’, ‘comment1’, etc.
Empty lines and lines without the equator character are ignored.
Keys and values are stored as strings.
- ngawari.fIO.writeDictionaryToFile(fileName: str, dictToWrite: Dict[str, str], equator: str = '=', commentor: str = '#', WRITE_COMMENTS: bool = True) str[source]
Write a dictionary to a file.
- Parameters:
fileName (str) – The name of the file to write to (if json then calls writeDictionaryToJSON - json.dump with Numpy encoder).
dictToWrite (dict) – The dictionary to write to the file.
equator (str, optional) – The character used to separate keys and values. Defaults to ‘=’.
commentor (str, optional) – The character used to denote comments. Defaults to ‘#’.
WRITE_COMMENTS (bool, optional) – Whether to write comments to the file. Defaults to True.
- Returns:
The name of the file written to.
- Return type:
str
- class ngawari.fIO.NumpyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]
Bases:
JSONEncoder- default(obj)[source]
Implement this method in a subclass such that it returns a serializable object for
o, or calls the base implementation (to raise aTypeError).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
- ngawari.fIO.strListToFloatList(strList: str) List[float][source]
Convert a string representation of a list to a list of floats.
- Parameters:
strList (str) – A string representation of a list of numbers.
- Returns:
A list of float values.
- Return type:
List[float]
- ngawari.fIO.xmlIndent(elem: Element, level: int = 0) None[source]
Indent an XML element for pretty printing.
- Parameters:
elem (ET.Element) – The XML element to indent.
level (int, optional) – The current indentation level. Defaults to 0.
- ngawari.fIO.findAndReplaceTextInFile(fileIn: str, txtFind: str, txtReplace: str) str[source]
Find and replace text in a file.
- Parameters:
fileIn (str) – The input file path.
txtFind (str) – The text to find.
txtReplace (str) – The text to replace with.
- Returns:
The path of the modified file.
- Return type:
str
- ngawari.fIO.readFileToListOfLines(fileName: str, commentSymbol: str = '#') List[List[str]][source]
Read a file and return a list of each line.
- Parameters:
fileName (str) – The path of the file to read.
commentSymbol (str, optional) – The symbol used to denote comments. Defaults to ‘#’.
- Returns:
A list of lines from the file.
- Return type:
List[List[str]]
Notes
Will split on “,” if present
Will skip starting with #
- ngawari.fIO.appendFiles(listOfFiles: List[str], carriageReturn: str = '') str[source]
Append the contents of multiple text files into a single string.
- Parameters:
listOfFiles (list) – A list of file names to append.
carriageReturn (str, optional) – The string to append after each file’s content. Defaults to an empty string.
- Returns:
A single string containing the concatenated contents of all files.
- Return type:
str
- ngawari.fIO.pickleData(data, pickleFileName: str) str[source]
Pickle data to a file.
- Parameters:
data – The data to pickle.
pickleFileName (str) – The name of the file to pickle to.
- Returns:
The name of the file written to.
- Return type:
str
- ngawari.fIO.unpickleData(pickleFileName: str)[source]
Unpickle data from a file.
- Parameters:
pickleFileName (str) – The name of the file to unpickle.
- Returns:
The unpickled data.
- ngawari.fIO.tarGZLocal_AndMove(dirToTarZip: str, tarGZFileName: str, localLocation: str, remoteLocation: str | None = None) None[source]
Compress and move a directory to a local location and optionally to a remote location. Uses Python’s tarfile module for cross-platform compatibility.
- Parameters:
dirToTarZip (str) – The directory to compress and zip.
tarGZFileName (str) – The name of the compressed file.
localLocation (str) – The local location to move the compressed file.
remoteLocation (str, optional) – The remote location to move the compressed file. Defaults to None.
- ngawari.fIO.addSuffixToName(fileName: str, suffix: str) str[source]
Add a suffix to the end of a file name (retains extn).
- Parameters:
fileName (str) – The name of the file to modify.
suffix (str) – The suffix to add to the file name.
- Returns:
The modified file name.
- Return type:
str
- ngawari.fIO.checkIfExtnPresent(fileName: str, extn: str) str[source]
Check if the extension of a file name is present and add it if it is not.
- Parameters:
fileName (str) – The name of the file to check.
extn (str) – The extension to check for.
- Returns:
The modified file name with the extension added if it was not present.
- Return type:
str
- ngawari.fIO.readDataCSV(csvFile: str, nHeaderLines: int = 0, quotechar: str = '"', decimalChar: str = '.', delimeterToUse: str | None = None) Tuple[List[str], List[List[str]]][source]
Read data from a CSV file.
- Parameters:
csvFile (str) – The path of the CSV file to read.
nHeaderLines (int, optional) – The number of header lines to skip. Defaults to 0.
quotechar (str, optional) – The character used to quote fields. Defaults to ‘”’.
decimalChar (str, optional) – The character used to denote decimal points. Defaults to ‘.’.
delimeterToUse (str, optional) – The delimiter to use. If not specified, it will be detected automatically.
- Returns:
A tuple containing the headers and the data.
- Return type:
Tuple[List[str], List[List[str]]]
Notes
Assumes Headers: then cols of floats
Try to automatically determine detectDelimiter
Read file (skip header lines)
Return last headers row as list of headers (if so) & list of lists of each row Can pass output to np.array() then have columns of data
e.g. : data = np.array(data, dtype=float)
- ngawari.fIO.writeCSVFile(data: List[List[str]], header: List[str], csvFile: str, FIX_NAN: bool = False) str[source]
Write data to a CSV file.
- Parameters:
data (List[List[str]]) – The data to write to the CSV file.
header (List[str]) – The header for the CSV file.
csvFile (str) – The path of the CSV file to write to.
FIX_NAN (bool, optional) – Whether to fix NaN values. Defaults to False.
- Returns:
The path of the CSV file written to.
- Return type:
str
- ngawari.fIO.detectDelimiter(csvFile: str, nHeader: int = 0, encoding: str | None = None) str[source]
Detect the delimiter used in a CSV file.
- Parameters:
csvFile (str) – The path of the CSV file to detect the delimiter of.
nHeader (int, optional) – The number of header lines to skip. Defaults to 0.
encoding (str, optional) – The encoding of the file. Defaults to None.
- Returns:
The detected delimiter.
- Return type:
str
- ngawari.fIO.writePlyFile(fullfileName: str, xyzPoints: List[List[float]], uvwPoints: List[List[float]] | None = None, comment: List[str] = ['Written via fIO module'], header: bool = True) str[source]
Write points and norms to PLY file :param fullfileName: :param xyzPoints: :param uvwPoints: :param comment: :param header: :return:
- ngawari.fIO.writeVTKFile(data: vtkDataObject, fileName: str, STL_ASCII: bool = False) str[source]
Writes a VTK object to a file. Uses the extension to determine the type of file to write.
- Parameters:
data (vtk.vtkDataObject) – The VTK object to write to a file.
fileName (str) – The full file name to write to.
STL_ASCII (bool, optional) – Set to True to write STL file in ASCII [default False -> write binary] (only used for STL).
- Returns:
The full file name.
- Return type:
str
- ngawari.fIO.readVTKFile(fileName: str) vtkDataObject[source]
Read a VTK file - the extension is used to determine the type of file to read.
- Parameters:
fileName (str) – The path of the VTK file to read.
- Returns:
The VTK data object.
- Return type:
vtk.vtkDataObject
- ngawari.fIO.nii_to_niigz(nii_file: str) str[source]
Compress a NIfTI file to a NIfTI.gz file.
- Parameters:
nii_file (str) – The path of the NIfTI file to compress.
- Returns:
The path of the compressed NIfTI file.
- Return type:
str
- ngawari.fIO.writeNifti(data: vtkDataObject, fileName: str, GZIP_COMPRESS: bool = False) str[source]
Write a NIfTI file.
- Parameters:
data (vtk.vtkDataObject) – The VTK data object to write.
fileName (str) – The path of the NIfTI file to write to.
- Returns:
The path of the NIfTI file written to.
- Return type:
str
- ngawari.fIO.readNifti(fileName: str) vtkDataObject[source]
Read a NIfTI file.
- Parameters:
fileName (str) – The path of the NIfTI file to read.
- Returns:
The VTK data object.
- Return type:
vtk.vtkDataObject
- ngawari.fIO.readNRRD(fileName: str) vtkDataObject[source]
Read a NRRD file.
- Parameters:
fileName (str) – The path of the NRRD file to read.
- Returns:
The VTK data object.
- Return type:
vtk.vtkDataObject
- ngawari.fIO.writeVTK_PVD_Dict(vtkDict: Dict[str | float, vtkDataObject], rootDir: str, filePrefix: str, fileExtn: str, BUILD_SUBDIR: bool = True) str[source]
- Write dict of time:vtkObj to pvd file
If dict is time:fileName then will copy files
- Parameters:
vtkDict (Dict[Union[str, float], vtk.vtkDataObject]) – The dictionary of VTK data objects.
rootDir (str) – The root directory.
filePrefix (str) – make filePrefix.pvd
fileExtn (str) – file extension (e.g. vtp, vti, vts etc)
BUILD_SUBDIR (bool, optional) – to build subdir (filePrefix.pvd in root, then data in root/filePrefix/). Defaults to True.
- Returns:
full file name
- Return type:
str
- ngawari.fIO.pvdAddTimeToFieldData(pvdf_or_vtkDict: str | Dict[str | float, vtkDataObject]) str | Dict[str | float, vtkDataObject][source]
Add time to field data.
- Parameters:
pvdf_or_vtkDict (Union[str, Dict[Union[str, float], vtk.vtkDataObject]]) – The PVD file path or dictionary of VTK data objects.
- Returns:
The PVD file path or dictionary of VTK data objects.
- Return type:
Union[str, Dict[Union[str, float], vtk.vtkDataObject]]
- ngawari.fIO.writeZipFromVTK_PVD_Dict(vtkDict: Dict[str | float, vtkDataObject], fileExt: str, zipFileOut: str) None[source]
Write a ZIP file from a dictionary of VTK data objects.
- Parameters:
vtkDict (Dict[Union[str, float], vtk.vtkDataObject]) – The dictionary of VTK data objects.
fileExt (str) – The file extension.
zipFileOut (str) – The output ZIP file path.
- ngawari.fIO.deleteFilesByPVD(pvdFile: str, FILE_ONLY: bool = False, QUIET: bool = False) int[source]
Delete files referenced by a PVD file.
- Parameters:
pvdFile (str) – The PVD file path.
FILE_ONLY (bool, optional) – Whether to delete only the files. Defaults to False.
QUIET (bool, optional) – Whether to suppress warnings. Defaults to False.
- Returns:
0 if successful, 1 if error.
- Return type:
int
- ngawari.fIO.readPVDFileName(fileIn: str, vtpTime: float = 0.0, timeIDs: List[int] = [], RETURN_OBJECTS_DICT: bool = False) Dict[float, str] | Dict[float, vtkDataObject][source]
Read PVD file, return dictionary of fullFileNames - keys = time So DOES NOT read file If not pvd - will return dict of {0.0 : fileName}
- Parameters:
fileIn – str - PVD file path
vtpTime – float - time to read
timeIDs – list of int - time IDs to read
RETURN_OBJECTS_DICT – bool - return dictionary of vtkDataObjects
- Returns:
dict of fullFileNames - keys = time
- ngawari.fIO.readImageFileToDict(imageFile: str) Dict[float, vtkDataObject][source]
Read an image file and return a dictionary of VTK data objects.
- Parameters:
imageFile (str) – The image file path.
- Returns:
A dictionary of VTK data objects (keys = time).
- Return type:
Dict[float, vtk.vtkDataObject]
- ngawari.fIO.readPVD(fileIn: str, timeIDs: List[int] = []) Dict[float, vtkDataObject][source]
Read a PVD file and return a dictionary of VTK data objects.
- Parameters:
fileIn (str) – The PVD file path.
timeIDs (List[int], optional) – A list of time step IDs to include. Defaults to an empty list.
- Returns:
A dictionary of VTK data objects (keys = time).
- Return type:
Dict[float, vtk.vtkDataObject]
- ngawari.fIO.pvdGetDict(pvd: str | Element | Dict[float, str], timeIDs: List[int] = []) Dict[float, str][source]
Get a dictionary of time steps and their corresponding file names from a PVD file.
- Parameters:
pvd (Union[str, ET.Element, Dict[float, str]]) – The PVD file path, XML element, or dictionary.
timeIDs (List[int], optional) – A list of time step IDs to include. Defaults to an empty list.
- Returns:
A dictionary mapping time steps to file names.
- Return type:
Dict[float, str]
- ngawari.fIO.pvdGetClosestTimeToT(pvd: str | Element | Dict[float, str], T: float) float[source]
Get the time step closest to a given time from a PVD file.
- Parameters:
pvd (Union[str, ET.Element, Dict[float, str]]) – The PVD file path, XML element, or dictionary.
T (float) – The target time.
- Returns:
The closest time step.
- Return type:
float
- ngawari.fIO.pvdGetTimes(pvd: str | Element | Dict[float, str]) List[float][source]
Get a list of time steps from a PVD file.
- Parameters:
pvd (Union[str, ET.Element, Dict[float, str]]) – The PVD file path, XML element, or dictionary.
- Returns:
A list of time steps.
- Return type:
List[float]
- ngawari.fIO.pvdGetIdOfT(pvd: str | Element | Dict[float, str], T: float) int[source]
Get the ID of the time step closest to a given time from a PVD file.
- Parameters:
pvd (Union[str, ET.Element, Dict[float, str]]) – The PVD file path, XML element, or dictionary.
T (float) – The target time.
- Returns:
The ID of the closest time step.
- Return type:
int
- ngawari.fIO.pvdGetFileAtT(pvd: str | Element | Dict[float, str], T: float) str[source]
Get the file name corresponding to the time step closest to a given time from a PVD file.
- Parameters:
pvd (Union[str, ET.Element, Dict[float, str]]) – The PVD file path, XML element, or dictionary.
T (float) – The target time.
- Returns:
The file name corresponding to the closest time step.
- Return type:
str
- ngawari.fIO.pvdGetNumberTimePoints(pvd: str | Element | Dict[float, str]) int[source]
Get the number of time points in a PVD file.
- Parameters:
pvd (Union[str, ET.Element, Dict[float, str]]) – The PVD file path, XML element, or dictionary.
- Returns:
The number of time points.
- Return type:
int
- ngawari.fIO.pvdGetDataFileRoot_Prefix_and_Ext(pvd: str | Element | Dict[float, str]) Tuple[str, str, str][source]
Get the root directory, prefix, and extension of the data files referenced in a PVD file.
- Parameters:
pvd (Union[str, ET.Element, Dict[float, str]]) – The PVD file path, XML element, or dictionary.
- Returns:
A tuple containing the root directory, prefix, and extension.
- Return type:
Tuple[str, str, str]
- ngawari.fIO.pvdGetDataClosestTo(pvd: str | Element | Dict[float, str], refT: float) vtkDataObject[source]
Get the data object corresponding to the time step closest to a given reference time from a PVD file.
- Parameters:
pvd (Union[str, ET.Element, Dict[float, str]]) – The PVD file path, XML element, or dictionary.
refT (float) – The reference time.
- Returns:
The data object corresponding to the closest time step.
- Return type:
vtk.vtkDataObject
- ngawari.fIO.pvdMultiply(pvdFile: str, nCycles: int, outputFileName: str | None = None) str[source]
Multiply the time steps in a PVD file by a given number of cycles.
- Parameters:
pvdFile (str) – The input PVD file path.
nCycles (int) – The number of cycles to multiply the time steps by.
outputFileName (Optional[str], optional) – The output PVD file path. Defaults to None.
- Returns:
The output PVD file path.
- Return type:
str
- ngawari.fIO.pvdReverse(pvdFileIn: str, suffix: str = 'REV', outfile: str | None = None) str[source]
Reverse the time steps in a PVD file.
- Parameters:
pvdFileIn (str) – The input PVD file path.
suffix (str, optional) – The suffix to append to the output file name. Defaults to “REV”.
outfile (Optional[str], optional) – The output file path. Defaults to None.
- Returns:
The output PVD file path.
- Return type:
str
- ngawari.fIO.pvdRestart_t(pvdFile: str, timeStart: float, outputFile: str | None = None) str[source]
Restart a PVD file from a given time.
- Parameters:
pvdFile (str) – The input PVD file path.
timeStart (float) – The start time.
outputFile (Optional[str], optional) – The output PVD file path. Defaults to None.
- Returns:
The output PVD file path.
- Return type:
str
- ngawari.fIO.pvdRestart(pvdFile: str, idStart: int, outputFile: str | None = None) str[source]
Restart a PVD file from a given time step ID.
- Parameters:
pvdFile (str) – The input PVD file path.
idStart (int) – The start time step ID.
outputFile (Optional[str], optional) – The output PVD file path. Defaults to None.
- Returns:
The output PVD file path.
- Return type:
str
- ngawari.fIO.pvdClip(pvdFile: str, idEnd: int, outputFile: str | None = None) str[source]
Clip a PVD file to a given time step ID.
- Parameters:
pvdFile (str) – The input PVD file path.
idEnd (int) – The end time step ID.
outputFile (Optional[str], optional) – The output PVD file path. Defaults to None.
- Returns:
The output PVD file path.
- Return type:
str
- ngawari.fIO.pvdResetTimes(pvdFile: str, startTime: float, endTime: float, pvdFileOut: str) str[source]
Reset the time steps in a PVD file to a given range.
- Parameters:
pvdFile (str) – The input PVD file path.
startTime (float) – The start time.
endTime (float) – The end time.
pvdFileOut (str) – The output PVD file path.
- Returns:
The output PVD file path.
- Return type:
str
- ngawari.fIO.pvdResetStartPoint_Id(pvdFile: str, startID: int, pvdFileOut: str) str[source]
Reset the start point of a PVD file to a given time step ID.
- Parameters:
pvdFile (str) – The input PVD file path.
startID (int) – The start time step ID.
pvdFileOut (str) – The output PVD file path.
- Returns:
The output PVD file path.
- Return type:
str
- ngawari.fIO.pvdResetStartPoint(pvdFile: str, startTime: float, pvdFileOut: str, QUIET: bool = True) str[source]
Reset the start point of a PVD file to a given time.
- Parameters:
pvdFile (str) – The input PVD file path.
startTime (float) – The start time.
pvdFileOut (str) – The output PVD file path.
QUIET (bool, optional) – Whether to suppress output. Defaults to True.
- Returns:
The output PVD file path.
- Return type:
str
- ngawari.fIO.pvdAddStartPointAtEndForPeriodicy(pvdFile: str, pvdFileOut: str) str[source]
Add a start point at the end of a PVD file for periodicity.
- Parameters:
pvdFile (str) – The input PVD file path.
pvdFileOut (str) – The output PVD file path.
- Returns:
The output PVD file path.
- Return type:
str
- ngawari.fIO.buildPVD_WaterFallRestarts(pvdFileIn: str, pvdFileOut: str, restartEvery: int, nCycle: int = 1, TO_REV: bool = False) List[str][source]
Build a waterfall of restarted PVD files.
- Parameters:
pvdFileIn (str) – The input PVD file path.
pvdFileOut (str) – The output PVD file path.
restartEvery (int) – The number of time steps between restarts.
nCycle (int, optional) – The number of cycles. Defaults to 1.
TO_REV (bool, optional) – Whether to reverse the time steps. Defaults to False.
- Returns:
A list of output PVD file paths.
- Return type:
List[str]
VTK File Formats
- ngawari.fIO.readVTKFile(fileName: str) vtkDataObject[source]
Read a VTK file - the extension is used to determine the type of file to read.
- Parameters:
fileName (str) – The path of the VTK file to read.
- Returns:
The VTK data object.
- Return type:
vtk.vtkDataObject
- ngawari.fIO.writeVTKFile(data: vtkDataObject, fileName: str, STL_ASCII: bool = False) str[source]
Writes a VTK object to a file. Uses the extension to determine the type of file to write.
- Parameters:
data (vtk.vtkDataObject) – The VTK object to write to a file.
fileName (str) – The full file name to write to.
STL_ASCII (bool, optional) – Set to True to write STL file in ASCII [default False -> write binary] (only used for STL).
- Returns:
The full file name.
- Return type:
str
Other File Formats
- ngawari.fIO.writePlyFile(fullfileName: str, xyzPoints: List[List[float]], uvwPoints: List[List[float]] | None = None, comment: List[str] = ['Written via fIO module'], header: bool = True) str[source]
Write points and norms to PLY file :param fullfileName: :param xyzPoints: :param uvwPoints: :param comment: :param header: :return:
- ngawari.fIO.readNifti(fileName: str) vtkDataObject[source]
Read a NIfTI file.
- Parameters:
fileName (str) – The path of the NIfTI file to read.
- Returns:
The VTK data object.
- Return type:
vtk.vtkDataObject
- ngawari.fIO.writeNifti(data: vtkDataObject, fileName: str, GZIP_COMPRESS: bool = False) str[source]
Write a NIfTI file.
- Parameters:
data (vtk.vtkDataObject) – The VTK data object to write.
fileName (str) – The path of the NIfTI file to write to.
- Returns:
The path of the NIfTI file written to.
- Return type:
str
PVD File Operations
- ngawari.fIO.readPVD(fileIn: str, timeIDs: List[int] = []) Dict[float, vtkDataObject][source]
Read a PVD file and return a dictionary of VTK data objects.
- Parameters:
fileIn (str) – The PVD file path.
timeIDs (List[int], optional) – A list of time step IDs to include. Defaults to an empty list.
- Returns:
A dictionary of VTK data objects (keys = time).
- Return type:
Dict[float, vtk.vtkDataObject]
- ngawari.fIO.writeVTK_PVD_Dict(vtkDict: Dict[str | float, vtkDataObject], rootDir: str, filePrefix: str, fileExtn: str, BUILD_SUBDIR: bool = True) str[source]
- Write dict of time:vtkObj to pvd file
If dict is time:fileName then will copy files
- Parameters:
vtkDict (Dict[Union[str, float], vtk.vtkDataObject]) – The dictionary of VTK data objects.
rootDir (str) – The root directory.
filePrefix (str) – make filePrefix.pvd
fileExtn (str) – file extension (e.g. vtp, vti, vts etc)
BUILD_SUBDIR (bool, optional) – to build subdir (filePrefix.pvd in root, then data in root/filePrefix/). Defaults to True.
- Returns:
full file name
- Return type:
str
- ngawari.fIO.pvdGetTimes(pvd: str | Element | Dict[float, str]) List[float][source]
Get a list of time steps from a PVD file.
- Parameters:
pvd (Union[str, ET.Element, Dict[float, str]]) – The PVD file path, XML element, or dictionary.
- Returns:
A list of time steps.
- Return type:
List[float]
- ngawari.fIO.pvdGetDataClosestTo(pvd: str | Element | Dict[float, str], refT: float) vtkDataObject[source]
Get the data object corresponding to the time step closest to a given reference time from a PVD file.
- Parameters:
pvd (Union[str, ET.Element, Dict[float, str]]) – The PVD file path, XML element, or dictionary.
refT (float) – The reference time.
- Returns:
The data object corresponding to the closest time step.
- Return type:
vtk.vtkDataObject