本文整理汇总了Python中stingray.Lightcurve.make_lightcurve方法的典型用法代码示例。如果您正苦于以下问题:Python Lightcurve.make_lightcurve方法的具体用法?Python Lightcurve.make_lightcurve怎么用?Python Lightcurve.make_lightcurve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stingray.Lightcurve
的用法示例。
在下文中一共展示了Lightcurve.make_lightcurve方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_lightcurve_from_toa
# 需要导入模块: from stingray import Lightcurve [as 别名]
# 或者: from stingray.Lightcurve import make_lightcurve [as 别名]
def test_lightcurve_from_toa(self):
lc = Lightcurve.make_lightcurve(self.times, self.dt, use_hist=True,
tstart=0.5)
lc2 = Lightcurve.make_lightcurve(self.times, self.dt, use_hist=False,
tstart=0.5)
assert np.allclose(lc.time, lc2.time)
assert np.all(lc.counts == lc2.counts)
示例2: test_lightcurve_from_toa_random_nums
# 需要导入模块: from stingray import Lightcurve [as 别名]
# 或者: from stingray.Lightcurve import make_lightcurve [as 别名]
def test_lightcurve_from_toa_random_nums(self):
times = np.random.uniform(0, 10, 1000)
lc = Lightcurve.make_lightcurve(times, self.dt, use_hist=True,
tstart=0.5)
lc2 = Lightcurve.make_lightcurve(times, self.dt, use_hist=False,
tstart=0.5)
assert np.allclose(lc.time, lc2.time)
assert np.all(lc.counts == lc2.counts)
示例3: test_tseg
# 需要导入模块: from stingray import Lightcurve [as 别名]
# 或者: from stingray.Lightcurve import make_lightcurve [as 别名]
def test_tseg(self):
tstart = 0.0
tseg = 5.0
lc = Lightcurve.make_lightcurve(self.times, self.dt, tseg=tseg, tstart=tstart)
assert lc.tseg == tseg
assert lc.time[-1] - lc.time[0] == tseg - self.dt
示例4: setup_class
# 需要导入模块: from stingray import Lightcurve [as 别名]
# 或者: from stingray.Lightcurve import make_lightcurve [as 别名]
def setup_class(cls):
photon_arrivals = np.sort(np.random.uniform(0,1000, size=10000))
cls.lc = Lightcurve.make_lightcurve(photon_arrivals, dt=1.0)
cls.ps = Powerspectrum(cls.lc, norm="frac")
pl = models.PowerLaw1D()
pl.x_0.fixed = True
cls.lpost = PSDPosterior(cls.ps.freq, cls.ps.power, pl, m=cls.ps.m)
示例5: test_nondivisble_tseg
# 需要导入模块: from stingray import Lightcurve [as 别名]
# 或者: from stingray.Lightcurve import make_lightcurve [as 别名]
def test_nondivisble_tseg(self):
"""
If the light curve length input is not divisible by the time
resolution, the last (fractional) time bin will be dropped.
"""
tstart = 0.0
tseg = 5.5
lc = Lightcurve.make_lightcurve(self.times, self.dt, tseg=tseg, tstart=tstart)
assert lc.tseg == int(tseg / self.dt)
示例6: test_bin_correctly
# 需要导入模块: from stingray import Lightcurve [as 别名]
# 或者: from stingray.Lightcurve import make_lightcurve [as 别名]
def test_bin_correctly(self):
ncounts = np.array([2, 1, 0, 3])
tstart = 0.0
tseg = 4.0
toa = np.hstack([np.random.uniform(i, i + 1, size=n) for i, n in enumerate(ncounts)])
dt = 1.0
lc = Lightcurve.make_lightcurve(toa, dt, tseg=tseg, tstart=tstart)
assert np.allclose(lc.counts, ncounts)
示例7: _make_reference_bands_from_event_data
# 需要导入模块: from stingray import Lightcurve [as 别名]
# 或者: from stingray.Lightcurve import make_lightcurve [as 别名]
def _make_reference_bands_from_event_data(self, data, bounds=None):
if not bounds:
bounds = [np.min(data[:, 1]), np.max(data[:, 1])]
if bounds[1] <= np.min(self.band_interest[:, 0]) or \
bounds[0] >= np.max(self.band_interest[:, 1]):
elow = bounds[0]
ehigh = bounds[1]
toa = data[np.logical_and(
data[:, 1] >= elow,
data[:, 1] <= ehigh)]
lc_all = Lightcurve.make_lightcurve(toa, self.dt,
tstart=self.tstart,
tseg=self.tseg)
else:
lc_all = []
for i, b in enumerate(self.band_interest):
elow = b[0]
ehigh = b[1]
emask1 = data[np.logical_and(
data[:, 1] <= elow,
data[:, 1] >= bounds[0])]
emask2 = data[np.logical_and(
data[:, 1] <= bounds[1],
data[:, 1] >= ehigh)]
toa = np.vstack([emask1, emask2])
lc = Lightcurve.make_lightcurve(toa, self.dt,
tstart=self.tstart,
tseg=self.tseg)
lc_all.append(lc)
return lc_all
示例8: _create_lc_and_lc_ref
# 需要导入模块: from stingray import Lightcurve [as 别名]
# 或者: from stingray.Lightcurve import make_lightcurve [as 别名]
def _create_lc_and_lc_ref(self, energy, energy_events):
lc = Lightcurve.make_lightcurve(
energy_events[energy], self.dt, tstart=self.min_time,
tseg=self.max_time - self.min_time)
# Calculating timestamps for lc_ref
toa_ref = []
for key, value in energy_events.items():
if key >= self.ref_band_interest[0] and \
key <= self.ref_band_interest[1]:
if key != energy:
toa_ref.extend(value)
toa_ref = np.array(sorted(toa_ref))
lc_ref = Lightcurve.make_lightcurve(
toa_ref, self.dt, tstart=self.min_time,
tseg=self.max_time - self.min_time)
assert len(lc.time) == len(lc_ref.time)
return lc, lc_ref
示例9: _make_lightcurves
# 需要导入模块: from stingray import Lightcurve [as 别名]
# 或者: from stingray.Lightcurve import make_lightcurve [as 别名]
def _make_lightcurves(self, data):
self.tstart = np.min(data[:, 0])
self.tend = np.max(data[:, 0])
self.tseg = self.tend - self.tstart
lc_all = []
for i, b in enumerate(self.band_interest):
elow = b[0]
ehigh = b[1]
toa = data[np.logical_and(
data[:, 1] >= elow,
data[:, 1] <= ehigh)]
lc = Lightcurve.make_lightcurve(toa, self.dt, tstart=self.tstart,
tseg=self.tseg)
lc_all.append(lc)
return lc_all
示例10: _make_lightcurves
# 需要导入模块: from stingray import Lightcurve [as 别名]
# 或者: from stingray.Lightcurve import make_lightcurve [as 别名]
def _make_lightcurves(self, data):
"""
Create light curves for all bands of interest from ``data``. Takes the information the
``band_interest`` attribute and event data in ``data``, and produces a list of
:class:`stingray.Lightcurve` objects.
Parameters
----------
data : numpy.ndarray
Array of shape ``(N, 2)``, where ``N`` is the number of photons. First column contains the
times of arrivals, second column the corresponding photon energies.
Returns
-------
lc_all : iterable of :class:`stingray.Lightcurve` objects
A list of :class:`stingray.Lightcurve` objects of all bands of interest.
"""
self.tstart = np.min(data[:, 0])
self.tend = np.max(data[:, 0])
self.tseg = self.tend - self.tstart
lc_all = []
for i, b in enumerate(self.band_interest):
elow = b[0]
ehigh = b[1]
toa = data[np.logical_and(
data[:, 1] >= elow,
data[:, 1] <= ehigh)]
lc = Lightcurve.make_lightcurve(toa, self.dt, tstart=self.tstart,
tseg=self.tseg)
lc_all.append(lc)
return lc_all
示例11: test_correct_timeresolution
# 需要导入模块: from stingray import Lightcurve [as 别名]
# 或者: from stingray.Lightcurve import make_lightcurve [as 别名]
def test_correct_timeresolution(self):
lc = Lightcurve.make_lightcurve(self.times, self.dt)
assert np.isclose(lc.dt, self.dt)
示例12: test_tstart
# 需要导入模块: from stingray import Lightcurve [as 别名]
# 或者: from stingray.Lightcurve import make_lightcurve [as 别名]
def test_tstart(self):
tstart = 0.0
lc = Lightcurve.make_lightcurve(self.times, self.dt, tstart=0.0)
assert lc.tstart == tstart
assert lc.time[0] == tstart + 0.5*self.dt
示例13: _make_reference_bands_from_event_data
# 需要导入模块: from stingray import Lightcurve [as 别名]
# 或者: from stingray.Lightcurve import make_lightcurve [as 别名]
def _make_reference_bands_from_event_data(self, data, bounds=None):
"""
Helper method constructing reference bands for each band of interest, and constructing
light curves from these reference bands. This operates only if the data given to
:class:`Covariancespectrum` is event list data (i.e. photon arrival times and energies).
Parameters
----------
data : numpy.ndarray
Array of shape ``(N, 2)``, where N is the number of photons. First column contains the
times of arrivals, second column the corresponding photon energies.
bounds : iterable
The energy bounds to use for the reference band. Must be of type ``(elow, ehigh)``.
Returns
-------
lc_all: list of :class:`stingray.Lightcurve` objects.
The list of `:class:`stingray.Lightcurve` objects containing all reference
bands, between the values given in ``bounds``.
"""
if not bounds:
bounds = [np.min(data[:, 1]), np.max(data[:, 1])]
if bounds[1] <= np.min(self.band_interest[:, 0]) or \
bounds[0] >= np.max(self.band_interest[:, 1]):
elow = bounds[0]
ehigh = bounds[1]
toa = data[np.logical_and(
data[:, 1] >= elow,
data[:, 1] <= ehigh)]
lc_all = Lightcurve.make_lightcurve(toa, self.dt,
tstart=self.tstart,
tseg=self.tseg)
else:
lc_all = []
for i, b in enumerate(self.band_interest):
elow = b[0]
ehigh = b[1]
emask1 = data[np.logical_and(
data[:, 1] <= elow,
data[:, 1] >= bounds[0])]
emask2 = data[np.logical_and(
data[:, 1] <= bounds[1],
data[:, 1] >= ehigh)]
toa = np.vstack([emask1, emask2])
lc = Lightcurve.make_lightcurve(toa, self.dt,
tstart=self.tstart,
tseg=self.tseg)
lc_all.append(lc)
return lc_all
示例14: test_lightcurve_from_toa
# 需要导入模块: from stingray import Lightcurve [as 别名]
# 或者: from stingray.Lightcurve import make_lightcurve [as 别名]
def test_lightcurve_from_toa(self):
lc = Lightcurve.make_lightcurve(self.times, self.dt)