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

snapshot...

parent 13a5e714
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@ import xarray as xr
from util.util import get_grid_values_all
def acspo_validate(oper_file, cspp_file, rel_tol=0.01, deg_tol=0.0002, outfile_nc=None):
def acspo_validate(oper_file, cspp_file, rel_tol=0.005, deg_tol=0.0002, outfile_nc=None):
h5f_oper = h5py.File(oper_file, 'r')
h5f_cspp = h5py.File(cspp_file, 'r')
......@@ -13,49 +13,41 @@ def acspo_validate(oper_file, cspp_file, rel_tol=0.01, deg_tol=0.0002, outfile_n
lon_cspp = get_grid_values_all(h5f_cspp, 'lon')
lat_cspp = get_grid_values_all(h5f_cspp, 'lat')
if np.any(np.isnan(lat_cspp)) or np.any(np.isnan(lon_cspp)):
print('Invalid lat')
print('Missing CSPP lat or lon')
return
if np.min(lat_cspp) < -90 or np.max(lat_cspp) > 90:
print('Invalid lat')
print('Invalid CSPP lat')
return
if np.min(lon_cspp) < -180 or np.max(lon_cspp) > 180:
print('Invalid lon')
# ----* Investigate: CSPP and OPER time values don't seem to ever match *-------------------
# dtime_cspp = get_grid_values_all(h5f_cspp, 'sst_dtime')[0, ]
# ref_time_cspp = get_grid_values_all(h5f_cspp, 'time')[0]
print('cspp shape: ', lat_cspp.shape)
print('Invalid CSPP lon')
return
cspp_track_len = lat_cspp.shape[0]
c_idx = lat_cspp.shape[1] // 2
print('cspp shape: ', lat_cspp.shape)
cntr_lon_cspp = lon_cspp[:, c_idx]
cntr_lat_cspp = lat_cspp[:, c_idx]
# cntr_dtime_cspp = dtime_cspp[::16, c_idx]
sst_cspp = get_grid_values_all(h5f_cspp, 'sea_surface_temperature')[0, ]
l2p_flags_cspp = get_grid_values_all(h5f_cspp, 'l2p_flags')[0, ]
lon_oper = get_grid_values_all(h5f_oper, 'lon')
lat_oper = get_grid_values_all(h5f_oper, 'lat')
if np.any(np.isnan(lat_cspp)) or np.any(np.isnan(lon_cspp)):
print('Invalid lat')
print('Missing OPER lon or lat')
return
if np.min(lat_cspp) < -90 or np.max(lat_cspp) > 90:
print('Invalid lat')
print('Invalid OPER lat')
return
if np.min(lon_cspp) < -180 or np.max(lon_cspp) > 180:
print('Invalid lon')
print('Invalid OPER lon')
return
# --* See note above on issue with time *-------------------------------------
# dtime_oper = get_grid_values_all(h5f_oper, 'sst_dtime')[0, ]
# ref_time_oper = get_grid_values_all(h5f_oper, 'time')[0]
cntr_lon_oper = lon_oper[:, c_idx]
cntr_lat_oper = lat_oper[:, c_idx]
# cntr_dtime_oper = dtime_oper[::16, c_idx]
print('oper shape: ', lat_oper.shape)
oper_track_len = lat_oper.shape[0]
sst_oper = get_grid_values_all(h5f_oper, 'sea_surface_temperature')[0, ]
l2p_flags_oper = get_grid_values_all(h5f_oper, 'l2p_flags')[0, ]
# cntr_time_cspp = cntr_dtime_cspp + ref_time_cspp
# cntr_time_oper = cntr_dtime_oper + ref_time_oper
# generate a ndarray of boolean, True: clear or probably clear
cspp_clear = (l2p_flags_cspp & (1 << 15)) == 0
oper_clear = (l2p_flags_oper & (1 << 15)) == 0
......@@ -64,7 +56,7 @@ def acspo_validate(oper_file, cspp_file, rel_tol=0.01, deg_tol=0.0002, outfile_n
start_idx_oper, stop_idx_oper = -1, -1
start_idx_cspp, stop_idx_cspp = -1, -1
# Average latitude spacing: 0.00652 deg
# Average latitude spacing: 0.00652 deg (VIIRS M-band)
for k in range(len(cntr_lat_oper)):
diff = np.abs(cntr_lat_oper[k] - cntr_lat_cspp)
......@@ -76,8 +68,8 @@ def acspo_validate(oper_file, cspp_file, rel_tol=0.01, deg_tol=0.0002, outfile_n
start_idx_cspp = idx_a[0]
break
else:
print("weirdness")
break
print("weirdness: two close points found")
return
if start_idx_oper < 0:
print("no overlap found")
......@@ -147,8 +139,6 @@ def acspo_validate(oper_file, cspp_file, rel_tol=0.01, deg_tol=0.0002, outfile_n
h5f_oper.close()
h5f_cspp.close()
return sst_cspp_2d, sst_oper_2d
def analyze_plot():
import h5py
......
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