scri.waveform_base

Functions

complex_array_abs(c, s)

complex_array_norm(c, s)

test_with_assertions(errs, val[, msg])

test_without_assertions(errs, val[, msg])

Replacement for np.testing.assert_

waveform_alterations(func)

Temporarily increment history depth safely

Classes

WaveformBase(*args, **kwargs)

Object containing time, frame, and data, along with related information

class scri.waveform_base.WaveformBase(*args, **kwargs)[source]

Object containing time, frame, and data, along with related information

This object is just the base object from which these other classes are derived:
  • WaveformModes

  • WaveformGrid

  • WaveformInDetector

  • WaveformInDetectorFT

For more specific information, see the documentation of those classes.

Attributes:
tfloat array

Time steps corresponding to other data

framequaternion array

Rotors taking static basis onto decomposition basis

data2-d array of complex or real numbers

The nature of this data depends on the derived type. First index is time, second index depends on type.

historylist of strings

As far as possible, all functions applied to the object are recorded in the history variable. In fact, the object should almost be able to be recreated using the commands in the history list. Commands taking large arrays, however, are shortened – so the data will not be entirely reconstructable.

version_histlist of pairs of strings

Records the git hash and description for any change in the way SpEC outputs waveform data.

frameTypeint

Index corresponding to scri.FrameType appropriate for data.

dataTypeint

Index corresponding to scri.DataType appropriate for data.

r_is_scaled_outbool

True if the data have been multiplied by the appropriate power of radius so that the asymptotic value can be finite and nonzero.

m_is_scaled_outbool

True if the data have been scaled by the appropriate value of the total mass so that they are dimensionless.

numint (read only)

Automatically assigned number of this object. The constructor of this type keeps count of the number of objects it has created, to assign each object a more-or-less unique ID for use in the history strings. This counter is reset at the beginning of each python session. Subclasses should automatically have a different counter.

Methods

SI_units(current_unit_mass_in_solar_masses)

Assuming current quantities are in geometric units, convert to SI units

compare(w_a[, min_time_step, min_time])

Return a waveform with differences between the two inputs

copy()

Return a (deep) copy of the object

copy_without_data()

Return a copy of the object, with empty t, frame, and data fields

deepcopy()

Return a deep copy of the object

ensure_validity([alter, assertions])

Try to ensure that the WaveformBase object is valid

interpolate(tprime)

Interpolate the frame and data onto the new set of time steps

max_norm_index([skip_fraction_of_data])

Index of time step with largest norm

max_norm_time([skip_fraction_of_data])

Return time at which largest norm occurs in data

norm([take_sqrt, indices])

L2 norm of the waveform

SI_units(current_unit_mass_in_solar_masses, distance_from_source_in_megaparsecs=100)[source]

Assuming current quantities are in geometric units, convert to SI units

This function assumes that the dataType, r_is_scaled_out, and m_is_scaled_out attributes are correct, then scales the amplitude and time data appropriately so that the data correspond to data that could be observed from a source with the given total mass at the given distance.

Note that the curvature scalars will have units of s^-2, rather than the arguably more correct m^-2. This seems to be more standard in numerical relativity. The result can be divided by scipy.constants.c**2 to give units of m^-2 if desired.

Parameters:
current_unit_mass_in_solar_massesfloat

Mass of the system in the data converted to solar masses

distance_from_source_in_megaparsecsfloat, optional

Output will be waveform as observed from this distance, default=100 (Mpc)

property abs
property arg
property arg_unwrapped
compare(w_a, min_time_step=0.005, min_time=-3e+300)[source]

Return a waveform with differences between the two inputs

This function simply subtracts the data in this waveform from the data in Waveform A, and finds the rotation needed to take this frame into frame A. Note that the waveform data are stored as complex numbers, rather than as modulus and phase.

property conformal_weight
copy()[source]

Return a (deep) copy of the object

Note that this also copies all members if the object is a subclass. If you want a forgetful WaveformBase object, you can simply use the copy constructor.

