本文整理匯總了Python中pycbc.types.FrequencySeries.data[kmin:kmax]方法的典型用法代碼示例。如果您正苦於以下問題:Python FrequencySeries.data[kmin:kmax]方法的具體用法?Python FrequencySeries.data[kmin:kmax]怎麽用?Python FrequencySeries.data[kmin:kmax]使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pycbc.types.FrequencySeries
的用法示例。
在下文中一共展示了FrequencySeries.data[kmin:kmax]方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_fd_qnm
# 需要導入模塊: from pycbc.types import FrequencySeries [as 別名]
# 或者: from pycbc.types.FrequencySeries import data[kmin:kmax] [as 別名]
def get_fd_qnm(template=None, **kwargs):
"""Return a frequency domain damped sinusoid.
Parameters
----------
template: object
An object that has attached properties. This can be used to substitute
for keyword arguments. A common example would be a row in an xml table.
f_0 : float
The ringdown-frequency.
tau : float
The damping time of the sinusoid.
amp : float
The amplitude of the ringdown (constant for now).
phi : float
The initial phase of the ringdown. Should also include the information
from the azimuthal angle (phi_0 + m*Phi).
inclination : {None, float}, optional
Inclination of the system in radians for the spherical harmonics.
l : {2, int}, optional
l mode for the spherical harmonics. Default is l=2.
m : {2, int}, optional
m mode for the spherical harmonics. Default is m=2.
t_0 : {0, float}, optional
The starting time of the ringdown.
delta_f : {None, float}, optional
The frequency step used to generate the ringdown.
If None, it will be set to the inverse of the time at which the
amplitude is 1/1000 of the peak amplitude.
f_lower: {None, float}, optional
The starting frequency of the output frequency series.
If None, it will be set to delta_f.
f_final : {None, float}, optional
The ending frequency of the output frequency series.
If None, it will be set to the frequency at which the amplitude is
1/1000 of the peak amplitude.
Returns
-------
hplustilde: FrequencySeries
The plus phase of the ringdown in frequency domain.
hcrosstilde: FrequencySeries
The cross phase of the ringdown in frequency domain.
"""
input_params = props(template, qnm_required_args, **kwargs)
f_0 = input_params.pop('f_0')
tau = input_params.pop('tau')
amp = input_params.pop('amp')
phi = input_params.pop('phi')
# the following have defaults, and so will be populated
t_0 = input_params.pop('t_0')
# the following may not be in input_params
inc = input_params.pop('inclination', None)
l = input_params.pop('l', 2)
m = input_params.pop('m', 2)
delta_f = input_params.pop('delta_f', None)
f_lower = input_params.pop('f_lower', None)
f_final = input_params.pop('f_final', None)
if not delta_f:
delta_f = 1. / qnm_time_decay(tau, 1./1000)
if not f_lower:
f_lower = delta_f
kmin = 0
else:
kmin = int(f_lower / delta_f)
if not f_final:
f_final = qnm_freq_decay(f_0, tau, 1./1000)
if f_final > max_freq:
f_final = max_freq
kmax = int(f_final / delta_f) + 1
freqs = numpy.arange(kmin, kmax)*delta_f
if inc is not None:
Y_plus, Y_cross = spher_harms(l, m, inc)
else:
Y_plus, Y_cross = 1, 1
denominator = 1 + (4j * pi * freqs * tau) - (4 * pi_sq * ( freqs*freqs - f_0*f_0) * tau*tau)
norm = amp * tau / denominator
if t_0 != 0:
time_shift = numpy.exp(-1j * two_pi * freqs * t_0)
norm *= time_shift
# Analytical expression for the Fourier transform of the ringdown (damped sinusoid)
hp_tilde = norm * Y_plus * ( (1 + 2j * pi * freqs * tau) * numpy.cos(phi)
- two_pi * f_0 * tau * numpy.sin(phi) )
hc_tilde = norm * Y_cross * ( (1 + 2j * pi * freqs * tau) * numpy.sin(phi)
+ two_pi * f_0 * tau * numpy.cos(phi) )
outplus = FrequencySeries(zeros(kmax, dtype=complex128), delta_f=delta_f)
outcross = FrequencySeries(zeros(kmax, dtype=complex128), delta_f=delta_f)
outplus.data[kmin:kmax] = hp_tilde
outcross.data[kmin:kmax] = hc_tilde
return outplus, outcross
示例2: get_fd_qnm
# 需要導入模塊: from pycbc.types import FrequencySeries [as 別名]
# 或者: from pycbc.types.FrequencySeries import data[kmin:kmax] [as 別名]
def get_fd_qnm(template=None, **kwargs):
"""Return a frequency domain damped sinusoid.
Parameters
----------
template: object
An object that has attached properties. This can be used to substitute
for keyword arguments. A common example would be a row in an xml table.
f_0 : float
The ringdown-frequency.
tau : float
The damping time of the sinusoid.
t_0 : {0, float}, optional
The starting time of the ringdown.
phi_0 : {0, float}, optional
The initial phase of the ringdown.
amp : {1, float}, optional
The amplitude of the ringdown (constant for now).
delta_f : {None, float}, optional
The frequency step used to generate the ringdown.
If None, it will be set to the inverse of the time at which the
amplitude is 1/1000 of the peak amplitude.
f_lower: {None, float}, optional
The starting frequency of the output frequency series.
If None, it will be set to delta_f.
f_final : {None, float}, optional
The ending frequency of the output frequency series.
If None, it will be set to the frequency at which the amplitude is
1/1000 of the peak amplitude.
Returns
-------
hplustilde: FrequencySeries
The plus phase of the ringdown in frequency domain.
hcrosstilde: FrequencySeries
The cross phase of the ringdown in frequency domain.
"""
input_params = props_ringdown(template,**kwargs)
# get required args
try:
f_0 = input_params['f_0']
except KeyError:
raise ValueError('f_0 is required')
try:
tau = input_params['tau']
except KeyError:
raise ValueError('tau is required')
# get optional args
# the following have defaults, and so will be populated
t_0 = input_params.pop('t_0')
phi_0 = input_params.pop('phi_0')
amp = input_params.pop('amp')
# the following may not be in input_params
delta_f = input_params.pop('delta_f', None)
f_lower = input_params.pop('f_lower', None)
f_final = input_params.pop('f_final', None)
if delta_f is None:
delta_f = 1. / qnm_time_decay(tau, 1./1000)
if f_lower is None:
f_lower = delta_f
kmin = 0
else:
kmin = int(f_lower / delta_f)
if f_final is None:
f_final = qnm_freq_decay(f_0, tau, 1./1000)
kmax = int(f_final / delta_f) + 1
pi = numpy.pi
two_pi = 2 * numpy.pi
pi_sq = numpy.pi * numpy.pi
freqs = numpy.arange(kmin, kmax)*delta_f
denominator = 1 + (4j * pi * freqs * tau) - (4 * pi_sq * ( freqs*freqs - f_0*f_0) * tau*tau)
norm = amp * tau / denominator
if t_0 != 0:
time_shift = numpy.exp(-1j * two_pi * freqs * t_0)
norm *= time_shift
hp_tilde = norm * ( (1 + 2j * pi * freqs * tau) * numpy.cos(phi_0) - two_pi * f_0 * tau * numpy.sin(phi_0) )
hc_tilde = norm * ( (1 + 2j * pi * freqs * tau) * numpy.sin(phi_0) + two_pi * f_0 * tau * numpy.cos(phi_0) )
hplustilde = FrequencySeries(zeros(kmax, dtype=complex128), delta_f=delta_f)
hcrosstilde = FrequencySeries(zeros(kmax, dtype=complex128), delta_f=delta_f)
hplustilde.data[kmin:kmax] = hp_tilde
hcrosstilde.data[kmin:kmax] = hc_tilde
return hplustilde, hcrosstilde