|
1
|
|
|
# -*- coding: utf-8 -*- |
|
2
|
|
|
# vim:fileencoding=utf-8 |
|
3
|
|
|
# |
|
4
|
|
|
# Copyright (c) 2019-2022 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 command line interface tests |
|
12
|
|
|
|
|
13
|
|
|
Test functions to assure that the command line interface works in |
|
14
|
|
|
most of the cases, if not all. |
|
15
|
|
|
""" |
|
16
|
|
|
from os import path |
|
17
|
|
|
from pytest import mark |
|
18
|
|
|
from subprocess import Popen |
|
19
|
|
|
try: |
|
20
|
|
|
import netCDF4 |
|
21
|
|
|
NC_EXT = ".nc" |
|
22
|
|
|
except ImportError: |
|
23
|
|
|
NC_EXT = ".nc3" |
|
24
|
|
|
|
|
25
|
|
|
DATA_FILE = path.join( |
|
26
|
|
|
".", "tests", "data", |
|
27
|
|
|
"scia_mlt_dzmNO_part_2008-2012_v6.2_2.1_akm0.002_geomag10_nw" + NC_EXT |
|
28
|
|
|
) |
|
29
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
def test_main_help(): |
|
32
|
|
|
p = Popen(["python", "-m", "sciapy.regress", "-h"]) |
|
33
|
|
|
p.communicate() |
|
34
|
|
|
p.wait() |
|
35
|
|
|
assert p.returncode == 0 |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
@mark.long |
|
39
|
|
|
def test_main_lin_mean(tmpdir): |
|
40
|
|
|
p = Popen(["python", "-m", "sciapy.regress", |
|
41
|
|
|
DATA_FILE, |
|
42
|
|
|
"-o", tmpdir, |
|
43
|
|
|
"-A", "70", |
|
44
|
|
|
"-L", "65", |
|
45
|
|
|
"-k", |
|
46
|
|
|
"-O1", |
|
47
|
|
|
"-w", "50", |
|
48
|
|
|
"-b", "10", |
|
49
|
|
|
"-p", "20", |
|
50
|
|
|
"--plot_corner", |
|
51
|
|
|
"--plot_maxlnp", |
|
52
|
|
|
"--plot_maxlnpres", |
|
53
|
|
|
"--plot_median", |
|
54
|
|
|
"--plot_residuals", |
|
55
|
|
|
"--plot_samples", |
|
56
|
|
|
"--random_seed=1234", |
|
57
|
|
|
"-q", |
|
58
|
|
|
]) |
|
59
|
|
|
p.communicate() |
|
60
|
|
|
p.wait() |
|
61
|
|
|
assert p.returncode == 0 |
|
62
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
@mark.long |
|
65
|
|
|
@mark.parametrize("optimize", range(5)) |
|
66
|
|
|
def test_main_lin_gp(tmpdir, optimize): |
|
67
|
|
|
p = Popen(["python", "-m", "sciapy.regress", |
|
68
|
|
|
DATA_FILE, |
|
69
|
|
|
"-o", tmpdir, |
|
70
|
|
|
"-A", "70", |
|
71
|
|
|
"-L", "65", |
|
72
|
|
|
"-k", |
|
73
|
|
|
"-K", "Mat32", |
|
74
|
|
|
"-O", str(optimize), |
|
75
|
|
|
"-w", "4", |
|
76
|
|
|
"-b", "5", |
|
77
|
|
|
"-p", "10", |
|
78
|
|
|
"--no-plot_corner", |
|
79
|
|
|
"--no-plot_maxlnp", |
|
80
|
|
|
"--no-plot_maxlnpres", |
|
81
|
|
|
"--no-plot_median", |
|
82
|
|
|
"--no-plot_residuals", |
|
83
|
|
|
"--no-plot_samples", |
|
84
|
|
|
"--random_seed=1234", |
|
85
|
|
|
"-q", |
|
86
|
|
|
]) |
|
87
|
|
|
p.communicate() |
|
88
|
|
|
p.wait() |
|
89
|
|
|
assert p.returncode == 0 |
|
90
|
|
|
|
|
91
|
|
|
|
|
92
|
|
|
@mark.long |
|
93
|
|
|
@mark.parametrize("gpopts", [(), ("-g",), ("-g", "-H")]) |
|
94
|
|
|
def test_main_nonlin_gp(tmpdir, gpopts): |
|
95
|
|
|
p = Popen(["python", "-m", "sciapy.regress", |
|
96
|
|
|
DATA_FILE, |
|
97
|
|
|
"-o", tmpdir, |
|
98
|
|
|
"-A", "70", |
|
99
|
|
|
"-L", "65", |
|
100
|
|
|
"-k", |
|
101
|
|
|
"-F", "\"\"", |
|
102
|
|
|
"-I", "GM", |
|
103
|
|
|
"--fit_annlifetimes", "GM", |
|
104
|
|
|
"--positive_proxies", "GM", |
|
105
|
|
|
"--lifetime_scan=60", |
|
106
|
|
|
"--lifetime_prior=exp", |
|
107
|
|
|
"--cnt_threshold=3", |
|
108
|
|
|
"--akd_threshold=0.01", |
|
109
|
|
|
"-K", "Mat32", |
|
110
|
|
|
"-W", |
|
111
|
|
|
"-O1", |
|
112
|
|
|
"-w", "4", |
|
113
|
|
|
"-b", "10", |
|
114
|
|
|
"-p", "20", |
|
115
|
|
|
"--no-plot_corner", |
|
116
|
|
|
"--no-plot_maxlnp", |
|
117
|
|
|
"--no-plot_maxlnpres", |
|
118
|
|
|
"--no-plot_median", |
|
119
|
|
|
"--no-plot_residuals", |
|
120
|
|
|
"--no-plot_samples", |
|
121
|
|
|
"--random_seed=1234", |
|
122
|
|
|
"-q", |
|
123
|
|
|
] + list(gpopts)) |
|
124
|
|
|
p.communicate() |
|
125
|
|
|
p.wait() |
|
126
|
|
|
assert p.returncode == 0 |
|
127
|
|
|
|