예제 #1
0
def test_create_glob_kw():
    PATTERN = os.path.join(
        os.path.dirname(CALLISTO_IMAGE),
        "BIR_*"
    )
    ca = CallistoSpectrogram.create(pattern=PATTERN)[0]
    assert np.array_equal(ca.data, CallistoSpectrogram.read(CALLISTO_IMAGE).data)
예제 #2
0
def test_create_single_glob():
    PATTERN = os.path.join(
        os.path.dirname(CALLISTO_IMAGE),
        "BIR_*"
    )
    ca = CallistoSpectrogram.create(PATTERN)
    assert np.array_equal(ca.data, CallistoSpectrogram.read(CALLISTO_IMAGE).data)
예제 #3
0
def test_create_glob_kw(CALLISTO_IMAGE, CALLISTO_IMAGE_GLOB_INDEX, CALLISTO_IMAGE_GLOB_KEY):
    PATTERN = os.path.join(
        os.path.dirname(CALLISTO_IMAGE),
        CALLISTO_IMAGE_GLOB_KEY
    )
    ca = CallistoSpectrogram.create(pattern=PATTERN)[CALLISTO_IMAGE_GLOB_INDEX]
    assert_allclose(ca.data, CallistoSpectrogram.read(CALLISTO_IMAGE).data)
예제 #4
0
def test_create_url_kw():
    URL = (
        "http://soleil.i4ds.ch/solarradio/data/2002-20yy_Callisto/2011/09/22/"
        "BIR_20110922_050000_01.fit.gz"
    )
    ca = CallistoSpectrogram.create(url=URL)
    assert np.array_equal(ca, CallistoSpectrogram.read(URL))
예제 #5
0
def test_create_glob_kw():
    PATTERN = os.path.join(
        os.path.dirname(CALLISTO_IMAGE),
        "BIR_*"
    )
    ca = CallistoSpectrogram.create(pattern=PATTERN)[0]
    assert np.array_equal(ca, CallistoSpectrogram.read(CALLISTO_IMAGE))
예제 #6
0
def test_create_url_kw():
    URL = (
        "http://soleil.i4ds.ch/solarradio/data/2002-20yy_Callisto/2011/09/22/"
        "BIR_20110922_050000_01.fit.gz"
    )
    ca = CallistoSpectrogram.create(url=URL)
    assert np.array_equal(ca.data, CallistoSpectrogram.read(URL).data)
예제 #7
0
def test_create_single_glob(CALLISTO_IMAGE, CALLISTO_IMAGE_GLOB_INDEX,
                            CALLISTO_IMAGE_GLOB_KEY):
    PATTERN = os.path.join(os.path.dirname(CALLISTO_IMAGE),
                           CALLISTO_IMAGE_GLOB_KEY)
    ca = CallistoSpectrogram.create(PATTERN)
    assert_allclose(ca[CALLISTO_IMAGE_GLOB_INDEX].data,
                    CallistoSpectrogram.read(CALLISTO_IMAGE).data)
예제 #8
0
def test_create_glob():
    PATTERN = os.path.join(
        os.path.dirname(sunpy.data.test.__file__),
        "BIR_*"
    )
    ca = CallistoSpectrogram.create(PATTERN)
    assert len(ca) == 2
예제 #9
0
def test_create_glob():
    PATTERN = os.path.join(
        os.path.dirname(sunpy.data.test.__file__),
        "BIR_*"
    )
    ca = CallistoSpectrogram.create(PATTERN)
    assert len(ca) == 2
예제 #10
0
def test_create_glob(CALLISTO_IMAGE_GLOB_KEY):
    PATTERN = os.path.join(
        os.path.dirname(sunpy.data.test.__file__),
        CALLISTO_IMAGE_GLOB_KEY
    )
    ca = CallistoSpectrogram.create(PATTERN)
    assert len(ca) == 2
예제 #11
0
def test_homogenize_rightfq():
    a = np.float64(np.random.randint(0, 255, 3600))[np.newaxis, :]

    c1 = CallistoSpectrogram(
        a,
        np.arange(3600),
        np.array([1]),
        datetime(2011, 1, 1),
        datetime(2011, 1, 1, 1),
        0,
        1,
        'Time',
        'Frequency',
        'Test',
        None,
        None,
        None,
        False
    )
    b = 2 * a + 1
    c2 = CallistoSpectrogram(
        np.concatenate([
            np.arange(3600)[np.newaxis, :], b,
            np.arange(3600)[np.newaxis, :]
            ], 0),
        np.arange(3600),
        np.array([0, 1, 2]),
        datetime(2011, 1, 1),
        datetime(2011, 1, 1, 1),
        0,
        1,
        'Time',
        'Frequency',
        'Test',
        None,
        None,
        None,
        False
    )
    pairs_indices, factors, constants = c1._homogenize_params(
        c2, 0
    )
    assert pairs_indices == [(0, 1)]
    assert_array_almost_equal(factors, [0.5], 2)
    assert_array_almost_equal(constants, [-0.5], 2)
    assert_array_almost_equal(factors[0] * b + constants[0], a)
