waveformtools.dataIO
Functions for handling data IO operations from waveforms class.
Functions
|
Construct a modes list in the form. |
|
Get the largest available mode number from available data in files. |
|
Get ell max from a list of keys. |
|
Get the ell_max from files in a tar.gz. |
|
Get the files in a tar.gz. |
|
Get the iteration number from keys. |
|
Initialize a modes array given the time axis |
|
Load the Psi4 waveforms from the RIT catalogue. |
|
Load the RIT or strain waveforms from the RIT/ MAYA catalogue data,. |
|
Load the SpECTRE or SpEC CCE waveform to modes_array, from hdf5 files from disk. |
|
Load the SpEC waveform to modes_array,from hdf5 files from disk. |
|
Load the SpEC waveform at finite radii. |
|
Load the RIT strain waveforms from the RIT catalogue,. |
Extract and read the data in a subfile inside the given open. |
|
|
Reorder a modes list. |
|
Save the waveform mode data to an hdf file. |
|
Sort the keys in a list based on its iteration number |
- waveformtools.dataIO.construct_mode_list(ell_max, spin_weight)[source]
Construct a modes list in the form.
[[ell1, [emm1, emm2, …], [ell2, [emm..]],..] given the \(\ell_{max}.\)
- Parameters:
- spin_weight: int
The spin weight of the modes.
- ell_max: int
The \(\ell_{max}\) of the modes list.
- Returns:
- modes_list: list
A list containg the mode indices lists.
Notes
The modes list is the form which the waveform object understands.
- waveformtools.dataIO.get_ell_max_from_file(data_dir, var_type='Psi4', file_name='*.h5')[source]
Get the largest available mode number from available data in files.
- Parameters:
- data_dir: string
A string containing the directory path where the mode files can be found.
- var_type: string, optional
A string that denotes the variable that is being loaded. Options are Psi4 and strain. The former is the default.
- file_name: string, optional
The h5 file that contains the modes data. It defaults to the only file in the directory. If there are multiple files, it throws an error.
- Returns
- ——-
- ell_max: int
The maximum available ell.
- keys_list: list
A list of data access keys.
Notes
Reads in various ASCII dat files for RIT Psi4, h5 files for RIT strain and gen strain.
- waveformtools.dataIO.get_ell_max_from_keys(all_keys)[source]
Get ell max from a list of keys.
- Parameters:
- all_keys: list
A list of strings string containing the modes keys.
- Returns
- ——-
- ell_max: int
The maximum available ell.
- waveformtools.dataIO.get_ell_max_from_tar_gz_file(file_path)[source]
Get the ell_max from files in a tar.gz.
- Parameters:
- file_path: str,pathlib.Path
The full path to the tar file
- Returns:
- ell_max: int
The l max of the modes available
- filtered_fnames: list of str
A list contaning the names of the modes files.
- waveformtools.dataIO.get_files_in_tar_gz(file_path)[source]
Get the files in a tar.gz.
- Parameters:
- file_path: str,pathlib.Path
The full path to the tar file
- waveformtools.dataIO.get_iteration_numbers_from_keys(keys_list)[source]
Get the iteration number from keys.
- Parameters:
- keys_list: list
The list of keys.
- Returns:
- iteration_numbers: list
The list containing the iteration numbers.
- waveformtools.dataIO.initialize_modes_array(time_axis, modes_array, resam_type='finest', ell_max=8)[source]
Initialize a modes array given the time axis
- waveformtools.dataIO.load_RIT_Psi4_data_from_disk(data_file_path, wfa=None, label='RIT_rPsi4inf', ell_max=None, modes_list=None, save_as_ma=False, spin_weight=-2, resam_type='finest', interp_kind='cubic', crop=False, centre=False, output_modes_array=False)[source]
Load the Psi4 waveforms from the RIT catalogue.
from ASCII files from disk.
- Parameters:
- wfa: ModesArray
An instance of the waveforms ModesArray class. Updates this instance if provided, else creates a new instance.
- data_file_path: string/pathlib.Path
A string containing the directory path where the mode files can be found.
- label: string, optional
The label of the modes_array object.
- ell_max: int, optional
The maximum mode number to load. If not specified, then all available modes are loaded.
- save_as_ma: bool, optional
Save to disk again as a modes_array h5 file?
- spin_weight: int, optional
The spin weight of the object. Used for filtering modes. Defaults to -2.
- resam_type: string, float, optional
The type of resampling to do. Options are finest and coarsest, and user input float.
- interp_kind: string, optional
The interpolation type to use. Default is cubic.
- Returns:
- rit_modes_array: modes_array
A modes_array instance containing the loaded modes if output_modes_array is True
- time_axis, modes_data: ndarray
Time axis and an array whose first axis is time and second is flatened modes index consistent with ModesArray
Notes
It seems like the time axis of individual modes are identical to each other. Hence, one need not worry about choosing the time domain. This may change in the future.
- waveformtools.dataIO.load_RIT_Strain_data_from_disk(wfa=None, data_dir='./', file_name='*', label='RIT_strain', spin_weight=-2, ell_max='auto', resam_type='auto', interp_kind='cubic', save_as_ma=False, modes_list=None, crop=False, centre=True, r_ext_factor=1, debug=False)[source]
Load the RIT or strain waveforms from the RIT/ MAYA catalogue data,.
from hdf5 files from disk.
- Parameters:
- wfa: waveforms
An instance of the waveforms class. Creates a new one if not provided.
- data_dir: string
A string containing the directory path where the mode files can be found.
- label: string, optional
The label of the modes_array object.
- ell_max: int, optional
The maximum mode number to load. If not specified, then all available modes are loaded.
- save_as_ma: bool, optional
Save to disk again as a modes_array h5 file?
- spin_weight: int, optional
The spin weight of the object. Used for filtering modes. Defaults to -2.
- resam_type: string, float, optional
The type of resampling to do. Options are the finest and coarsest, and user input float.
- interp_kind: string, optional
The interpolation type to use. Default is cubic.
- Returns:
- rit_modes_array: modes_array
A modes_array instance containing the loaded modes.
Notes
It seems like the time axis of individual modes are identical to each other. Hence, one need not worry about choosing the time domain. This may change in future.
- waveformtools.dataIO.load_SpECTRE_data_from_disk(wfa=None, label='SpECTRE Strain', data_dir='./', file_name='rhOverM_Extrapolated_N5_CoM_Mem.h5', r_ext=None, ell_max=12, centre=True, modes_list=None, r_ext_factor=1, save_as_ma='False', resam_type='auto', kind='cubic', compression_opts=0, spin_weight=None)[source]
Load the SpECTRE or SpEC CCE waveform to modes_array, from hdf5 files from disk.
- Parameters:
- wfa: modes_array, optional
The modes array to which to store the loaded waveform to. A new modes array will be returned if not provided.
- data_dir: string
A string containing the directory path where the mode files can be found.
- file_name: string
The name of the file containing the waveform data.
- label: string, optional
The label of the modes_array object.
- ell_max: int, optional
The maximum mode number to load. If not specified, then all available modes are loaded.
- save_as_ma: bool, optional
Save to disk again as a modes_array h5 file?
- resam_type: string, float, optional
The type of resampling to do. Options are finest and coarsest, and user input float.
- interp_kind: string, optional
The interpolation type to use. Default is cubic.
- Returns:
- modes_array: modes_array
A modes_array instance containing the loaded modes.
- waveformtools.dataIO.load_SpEC_data_from_disk(wfa=None, label='SXS Strain', data_dir='./', file_name='rhOverM_Extrapolated_N5_CoM_Mem.h5', extrap_order=None, r_ext=None, ell_max=None, centre=True, modes_list=None, save_as_ma='False', resam_type='auto', interp_kind='cubic', compression_opts=0, r_ext_factor=1, debug=False)[source]
Load the SpEC waveform to modes_array,from hdf5 files from disk.
- Parameters:
- wfa: modes_array, optional
The modes array to which to store the loaded waveform to. A new modes array will be returned if not provided.
- data_dir: string
A string containing the directory path where the mode files can be found.
- file_name: string
The name of the file containing the waveform data.
- label: string, optional
The label of the modes_array object.
- ell_max: int, optional
The maximum mode number to load. If not specified, then all available modes are loaded.
- save_as_ma: bool, optional
Save to disk again as a modes_array h5 file?
- resam_type: string, float, optional
The type of resampling to do. Options are finest and coarsest, and user input float.
- interp_kind: string, optional
The interpolation type to use. Default is cubic.
- Returns:
- modes_array: modes_array
A modes_array instance containing the loaded modes.
- waveformtools.dataIO.load_SpEC_non_extrap_data_from_disk(wfa=None, label='SXS Strain', data_dir='./', file_name='rh_FiniteRadii_CodeUnits.h5', r_ext=None, ell_max=None, centre=True, modes_list=None, save_as_ma='False', resam_type='auto', interp_kind='cubic', compression_opts=0, r_ext_factor=1, debug=False)[source]
Load the SpEC waveform at finite radii.
to modes_array, from hdf5 files from disk.
- Parameters:
- wfa: modes_array, optional
The modes array to which to store the loaded waveform to. A new modes array will be returned if not provided.
- data_dir: string
A string containing the directory path where the mode files can be found.
- file_name: string
The name of the file containing the waveform data.
- label: string, optional
The label of the modes_array object.
- ell_max: int, optional
The maximum mode number to load. If not specified, then all available modes are loaded.
- save_as_ma: bool, optional
Save to disk again as a modes_array h5 file?
- resam_type: string, float, optional
The type of resampling to do. Options are finest and coarsest, and user input float.
- interp_kind: string, optional
The interpolation type to use. Default is cubic.
- Returns:
- modes_array: modes_array
A modes_array instance containing the loaded modes.
- waveformtools.dataIO.load_gen_data_from_disk(wfa=None, label='generic waveform', data_dir='./', file_name='*.h5', r_ext=None, ell_max=8, pre_key=None, modes_list=None, crop=False, centre=True, key_ex=None, r_ext_factor=1, *args, **kwargs)[source]
Load the RIT strain waveforms from the RIT catalogue,.
from hdf5 files from disk.
- Parameters:
- data_dir: string
A string containing the directory path where the mode files can be found.
- label: string, optional
The label of the modes_array object.
- ell_max: int, optional
The maximum mode number to load. If not specified, then all available modes are loaded.
- save_as_ma: bool, optional
Save to disk again as a modes_array h5 file?
- spin_weight: int, optional
The spin weight of the object. Used for filtering modes. Defaults to -2.
- resam_type: string, float, optional
The type of resampling to do. Options are finest and coarsest, and user input float.
- interp_kind: string, optional
The interpolation type to use. Default is cubic.
- Returns:
- rit_modes_array: modes_array
A modes_array instance containing the loaded modes.
Notes
It seems like the time axis of individual modes are identical to each other. Hence, one need not worry about choosing the time domain. This may change in future.
- waveformtools.dataIO.read_data_from_tar_gz_subfile(tar_gz_file_handle, subfile_name)[source]
Extract and read the data in a subfile inside the given open.
tar gz file handle
- waveformtools.dataIO.save_modes_data_to_gen(wfa, ell_max=None, pre_key=None, key_format=None, modes_to_save=None, out_file_name='mp_new_modes.h5', r_ext_factor=None, compression_opts=0, r_ext=None)[source]
Save the waveform mode data to an hdf file.
- Parameters:
- pre_key: str, optional
A string containing the key of the group in the HDF file in which the modes` dataset exists. It defaults to None.
- mode_numbers: list
The mode numbers to load from the file. Each item in the list is a list that contains two integrer numbers, one for the mode index \(\ell\) and the other for the mode index \(m\).
- Returns:
- waveform_obj: 3d array
Sets the three dimensional array waveform.modes that contains the required \(\ell, m\) modes.
Examples
>>> from waveformtools.modes_array import ModesArray >>> wf = modes_array() >>> wf.data_dir = './' >>> wf.filename = 'data_file.h5' >>> wf.modes_list = [[2, 2], [3, 3]] >>> wf.load_gen_data()