Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import numpy as np
import xarray as xr
import os
import pytest
import read_data as rd
@pytest.fixture
def fixturepath():
return os.path.join(os.path.dirname(__file__), 'fixtures')
# @pytest.fixture()
# def l1b_file(fixturepath):
# return os.path.join(fixturepath, '')
# @pytest.fixture()
# def geo_file(fixturepath):
# return os.path.join(fixturepath, '')
# @pytest.fixture
# def ancillary_dir(fixturepath):
# return os.path.join(fixturepath, '')
@pytest.fixture
def sst_file():
return 'oisst.20220622'
@pytest.fixture
def ndvi_file():
return 'NDVI.FM.c004.v2.0.WS.00-04.177.hdf'
@pytest.fixture
def geos_file_1():
return 'GEOS.fpit.asm.inst3_2d_asm_Nx.GEOS5124.20220622_1200.V01.nc4'
@pytest.fixture
def geos_file_2():
return 'GEOS.fpit.asm.inst3_2d_asm_Nx.GEOS5124.20220622_1500.V01.nc4'
@pytest.fixture
def geos_land():
return 'GEOS.fpit.asm.tavg1_2d_lnd_Nx.GEOS5124.20220622_1330.V01.nc4'
@pytest.fixture
def geos_ocean():
return 'GEOS.fpit.asm.tavg1_2d_ocn_Nx.GEOS5124.20220622_1330.V01.nc4'
@pytest.fixture
def geos_constants():
return 'GEOS.fp.asm.const_2d_asm_Nx.00000000_0000.V01.nc4'
@pytest.fixture
def ref_file(fixturepath):
return os.path.join(fixturepath, 'ref_ancillary.nc')
def test_sst(fixturepath, sst_file, ref_file):
viirs = rd.ReadData(satellite='snpp',
sensor='viirs')
geo = viirs.read_viirs_geo()
ancillary = rd.ReadAncillary(latitude=geo.latitude.values,
longitude=geo.longitude.values,
resolution=1,
ancillary_dir=fixturepath,
sst_file=sst_file)
sst = ancillary.get_sst()
check_differences(ref_file, sst, 'sst')
def test_ndvi(fixturepath, ndvi_file, ref_file):
viirs = rd.ReadData(satellite='snpp',
sensor='viirs')
geo = viirs.read_viirs_geo()
ancillary = rd.ReadAncillary(latitude=geo.latitude.values,
longitude=geo.longitude.values,
resolution=1,
ancillary_dir=fixturepath,
ndvi_file=ndvi_file)
ndvi = ancillary.get_ndvi()
check_differences(ref_file, ndvi, 'ndvi')
def test_geos(fixturepath, geos_file_1, geos_file_2, geos_land, geos_ocean,
geos_constants, ref_file):
viirs = rd.ReadData(satellite='snpp',
sensor='viirs')
geo = viirs.read_viirs_geo()
ancillary = rd.ReadAncillary(latitude=geo.latitude.values,
longitude=geo.longitude.values,
resolution=1,
ancillary_dir=fixturepath,
geos_file_1=geos_file_1,
geos_file_2=geos_file_2,
geos_land=geos_land,
geos_ocean=geos_ocean,
geos_constants=geos_constants)
geos_data = ancillary.get_geos()
for var in list(geos_data.keys()):
check_differences(ref_file, geos_data[var], f'geos_{var}')
def check_differences(ref_file, test_data, var_name):
ref_data = xr.open_dataset(ref_file)
check = np.allclose(ref_data[var_name].values, test_data, equal_nan=True)
assert check