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)
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)
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)
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))
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))
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)
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)
def test_create_glob(): PATTERN = os.path.join( os.path.dirname(sunpy.data.test.__file__), "BIR_*" ) ca = CallistoSpectrogram.create(PATTERN) assert len(ca) == 2
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
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)
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
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
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)
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')
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()
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)
def test_create_file_kw(CALLISTO_IMAGE): ca = CallistoSpectrogram.create(filename=CALLISTO_IMAGE) assert np.array_equal(ca.data, CallistoSpectrogram.read(CALLISTO_IMAGE).data)
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)
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))
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)
def test_create_file(): ca = CallistoSpectrogram.create(CALLISTO_IMAGE) assert np.array_equal(ca, CallistoSpectrogram.read(CALLISTO_IMAGE))
def test_extend(): im = CallistoSpectrogram.create(CALLISTO_IMAGE) im2 = im.extend() # Not too stable test, but works. assert im2.data.shape == (200, 7196)
def test_create_file_kw(): ca = CallistoSpectrogram.create(filename=CALLISTO_IMAGE) assert np.array_equal(ca, CallistoSpectrogram.read(CALLISTO_IMAGE))
def test_create_file(): ca = CallistoSpectrogram.create(CALLISTO_IMAGE) assert np.array_equal(ca.data, CallistoSpectrogram.read(CALLISTO_IMAGE).data)