def __init__(self, initial_array, delta_t=None, epoch="", dtype=None, copy=True): if len(initial_array) < 1: raise ValueError('initial_array must contain at least one sample.') if delta_t is None: try: delta_t = initial_array.delta_t except AttributeError: raise TypeError('must provide either an initial_array with a delta_t attribute, or a value for delta_t') if not delta_t > 0: raise ValueError('delta_t must be a positive number') # We gave a nonsensical default value to epoch so we can test if it's been set. # If the user passes in an initial_array that has an 'epoch' attribute and doesn't # pass in a value of epoch, then our new object's epoch comes from initial_array. # But if the user passed in a value---even 'None'---that will take precedence over # anything set in initial_array. Finally, if the user passes in something without # an epoch attribute *and* doesn't pass in a value of epoch, it becomes 'None' if not isinstance(epoch,_lal.LIGOTimeGPS): if epoch == "": if isinstance(initial_array, TimeSeries): epoch = initial_array._epoch else: epoch = _lal.LIGOTimeGPS(0) elif epoch is not None: try: epoch = _lal.LIGOTimeGPS(epoch) except: raise TypeError('epoch must be either None or a lal.LIGOTimeGPS') Array.__init__(self, initial_array, dtype=dtype, copy=copy) self._delta_t = delta_t self._epoch = epoch
def __init__(self, initial_array, delta_f=None, epoch="", dtype=None, copy=True): if len(initial_array) < 1: raise ValueError('initial_array must contain at least one sample.') if delta_f == None: try: delta_f = initial_array.delta_f except AttributeError: raise TypeError('must provide either an initial_array with a delta_f attribute, or a value for delta_f') if not delta_f > 0: raise ValueError('delta_f must be a positive number') # We gave a nonsensical default value to epoch so we can test if it's been set. # If the user passes in an initial_array that has an 'epoch' attribute and doesn't # pass in a value of epoch, then our new object's epoch comes from initial_array. # But if the user passed in a value---even 'None'---that will take precedence over # anything set in initial_array. Finally, if the user passes in something without # an epoch attribute *and* doesn't pass in a value of epoch, it becomes 'None' if not isinstance(epoch,_lal.LIGOTimeGPS): if epoch == "": if isinstance(initial_array,FrequencySeries): epoch = initial_array._epoch else: epoch = _lal.LIGOTimeGPS(0) elif epoch is not None: try: epoch = _lal.LIGOTimeGPS(epoch) except: raise TypeError('epoch must be either None or a lal.LIGOTimeGPS') Array.__init__(self, initial_array, dtype=dtype, copy=copy) self._delta_f = delta_f self._epoch = epoch
def __init__(self, initial_array, delta_t=None, epoch=None, dtype=None, copy=True): if len(initial_array) < 1: raise ValueError('initial_array must contain at least one sample.') if delta_t is None: try: delta_t = initial_array.delta_t except AttributeError: raise TypeError('must provide either an initial_array with a delta_t attribute, or a value for delta_t') if not delta_t > 0: raise ValueError('delta_t must be a positive number') # Get epoch from initial_array if epoch not given (or is None) # If initialy array has no epoch, set epoch to 0. # If epoch is provided, use that. if not isinstance(epoch, _lal.LIGOTimeGPS): if epoch is None: if isinstance(initial_array, TimeSeries): epoch = initial_array._epoch else: epoch = _lal.LIGOTimeGPS(0) elif epoch is not None: try: epoch = _lal.LIGOTimeGPS(epoch) except: raise TypeError('epoch must be either None or a lal.LIGOTimeGPS') Array.__init__(self, initial_array, dtype=dtype, copy=copy) self._delta_t = delta_t self._epoch = epoch
def __init__(self, initial_array, delta_f=None, epoch="", dtype=None, copy=True): if len(initial_array) < 1: raise ValueError('initial_array must contain at least one sample.') if delta_f is None: try: delta_f = initial_array.delta_f except AttributeError: raise TypeError( 'must provide either an initial_array with a delta_f attribute, or a value for delta_f' ) if not delta_f > 0: raise ValueError('delta_f must be a positive number') # We gave a nonsensical default value to epoch so we can test if it's been set. # If the user passes in an initial_array that has an 'epoch' attribute and doesn't # pass in a value of epoch, then our new object's epoch comes from initial_array. # But if the user passed in a value---even 'None'---that will take precedence over # anything set in initial_array. Finally, if the user passes in something without # an epoch attribute *and* doesn't pass in a value of epoch, it becomes 'None' if not isinstance(epoch, _lal.LIGOTimeGPS): if epoch == "": if isinstance(initial_array, FrequencySeries): epoch = initial_array._epoch else: epoch = _lal.LIGOTimeGPS(0) elif epoch is not None: try: if isinstance(epoch, _numpy.generic): # In python3 lal LIGOTimeGPS will not work on numpy # types as input. A quick google on how to generically # convert numpy floats/ints to the python equivalent # https://stackoverflow.com/questions/9452775/ epoch = _lal.LIGOTimeGPS(epoch.item()) else: epoch = _lal.LIGOTimeGPS(epoch) except: raise TypeError( 'epoch must be either None or a lal.LIGOTimeGPS') Array.__init__(self, initial_array, dtype=dtype, copy=copy) self._delta_f = delta_f self._epoch = epoch
def __init__(self, initial_array, delta_t, epoch=None, dtype=None, copy=True): """initial_array: array containing sampled data. delta_t: time between consecutive samples in seconds. epoch: time series start time in seconds. Must be a lal.LIGOTimeGPS object. """ if len(initial_array) < 1: raise ValueError('initial_array must contain at least one sample.') if not delta_t > 0: raise ValueError('delta_t must be a positive number') if epoch is not None and not isinstance(epoch, _lal.LIGOTimeGPS): raise TypeError('epoch must be either None or a lal.LIGOTimeGPS') if epoch is None: epoch = _lal.LIGOTimeGPS(0, 0) else: epoch = _lal.LIGOTimeGPS(epoch) Array.__init__(self, initial_array, dtype=dtype, copy=copy) self._delta_t = delta_t self._epoch = epoch
def __init__(self, initial_array, delta_f, epoch=None, dtype=None, copy=True): """initial_array: array containing sampled data. delta_f: frequency between consecutive samples in Hertz. epoch: start time of the associated time domain data, in seconds. Must be a lal.LIGOTimeGPS object. """ if len(initial_array) < 1: raise ValueError('initial_array must contain at least one sample.') if not delta_f > 0: raise ValueError('delta_f must be a positive number') if epoch is not None and not isinstance(epoch, _lal.LIGOTimeGPS): raise TypeError('epoch must be either None or a lal.LIGOTimeGPS') if epoch is None: epoch = _lal.LIGOTimeGPS(0, 0) else: epoch = _lal.LIGOTimeGPS(epoch) Array.__init__(self, initial_array, dtype=dtype, copy=copy) self._delta_f = delta_f self._epoch = epoch