예제 #12
0
def test_homogenize_rightfq():
    a = np.float64(np.random.randint(0, 255, 3600))[np.newaxis, :]
        
    c1 = CallistoSpectrogram(
        a,
        np.arange(3600),
        np.array([1]),
        datetime(2011, 1, 1),
        datetime(2011, 1, 1, 1),
        0,
        1,
        'Time',
        'Frequency',
        'Test',
        None,
        None,
        None,
        False
    )
    b = 2 * a + 1
    c2 = CallistoSpectrogram(
        np.concatenate([
            np.arange(3600)[np.newaxis, :], b,
            np.arange(3600)[np.newaxis, :]
            ], 0),
        np.arange(3600),
        np.array([0, 1, 2]),
        datetime(2011, 1, 1),
        datetime(2011, 1, 1, 1),
        0,
        1,
        'Time',
        'Frequency',
        'Test',
        None,
        None,
        None,
        False
    )
    pairs_indices, factors, constants = c1._homogenize_params(
        c2, 0
    )    
    assert pairs_indices == [(0, 1)]
    assert_array_almost_equal(factors, [0.5], 2)
    assert_array_almost_equal(constants, [-0.5], 2)
    assert_array_almost_equal(factors[0] * b + constants[0], a)
예제 #13
0
def test_read(CALLISTO_IMAGE):
    ca = CallistoSpectrogram.read(CALLISTO_IMAGE)
    assert ca.start == datetime(2011, 9, 22, 5, 0, 0, 454000)
    assert ca.t_init == 18000.0
    assert ca.shape == (200, 3600)
    assert ca.t_delt == 0.25
    # Test linearity of time axis.
    assert np.array_equal(ca.time_axis, np.linspace(0, 0.25 * (ca.shape[1] - 1), ca.shape[1]))
    assert ca.dtype == np.uint8
예제 #14
0
def test_read(CALLISTO_IMAGE):
    ca = CallistoSpectrogram.read(CALLISTO_IMAGE)
    assert ca.start == datetime(2011, 9, 22, 5, 0, 0, 454000)
    assert ca.t_init == 18000.0
    assert ca.shape == (200, 3600)
    assert ca.t_delt == 0.25
    # Test linearity of time axis.
    assert np.array_equal(
        ca.time_axis, np.linspace(0, 0.25 * (ca.shape[1] - 1), ca.shape[1]))
    assert ca.dtype == np.uint8
예제 #15
0
def test_homogenize_both():
    a = np.float64(np.random.randint(0, 255, 3600))[np.newaxis, :]

    c1 = CallistoSpectrogram(
        a,
        np.arange(3600),
        np.array([1]),
        datetime(2011, 1, 1),
        datetime(2011, 1, 1, 1),
        0,
        1,
        "Time",
        "Frequency",
        "Test",
        None,
        None,
        None,
        False,
    )
    b = 2 * a + 1
    c2 = CallistoSpectrogram(
        b,
        np.arange(3600),
        np.array([1]),
        datetime(2011, 1, 1),
        datetime(2011, 1, 1, 1),
        0,
        1,
        "Time",
        "Frequency",
        "Test",
        None,
        None,
        None,
        False,
    )

    pairs_indices, factors, constants = c1._homogenize_params(c2, 0)

    assert pairs_indices == [(0, 0)]
    assert_array_almost_equal(factors, [0.5], 2)
    assert_array_almost_equal(constants, [-0.5], 2)
    assert_array_almost_equal(factors[0] * b + constants[0], a)
예제 #16
0
def test_create_glob(CALLISTO_IMAGE_GLOB_KEY):
    PATTERN = os.path.join(os.path.dirname(sunpy.data.test.__file__),
                           CALLISTO_IMAGE_GLOB_KEY)
    ca = CallistoSpectrogram.create(PATTERN)
    assert len(ca) == 2
import numpy as np
import matplotlib.pyplot as plt
from sunpy import lightcurve as lc
from sunpy.spectra.sources.callisto import CallistoSpectrogram
import scipy
smooth = scipy.ndimage.filters.uniform_filter 
from sunpy.time import parse_time
basetime=parse_time('1979-01-01 00:00:00')

t_start ='2015-11-04 13:00'
t_end ='2015-11-04 14:30'
start_time_day = '2015-11-04 00:00'


