|
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 level 1c tests |
|
12
|
|
|
""" |
|
13
|
|
|
import os |
|
14
|
|
|
|
|
15
|
|
|
import numpy as np |
|
16
|
|
|
|
|
17
|
|
|
import sciapy.level1c |
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
def test_module_object_structure(): |
|
21
|
|
|
assert sciapy.level1c |
|
22
|
|
|
assert sciapy.level1c.scia_limb |
|
23
|
|
|
assert sciapy.level1c.scia_limb.scia_limb_point |
|
24
|
|
|
assert sciapy.level1c.scia_limb.scia_limb_scan |
|
25
|
|
|
assert sciapy.level1c.scia_limb_point |
|
26
|
|
|
assert sciapy.level1c.scia_limb_scan |
|
27
|
|
|
assert sciapy.level1c.scia_solar |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
def test_limbmodule_method_structure(): |
|
31
|
|
|
assert sciapy.level1c.scia_limb.scia_limb_point.from_limb_scan |
|
32
|
|
|
assert sciapy.level1c.scia_limb_point.from_limb_scan |
|
33
|
|
|
assert sciapy.level1c.scia_limb.scia_limb_scan.assemble_textheader |
|
34
|
|
|
assert sciapy.level1c.scia_limb.scia_limb_scan.local_solar_time |
|
35
|
|
|
assert sciapy.level1c.scia_limb.scia_limb_scan.parse_textheader |
|
36
|
|
|
assert sciapy.level1c.scia_limb.scia_limb_scan.read_from_file |
|
37
|
|
|
assert sciapy.level1c.scia_limb.scia_limb_scan.read_from_hdf5 |
|
38
|
|
|
assert sciapy.level1c.scia_limb.scia_limb_scan.read_from_mpl_binary |
|
39
|
|
|
assert sciapy.level1c.scia_limb.scia_limb_scan.read_from_netcdf |
|
40
|
|
|
assert sciapy.level1c.scia_limb.scia_limb_scan.read_from_textfile |
|
41
|
|
|
assert sciapy.level1c.scia_limb.scia_limb_scan.write_to_mpl_binary |
|
42
|
|
|
assert sciapy.level1c.scia_limb.scia_limb_scan.write_to_netcdf |
|
43
|
|
|
assert sciapy.level1c.scia_limb.scia_limb_scan.write_to_textfile |
|
44
|
|
|
assert sciapy.level1c.scia_limb_scan.assemble_textheader |
|
45
|
|
|
assert sciapy.level1c.scia_limb_scan.local_solar_time |
|
46
|
|
|
assert sciapy.level1c.scia_limb_scan.parse_textheader |
|
47
|
|
|
assert sciapy.level1c.scia_limb_scan.read_from_file |
|
48
|
|
|
assert sciapy.level1c.scia_limb_scan.read_from_hdf5 |
|
49
|
|
|
assert sciapy.level1c.scia_limb_scan.read_from_mpl_binary |
|
50
|
|
|
assert sciapy.level1c.scia_limb_scan.read_from_netcdf |
|
51
|
|
|
assert sciapy.level1c.scia_limb_scan.read_from_textfile |
|
52
|
|
|
assert sciapy.level1c.scia_limb_scan.write_to_mpl_binary |
|
53
|
|
|
assert sciapy.level1c.scia_limb_scan.write_to_netcdf |
|
54
|
|
|
assert sciapy.level1c.scia_limb_scan.write_to_textfile |
|
55
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
def test_solarmodule_method_structure(): |
|
58
|
|
|
assert sciapy.level1c.scia_solar.read_from_hdf5 |
|
59
|
|
|
assert sciapy.level1c.scia_solar.read_from_netcdf |
|
60
|
|
|
assert sciapy.level1c.scia_solar.read_from_textfile |
|
61
|
|
|
assert sciapy.level1c.scia_solar.read_from_file |
|
62
|
|
|
assert sciapy.level1c.scia_solar.write_to_netcdf |
|
63
|
|
|
assert sciapy.level1c.scia_solar.write_to_textfile |
|
64
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
DATADIR = os.path.join(".", "tests", "data", "l1c") |
|
67
|
|
|
IFILE = os.path.join( |
|
68
|
|
|
DATADIR, "2010", "20100203", |
|
69
|
|
|
"SCIA_limb_20100203_015238_1_0_41454.dat.l_mpl_binary", |
|
70
|
|
|
) |
|
71
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
def test_level1c_round_trip_mpl(tmpdir): |
|
74
|
|
|
obase = os.path.join(tmpdir, "test_l1c_t") |
|
75
|
|
|
ofmpl = obase + ".l_mpl_binary" |
|
76
|
|
|
l1c_o = sciapy.level1c.scia_limb_scan() |
|
77
|
|
|
l1c_o.read_from_file(IFILE) |
|
78
|
|
|
l1c_o.write_to_mpl_binary(ofmpl) |
|
79
|
|
|
l1c_t = sciapy.level1c.scia_limb_scan() |
|
80
|
|
|
l1c_t.read_from_mpl_binary(ofmpl) |
|
81
|
|
|
for _k, _v in l1c_o.__dict__.items(): |
|
82
|
|
|
assert np.all(_v == l1c_t.__dict__[_k]), "mpl round trip failed" |
|
83
|
|
|
|
|
84
|
|
|
|
|
85
|
|
|
def test_level1c_round_trip_nc(tmpdir): |
|
86
|
|
|
obase = os.path.join(tmpdir, "test_l1c_t") |
|
87
|
|
|
ofnc = obase + ".nc" |
|
88
|
|
|
l1c_o = sciapy.level1c.scia_limb_scan() |
|
89
|
|
|
l1c_o.read_from_file(IFILE) |
|
90
|
|
|
l1c_o.write_to_netcdf(ofnc) |
|
91
|
|
|
l1c_t = sciapy.level1c.scia_limb_scan() |
|
92
|
|
|
l1c_t.read_from_netcdf(ofnc) |
|
93
|
|
|
for _k, _v in l1c_o.__dict__.items(): |
|
94
|
|
|
assert np.all(_v == l1c_t.__dict__[_k]), "netcdf round trip failed" |
|
95
|
|
|
|
|
96
|
|
|
|
|
97
|
|
|
def test_level1c_round_trip_txt(tmpdir): |
|
98
|
|
|
obase = os.path.join(tmpdir, "test_l1c_t") |
|
99
|
|
|
oftxt = obase + ".dat" |
|
100
|
|
|
l1c_o = sciapy.level1c.scia_limb_scan() |
|
101
|
|
|
l1c_o.read_from_file(IFILE) |
|
102
|
|
|
l1c_o.write_to_textfile(oftxt) |
|
103
|
|
|
l1c_t = sciapy.level1c.scia_limb_scan() |
|
104
|
|
|
l1c_t.read_from_textfile(oftxt) |
|
105
|
|
|
for _k, _v in l1c_o.__dict__.items(): |
|
106
|
|
|
assert np.all(_v == l1c_t.__dict__[_k]), "ascii round trip failed" |
|
107
|
|
|
|