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

snapshot...

parent a153e27a
No related branches found
No related tags found
No related merge requests found
......@@ -37,7 +37,7 @@ def acspo_validate(oper_file, cspp_file, rel_tol=0.001, outfile_nc=None):
start_idx_cspp, stop_idx_cspp = -1, -1
for k in range(len(cntr_lat_oper)):
c_a = np.logical_and(np.isclose(cntr_lat_oper[k], cntr_lat_cspp, rtol=rel_tol), np.isclose(cntr_lon_oper[k], cntr_lon_cspp, rtol=rel_tol))
c_a = np.logical_and(np.isclose(cntr_lat_oper[k], cntr_lat_cspp), np.isclose(cntr_lon_oper[k], cntr_lon_cspp))
if np.size(np.nonzero(c_a)[0]) == 1:
if start_idx_oper == -1:
start_idx_oper = k
......@@ -56,6 +56,8 @@ def acspo_validate(oper_file, cspp_file, rel_tol=0.001, outfile_nc=None):
lat_oper = lat_oper[start_idx_oper:stop_idx_oper, :]
cspp_clear = cspp_clear[start_idx_cspp:stop_idx_cspp, :]
oper_clear = oper_clear[start_idx_oper:stop_idx_oper, :]
sst_cspp_2d = sst_cspp[start_idx_cspp:stop_idx_cspp, :]
sst_oper_2d = sst_oper[start_idx_oper:stop_idx_oper, :]
overlap_shape = lon_cspp.shape
print('overlap shape, size: ', overlap_shape, np.size(lon_cspp))
......@@ -63,11 +65,8 @@ def acspo_validate(oper_file, cspp_file, rel_tol=0.001, outfile_nc=None):
print('num of close overlap lons: ', np.sum(np.isclose(lon_cspp, lon_oper, rtol=rel_tol)))
print('num of close overlap lats: ', np.sum(np.isclose(lat_cspp, lat_oper, rtol=rel_tol)))
sst_cspp_2d = sst_cspp[start_idx_cspp:stop_idx_cspp, :]
sst_oper_2d = sst_oper[start_idx_oper:stop_idx_oper, :]
sst_cspp_2d = np.where(cspp_clear, sst_cspp_2d, np.nan)
sst_oper_2d = np.where(oper_clear, sst_oper_2d, np.nan)
# sst_cspp_2d = np.where(cspp_clear, sst_cspp_2d, np.nan)
# sst_oper_2d = np.where(oper_clear, sst_oper_2d, np.nan)
sst_cspp = sst_cspp_2d.flatten()
sst_oper = sst_oper_2d.flatten()
......@@ -78,23 +77,16 @@ def acspo_validate(oper_file, cspp_file, rel_tol=0.001, outfile_nc=None):
lon_oper = lon_oper.flatten()
lat_oper = lat_oper.flatten()
both_valid = np.invert(np.isnan(sst_cspp)) & np.invert(np.isnan(sst_oper))
both_clear = oper_clear & cspp_clear
sst_cspp = sst_cspp[both_clear]
sst_oper = sst_oper[both_clear]
lon_cspp = lon_cspp[both_clear]
lat_cspp = lat_cspp[both_clear]
lon_oper = lon_oper[both_clear]
lat_oper = lat_oper[both_clear]
print('number of clear pixels in both: ', np.sum(both_clear))
keep = both_valid & both_clear
both_valid = np.invert(np.isnan(sst_cspp)) & np.invert(np.isnan(sst_oper))
print('number of clear pixels with 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]
valid_sst_cspp = sst_cspp[keep]
valid_sst_oper = sst_oper[keep]
valid_lon_cspp = lon_cspp[keep]
valid_lat_cspp = lat_cspp[keep]
valid_lon_oper = lon_oper[keep]
valid_lat_oper = lat_oper[keep]
xarray_data = xr.Dataset({
'sst_cspp': xr.DataArray(valid_sst_cspp, coords=None, dims=None, name='sst_cspp'),
......@@ -108,7 +100,7 @@ def acspo_validate(oper_file, cspp_file, rel_tol=0.001, outfile_nc=None):
xarray_data.to_netcdf(outfile_nc)
print('fraction approx equal: ',
np.sum(np.isclose(valid_sst_cspp, valid_sst_oper, rtol=rel_tol))/np.sum(both_valid))
np.sum(np.isclose(valid_sst_cspp, valid_sst_oper, rtol=rel_tol))/np.sum(keep))
h5f_oper.close()
h5f_cspp.close()
......
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