本文整理汇总了Python中sunpy.spectra.spectrogram.LinearTimeSpectrogram.join_many方法的典型用法代码示例。如果您正苦于以下问题:Python LinearTimeSpectrogram.join_many方法的具体用法?Python LinearTimeSpectrogram.join_many怎么用?Python LinearTimeSpectrogram.join_many使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sunpy.spectra.spectrogram.LinearTimeSpectrogram
的用法示例。
在下文中一共展示了LinearTimeSpectrogram.join_many方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_join_with_gap_fill
# 需要导入模块: from sunpy.spectra.spectrogram import LinearTimeSpectrogram [as 别名]
# 或者: from sunpy.spectra.spectrogram.LinearTimeSpectrogram import join_many [as 别名]
def test_join_with_gap_fill():
image = np.random.rand(200, 3600)
one = LinearTimeSpectrogram(
image, np.linspace(0, 0.5 * (image.shape[1] - 1), image.shape[1]),
np.linspace(0, image.shape[0] - 1, image.shape[0]),
datetime(2010, 10, 10, 23, 45),
datetime(2010, 10, 11, 0, 15,), 85500, 0.5,
)
image = np.random.rand(200, 3600)
other = LinearTimeSpectrogram(
image, np.linspace(0, image.shape[1] - 1, image.shape[1]),
np.linspace(0, image.shape[0] - 1, image.shape[0]),
datetime(2010, 10, 11, 0, 15), datetime(2010, 10, 11, 1, 15), 901, 1,
)
z = LinearTimeSpectrogram.join_many(
[one, other], nonlinear=False, maxgap=2, fill=np.NaN
)
# The - 1 is because resampling other produces an image of size
# 2 * 3600 - 1
# The + 2 is because there is one second without data inserted.
assert z.shape == (200, 3 * 3600 + 2 - 1)
assert np.array_equal(z.data[:, :3600], one.data)
print(type(z.data))
# Second data to unpack masked array
assert np.isnan(z.data.data[:, 3600:3602]).all()
assert is_linear(z.time_axis)
assert isinstance(z, LinearTimeSpectrogram)
示例2: test_join_nonlinear
# 需要导入模块: from sunpy.spectra.spectrogram import LinearTimeSpectrogram [as 别名]
# 或者: from sunpy.spectra.spectrogram.LinearTimeSpectrogram import join_many [as 别名]
def test_join_nonlinear():
image = np.random.rand(200, 3600)
one = LinearTimeSpectrogram(
image, np.linspace(0, 0.5 * (image.shape[1] - 1), image.shape[1]),
np.linspace(0, image.shape[0] - 1, image.shape[0]),
datetime(2010, 10, 10, 23, 45),
datetime(2010, 10, 11, 0, 15,), 85500, 0.5,
)
image = np.random.rand(200, 3600)
other = LinearTimeSpectrogram(
image, np.linspace(0, image.shape[1] - 1, image.shape[1]),
np.linspace(0, image.shape[0] - 1, image.shape[0]),
datetime(2010, 10, 11, 0, 15),
datetime(2010, 10, 11, 1, 15), 901, 1,
)
oz = other.resample_time(0.5)
z = LinearTimeSpectrogram.join_many(
[one, other], nonlinear=True, maxgap=2
)
# The - 1 is because resampling other produces an image of size
# 2 * 3600 - 1
assert z.shape == (200, 3 * 3600 - 1)
assert np.array_equal(z.data[:, :3600], one.data)
assert np.array_equal(z.time_axis[:3600], one.time_axis)
assert np.array_equal(z.time_axis[3600:], oz.time_axis + 1801)
assert isinstance(z, Spectrogram)
示例3: test_join_year
# 需要导入模块: from sunpy.spectra.spectrogram import LinearTimeSpectrogram [as 别名]
# 或者: from sunpy.spectra.spectrogram.LinearTimeSpectrogram import join_many [as 别名]
def test_join_year():
image = np.random.rand(200, 3600)
one = LinearTimeSpectrogram(
image, np.linspace(0, 0.5 * (image.shape[1] - 1), image.shape[1]),
np.linspace(0, image.shape[0] - 1, image.shape[0]),
datetime(2012, 12, 31, 23, 30),
datetime(2013, 1, 1, 0, 0, 0), 84600, 0.5,
)
image = np.random.rand(200, 3600)
other = LinearTimeSpectrogram(
image, np.linspace(0, image.shape[1] - 1, image.shape[1]),
np.linspace(0, image.shape[0] - 1, image.shape[0]),
datetime(2013, 1, 1), datetime(2013, 1, 1, 1), 0, 1,
)
z = LinearTimeSpectrogram.join_many(
[one, other], nonlinear=False, maxgap=0
)
# The - 1 is because resampling other produces an image of size
# 2 * 3600 - 1
assert z.shape == (200, 3 * 3600 - 1)
assert np.array_equal(z.data[:, :3600], one.data)
assert is_linear(z.time_axis)
assert isinstance(z, LinearTimeSpectrogram)
示例4: test_join
# 需要导入模块: from sunpy.spectra.spectrogram import LinearTimeSpectrogram [as 别名]
# 或者: from sunpy.spectra.spectrogram.LinearTimeSpectrogram import join_many [as 别名]
def test_join():
image = np.random.rand(200, 3600)
one = LinearTimeSpectrogram(
image, np.linspace(0, 0.5 * (image.shape[1] - 1), image.shape[1]),
np.linspace(0, image.shape[0] - 1, image.shape[0]),
datetime(2010, 10, 10), datetime(2010, 10, 10, 0, 30), 0, 0.5,
)
image = np.random.rand(200, 3600)
other = LinearTimeSpectrogram(
image, np.linspace(0, image.shape[1] - 1, image.shape[1]),
np.linspace(0, image.shape[0] - 1, image.shape[0]),
datetime(2010, 10, 10, 0, 29),
datetime(2010, 10, 10, 1, 29), 1799, 1,
)
z = LinearTimeSpectrogram.join_many(
[one, other], nonlinear=False, maxgap=0
)
# The - 1 is because resampling other produces an image of size
# 2 * 3600 - 1
# The - 2 is because there is one second overlap.
assert z.shape == (200, 3 * 3600 - 2 - 1)
assert np.array_equal(z.data[:, :3598], one.data[:, :-2])
# assert np.array_equal(z[:, 3598:], ndimage.zoom(other, (1, 2)))
assert z.start == one.start
assert z.end == other.end
assert is_linear(z.time_axis)
assert isinstance(z, LinearTimeSpectrogram)
示例5: test_join_over_midnight
# 需要导入模块: from sunpy.spectra.spectrogram import LinearTimeSpectrogram [as 别名]
# 或者: from sunpy.spectra.spectrogram.LinearTimeSpectrogram import join_many [as 别名]
def test_join_over_midnight():
image = np.random.rand(200, 3600)
one = LinearTimeSpectrogram(
image, np.linspace(0, 0.5 * (image.shape[1] - 1), image.shape[1]),
np.linspace(0, image.shape[0] - 1, image.shape[0]),
datetime(2010, 10, 10, 23, 45),
datetime(2010, 10, 11, 0, 15,), 85500, 0.5,
)
image = np.random.rand(200, 3600)
other = LinearTimeSpectrogram(
image, np.linspace(0, image.shape[1] - 1, image.shape[1]),
np.linspace(0, image.shape[0] - 1, image.shape[0]),
datetime(2010, 10, 11, 0, 15), datetime(2010, 10, 11, 1, 15), 900, 1,
)
z = LinearTimeSpectrogram.join_many(
[one, other], nonlinear=False, maxgap=0
)
oz = other.resample_time(0.5)
# The - 1 is because resampling other procuces an image of size
# 2 * 3600 - 1
assert z.shape == (200, 3 * 3600 - 1)
assert np.array_equal(z[:, :3600], one)
assert np.array_equal(z.time_axis[:3600], one.time_axis)
assert is_linear(z.time_axis)
assert isinstance(z, LinearTimeSpectrogram)
示例6: test_join_gap
# 需要导入模块: from sunpy.spectra.spectrogram import LinearTimeSpectrogram [as 别名]
# 或者: from sunpy.spectra.spectrogram.LinearTimeSpectrogram import join_many [as 别名]
def test_join_gap():
image = np.random.rand(200, 3600)
one = LinearTimeSpectrogram(
image, np.linspace(0, 0.5 * (image.shape[1] - 1), image.shape[1]),
np.linspace(0, image.shape[0] - 1, image.shape[0]),
datetime(2010, 10, 10, 23, 45),
datetime(2010, 10, 11, 0, 15,), 85500, 0.5,
)
image = np.random.rand(200, 3600)
other = LinearTimeSpectrogram(
image, np.linspace(0, image.shape[1] - 1, image.shape[1]),
np.linspace(0, image.shape[0] - 1, image.shape[0]),
datetime(2010, 10, 11, 0, 15, 1),
datetime(2010, 10, 11, 1, 15), 901, 1,
)
with pytest.raises(ValueError) as excinfo:
LinearTimeSpectrogram.join_many(
[one, other], nonlinear=False, maxgap=0
)
assert excinfo.value.message == "Too large gap."
示例7: test_join_diff_freq
# 需要导入模块: from sunpy.spectra.spectrogram import LinearTimeSpectrogram [as 别名]
# 或者: from sunpy.spectra.spectrogram.LinearTimeSpectrogram import join_many [as 别名]
def test_join_diff_freq():
image = np.random.rand(5, 3600)
spec = LinearTimeSpectrogram(image,
np.linspace(0, 0.25 * (image.shape[1] - 1), image.shape[1]),
np.array([8, 6, 4, 2, 0]),
datetime(2010, 1, 1, 0, 15),
datetime(2010, 1, 1, 0, 30),
900,
0.25
)
image = np.random.rand(5, 3600)
spec2 = LinearTimeSpectrogram(image,
np.linspace(0, 0.25 * (image.shape[1] - 1), image.shape[1]),
np.array([9, 7, 5, 3, 1]),
datetime(2010, 1, 1, 0, 15),
datetime(2010, 1, 1, 0, 30),
1800,
0.25
)
with pytest.raises(ValueError) as excinfo:
LinearTimeSpectrogram.join_many([spec, spec2])
assert excinfo.value.message == "Frequency channels do not match."
示例8: test_join_different_dtype
# 需要导入模块: from sunpy.spectra.spectrogram import LinearTimeSpectrogram [as 别名]
# 或者: from sunpy.spectra.spectrogram.LinearTimeSpectrogram import join_many [as 别名]
def test_join_different_dtype():
image = np.random.rand(200, 3600).astype(np.uint16)
one = LinearTimeSpectrogram(
image, np.linspace(0, 0.5 * (image.shape[1] - 1), image.shape[1]),
np.linspace(0, image.shape[0] - 1, image.shape[0]),
datetime(2010, 10, 10), datetime(2010, 10, 10, 0, 30), 0, 0.5,
)
image = np.random.rand(200, 3600).astype(np.uint8)
other = LinearTimeSpectrogram(
image, np.linspace(0, image.shape[1] - 1, image.shape[1]),
np.linspace(0, image.shape[0] - 1, image.shape[0]),
datetime(2010, 10, 10, 0, 29),
datetime(2010, 10, 10, 1, 29), 1799, 1,
)
z = LinearTimeSpectrogram.join_many(
[one, other], nonlinear=False, maxgap=0
)
assert z.dtype == np.dtype('uint16')