From 0b219169d38538c4517445bac7d50117306d6b53 Mon Sep 17 00:00:00 2001 From: tomrink <rink@ssec.wisc.edu> Date: Wed, 13 Nov 2024 15:18:22 -0600 Subject: [PATCH] snapshot... --- modules/util/acspo_validate.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/modules/util/acspo_validate.py b/modules/util/acspo_validate.py index a503e78d..e3ae5622 100644 --- a/modules/util/acspo_validate.py +++ b/modules/util/acspo_validate.py @@ -1,5 +1,6 @@ import numpy as np import h5py +import xarray as xr from util.util import get_grid_values_all @@ -68,13 +69,37 @@ def acspo_validate(oper_file, cspp_file): both_clear = oper_clear & cspp_clear sst_cspp = sst_cspp[both_clear] sst_oper = sst_oper[both_clear] + lon_cspp = lon_cspp.flatten() + lat_cspp = lat_cspp.flatten() + lon_oper = lon_oper.flatten() + lat_oper = lat_oper.flatten() + lon_cspp = lon_cspp[both_clear] + lat_cspp = lat_cspp[both_clear] + lon_oper = lon_oper[both_clear] + lat_oper = lat_oper[both_clear] both_valid = np.invert(np.isnan(sst_cspp)) & np.invert(np.isnan(sst_oper)) print('number of clear and valid SSTs in both: ', np.sum(both_valid)) + valid_sst_cspp = sst_cspp[both_valid] + valid_sst_oper = sst_oper[both_valid] + valid_lon_cspp = lon_cspp[both_valid] + valid_lat_cspp = lat_cspp[both_valid] + valid_lon_oper = lon_oper[both_valid] + valid_lat_oper = lat_oper[both_valid] + + xarray_data = xr.Dataset({ + 'sst_cspp': xr.DataArray([valid_sst_cspp], coords=None, dims=None, name='sst_cspp'), + 'sst_oper': xr.DataArray([valid_sst_oper], coords=None, dims=None, name='sst_oper'), + 'cspp_lat': xr.DataArray([valid_lat_cspp], coords=None, dims=None, name='cspp_lat'), + 'cspp_lon': xr.DataArray([valid_lon_cspp], coords=None, dims=None, name='cspp_lon'), + 'oper_lat': xr.DataArray([valid_lat_oper], coords=None, dims=None, name='oper_lat'), + 'oper_lon': xr.DataArray([valid_lon_oper], coords=None, dims=None, name='oper_lon'), + }) + xarray_data.to_netcdf('/Users/tomrink/sst_values.nc') print('fraction approx equal: ', - np.sum(np.isclose(sst_cspp[both_valid], sst_oper[both_valid], rtol=0.001))/np.sum(both_valid)) + np.sum(np.isclose(valid_sst_cspp, valid_sst_oper, rtol=0.001))/np.sum(both_valid)) # print(np.histogram((sst_cspp[both_valid] - sst_oper[both_valid]), bins=10)) - - + h5f_oper.close() + h5f_cspp.close() \ No newline at end of file -- GitLab