本文整理汇总了Python中sunpy.spectra.spectrogram.LinearTimeSpectrogram类的典型用法代码示例。如果您正苦于以下问题:Python LinearTimeSpectrogram类的具体用法?Python LinearTimeSpectrogram怎么用?Python LinearTimeSpectrogram使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LinearTimeSpectrogram类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_join_nonlinear
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)
开发者ID:derdon,项目名称:sunpy,代码行数:31,代码来源:test_spectrogram.py
示例2: test_linearize
def test_linearize():
image = np.random.rand(5, 900)
spec = LinearTimeSpectrogram(image,
np.linspace(0, 1 * (image.shape[1] - 1), image.shape[1]),
np.array([20, 10, 5, 0]),
datetime(2010, 1, 1, 0, 15),
datetime(2010, 1, 1, 0, 30),
900,
1
)
# 0 1 2 3 4 5 6 7 8
# -------- ----------- ----- ---
# 20 17.5 15 12.5 10 7.5 5 2.5 0
linear = spec.linearize_freqs()
assert ((linear.freq_axis[:-1] - linear.freq_axis[1:]) == 2.5).all()
assert (linear[0] == image[0, :]).all()
assert (linear[1] == image[0, :]).all()
assert (linear[2] == image[0, :]).all()
assert (linear[3] == image[1, :]).all()
assert (linear[4] == image[1, :]).all()
assert (linear[5] == image[1, :]).all()
assert (linear[6] == image[2, :]).all()
assert (linear[7] == image[2, :]).all()
assert (linear[8] == image[3, :]).all()
开发者ID:derdon,项目名称:sunpy,代码行数:26,代码来源:test_spectrogram.py
示例3: test_join_over_midnight
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)
开发者ID:ToyDragon,项目名称:sunpy,代码行数:28,代码来源:test_spectrogram.py
示例4: test_upsample
def test_upsample():
image = np.array([[0, 1, 2, 3], [0, 1, 2, 3]])
spec = LinearTimeSpectrogram(
image, np.array([0, 1, 2]), np.array([0]),
datetime(2012, 1, 1), datetime(2012, 1, 1, 0, 0, 3),
0, 1
)
r = spec.resample_time(2)
assert r.shape[1] == 2
开发者ID:derdon,项目名称:sunpy,代码行数:9,代码来源:test_spectrogram.py
示例5: test_resample
def test_resample():
image = np.array([[0, 1, 2], [0, 1, 2]])
spec = LinearTimeSpectrogram(
image, np.array([0, 1, 2]), np.array([0]),
datetime(2012, 1, 1), datetime(2012, 1, 1, 0, 0, 3),
0, 1
)
r = spec.resample_time(0.5)
assert r.shape[1] == 5
assert np.array_equal(r.time_axis, np.linspace(0, 2, 5))
开发者ID:derdon,项目名称:sunpy,代码行数:10,代码来源:test_spectrogram.py
示例6: test_time_to_x
def test_time_to_x():
image = np.zeros((200, 3600))
spectrogram = 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), datetime(2010, 10, 10, 1), 0, 1
)
ret = spectrogram.time_to_x(datetime(2010, 10, 10, 0, 0, 59))
assert isinstance(ret, int)
assert ret == 59
开发者ID:derdon,项目名称:sunpy,代码行数:10,代码来源:test_spectrogram.py
示例7: test_in_interval
def test_in_interval():
image = np.random.rand(5, 900)
spec = LinearTimeSpectrogram(image,
np.linspace(0, 1 * (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,
1
)
assert np.array_equal(spec.in_interval("00:15", "00:30").data, spec.data)
开发者ID:derdon,项目名称:sunpy,代码行数:12,代码来源:test_spectrogram.py
示例8: test_flatten
def test_flatten():
flat = np.arange(5 * 3600)
image = flat.reshape(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
)
assert np.array_equal(flat, spec.flatten())
开发者ID:ToyDragon,项目名称:sunpy,代码行数:12,代码来源:test_spectrogram.py
示例9: test_intersect_time
def test_intersect_time():
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),
901,
0.25
)
one, other = LinearTimeSpectrogram.intersect_time(
[spec, spec2]
)
assert one.shape[1] == other.shape[1]
assert one.shape[1] == 3596
assert np.array_equal(one.data, spec.data[:, 4:])
assert np.array_equal(other.data, spec2.data[:, :-4])
assert np.array_equal(one.time_axis, other.time_axis)
assert one.t_init == other.t_init
assert is_linear(one.time_axis)
assert is_linear(other.time_axis)
开发者ID:derdon,项目名称:sunpy,代码行数:33,代码来源:test_spectrogram.py
示例10: test_combine_freqs
def test_combine_freqs():
image = np.random.rand(5, 3600)
spec = LinearTimeSpectrogram(image,
np.linspace(0, 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, 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),
900,
0.25
)
comb = LinearTimeSpectrogram.combine_frequencies([spec, spec2])
stuff = [spec, spec2]
# print comb
for freq in range(10):
assert np.array_equal(
comb[9 - freq, :], stuff[freq % 2][4 - freq // 2, :]
)
开发者ID:derdon,项目名称:sunpy,代码行数:28,代码来源:test_spectrogram.py
示例11: test_join_with_gap_fill
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)
开发者ID:derdon,项目名称:sunpy,代码行数:32,代码来源:test_spectrogram.py
示例12: test_join_year
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)
开发者ID:derdon,项目名称:sunpy,代码行数:26,代码来源:test_spectrogram.py
示例13: test_join
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)
开发者ID:derdon,项目名称:sunpy,代码行数:30,代码来源:test_spectrogram.py
示例14: test_check_linearity
def test_check_linearity():
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
)
assert spec.check_linearity()
spec.time_axis[1] += 0.1
assert not spec.check_linearity()
assert spec.check_linearity(0.1)
spec.time_axis[1] -= 0.1
# The average stays (almost) the same because there are 3600 items.
spec.time_axis[1] += 0.2 * 0.25
assert spec.check_linearity(None, 0.2)
开发者ID:derdon,项目名称:sunpy,代码行数:18,代码来源:test_spectrogram.py
示例15: test_join_gap
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."
开发者ID:derdon,项目名称:sunpy,代码行数:21,代码来源:test_spectrogram.py
示例16: test_join_diff_freq
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."
开发者ID:derdon,项目名称:sunpy,代码行数:23,代码来源:test_spectrogram.py
示例17: test_join_different_dtype
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')
开发者ID:derdon,项目名称:sunpy,代码行数:20,代码来源:test_spectrogram.py
注:本文中的sunpy.spectra.spectrogram.LinearTimeSpectrogram类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论