# waveformtools.dataIO

Functions for handling data IO operations from waveforms class

Functions

`get_ell_max_from_file`(data_dir[, var_type, ...]) | Get the largest available mode number from available data in files.
`get_ell_max_from_keys`(all_keys) | Get ell max from a list of keys.
`load_RIT_Psi4_from_disk`([wfa, data_dir, ...]) | Load the Psi4 waveforms from the RIT catalogue from ASCII files from disk.
`load_RIT_Strain_data_from_disk`([wfa, ...]) | Load the RIT strain waveforms from the RIT catalogue, from hdf5 files from disk.
`load_SpECTRE_data_from_disk`([wfa, label, ...]) | Load the SpECTRE or SpEC CCE waveform to modes_array,from hdf5 files from disk.
`load_SpEC_data_from_disk`([wfa, label, ...]) | Load the SpEC waveform to modes_array,from hdf5 files from disk.
`load_gen_data_from_disk`([wfa, label, ...]) | Load the RIT strain waveforms from the RIT catalogue, from hdf5 files from disk.
`save_modes_data_to_gen`(wfa[, ell_max, ...]) | Save the waveform mode data to an hdf file.

waveformtools.dataIO.get_ell_max_from_file(data_dir, var_type='Psi4', file_name='*.h5')

  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)

  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.load_RIT_Psi4_from_disk(wfa=None, data_dir='./', label='RIT_rPsi4inf', ell_max=None, save_as_ma=False, spin_weight=- 2, resam_type='finest', interp_kind='cubic')

  Load the Psi4 waveforms from the RIT catalogue from ASCII files from disk.

  Parameters:
    wfa waveforms

      An instance of the waveforms class. Updates this instance if provided, else creates a new instance.

    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.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)

  Load the RIT strain waveforms from the RIT catalogue, 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 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', interp_kind='cubic', compression_opts=0)

  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=4, 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)

  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_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)

  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.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)

  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.waveforms import waveform
      >>> waveform.set_basedir('./')
      >>> waveform.set_datadir('data/')
      >>> mode_numbers = [[2, 2], [3, 3]]
      >>> waveform.load_data(mode_numbers=mode_numbers)