copy_without_data()[source]

Return a copy of the object, with empty t, frame, and data fields

Note that subclasses may override this to set some related data members. For example, WaveformModes.copy_without_data sets the ell_min and ell_max fields appropriately. If you wish to only skip t, frame, and data, you can simply use WaveformBase.copy_without_data(W). The latter is useful if, for example, you will only be making changes to those three fields, and want everything else preserved.

Also note that some slicing operations can achieve similar – but different – goals. For example, w = w[:, :0] will simply empty data and ells, without affecting the time and frame.

property data_2d
property data_ddot
property data_dot
property data_iint
property data_int
property data_type_latex
property data_type_string
deepcopy()[source]

Return a deep copy of the object

This is just an alias for copy, which is deep anyway.

property descriptor_string

Create a simple string describing the content of the waveform

This string will be suitable for file names. For example, ‘rMpsi4’ or ‘rhOverM’. It uses the waveform’s knowledge of itself, so if this is incorrect, the result will be incorrect.

ensure_validity(alter=True, assertions=False)[source]

Try to ensure that the WaveformBase object is valid

This tests various qualities of the WaveformBase’s members that are frequently assumed throughout the code. If the optional argument alter is True (which is the default), this function tries to alter the WaveformBase in place to ensure validity. Note that this is not always possible. If that is the case, an exception may be raised. For example, if the t member is not a one-dimensional array of floats, it is not clear what that data should be. Similarly, if the t and data members have mismatched dimensions, there is no way to resolve that automatically.

Also note that this is almost certainly not be an exhaustive test of all assumptions made in the code.

If the optional assertions argument is True (default is False), the first test that fails will raise an assertion error.

property frame_type_string
property gamma_weight

Non-conformal effect of a boost.

This factor allows for mass-scaling, for example. If the waveform describes r*h/M, for example, then r and h vary by the conformal weight, which depends on the direction; whereas M is a monopole, and thus cannot depend on the direction. Instead, M simply obeys the standard formula, scaling with gamma.

interpolate(tprime)[source]

Interpolate the frame and data onto the new set of time steps

Note that only t, frame, and data are changed in this function. If there is a corresponding data set in a subclass, for example, the subclass must override this function to set that data set – though this function should probably be called to handle the ugly stuff.

property is_valid
property m_scaling
max_norm_index(skip_fraction_of_data=4)[source]

Index of time step with largest norm

The optional argument skips a fraction of the data. The default is 4, which means that it only searches the last three-fourths of the data for the max. If 0 or 1 is input, this is ignored, and all the data is searched.

max_norm_time(skip_fraction_of_data=4)[source]

Return time at which largest norm occurs in data

See help(max_norm_index) for explanation of the optional argument.

property n_data_sets
property n_times
norm(take_sqrt=False, indices=slice(None, None, None))[source]

L2 norm of the waveform

The optional arguments say whether to take the square-root of the norm at each time, and allow restriction to a slice of the data, respectively.

property num
property r_scaling
property spin_weight
scri.waveform_base.complex_array_abs(c, s)[source]
scri.waveform_base.complex_array_norm(c, s)[source]
scri.waveform_base.test_with_assertions(errs, val, msg='')[source]
scri.waveform_base.test_without_assertions(errs, val, msg='')[source]

Replacement for np.testing.assert_

This function should be able to replace assert_, but rather than raising an exception, this just adds a description of the problem to the errors variable.

scri.waveform_base.waveform_alterations(func)[source]

Temporarily increment history depth safely

This decorator stores the value of self.__history_depth__, then increments it by 1, calls the function, returns the history depth to its original value, and then returns the result of the function. This should be used on any member function that could alter the waveform on which it is called, or which could return a new altered version of the original.

Typically, within the function itself, you will want to decrement the depth manually just before appending to the history – which will presumably take place at the end of the function. You do not need to undo this, as the decorator will take care of that part.