cloudnetpy 1.49.9__py3-none-any.whl → 1.87.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cloudnetpy/categorize/__init__.py +1 -2
- cloudnetpy/categorize/atmos_utils.py +297 -67
- cloudnetpy/categorize/attenuation.py +31 -0
- cloudnetpy/categorize/attenuations/__init__.py +37 -0
- cloudnetpy/categorize/attenuations/gas_attenuation.py +30 -0
- cloudnetpy/categorize/attenuations/liquid_attenuation.py +84 -0
- cloudnetpy/categorize/attenuations/melting_attenuation.py +78 -0
- cloudnetpy/categorize/attenuations/rain_attenuation.py +84 -0
- cloudnetpy/categorize/categorize.py +332 -156
- cloudnetpy/categorize/classify.py +127 -125
- cloudnetpy/categorize/containers.py +107 -76
- cloudnetpy/categorize/disdrometer.py +40 -0
- cloudnetpy/categorize/droplet.py +23 -21
- cloudnetpy/categorize/falling.py +53 -24
- cloudnetpy/categorize/freezing.py +25 -12
- cloudnetpy/categorize/insects.py +35 -23
- cloudnetpy/categorize/itu.py +243 -0
- cloudnetpy/categorize/lidar.py +36 -41
- cloudnetpy/categorize/melting.py +34 -26
- cloudnetpy/categorize/model.py +84 -37
- cloudnetpy/categorize/mwr.py +18 -14
- cloudnetpy/categorize/radar.py +215 -102
- cloudnetpy/cli.py +578 -0
- cloudnetpy/cloudnetarray.py +43 -89
- cloudnetpy/concat_lib.py +218 -78
- cloudnetpy/constants.py +28 -10
- cloudnetpy/datasource.py +61 -86
- cloudnetpy/exceptions.py +49 -20
- cloudnetpy/instruments/__init__.py +5 -0
- cloudnetpy/instruments/basta.py +29 -12
- cloudnetpy/instruments/bowtie.py +135 -0
- cloudnetpy/instruments/ceilo.py +138 -115
- cloudnetpy/instruments/ceilometer.py +164 -80
- cloudnetpy/instruments/cl61d.py +21 -5
- cloudnetpy/instruments/cloudnet_instrument.py +74 -36
- cloudnetpy/instruments/copernicus.py +108 -30
- cloudnetpy/instruments/da10.py +54 -0
- cloudnetpy/instruments/disdrometer/common.py +126 -223
- cloudnetpy/instruments/disdrometer/parsivel.py +453 -94
- cloudnetpy/instruments/disdrometer/thies.py +254 -87
- cloudnetpy/instruments/fd12p.py +201 -0
- cloudnetpy/instruments/galileo.py +65 -23
- cloudnetpy/instruments/hatpro.py +123 -49
- cloudnetpy/instruments/instruments.py +113 -1
- cloudnetpy/instruments/lufft.py +39 -17
- cloudnetpy/instruments/mira.py +268 -61
- cloudnetpy/instruments/mrr.py +187 -0
- cloudnetpy/instruments/nc_lidar.py +19 -8
- cloudnetpy/instruments/nc_radar.py +109 -55
- cloudnetpy/instruments/pollyxt.py +135 -51
- cloudnetpy/instruments/radiometrics.py +313 -59
- cloudnetpy/instruments/rain_e_h3.py +171 -0
- cloudnetpy/instruments/rpg.py +321 -189
- cloudnetpy/instruments/rpg_reader.py +74 -40
- cloudnetpy/instruments/toa5.py +49 -0
- cloudnetpy/instruments/vaisala.py +95 -343
- cloudnetpy/instruments/weather_station.py +774 -105
- cloudnetpy/metadata.py +90 -19
- cloudnetpy/model_evaluation/file_handler.py +55 -52
- cloudnetpy/model_evaluation/metadata.py +46 -20
- cloudnetpy/model_evaluation/model_metadata.py +1 -1
- cloudnetpy/model_evaluation/plotting/plot_tools.py +32 -37
- cloudnetpy/model_evaluation/plotting/plotting.py +327 -117
- cloudnetpy/model_evaluation/products/advance_methods.py +92 -83
- cloudnetpy/model_evaluation/products/grid_methods.py +88 -63
- cloudnetpy/model_evaluation/products/model_products.py +43 -35
- cloudnetpy/model_evaluation/products/observation_products.py +41 -35
- cloudnetpy/model_evaluation/products/product_resampling.py +17 -7
- cloudnetpy/model_evaluation/products/tools.py +29 -20
- cloudnetpy/model_evaluation/statistics/statistical_methods.py +30 -20
- cloudnetpy/model_evaluation/tests/e2e/conftest.py +3 -3
- cloudnetpy/model_evaluation/tests/e2e/process_cf/main.py +9 -5
- cloudnetpy/model_evaluation/tests/e2e/process_cf/tests.py +15 -14
- cloudnetpy/model_evaluation/tests/e2e/process_iwc/main.py +9 -5
- cloudnetpy/model_evaluation/tests/e2e/process_iwc/tests.py +15 -14
- cloudnetpy/model_evaluation/tests/e2e/process_lwc/main.py +9 -5
- cloudnetpy/model_evaluation/tests/e2e/process_lwc/tests.py +15 -14
- cloudnetpy/model_evaluation/tests/unit/conftest.py +42 -41
- cloudnetpy/model_evaluation/tests/unit/test_advance_methods.py +41 -48
- cloudnetpy/model_evaluation/tests/unit/test_grid_methods.py +216 -194
- cloudnetpy/model_evaluation/tests/unit/test_model_products.py +23 -21
- cloudnetpy/model_evaluation/tests/unit/test_observation_products.py +37 -38
- cloudnetpy/model_evaluation/tests/unit/test_plot_tools.py +43 -40
- cloudnetpy/model_evaluation/tests/unit/test_plotting.py +30 -36
- cloudnetpy/model_evaluation/tests/unit/test_statistical_methods.py +68 -31
- cloudnetpy/model_evaluation/tests/unit/test_tools.py +33 -26
- cloudnetpy/model_evaluation/utils.py +2 -1
- cloudnetpy/output.py +170 -111
- cloudnetpy/plotting/__init__.py +2 -1
- cloudnetpy/plotting/plot_meta.py +562 -822
- cloudnetpy/plotting/plotting.py +1142 -704
- cloudnetpy/products/__init__.py +1 -0
- cloudnetpy/products/classification.py +370 -88
- cloudnetpy/products/der.py +85 -55
- cloudnetpy/products/drizzle.py +77 -34
- cloudnetpy/products/drizzle_error.py +15 -11
- cloudnetpy/products/drizzle_tools.py +79 -59
- cloudnetpy/products/epsilon.py +211 -0
- cloudnetpy/products/ier.py +27 -50
- cloudnetpy/products/iwc.py +55 -48
- cloudnetpy/products/lwc.py +96 -70
- cloudnetpy/products/mwr_tools.py +186 -0
- cloudnetpy/products/product_tools.py +170 -128
- cloudnetpy/utils.py +455 -240
- cloudnetpy/version.py +2 -2
- {cloudnetpy-1.49.9.dist-info → cloudnetpy-1.87.3.dist-info}/METADATA +44 -40
- cloudnetpy-1.87.3.dist-info/RECORD +127 -0
- {cloudnetpy-1.49.9.dist-info → cloudnetpy-1.87.3.dist-info}/WHEEL +1 -1
- cloudnetpy-1.87.3.dist-info/entry_points.txt +2 -0
- docs/source/conf.py +2 -2
- cloudnetpy/categorize/atmos.py +0 -361
- cloudnetpy/products/mwr_multi.py +0 -68
- cloudnetpy/products/mwr_single.py +0 -75
- cloudnetpy-1.49.9.dist-info/RECORD +0 -112
- {cloudnetpy-1.49.9.dist-info → cloudnetpy-1.87.3.dist-info/licenses}/LICENSE +0 -0
- {cloudnetpy-1.49.9.dist-info → cloudnetpy-1.87.3.dist-info}/top_level.txt +0 -0
|
@@ -39,16 +39,16 @@ PRODUCT = "iwc"
|
|
|
39
39
|
("lwc", ("lwc_ecmwf", "lwc_ecmwf", "lwc_adv_ecmwf")),
|
|
40
40
|
],
|
|
41
41
|
)
|
|
42
|
-
def test_generate_regrid_product(model_file, obs_file, product, variables):
|
|
42
|
+
def test_generate_regrid_product(model_file, obs_file, product, variables) -> None:
|
|
43
43
|
obs = ObservationManager(product, str(obs_file))
|
|
44
44
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, product)
|
|
45
45
|
ProductGrid(model, obs)
|
|
46
46
|
for var in variables:
|
|
47
|
-
assert var in model.data
|
|
47
|
+
assert var in model.data
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
@pytest.mark.parametrize("key, value", [("iwc", 3), ("lwc", 1), ("cf", 2)])
|
|
51
|
-
def test_get_method_storage(key, value, model_file, obs_file):
|
|
51
|
+
def test_get_method_storage(key, value, model_file, obs_file) -> None:
|
|
52
52
|
obs = ObservationManager(key, str(obs_file))
|
|
53
53
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, key)
|
|
54
54
|
obj = ProductGrid(model, obs)
|
|
@@ -57,7 +57,7 @@ def test_get_method_storage(key, value, model_file, obs_file):
|
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
@pytest.mark.parametrize("key, value", [("iwc", 3), ("lwc", 1), ("cf", 2)])
|
|
60
|
-
def test_get_method_storage_adv(key, value, model_file, obs_file):
|
|
60
|
+
def test_get_method_storage_adv(key, value, model_file, obs_file) -> None:
|
|
61
61
|
obs = ObservationManager(key, str(obs_file))
|
|
62
62
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, key)
|
|
63
63
|
obj = ProductGrid(model, obs)
|
|
@@ -66,34 +66,34 @@ def test_get_method_storage_adv(key, value, model_file, obs_file):
|
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
@pytest.mark.parametrize("name", ["cf_V", "cf_A"])
|
|
69
|
-
def test_cf_method_storage(name, model_file, obs_file):
|
|
69
|
+
def test_cf_method_storage(name, model_file, obs_file) -> None:
|
|
70
70
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
71
71
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
72
72
|
obj = ProductGrid(model, obs)
|
|
73
73
|
x, y = obj._cf_method_storage()
|
|
74
|
-
assert name in x
|
|
74
|
+
assert name in x
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
@pytest.mark.parametrize("name", ["cf_V_adv", "cf_A_adv"])
|
|
78
|
-
def test_cf_method_storage_adv(name, model_file, obs_file):
|
|
78
|
+
def test_cf_method_storage_adv(name, model_file, obs_file) -> None:
|
|
79
79
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
80
80
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
81
81
|
obj = ProductGrid(model, obs)
|
|
82
82
|
x, y = obj._cf_method_storage()
|
|
83
|
-
assert name in y
|
|
83
|
+
assert name in y
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
@pytest.mark.parametrize("name", ["iwc", "iwc_att", "iwc_rain"])
|
|
87
|
-
def test_iwc_method_storage(name, model_file, obs_file):
|
|
87
|
+
def test_iwc_method_storage(name, model_file, obs_file) -> None:
|
|
88
88
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
89
89
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
90
90
|
obj = ProductGrid(model, obs)
|
|
91
91
|
x, y = obj._iwc_method_storage()
|
|
92
|
-
assert name in x
|
|
92
|
+
assert name in x
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
@pytest.mark.parametrize("name", ["iwc_adv", "iwc_att_adv", "iwc_rain_adv"])
|
|
96
|
-
def test_iwc_method_storage_adv(name, model_file, obs_file):
|
|
96
|
+
def test_iwc_method_storage_adv(name, model_file, obs_file) -> None:
|
|
97
97
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
98
98
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
99
99
|
obj = ProductGrid(model, obs)
|
|
@@ -101,7 +101,7 @@ def test_iwc_method_storage_adv(name, model_file, obs_file):
|
|
|
101
101
|
assert name in y
|
|
102
102
|
|
|
103
103
|
|
|
104
|
-
def test_product_method_storage(model_file, obs_file):
|
|
104
|
+
def test_product_method_storage(model_file, obs_file) -> None:
|
|
105
105
|
obs = ObservationManager("lwc", str(obs_file))
|
|
106
106
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, "lwc")
|
|
107
107
|
obj = ProductGrid(model, obs)
|
|
@@ -109,7 +109,7 @@ def test_product_method_storage(model_file, obs_file):
|
|
|
109
109
|
assert "lwc" in x
|
|
110
110
|
|
|
111
111
|
|
|
112
|
-
def test_product_method_storage_adv(model_file, obs_file):
|
|
112
|
+
def test_product_method_storage_adv(model_file, obs_file) -> None:
|
|
113
113
|
obs = ObservationManager("lwc", str(obs_file))
|
|
114
114
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, "lwc")
|
|
115
115
|
obj = ProductGrid(model, obs)
|
|
@@ -117,146 +117,139 @@ def test_product_method_storage_adv(model_file, obs_file):
|
|
|
117
117
|
assert "lwc_adv" in y
|
|
118
118
|
|
|
119
119
|
|
|
120
|
-
def test_regrid_cf_area(model_file, obs_file):
|
|
120
|
+
def test_regrid_cf_area(model_file, obs_file) -> None:
|
|
121
121
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
122
122
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
123
123
|
obj = ProductGrid(model, obs)
|
|
124
124
|
data = ma.array([[1, 1, 1], [0, 1, 1], [0, 0, 1], [0, 0, 0]])
|
|
125
|
-
d = {"cf_A":
|
|
125
|
+
d = {"cf_A": ma.zeros((1, 1))}
|
|
126
126
|
d = obj._regrid_cf(d, 0, 0, data)
|
|
127
127
|
x = d["cf_A"]
|
|
128
128
|
assert x[0, 0] == 0.75
|
|
129
129
|
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
# obs = ObservationManager(PRODUCT, str(obs_file))
|
|
133
|
-
# model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
134
|
-
# obj = ProductGrid(model, obs)
|
|
135
|
-
# data = np.array([])
|
|
136
|
-
# d = {"cf_A": np.zeros((1, 1))}
|
|
137
|
-
# d = obj._regrid_cf(d, 0, 0, data)
|
|
138
|
-
# x = d["cf_A"]
|
|
139
|
-
# assert np.isnan(x[0, 0])
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
def test_regrid_cf_area_masked(model_file, obs_file):
|
|
131
|
+
def test_regrid_cf_area_masked(model_file, obs_file) -> None:
|
|
143
132
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
144
133
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
145
134
|
obj = ProductGrid(model, obs)
|
|
146
135
|
data = ma.array([[1, 1, 1], [0, 1, 1], [0, 0, 1], [0, 0, 0]])
|
|
147
136
|
data[1, :] = ma.masked
|
|
148
|
-
d = {"cf_A":
|
|
137
|
+
d = {"cf_A": ma.zeros((1, 1))}
|
|
149
138
|
d = obj._regrid_cf(d, 0, 0, data)
|
|
150
139
|
x = d["cf_A"]
|
|
151
140
|
assert round(x[0, 0], 3) == 0.667
|
|
152
141
|
|
|
153
142
|
|
|
154
|
-
def test_regrid_cf_area_all_masked(model_file, obs_file):
|
|
143
|
+
def test_regrid_cf_area_all_masked(model_file, obs_file) -> None:
|
|
155
144
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
156
145
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
157
146
|
obj = ProductGrid(model, obs)
|
|
158
147
|
data = ma.array([[1, 1, 1], [0, 1, 1], [0, 0, 1], [0, 0, 0]])
|
|
159
148
|
data[:, :] = ma.masked
|
|
160
|
-
d = {"cf_A":
|
|
149
|
+
d = {"cf_A": ma.zeros((1, 1))}
|
|
161
150
|
d = obj._regrid_cf(d, 0, 0, data)
|
|
162
151
|
x = d["cf_A"]
|
|
163
|
-
testing.assert_equal(x,
|
|
152
|
+
testing.assert_equal(x, ma.masked)
|
|
164
153
|
|
|
165
154
|
|
|
166
|
-
def test_regrid_cf_area_nan(model_file, obs_file):
|
|
155
|
+
def test_regrid_cf_area_nan(model_file, obs_file) -> None:
|
|
167
156
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
168
157
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
169
158
|
obj = ProductGrid(model, obs)
|
|
170
|
-
data = ma.array([[1,
|
|
171
|
-
|
|
159
|
+
data = ma.array([[1, 99, 1], [0, 1, 1], [99, 0, 1], [0, 0, 0]])
|
|
160
|
+
data = ma.masked_where(data == 99, data)
|
|
161
|
+
d = {"cf_A": ma.zeros((1, 1))}
|
|
172
162
|
d = obj._regrid_cf(d, 0, 0, data)
|
|
173
163
|
x = d["cf_A"]
|
|
174
164
|
assert x[0, 0] == 0.75
|
|
175
165
|
|
|
176
166
|
|
|
177
|
-
def test_regrid_cf_area_all_nan(model_file, obs_file):
|
|
167
|
+
def test_regrid_cf_area_all_nan(model_file, obs_file) -> None:
|
|
178
168
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
179
169
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
180
170
|
obj = ProductGrid(model, obs)
|
|
181
171
|
data = ma.array(
|
|
182
172
|
[
|
|
183
|
-
[
|
|
184
|
-
[
|
|
185
|
-
[
|
|
186
|
-
[
|
|
187
|
-
]
|
|
173
|
+
[1, 1, 1],
|
|
174
|
+
[1, 1, 1],
|
|
175
|
+
[1, 1, 1],
|
|
176
|
+
[1, 1, 1],
|
|
177
|
+
],
|
|
178
|
+
mask=True,
|
|
188
179
|
)
|
|
189
|
-
d = {"cf_A":
|
|
180
|
+
d = {"cf_A": ma.zeros((1, 1))}
|
|
190
181
|
d = obj._regrid_cf(d, 0, 0, data)
|
|
191
182
|
x = d["cf_A"]
|
|
192
|
-
testing.assert_equal(x,
|
|
183
|
+
testing.assert_equal(x, ma.masked)
|
|
193
184
|
|
|
194
185
|
|
|
195
|
-
def test_regrid_cf_volume(model_file, obs_file):
|
|
186
|
+
def test_regrid_cf_volume(model_file, obs_file) -> None:
|
|
196
187
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
197
188
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
198
189
|
obj = ProductGrid(model, obs)
|
|
199
190
|
data = ma.array([[1, 1, 1], [0, 1, 1], [0, 0, 1], [0, 0, 0]])
|
|
200
|
-
d = {"cf_V":
|
|
191
|
+
d = {"cf_V": ma.zeros((1, 1))}
|
|
201
192
|
d = obj._regrid_cf(d, 0, 0, data)
|
|
202
193
|
x = d["cf_V"]
|
|
203
194
|
assert x[0, 0] == 0.5
|
|
204
195
|
|
|
205
196
|
|
|
206
|
-
def test_regrid_cf_volume_nan(model_file, obs_file):
|
|
197
|
+
def test_regrid_cf_volume_nan(model_file, obs_file) -> None:
|
|
207
198
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
208
199
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
209
200
|
obj = ProductGrid(model, obs)
|
|
210
|
-
data = ma.array([[1,
|
|
211
|
-
|
|
201
|
+
data = ma.array([[1, 99, 1], [0, 1, 1], [99, 0, 1], [0, 0, 0]])
|
|
202
|
+
data = ma.masked_where(data == 99, data)
|
|
203
|
+
d = {"cf_V": ma.zeros((1, 1))}
|
|
212
204
|
d = obj._regrid_cf(d, 0, 0, data)
|
|
213
205
|
x = d["cf_V"]
|
|
214
206
|
assert x[0, 0] == 0.5
|
|
215
207
|
|
|
216
208
|
|
|
217
|
-
def test_regrid_cf_volume_all_nan(model_file, obs_file):
|
|
209
|
+
def test_regrid_cf_volume_all_nan(model_file, obs_file) -> None:
|
|
218
210
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
219
211
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
220
212
|
obj = ProductGrid(model, obs)
|
|
221
213
|
data = ma.array(
|
|
222
214
|
[
|
|
223
|
-
[
|
|
224
|
-
[
|
|
225
|
-
[
|
|
226
|
-
[
|
|
227
|
-
]
|
|
215
|
+
[99, 99, 99],
|
|
216
|
+
[99, 99, 99],
|
|
217
|
+
[99, 99, 99],
|
|
218
|
+
[99, 99, 99],
|
|
219
|
+
],
|
|
228
220
|
)
|
|
229
|
-
|
|
221
|
+
data = ma.masked_where(data == 99, data)
|
|
222
|
+
d = {"cf_V": ma.zeros((1, 1))}
|
|
230
223
|
d = obj._regrid_cf(d, 0, 0, data)
|
|
231
224
|
x = d["cf_V"]
|
|
232
|
-
testing.assert_equal(x,
|
|
225
|
+
testing.assert_equal(x, ma.masked)
|
|
233
226
|
|
|
234
227
|
|
|
235
|
-
def test_regrid_cf_volume_masked(model_file, obs_file):
|
|
228
|
+
def test_regrid_cf_volume_masked(model_file, obs_file) -> None:
|
|
236
229
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
237
230
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
238
231
|
obj = ProductGrid(model, obs)
|
|
239
232
|
data = ma.array([[1, 1, 1], [0, 1, 1], [0, 0, 1], [0, 0, 0]])
|
|
240
233
|
data[1, :] = ma.masked
|
|
241
|
-
d = {"cf_V":
|
|
234
|
+
d = {"cf_V": ma.zeros((1, 1))}
|
|
242
235
|
d = obj._regrid_cf(d, 0, 0, data)
|
|
243
236
|
x = d["cf_V"]
|
|
244
237
|
assert round(x[0, 0], 3) == 0.444
|
|
245
238
|
|
|
246
239
|
|
|
247
|
-
def test_regrid_cf_volume_all_masked(model_file, obs_file):
|
|
240
|
+
def test_regrid_cf_volume_all_masked(model_file, obs_file) -> None:
|
|
248
241
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
249
242
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
250
243
|
obj = ProductGrid(model, obs)
|
|
251
244
|
data = ma.array([[1, 1, 1], [0, 1, 1], [0, 0, 1], [0, 0, 0]])
|
|
252
245
|
data[:, :] = ma.masked
|
|
253
|
-
d = {"cf_V":
|
|
246
|
+
d = {"cf_V": ma.zeros((1, 1))}
|
|
254
247
|
d = obj._regrid_cf(d, 0, 0, data)
|
|
255
248
|
x = d["cf_V"]
|
|
256
|
-
testing.assert_equal(x,
|
|
249
|
+
testing.assert_equal(x, ma.masked)
|
|
257
250
|
|
|
258
251
|
|
|
259
|
-
def test_reshape_data_to_window(model_file, obs_file):
|
|
252
|
+
def test_reshape_data_to_window(model_file, obs_file) -> None:
|
|
260
253
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
261
254
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
262
255
|
obj = ProductGrid(model, obs)
|
|
@@ -281,7 +274,7 @@ def test_reshape_data_to_window(model_file, obs_file):
|
|
|
281
274
|
[5, 6, 7, 8],
|
|
282
275
|
[55, 66, 77, 88],
|
|
283
276
|
[555, 666, 777, 888],
|
|
284
|
-
]
|
|
277
|
+
],
|
|
285
278
|
)
|
|
286
279
|
x = obj._reshape_data_to_window(ind, xnd, ynd)
|
|
287
280
|
compare = np.array([[1, 2], [11, 22], [111, 222]])
|
|
@@ -289,7 +282,7 @@ def test_reshape_data_to_window(model_file, obs_file):
|
|
|
289
282
|
testing.assert_array_almost_equal(x, compare)
|
|
290
283
|
|
|
291
284
|
|
|
292
|
-
def test_reshape_data_to_window_middle(model_file, obs_file):
|
|
285
|
+
def test_reshape_data_to_window_middle(model_file, obs_file) -> None:
|
|
293
286
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
294
287
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
295
288
|
obj = ProductGrid(model, obs)
|
|
@@ -314,7 +307,7 @@ def test_reshape_data_to_window_middle(model_file, obs_file):
|
|
|
314
307
|
[5, 6, 7, 8],
|
|
315
308
|
[55, 66, 77, 88],
|
|
316
309
|
[555, 666, 777, 888],
|
|
317
|
-
]
|
|
310
|
+
],
|
|
318
311
|
)
|
|
319
312
|
x = obj._reshape_data_to_window(ind, xnd, ynd)
|
|
320
313
|
compare = np.array([[222, 333], [6, 7], [66, 77]])
|
|
@@ -322,7 +315,7 @@ def test_reshape_data_to_window_middle(model_file, obs_file):
|
|
|
322
315
|
testing.assert_array_almost_equal(x, compare)
|
|
323
316
|
|
|
324
317
|
|
|
325
|
-
def test_reshape_data_to_window_empty(model_file, obs_file):
|
|
318
|
+
def test_reshape_data_to_window_empty(model_file, obs_file) -> None:
|
|
326
319
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
327
320
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
328
321
|
obj = ProductGrid(model, obs)
|
|
@@ -334,7 +327,7 @@ def test_reshape_data_to_window_empty(model_file, obs_file):
|
|
|
334
327
|
0,
|
|
335
328
|
0,
|
|
336
329
|
0,
|
|
337
|
-
]
|
|
330
|
+
],
|
|
338
331
|
)
|
|
339
332
|
ynd = np.array([0, 0, 0, 0])
|
|
340
333
|
ind = np.array([1, 1, 0, 0], dtype=bool)
|
|
@@ -342,114 +335,120 @@ def test_reshape_data_to_window_empty(model_file, obs_file):
|
|
|
342
335
|
assert x is None
|
|
343
336
|
|
|
344
337
|
|
|
345
|
-
def test_regrid_iwc(model_file, obs_file):
|
|
338
|
+
def test_regrid_iwc(model_file, obs_file) -> None:
|
|
346
339
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
347
340
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
348
341
|
obj = ProductGrid(model, obs)
|
|
349
342
|
obj._obs_data = ma.array([[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 3]])
|
|
350
|
-
d = {"iwc":
|
|
351
|
-
ind = ma.array([[0, 1, 1, 1]], dtype=bool)
|
|
352
|
-
no_rain = ma.array(
|
|
353
|
-
[[0, 1, 1, 1], [0, 0, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]],
|
|
343
|
+
d = {"iwc": ma.zeros((1, 1))}
|
|
344
|
+
ind: ma.MaskedArray = ma.array([[0, 1, 1, 1]], dtype=bool)
|
|
345
|
+
no_rain: ma.MaskedArray = ma.array(
|
|
346
|
+
[[0, 1, 1, 1], [0, 0, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]],
|
|
347
|
+
dtype=bool,
|
|
354
348
|
)
|
|
355
349
|
d = obj._regrid_iwc(d, 0, 0, ind, no_rain)
|
|
356
350
|
x = d["iwc"]
|
|
357
351
|
testing.assert_almost_equal(x[0, 0], 1.4)
|
|
358
352
|
|
|
359
353
|
|
|
360
|
-
def test_regrid_iwc_nan(model_file, obs_file):
|
|
354
|
+
def test_regrid_iwc_nan(model_file, obs_file) -> None:
|
|
361
355
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
362
356
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
363
357
|
obj = ProductGrid(model, obs)
|
|
364
358
|
obj._obs_data = ma.array(
|
|
365
|
-
[[1, 1,
|
|
359
|
+
[[1, 1, 99, 1], [2, 99, 2, 2], [3, 3, 3, 3], [4, 4, 4, 99]],
|
|
366
360
|
)
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
361
|
+
obj._obs_data = ma.masked_where(obj._obs_data == 99, obj._obs_data)
|
|
362
|
+
d = {"iwc": ma.zeros((1, 1))}
|
|
363
|
+
ind: ma.MaskedArray = ma.array([[0, 1, 1, 1]], dtype=bool)
|
|
364
|
+
no_rain: ma.MaskedArray = ma.array(
|
|
365
|
+
[[0, 1, 1, 1], [0, 0, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]],
|
|
366
|
+
dtype=bool,
|
|
371
367
|
)
|
|
372
368
|
d = obj._regrid_iwc(d, 0, 0, ind, no_rain)
|
|
373
369
|
x = d["iwc"]
|
|
374
370
|
testing.assert_almost_equal(x[0, 0], 1.5)
|
|
375
371
|
|
|
376
372
|
|
|
377
|
-
def test_regrid_iwc_all_nan(model_file, obs_file):
|
|
373
|
+
def test_regrid_iwc_all_nan(model_file, obs_file) -> None:
|
|
378
374
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
379
375
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
380
376
|
obj = ProductGrid(model, obs)
|
|
381
377
|
obj._obs_data = ma.array(
|
|
382
378
|
[
|
|
383
|
-
[
|
|
384
|
-
[
|
|
385
|
-
[
|
|
386
|
-
[
|
|
387
|
-
]
|
|
388
|
-
)
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
379
|
+
[99, 99, 99, 99],
|
|
380
|
+
[99, 99, 99, 99],
|
|
381
|
+
[99, 99, 99, 99],
|
|
382
|
+
[99, 99, 99, 99],
|
|
383
|
+
],
|
|
384
|
+
)
|
|
385
|
+
obj._obs_data = ma.masked_where(obj._obs_data == 99, obj._obs_data)
|
|
386
|
+
d = {"iwc": ma.zeros((1, 1))}
|
|
387
|
+
ind: ma.MaskedArray = ma.array([[0, 1, 1, 1]], dtype=bool)
|
|
388
|
+
no_rain: ma.MaskedArray = ma.array(
|
|
389
|
+
[[0, 1, 1, 1], [0, 0, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]],
|
|
390
|
+
dtype=bool,
|
|
393
391
|
)
|
|
394
392
|
d = obj._regrid_iwc(d, 0, 0, ind, no_rain)
|
|
395
|
-
|
|
396
|
-
testing.assert_almost_equal(x[0, 0], np.nan)
|
|
393
|
+
assert d["iwc"][0, 0].mask == True
|
|
397
394
|
|
|
398
395
|
|
|
399
|
-
def test_regrid_iwc_masked(model_file, obs_file):
|
|
396
|
+
def test_regrid_iwc_masked(model_file, obs_file) -> None:
|
|
400
397
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
401
398
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
402
399
|
obj = ProductGrid(model, obs)
|
|
403
400
|
obj._obs_data = ma.array([[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]])
|
|
404
401
|
obj._obs_data[1, :] = ma.masked
|
|
405
|
-
d = {"iwc":
|
|
406
|
-
ind = ma.array([[0, 1, 1, 1]], dtype=bool)
|
|
407
|
-
no_rain = ma.array(
|
|
408
|
-
[[0, 1, 1, 1], [0, 0, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]],
|
|
402
|
+
d = {"iwc": ma.zeros((1, 1))}
|
|
403
|
+
ind: ma.MaskedArray = ma.array([[0, 1, 1, 1]], dtype=bool)
|
|
404
|
+
no_rain: ma.MaskedArray = ma.array(
|
|
405
|
+
[[0, 1, 1, 1], [0, 0, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]],
|
|
406
|
+
dtype=bool,
|
|
409
407
|
)
|
|
410
408
|
d = obj._regrid_iwc(d, 0, 0, ind, no_rain)
|
|
411
409
|
x = d["iwc"]
|
|
412
410
|
testing.assert_almost_equal(x[0, 0], 1.0)
|
|
413
411
|
|
|
414
412
|
|
|
415
|
-
def test_regrid_iwc_all_masked(model_file, obs_file):
|
|
413
|
+
def test_regrid_iwc_all_masked(model_file, obs_file) -> None:
|
|
416
414
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
417
415
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
418
416
|
obj = ProductGrid(model, obs)
|
|
419
|
-
obj._obs_data = ma.array(
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
417
|
+
obj._obs_data = ma.array(
|
|
418
|
+
[[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]], mask=True
|
|
419
|
+
)
|
|
420
|
+
d = {"iwc": ma.zeros((1, 1))}
|
|
421
|
+
ind: ma.MaskedArray = ma.array([[0, 1, 1, 1]], dtype=bool)
|
|
422
|
+
no_rain: ma.MaskedArray = ma.array(
|
|
423
|
+
[[0, 1, 1, 1], [0, 0, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]],
|
|
424
|
+
dtype=bool,
|
|
425
425
|
)
|
|
426
426
|
d = obj._regrid_iwc(d, 0, 0, ind, no_rain)
|
|
427
|
-
|
|
428
|
-
testing.assert_almost_equal(x[0, 0], np.nan)
|
|
427
|
+
assert d["iwc"][0, 0].mask == True
|
|
429
428
|
|
|
430
429
|
|
|
431
|
-
def test_regrid_iwc_none(model_file, obs_file):
|
|
430
|
+
def test_regrid_iwc_none(model_file, obs_file) -> None:
|
|
432
431
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
433
432
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
434
433
|
obj = ProductGrid(model, obs)
|
|
435
434
|
obj._obs_data = ma.array([[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]])
|
|
436
|
-
d = {"iwc":
|
|
437
|
-
ind = ma.array([[0, 1, 1, 1]], dtype=bool)
|
|
438
|
-
no_rain = ma.array(
|
|
439
|
-
[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],
|
|
435
|
+
d = {"iwc": ma.zeros((1, 1))}
|
|
436
|
+
ind: ma.MaskedArray = ma.array([[0, 1, 1, 1]], dtype=bool)
|
|
437
|
+
no_rain: ma.MaskedArray = ma.array(
|
|
438
|
+
[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],
|
|
439
|
+
dtype=bool,
|
|
440
440
|
)
|
|
441
441
|
d = obj._regrid_iwc(d, 0, 0, ind, no_rain)
|
|
442
|
-
|
|
443
|
-
testing.assert_equal(x[0, 0], np.nan)
|
|
442
|
+
assert d["iwc"][0, 0].mask == True
|
|
444
443
|
|
|
445
444
|
|
|
446
|
-
def test_regrid_iwc_att(model_file, obs_file):
|
|
445
|
+
def test_regrid_iwc_att(model_file, obs_file) -> None:
|
|
447
446
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
448
447
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
449
448
|
obj = ProductGrid(model, obs)
|
|
450
|
-
d = {"iwc_att":
|
|
451
|
-
ind = ma.array([[0, 1, 1, 1]], dtype=bool)
|
|
452
|
-
no_rain = ma.array(
|
|
449
|
+
d = {"iwc_att": ma.zeros((1, 1))}
|
|
450
|
+
ind: ma.MaskedArray = ma.array([[0, 1, 1, 1]], dtype=bool)
|
|
451
|
+
no_rain: ma.MaskedArray = ma.array(
|
|
453
452
|
[
|
|
454
453
|
[0, 1, 1, 1],
|
|
455
454
|
[0, 0, 1, 1],
|
|
@@ -465,7 +464,7 @@ def test_regrid_iwc_att(model_file, obs_file):
|
|
|
465
464
|
testing.assert_almost_equal(x[0, 0], 0.018)
|
|
466
465
|
|
|
467
466
|
|
|
468
|
-
def test_regrid_iwc_att_masked(model_file, obs_file):
|
|
467
|
+
def test_regrid_iwc_att_masked(model_file, obs_file) -> None:
|
|
469
468
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
470
469
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
471
470
|
obj = ProductGrid(model, obs)
|
|
@@ -480,9 +479,9 @@ def test_regrid_iwc_att_masked(model_file, obs_file):
|
|
|
480
479
|
],
|
|
481
480
|
dtype=bool,
|
|
482
481
|
)
|
|
483
|
-
d = {"iwc_att":
|
|
484
|
-
ind = ma.array([[0, 1, 1, 1]], dtype=bool)
|
|
485
|
-
no_rain = ma.array(
|
|
482
|
+
d = {"iwc_att": ma.zeros((1, 1))}
|
|
483
|
+
ind: ma.MaskedArray = ma.array([[0, 1, 1, 1]], dtype=bool)
|
|
484
|
+
no_rain: ma.MaskedArray = ma.array(
|
|
486
485
|
[
|
|
487
486
|
[0, 1, 1, 1],
|
|
488
487
|
[0, 0, 1, 1],
|
|
@@ -498,7 +497,7 @@ def test_regrid_iwc_att_masked(model_file, obs_file):
|
|
|
498
497
|
testing.assert_almost_equal(x[0, 0], 0.018)
|
|
499
498
|
|
|
500
499
|
|
|
501
|
-
def test_regrid_iwc_att_all_masked(model_file, obs_file):
|
|
500
|
+
def test_regrid_iwc_att_all_masked(model_file, obs_file) -> None:
|
|
502
501
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
503
502
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
504
503
|
obj = ProductGrid(model, obs)
|
|
@@ -513,9 +512,9 @@ def test_regrid_iwc_att_all_masked(model_file, obs_file):
|
|
|
513
512
|
],
|
|
514
513
|
dtype=bool,
|
|
515
514
|
)
|
|
516
|
-
d = {"iwc_att":
|
|
517
|
-
ind = ma.array([[0, 1, 1, 1]], dtype=bool)
|
|
518
|
-
no_rain = ma.array(
|
|
515
|
+
d = {"iwc_att": ma.zeros((1, 1))}
|
|
516
|
+
ind: ma.MaskedArray = ma.array([[0, 1, 1, 1]], dtype=bool)
|
|
517
|
+
no_rain: ma.MaskedArray = ma.array(
|
|
519
518
|
[
|
|
520
519
|
[0, 1, 1, 1],
|
|
521
520
|
[0, 0, 1, 1],
|
|
@@ -528,16 +527,17 @@ def test_regrid_iwc_att_all_masked(model_file, obs_file):
|
|
|
528
527
|
)
|
|
529
528
|
d = obj._regrid_iwc(d, 0, 0, ind, no_rain)
|
|
530
529
|
x = d["iwc_att"]
|
|
531
|
-
|
|
530
|
+
# Simo: not sure if this should be masked or not
|
|
531
|
+
assert x[0, 0] == 0.01
|
|
532
532
|
|
|
533
533
|
|
|
534
|
-
def test_regrid_iwc_att_none(model_file, obs_file):
|
|
534
|
+
def test_regrid_iwc_att_none(model_file, obs_file) -> None:
|
|
535
535
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
536
536
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
537
537
|
obj = ProductGrid(model, obs)
|
|
538
|
-
d = {"iwc_att":
|
|
539
|
-
ind = ma.array([[0, 1, 1, 1]], dtype=bool)
|
|
540
|
-
no_rain = ma.array(
|
|
538
|
+
d = {"iwc_att": ma.zeros((1, 1))}
|
|
539
|
+
ind: ma.MaskedArray = ma.array([[0, 1, 1, 1]], dtype=bool)
|
|
540
|
+
no_rain: ma.MaskedArray = ma.array(
|
|
541
541
|
[
|
|
542
542
|
[0, 0, 0, 0],
|
|
543
543
|
[0, 0, 0, 0],
|
|
@@ -550,190 +550,212 @@ def test_regrid_iwc_att_none(model_file, obs_file):
|
|
|
550
550
|
)
|
|
551
551
|
d = obj._regrid_iwc(d, 0, 0, ind, no_rain)
|
|
552
552
|
x = d["iwc_att"]
|
|
553
|
-
assert
|
|
553
|
+
assert x[0, 0].mask == True
|
|
554
554
|
|
|
555
555
|
|
|
556
|
-
def test_regrid_iwc_rain(model_file, obs_file):
|
|
556
|
+
def test_regrid_iwc_rain(model_file, obs_file) -> None:
|
|
557
557
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
558
558
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
559
559
|
obj = ProductGrid(model, obs)
|
|
560
560
|
obj._obs_data = ma.array([[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 3]])
|
|
561
|
-
d = {"iwc_rain":
|
|
562
|
-
ind = ma.array(
|
|
563
|
-
no_rain = ma.array(
|
|
561
|
+
d = {"iwc_rain": ma.zeros((1, 1))}
|
|
562
|
+
ind: ma.MaskedArray = ma.array(
|
|
564
563
|
[[0, 1, 1, 1], [0, 0, 1, 1], [0, 1, 1, 1], [0, 0, 1, 1]], dtype=bool
|
|
565
564
|
)
|
|
565
|
+
no_rain: ma.MaskedArray = ma.array(
|
|
566
|
+
[[0, 1, 1, 1], [0, 0, 1, 1], [0, 1, 1, 1], [0, 0, 1, 1]],
|
|
567
|
+
dtype=bool,
|
|
568
|
+
)
|
|
566
569
|
d = obj._regrid_iwc(d, 0, 0, ind, no_rain)
|
|
567
570
|
x = d["iwc_rain"]
|
|
568
571
|
testing.assert_almost_equal(x[0, 0], 2.3)
|
|
569
572
|
|
|
570
573
|
|
|
571
|
-
def test_regrid_iwc_rain_nan(model_file, obs_file):
|
|
574
|
+
def test_regrid_iwc_rain_nan(model_file, obs_file) -> None:
|
|
572
575
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
573
576
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
574
577
|
obj = ProductGrid(model, obs)
|
|
575
578
|
obj._obs_data = ma.array(
|
|
576
579
|
[
|
|
577
|
-
[1,
|
|
578
|
-
[2, 2, 2,
|
|
580
|
+
[1, 99, 1, 1],
|
|
581
|
+
[2, 2, 2, 99],
|
|
579
582
|
[3, 3, 3, 3],
|
|
580
|
-
[
|
|
581
|
-
]
|
|
583
|
+
[99, 4, 4, 99],
|
|
584
|
+
],
|
|
582
585
|
)
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
+
obj._obs_data = ma.masked_where(obj._obs_data == 99, obj._obs_data)
|
|
587
|
+
d = {"iwc_rain": ma.zeros((1, 1))}
|
|
588
|
+
ind: ma.MaskedArray = ma.array(
|
|
586
589
|
[[0, 1, 1, 1], [0, 0, 1, 1], [0, 1, 1, 1], [0, 0, 1, 1]], dtype=bool
|
|
587
590
|
)
|
|
591
|
+
no_rain: ma.MaskedArray = ma.array(
|
|
592
|
+
[[0, 1, 1, 1], [0, 0, 1, 1], [0, 1, 1, 1], [0, 0, 1, 1]],
|
|
593
|
+
dtype=bool,
|
|
594
|
+
)
|
|
588
595
|
d = obj._regrid_iwc(d, 0, 0, ind, no_rain)
|
|
589
596
|
x = d["iwc_rain"]
|
|
590
597
|
testing.assert_almost_equal(round(x[0, 0], 3), 2.429)
|
|
591
598
|
|
|
592
599
|
|
|
593
|
-
def test_regrid_iwc_rain_all_nan(model_file, obs_file):
|
|
600
|
+
def test_regrid_iwc_rain_all_nan(model_file, obs_file) -> None:
|
|
594
601
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
595
602
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
596
603
|
obj = ProductGrid(model, obs)
|
|
597
604
|
obj._obs_data = ma.array(
|
|
598
605
|
[
|
|
599
|
-
[
|
|
600
|
-
[
|
|
601
|
-
[
|
|
602
|
-
[
|
|
603
|
-
]
|
|
604
|
-
)
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
606
|
+
[99, 99, 99, 99],
|
|
607
|
+
[99, 99, 99, 99],
|
|
608
|
+
[99, 99, 99, 99],
|
|
609
|
+
[99, 99, 99, 99],
|
|
610
|
+
],
|
|
611
|
+
)
|
|
612
|
+
obj._obs_data = ma.masked_where(obj._obs_data == 99, obj._obs_data)
|
|
613
|
+
d = {"iwc_rain": ma.zeros((1, 1))}
|
|
614
|
+
ind: ma.MaskedArray = ma.array(
|
|
608
615
|
[[0, 1, 1, 1], [0, 0, 1, 1], [0, 1, 1, 1], [0, 0, 1, 1]], dtype=bool
|
|
609
616
|
)
|
|
617
|
+
no_rain: ma.MaskedArray = ma.array(
|
|
618
|
+
[[0, 1, 1, 1], [0, 0, 1, 1], [0, 1, 1, 1], [0, 0, 1, 1]],
|
|
619
|
+
dtype=bool,
|
|
620
|
+
)
|
|
610
621
|
d = obj._regrid_iwc(d, 0, 0, ind, no_rain)
|
|
611
622
|
x = d["iwc_rain"]
|
|
612
|
-
|
|
623
|
+
assert x[0, 0].mask == True
|
|
613
624
|
|
|
614
625
|
|
|
615
|
-
def test_regrid_iwc_rain_masked(model_file, obs_file):
|
|
626
|
+
def test_regrid_iwc_rain_masked(model_file, obs_file) -> None:
|
|
616
627
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
617
628
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
618
629
|
obj = ProductGrid(model, obs)
|
|
619
630
|
obj._obs_data = ma.array([[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]])
|
|
620
631
|
obj._obs_data[2, :] = ma.masked
|
|
621
|
-
d = {"iwc_rain":
|
|
622
|
-
ind = ma.array(
|
|
623
|
-
no_rain = ma.array(
|
|
632
|
+
d = {"iwc_rain": ma.zeros((1, 1))}
|
|
633
|
+
ind: ma.MaskedArray = ma.array(
|
|
624
634
|
[[0, 1, 1, 1], [0, 0, 1, 1], [0, 1, 1, 1], [0, 0, 1, 1]], dtype=bool
|
|
625
635
|
)
|
|
636
|
+
no_rain: ma.MaskedArray = ma.array(
|
|
637
|
+
[[0, 1, 1, 1], [0, 0, 1, 1], [0, 1, 1, 1], [0, 0, 1, 1]],
|
|
638
|
+
dtype=bool,
|
|
639
|
+
)
|
|
626
640
|
d = obj._regrid_iwc(d, 0, 0, ind, no_rain)
|
|
627
641
|
x = d["iwc_rain"]
|
|
628
642
|
testing.assert_almost_equal(round(x[0, 0], 3), 2.143)
|
|
629
643
|
|
|
630
644
|
|
|
631
|
-
def test_regrid_iwc_rain_all_masked(model_file, obs_file):
|
|
645
|
+
def test_regrid_iwc_rain_all_masked(model_file, obs_file) -> None:
|
|
632
646
|
obs = ObservationManager(PRODUCT, str(obs_file))
|
|
633
647
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, PRODUCT)
|
|
634
648
|
obj = ProductGrid(model, obs)
|
|
635
649
|
obj._obs_data = ma.array([[1, 3, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]])
|
|
636
650
|
obj._obs_data[:, :] = ma.masked
|
|
637
|
-
d = {"iwc_rain":
|
|
638
|
-
ind = ma.array(
|
|
639
|
-
no_rain = ma.array(
|
|
651
|
+
d = {"iwc_rain": ma.zeros((1, 1))}
|
|
652
|
+
ind: ma.MaskedArray = ma.array(
|
|
640
653
|
[[0, 1, 1, 1], [0, 0, 1, 1], [0, 1, 1, 1], [0, 0, 1, 1]], dtype=bool
|
|
641
654
|
)
|
|
655
|
+
no_rain: ma.MaskedArray = ma.array(
|
|
656
|
+
[[0, 1, 1, 1], [0, 0, 1, 1], [0, 1, 1, 1], [0, 0, 1, 1]],
|
|
657
|
+
dtype=bool,
|
|
658
|
+
)
|
|
642
659
|
d = obj._regrid_iwc(d, 0, 0, ind, no_rain)
|
|
643
660
|
x = d["iwc_rain"]
|
|
644
|
-
|
|
661
|
+
assert x[0, 0].mask == True
|
|
645
662
|
|
|
646
663
|
|
|
647
|
-
def test_regrid_product(model_file, obs_file):
|
|
664
|
+
def test_regrid_product(model_file, obs_file) -> None:
|
|
648
665
|
obs = ObservationManager("lwc", str(obs_file))
|
|
649
666
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, "lwc")
|
|
650
667
|
obj = ProductGrid(model, obs)
|
|
651
668
|
obj._obs_data = ma.array([[1, 1, 1, 1], [2, 1, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]])
|
|
652
|
-
d = {"lwc":
|
|
653
|
-
ind = ma.array(
|
|
669
|
+
d = {"lwc": ma.zeros((1, 1))}
|
|
670
|
+
ind: ma.MaskedArray = ma.array(
|
|
671
|
+
[[0, 1, 1, 1], [0, 0, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]], dtype=bool
|
|
672
|
+
)
|
|
654
673
|
d = obj._regrid_product(d, 0, 0, ind)
|
|
655
674
|
x = d["lwc"]
|
|
656
675
|
testing.assert_almost_equal(x[0, 0], 1.4)
|
|
657
676
|
|
|
658
677
|
|
|
659
|
-
def test_regrid_product_nan(model_file, obs_file):
|
|
678
|
+
def test_regrid_product_nan(model_file, obs_file) -> None:
|
|
660
679
|
obs = ObservationManager("lwc", str(obs_file))
|
|
661
680
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, "lwc")
|
|
662
681
|
obj = ProductGrid(model, obs)
|
|
663
682
|
obj._obs_data = ma.array(
|
|
664
683
|
[
|
|
665
|
-
[1,
|
|
666
|
-
[
|
|
667
|
-
[3, 3,
|
|
668
|
-
[4,
|
|
669
|
-
]
|
|
670
|
-
)
|
|
671
|
-
|
|
672
|
-
|
|
684
|
+
[1, 99, 1, 1],
|
|
685
|
+
[99, 1, 2, 2],
|
|
686
|
+
[3, 3, 99, 3],
|
|
687
|
+
[4, 99, 4, 4],
|
|
688
|
+
],
|
|
689
|
+
)
|
|
690
|
+
obj._obs_data = ma.masked_where(obj._obs_data == 99, obj._obs_data)
|
|
691
|
+
d = {"lwc": ma.zeros((1, 1))}
|
|
692
|
+
ind: ma.MaskedArray = ma.array(
|
|
693
|
+
[[0, 1, 1, 1], [0, 0, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]], dtype=bool
|
|
694
|
+
)
|
|
673
695
|
d = obj._regrid_product(d, 0, 0, ind)
|
|
674
696
|
x = d["lwc"]
|
|
675
697
|
testing.assert_almost_equal(x[0, 0], 1.5)
|
|
676
698
|
|
|
677
699
|
|
|
678
|
-
def test_regrid_product_all_nan(model_file, obs_file):
|
|
700
|
+
def test_regrid_product_all_nan(model_file, obs_file) -> None:
|
|
679
701
|
obs = ObservationManager("lwc", str(obs_file))
|
|
680
702
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, "lwc")
|
|
681
703
|
obj = ProductGrid(model, obs)
|
|
682
|
-
|
|
704
|
+
data = ma.array(
|
|
683
705
|
[
|
|
684
|
-
[
|
|
685
|
-
[
|
|
686
|
-
[
|
|
687
|
-
[
|
|
688
|
-
]
|
|
706
|
+
[99, 99, 99, 99],
|
|
707
|
+
[99, 99, 99, 99],
|
|
708
|
+
[99, 99, 99, 99],
|
|
709
|
+
[99, 99, 99, 99],
|
|
710
|
+
],
|
|
689
711
|
)
|
|
690
|
-
|
|
712
|
+
obj._obs_data = ma.masked_where(data == 99, data)
|
|
713
|
+
d = {"lwc": ma.zeros((1, 1))}
|
|
691
714
|
ind = np.array([[0, 1, 1, 1], [0, 0, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]], dtype=bool)
|
|
692
715
|
d = obj._regrid_product(d, 0, 0, ind)
|
|
693
|
-
|
|
694
|
-
testing.assert_almost_equal(x[0, 0], np.nan)
|
|
716
|
+
assert d["lwc"][0, 0].mask == True
|
|
695
717
|
|
|
696
718
|
|
|
697
|
-
def test_regrid_product_masked(model_file, obs_file):
|
|
719
|
+
def test_regrid_product_masked(model_file, obs_file) -> None:
|
|
698
720
|
obs = ObservationManager("lwc", str(obs_file))
|
|
699
721
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, "lwc")
|
|
700
722
|
obj = ProductGrid(model, obs)
|
|
701
723
|
obj._obs_data = ma.array([[1, 1, 1, 1], [2, 1, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]])
|
|
702
724
|
obj._obs_data[2, :] = ma.masked
|
|
703
|
-
d = {"lwc":
|
|
725
|
+
d = {"lwc": ma.zeros((1, 1))}
|
|
704
726
|
ind = np.array([[0, 1, 1, 1], [0, 0, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]], dtype=bool)
|
|
705
727
|
d = obj._regrid_product(d, 0, 0, ind)
|
|
706
728
|
x = d["lwc"]
|
|
707
729
|
testing.assert_almost_equal(x[0, 0], 1.4)
|
|
708
730
|
|
|
709
731
|
|
|
710
|
-
def test_regrid_product_all_masked(model_file, obs_file):
|
|
732
|
+
def test_regrid_product_all_masked(model_file, obs_file) -> None:
|
|
711
733
|
obs = ObservationManager("lwc", str(obs_file))
|
|
712
734
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, "lwc")
|
|
713
735
|
obj = ProductGrid(model, obs)
|
|
714
736
|
obj._obs_data = ma.array([[1, 1, 1, 1], [2, 1, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]])
|
|
715
737
|
obj._obs_data[:, :] = ma.masked
|
|
716
|
-
d = {"lwc":
|
|
738
|
+
d = {"lwc": ma.zeros((1, 1))}
|
|
717
739
|
ind = np.array([[0, 1, 1, 1], [0, 0, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0]], dtype=bool)
|
|
718
740
|
d = obj._regrid_product(d, 0, 0, ind)
|
|
719
741
|
x = d["lwc"]
|
|
720
|
-
testing.assert_almost_equal(x,
|
|
742
|
+
testing.assert_almost_equal(x, ma.masked)
|
|
721
743
|
|
|
722
744
|
|
|
723
|
-
def test_regrid_product_none(model_file, obs_file):
|
|
745
|
+
def test_regrid_product_none(model_file, obs_file) -> None:
|
|
724
746
|
obs = ObservationManager("lwc", str(obs_file))
|
|
725
747
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, "lwc")
|
|
726
748
|
obj = ProductGrid(model, obs)
|
|
727
749
|
obj._obs_data = ma.array([[1, 1, 1, 1], [2, 1, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]])
|
|
728
|
-
d = {"lwc":
|
|
750
|
+
d = {"lwc": ma.zeros((1, 1))}
|
|
729
751
|
ind = np.array([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]], dtype=bool)
|
|
730
752
|
d = obj._regrid_product(d, 0, 0, ind)
|
|
731
753
|
x = d["lwc"]
|
|
732
|
-
|
|
754
|
+
assert x[0, 0].mask == True
|
|
733
755
|
|
|
734
756
|
|
|
735
757
|
@pytest.mark.parametrize("product", ["cf_A", "cf_V", "cf_A_adv", "cf_V_adv"])
|
|
736
|
-
def test_append_data2object_cf(product, model_file, obs_file):
|
|
758
|
+
def test_append_data2object_cf(product, model_file, obs_file) -> None:
|
|
737
759
|
obs = ObservationManager("cf", str(obs_file))
|
|
738
760
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, "cf")
|
|
739
761
|
ProductGrid(model, obs)
|
|
@@ -744,7 +766,7 @@ def test_append_data2object_cf(product, model_file, obs_file):
|
|
|
744
766
|
"product",
|
|
745
767
|
["iwc", "iwc_att", "iwc_rain", "iwc_adv", "iwc_att_adv", "iwc_rain_adv"],
|
|
746
768
|
)
|
|
747
|
-
def test_append_data2object_iwc(product, model_file, obs_file):
|
|
769
|
+
def test_append_data2object_iwc(product, model_file, obs_file) -> None:
|
|
748
770
|
obs = ObservationManager("iwc", str(obs_file))
|
|
749
771
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, "iwc")
|
|
750
772
|
ProductGrid(model, obs)
|
|
@@ -752,7 +774,7 @@ def test_append_data2object_iwc(product, model_file, obs_file):
|
|
|
752
774
|
|
|
753
775
|
|
|
754
776
|
@pytest.mark.parametrize("product", ["lwc", "lwc_adv"])
|
|
755
|
-
def test_append_data2object_lwc(product, model_file, obs_file):
|
|
777
|
+
def test_append_data2object_lwc(product, model_file, obs_file) -> None:
|
|
756
778
|
obs = ObservationManager("lwc", str(obs_file))
|
|
757
779
|
model = ModelManager(str(model_file), MODEL, OUTPUT_FILE, "lwc")
|
|
758
780
|
ProductGrid(model, obs)
|