g = lc.GOESLightCurve.create(t_start, t_end)
gl = g.data['xrsb']


d = CallistoSpectrogram.from_range('BIR', t_start, t_end)
c = d.subtract_bg()

y = (parse_time(start_time_day) - basetime).total_seconds() + d.t_init
new_time = d.time_axis + y

callisto_times = []
for i in range(len(new_time)):
	callisto_times.append(parse_time(new_time[i]))


c.plot(cmap = 'viridis')
예제 #18
0
import numpy as np
import sunpy.data.sample
from sunpy.lightcurve import LightCurve
times = np.arange(1000) * 2.0
signal = np.sin(np.arange(1000) * 0.02) + np.random.random(1000)
light_curve = LightCurve.create({"signal": signal}, index=times)
light_curve.peek()
# endregion

# region Description
import matplotlib.pyplot as plt
import sunpy.spectra
plt.ion
import sunpy.data.sample
from sunpy.spectra.sources.callisto import CallistoSpectrogram
image = CallistoSpectrogram.read(sunpy.data.sample.CALLISTO_IMAGE)
image.peek()
# endregion

# region Description
import sunpy.map
import matplotlib.pyplot as plt
import sunpy.data.sample
plt.ion
aia = sunpy.map.Map(sunpy.data.sample.AIA_171_IMAGE)
fig = plt.figure()
ax = plt.subplot(111)
aia.plot()
aia.draw_limb()
aia.draw_grid()
plt.colorbar()
예제 #19
0
def test_extend(CALLISTO_IMAGE):
    im = CallistoSpectrogram.create(CALLISTO_IMAGE)
    im2 = im.extend()
    # Not too stable test, but works.
    assert im2.data.shape == (200, 7200)
예제 #20
0
def test_create_single_glob(CALLISTO_IMAGE, CALLISTO_IMAGE_GLOB_INDEX, CALLISTO_IMAGE_GLOB_KEY):
    PATTERN = os.path.join(os.path.dirname(CALLISTO_IMAGE), CALLISTO_IMAGE_GLOB_KEY)
    ca = CallistoSpectrogram.create(PATTERN)
    assert_allclose(ca[CALLISTO_IMAGE_GLOB_INDEX].data,
                    CallistoSpectrogram.read(CALLISTO_IMAGE).data)
예제 #21
0
def test_create_file_kw(CALLISTO_IMAGE):
    ca = CallistoSpectrogram.create(filename=CALLISTO_IMAGE)
    assert np.array_equal(ca.data, CallistoSpectrogram.read(CALLISTO_IMAGE).data)
예제 #22
0
def test_create_glob_kw(CALLISTO_IMAGE, CALLISTO_IMAGE_GLOB_INDEX,
                        CALLISTO_IMAGE_GLOB_KEY):
    PATTERN = os.path.join(os.path.dirname(CALLISTO_IMAGE),
                           CALLISTO_IMAGE_GLOB_KEY)
    ca = CallistoSpectrogram.create(pattern=PATTERN)[CALLISTO_IMAGE_GLOB_INDEX]
    assert_allclose(ca.data, CallistoSpectrogram.read(CALLISTO_IMAGE).data)
예제 #23
0
def test_create_single_glob():
    PATTERN = os.path.join(os.path.dirname(CALLISTO_IMAGE), "BIR_*")
    ca = CallistoSpectrogram.create(PATTERN)
    assert np.array_equal(ca, CallistoSpectrogram.read(CALLISTO_IMAGE))
예제 #24
0
from sunpy.spectra.sources.callisto import CallistoSpectrogram
tstart, tend = "2011-06-07T06:00:00", "2011-06-07T07:45:00"
callisto = CallistoSpectrogram.from_range("BIR", tstart, tend)
callisto_nobg = callisto.subtract_bg()
callisto_nobg.peek(vmin=0)
예제 #25
0
def test_create_file():
    ca = CallistoSpectrogram.create(CALLISTO_IMAGE)
    assert np.array_equal(ca, CallistoSpectrogram.read(CALLISTO_IMAGE))
예제 #26
0
def test_extend():
    im = CallistoSpectrogram.create(CALLISTO_IMAGE)
    im2 = im.extend()
    # Not too stable test, but works.
    assert im2.data.shape == (200, 7196)
예제 #27
0
def test_create_file_kw():
    ca = CallistoSpectrogram.create(filename=CALLISTO_IMAGE)
    assert np.array_equal(ca, CallistoSpectrogram.read(CALLISTO_IMAGE))
예제 #28
0
def test_create_file():
    ca = CallistoSpectrogram.create(CALLISTO_IMAGE)
    assert np.array_equal(ca.data, CallistoSpectrogram.read(CALLISTO_IMAGE).data)