In [1]:
import cris_pca_red.rd_pca_red_file as red_file
import cris_pca_red.rd_pca_red_file as red_file
d, gpc = red_file.rd_pca_red_file('input/SNDR.J1.CRIS.20240312T0512.m06.g053.PCA_RED.std.v0_2_0.W.240312174418.nc', 'anc/SNDRGBLPCv2.J1.CRIS.20180325T0000.20190324T2354.L1B.v03_08_nznorm1_latwt1_qc2.nc')
d['rad_lw'].shape
(45, 30, 9, 717)
d['rad_mw'].shape
(45, 30, 9, 869)
d['rad_sw'].shape
(45, 30, 9, 637)
from bokeh.io import push_notebook, output_notebook
from bokeh.layouts import row
from bokeh.models import Div
from bokeh.plotting import figure, show
import ipywidgets as wdgt
output_notebook()
x1 = d['wnum_lw']
x2 = d['wnum_mw']
x3 = d['wnum_sw']
y1 = d['rad_lw'][23,15].squeeze()
y2 = d['rad_mw'][23,15].squeeze()
y3 = d['rad_sw'][23,15].squeeze()
yn = min(y1.shape[0], y2.shape[0], y3.shape[0])
fig = figure(title='Radiance Reconstruction Test', height=600, width=1000)
#, x_range = (0., 100.,0, y_range=(0.,100.))
line1 = fig.line(x1, y1[0], color='#ff4444')
line2 = fig.line(x2, y2[0], color='#44ff44')
line3 = fig.line(x3, y3[0], color='#4444ff')
fig.xaxis.axis_label = 'wnum'
fig.yaxis.axis_label = 'radiance'
def _update(dex):
line1.data_source.data['y'] = y1[dex]
line2.data_source.data['y'] = y2[dex]
line3.data_source.data['y'] = y3[dex]
fig.title.text = str(dex)
push_notebook()
hnd = show(fig, notebook_handle=True)
wdgt.interact(_update, dex=(0, yn, 1))
interactive(children=(IntSlider(value=4, description='dex', max=9), Output()), _dom_classes=('widget-interact'…
<function __main__._update(dex)>
d['rad_lw'].shape, d['rad_mw'].shape, d['rad_sw'].shape
((45, 30, 9, 717), (45, 30, 9, 869), (45, 30, 9, 637))
from scipy.io.matlab import loadmat
tru = loadmat('truth/SNDR.J1.CRIS.20240312T0512.m06.g053.mat')
tru.keys()
dict_keys(['__header__', '__version__', '__globals__', 'info', 'local_pc_eig', 'local_pc_mean', 'global_pc_score', 'local_pc_score', 'pca_red', 'pca_qc', 'rad_outlier', 'None', 'obs_time_tai93', 'lat', 'lon', 'lat_bnds', 'lon_bnds', 'land_frac', 'sol_zen', 'sat_zen', 'sat_azi', 'asc_flag', 'mean_anom_wrt_equat', 'rad_lw_qc', 'rad_mw_qc', 'rad_sw_qc', 'scan_sweep_dir', 'for_num', 'fov_num', 'wnum_lw', 'wnum_mw', 'wnum_sw', 'wnum_all', 'nz_norm', 'rad_lw', 'rad_mw', 'rad_sw', '__function_workspace__'])
d.keys()
dict_keys(['local_pc_eig', 'local_pc_mean', 'global_pc_score', 'local_pc_score', 'pca_red', 'pca_qc', 'rad_outlier', 'obs_time_tai93', 'lat', 'lon', 'lat_bnds', 'lon_bnds', 'land_frac', 'sol_zen', 'sat_zen', 'sat_azi', 'asc_flag', 'mean_anom_wrt_equat', 'rad_lw_qc', 'rad_mw_qc', 'rad_sw_qc', 'scan_sweep_dir', 'for_num', 'fov_num', 'wnum_lw', 'wnum_mw', 'wnum_sw', 'wnum_all', 'nz_norm', 'rad_lw', 'rad_mw', 'rad_sw'])
tru['rad_lw'].shape
(717, 9, 30, 45)
import numpy as np
np.all(tru['rad_lw'][:,0,0,0].squeeze() == d['rad_lw'][0,0,0,:])
True
mlw = tru['rad_lw']
mlw = np.swapaxes(mlw, 1, 2)
mlw = np.swapaxes(mlw, 0, 3)
mlw.shape
(45, 30, 9, 717)
np.all(mlw[0,0,0,:].squeeze() == d['rad_lw'][0,0,0,:])
True
np.all(mlw==d['rad_lw'])
True
mlw[0,0,0,25:40]
array([54.89318708, 54.4612455 , 53.80879517, 52.73572163, 52.11093211,
68.74785291, 71.79915418, 62.47005973, 58.80166808, 56.43533306,
51.63145986, 56.01718675, 51.57781785, 53.06464813, 55.38478631])
def baltam(x):
"reverse axis order for radiance 4D arrays"
return np.swapaxes( np.swapaxes(x, 1, 2), 0, 3 )
tlw = baltam(tru['rad_lw'])
tmw = baltam(tru['rad_mw'])
tsw = baltam(tru['rad_sw'])
plw = d['rad_lw']
pmw = d['rad_mw']
psw = d['rad_sw']
np.all(tmw == pmw)
True
np.all(tsw == psw)
True
np.all(tlw == plw)
True
tlw.shape, tmw.shape, tsw.shape
((45, 30, 9, 717), (45, 30, 9, 869), (45, 30, 9, 637))
x1 = d['wnum_lw']
x2 = d['wnum_mw']
x3 = d['wnum_sw']
y1 = tlw[23,15].squeeze()
y2 = tmw[23,15].squeeze()
y3 = tsw[23,15].squeeze()
yn = min(y1.shape[0], y2.shape[0], y3.shape[0])
fig = figure(title='Radiance Reconstruction Test', height=600, width=1000)
#, x_range = (0., 100.,0, y_range=(0.,100.))
line1 = fig.line(x1, y1[0], color='#ff4444')
line2 = fig.line(x2, y2[0], color='#44ff44')
line3 = fig.line(x3, y3[0], color='#4444ff')
fig.xaxis.axis_label = 'wnum'
fig.yaxis.axis_label = 'radiance'
def _update(dex):
line1.data_source.data['y'] = y1[dex]
line2.data_source.data['y'] = y2[dex]
line3.data_source.data['y'] = y3[dex]
fig.title.text = str(dex)
push_notebook()
hnd = show(fig, notebook_handle=True)
wdgt.interact(_update, dex=(0, yn, 1))
interactive(children=(IntSlider(value=4, description='dex', max=9), Output()), _dom_classes=('widget-interact'…
<function __main__._update(dex)>
x1 = d['wnum_mw']
x2 = d['wnum_mw']
x3 = d['wnum_mw']
y1 = pmw[23,15].squeeze()
y2 = tmw[23,15].squeeze()
y3 = y1 - y2
# y3 = d['rad_sw'][23,15].squeeze()
yn = min(y1.shape[0], y2.shape[0], y3.shape[0])
print(max(abs(y3.ravel())))
fig = figure(title='Radiance Reconstruction Test', height=600, width=1000)
#, x_range = (0., 100.,0, y_range=(0.,100.))
line1 = fig.line(x1, y1[0], color='#ff4444')
line2 = fig.line(x2, y2[0], color='#44ff44')
line3 = fig.line(x3, y3[0], color='#4444ff')
fig.xaxis.axis_label = 'wnum'
fig.yaxis.axis_label = 'radiance'
def _update(dex):
line1.data_source.data['y'] = y1[dex]
line2.data_source.data['y'] = y2[dex]
line3.data_source.data['y'] = y3[dex]
fig.title.text = str(dex)
push_notebook()
hnd = show(fig, notebook_handle=True)
wdgt.interact(_update, dex=(0, yn, 1))
0.0
interactive(children=(IntSlider(value=4, description='dex', max=9), Output()), _dom_classes=('widget-interact'…
<function __main__._update(dex)>
np.nanmax(abs((plw-tlw).ravel()))
0.0
np.nanmax(abs((pmw-tmw).ravel()))
0.0
np.nanmax(abs((psw-tsw).ravel()))
0.0