Passed
Push — master ( 822a99...4b62a2 )
by Stefan
08:21
created

test_regress_load_data.test_load_dzm_summerNH()   A

Complexity

Conditions 2

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
2
# vim:fileencoding=utf-8
3
#
4
# Copyright (c) 2018 Stefan Bender
5
#
6
# This module is part of sciapy.
7
# sciapy is free software: you can redistribute it or modify
8
# it under the terms of the GNU General Public License as published
9
# by the Free Software Foundation, version 2.
10
# See accompanying LICENSE file or http://www.gnu.org/licenses/gpl-2.0.html.
11
"""SCIAMACHY regression module data loading tests
12
"""
13
14
from pkg_resources import resource_filename
15
16
import numpy as np
17
from pytest import raises
18
19
import sciapy.regress
20
21
DZM_FILE = resource_filename(__name__, "sciaNO_20100203_v6.2.1_geogra30.nc")
22
23
24
def test_load_proxydata():
25
	import pandas as pd
26
	AEfile = resource_filename(__name__,
27
			"../data/indices/AE_Kyoto_1980-2016_daily2_shift12h.dat")
28
	Lyafile = resource_filename(__name__,
29
			"../data/indices/lisird_lya3_1980-2017.dat")
30
	pAEt, pAEv = sciapy.regress.load_solar_gm_table(AEfile,
31
			cols=[0, 1], names=["time", "AE"], tfmt="jyear")
32
	pLyat, pLyav = sciapy.regress.load_solar_gm_table(Lyafile,
33
			cols=[0, 1], names=["time", "Lya"], tfmt="jyear")
34
	pAEt2, pAEv2 = sciapy.regress.load_data.load_dailymeanAE()
35
	pLyat2, pLyav2 = sciapy.regress.load_data.load_dailymeanLya()
36
	np.testing.assert_allclose(pAEt, pAEt2)
37
	np.testing.assert_allclose(pLyat, pLyat2)
38
	pd.testing.assert_frame_equal(pAEv, pAEv2)
39
	pd.testing.assert_frame_equal(pLyav, pLyav2)
40
41
42
def test_load_dzm_normal():
43
	data = sciapy.regress.load_scia_dzm(DZM_FILE, 70., -75.)
44
	np.testing.assert_allclose(data[0], np.array([2010.09184335]))
45
	np.testing.assert_allclose(data[1], np.array([25992364.81988303]))
46
	np.testing.assert_allclose(data[2], np.array([2722294.10593951]))
47
	np.testing.assert_allclose(data[3], np.array([65.5642548]))
48
49
50
def test_load_dzm_center():
51
	data = sciapy.regress.load_scia_dzm(DZM_FILE, 70., -45., center=True)
52
	np.testing.assert_allclose(data[0], np.array([2010.09184335]))
53
	np.testing.assert_allclose(data[1], np.array([-9293324.84946741]))
54
	np.testing.assert_allclose(data[2], np.array([2337592.1464543]))
55
	np.testing.assert_allclose(data[3], np.array([46.02054338]))
56
57
58
def test_load_dzm_spe():
59
	data = sciapy.regress.load_scia_dzm(DZM_FILE, 70., 15., SPEs=True)
60
	np.testing.assert_allclose(data[0], np.array([2010.09184335]))
61
	np.testing.assert_allclose(data[1], np.array([10184144.7669378]))
62
	np.testing.assert_allclose(data[2], np.array([2633165.7502271]))
63
	np.testing.assert_allclose(data[3], np.array([45.41338086]))
64
65
66
def test_load_dzm_summerSH():
67
	data = sciapy.regress.load_scia_dzm(DZM_FILE, 70., 45., season="summerSH")
68
	np.testing.assert_allclose(data[0], np.array([2010.09184335]))
69
	np.testing.assert_allclose(data[1], np.array([24484783.29918655]))
70
	np.testing.assert_allclose(data[2], np.array([2814284.4588219]))
71
	np.testing.assert_allclose(data[3], np.array([65.04123748]))
72
73
74
def test_load_dzm_summerNH():
75
	with raises(IndexError):
76
		sciapy.regress.load_scia_dzm(DZM_FILE, 70., 75., season="summerNH")
77