Skip to content
Snippets Groups Projects
Commit 0b219169 authored by tomrink's avatar tomrink
Browse files

snapshot...

parent a839bc9a
No related branches found
No related tags found
No related merge requests found
import numpy as np import numpy as np
import h5py import h5py
import xarray as xr
from util.util import get_grid_values_all from util.util import get_grid_values_all
...@@ -68,13 +69,37 @@ def acspo_validate(oper_file, cspp_file): ...@@ -68,13 +69,37 @@ def acspo_validate(oper_file, cspp_file):
both_clear = oper_clear & cspp_clear both_clear = oper_clear & cspp_clear
sst_cspp = sst_cspp[both_clear] sst_cspp = sst_cspp[both_clear]
sst_oper = sst_oper[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)) 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)) 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: ', 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)) # 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment