From ca39f4fc32117535465959215d4f361973850bec Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 12 Dec 2025 10:22:33 +0000 Subject: [PATCH 1/2] Initial plan From b91a7020fe001bf66dd8a51c7caf6fa5d1dc5d1d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 12 Dec 2025 10:25:54 +0000 Subject: [PATCH 2/2] Pass comp and verbose parameters to convert_psp_to_hdf5 method Co-authored-by: michael-petersen <19195541+michael-petersen@users.noreply.github.com> --- exptool/io/psp_to_hdf5.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/exptool/io/psp_to_hdf5.py b/exptool/io/psp_to_hdf5.py index d9f5ece..d53ff78 100644 --- a/exptool/io/psp_to_hdf5.py +++ b/exptool/io/psp_to_hdf5.py @@ -88,22 +88,34 @@ def __init__(self, filename, comp=None, verbose=0): self.verbose = verbose # Start the conversion process - self.convert_psp_to_hdf5() + self.convert_psp_to_hdf5(self.filename, comp=self.comp, verbose=self.verbose) @staticmethod - def convert_psp_to_hdf5(inputfilename): + def convert_psp_to_hdf5(inputfilename, comp=None, verbose=0): """ Convert a PSP input file to HDF5 format. Args: inputfilename (str): The name of the PSP input file to be converted. + comp (str, optional): The specific component to convert. If provided, only the data for the specified component will be converted. + verbose (int, optional): Verbosity level for printing progress and messages during conversion. """ # Define the output file name outputfilename = inputfilename + '.h5' + if verbose > 0: + print(f"Converting {inputfilename} to {outputfilename}") + # Open the PSP input file and extract components O = particle.Input(inputfilename) - comps = list(O.header.keys()) + + # Determine which components to convert + if comp is not None: + comps = [comp] if comp in O.header.keys() else [] + if not comps and verbose > 0: + print(f"Warning: Component '{comp}' not found in file") + else: + comps = list(O.header.keys()) # Create a new HDF5 file for storing the converted data f = h5py.File(outputfilename, 'w') @@ -112,6 +124,9 @@ def convert_psp_to_hdf5(inputfilename): f['time'] = O.time for comp in comps: + if verbose > 0: + print(f"Processing component: {comp}") + # Create a group for each component f.create_group(comp) @@ -123,6 +138,9 @@ def convert_psp_to_hdf5(inputfilename): # Close the HDF5 file f.close() + + if verbose > 0: + print(f"Conversion complete: {outputfilename}") @staticmethod def print_component_header(f, O, comp):