diff --git a/modules/util/acspo_validate.py b/modules/util/acspo_validate.py index bf0446d6fdbcbfaaf1c1ad95b1dcf4f00e58e2c3..1674cbf3bf5550c16a9c4fab10c273d20f053442 100644 --- a/modules/util/acspo_validate.py +++ b/modules/util/acspo_validate.py @@ -111,3 +111,109 @@ def acspo_validate(oper_file, cspp_file, rel_tol=0.001, outfile_nc=None): h5f_cspp.close() return sst_cspp_2d, sst_oper_2d + + +def analyze_plot(): + import h5py + h5f_a = h5py.File('/Users/tomrink/20241107055000.nc', 'r') + h5f_b = h5py.File('/Users/tomrink/20241107072000.nc', 'r') + h5f_c = h5py.File('/Users/tomrink/20241107073000.nc', 'r') + h5f_d = h5py.File('/Users/tomrink/20241107170000.nc', 'r') + h5f_e = h5py.File('/Users/tomrink/20241107171000.nc', 'r') + h5f_f = h5py.File('/Users/tomrink/20241107202000.nc', 'r') + h5f_g = h5py.File('/Users/tomrink/20241107203000.nc', 'r') + import numpy as np + sst_cspp_all = np.concatenate([h5f_a['sst_cspp'][0, :], h5f_b['sst_cspp'][0, :], h5f_c['sst_cspp'][0, :], h5f_d['sst_cspp'][0, :], h5f_e['sst_cspp'][0, :], h5f_f['sst_cspp'][0, :], h5f_g['sst_cspp'][0, :]]) + sst_cspp_all.shape + sst_oper_all = np.concatenate([h5f_a['sst_oper'][0, :], h5f_b['sst_oper'][0, :], h5f_c['sst_oper'][0, :], h5f_d['sst_oper'][0, :], h5f_e['sst_oper'][0, :], h5f_f['sst_oper'][0, :], h5f_g['sst_oper'][0, :]]) + sst_oper_all.shape + diff = sst_cspp_all - sst_oper_all + import matplotlib.pyplot as plt + plt.hist(diff, bins=40) + plt.yscale('log') + plt.title('ACSPO SST (CSPP - OPER)') + import h5py + h5f_a = h5py.File('/Users/tomrink/20241107055000.nc', 'r') + h5f_b = h5py.File('/Users/tomrink/20241107072000.nc', 'r') + h5f_c = h5py.File('/Users/tomrink/20241107073000.nc', 'r') + h5f_d = h5py.File('/Users/tomrink/20241107170000.nc', 'r') + h5f_e = h5py.File('/Users/tomrink/20241107171000.nc', 'r') + h5f_f = h5py.File('/Users/tomrink/20241107202000.nc', 'r') + h5f_g = h5py.File('/Users/tomrink/20241107203000.nc', 'r') + import numpy as np + sst_cspp_all = np.concatenate([h5f_a['sst_cspp'][0, :], h5f_b['sst_cspp'][0, :], h5f_c['sst_cspp'][0, :], h5f_d['sst_cspp'][0, :], h5f_e['sst_cspp'][0, :], h5f_f['sst_cspp'][0, :], h5f_g['sst_cspp'][0, :]]) + sst_oper_all = np.concatenate([h5f_a['sst_oper'][0, :], h5f_b['sst_oper'][0, :], h5f_c['sst_oper'][0, :], h5f_d['sst_oper'][0, :], h5f_e['sst_oper'][0, :], h5f_f['sst_oper'][0, :], h5f_g['sst_oper'][0, :]]) + diff = sst_cspp_all - sst_oper_all + import matplotlib.pyplot as plt + plt.hist(diff, bins=40) + plt.yscale('log') + plt.xlabel('SST (\u00b0K)') + plt.title('ACSPO SST (CSPP - OPER), Clear Sky, 2024-11_07') + import numpy as np + c_a = np.isclose(sst_cspp_all, sst_oper_all, rtol=0.001) + c_a.shape + sst_cspp_all.shape + c_a_i = np.invert(c_a) + plt.scatter(sst_cspp_all[c_a_i], diff[c_a_i]) + plt.close() + plt.scatter(sst_cspp_all[c_a_i], diff[c_a_i], s=1) + plt.title('ACSPO SST (CSPP-OPER) > rel_tol=0.001 vs SST') + plt.xlabel('SST (\u00b0K)') + plt.ylabel('SST (\u00b0K)') + plt.show() + + import h5py + h5f_a = h5py.File('/Users/tomrink/20241107055000.nc', 'r') + h5f_b = h5py.File('/Users/tomrink/20241107072000.nc', 'r') + h5f_c = h5py.File('/Users/tomrink/20241107073000.nc', 'r') + h5f_d = h5py.File('/Users/tomrink/20241107170000.nc', 'r') + h5f_e = h5py.File('/Users/tomrink/20241107171000.nc', 'r') + h5f_f = h5py.File('/Users/tomrink/20241107202000.nc', 'r') + h5f_g = h5py.File('/Users/tomrink/20241107203000.nc', 'r') + import numpy as np + sst_cspp_all = np.concatenate( + [h5f_a['sst_cspp'][0, :], h5f_b['sst_cspp'][0, :], h5f_c['sst_cspp'][0, :], h5f_d['sst_cspp'][0, :], + h5f_e['sst_cspp'][0, :], h5f_f['sst_cspp'][0, :], h5f_g['sst_cspp'][0, :]]) + sst_cspp_all.shape + sst_oper_all = np.concatenate( + [h5f_a['sst_oper'][0, :], h5f_b['sst_oper'][0, :], h5f_c['sst_oper'][0, :], h5f_d['sst_oper'][0, :], + h5f_e['sst_oper'][0, :], h5f_f['sst_oper'][0, :], h5f_g['sst_oper'][0, :]]) + sst_oper_all.shape + diff = sst_cspp_all - sst_oper_all + import matplotlib.pyplot as plt + plt.hist(diff, bins=40) + plt.yscale('log') + plt.title('ACSPO SST (CSPP - OPER)') + import h5py + h5f_a = h5py.File('/Users/tomrink/20241107055000.nc', 'r') + h5f_b = h5py.File('/Users/tomrink/20241107072000.nc', 'r') + h5f_c = h5py.File('/Users/tomrink/20241107073000.nc', 'r') + h5f_d = h5py.File('/Users/tomrink/20241107170000.nc', 'r') + h5f_e = h5py.File('/Users/tomrink/20241107171000.nc', 'r') + h5f_f = h5py.File('/Users/tomrink/20241107202000.nc', 'r') + h5f_g = h5py.File('/Users/tomrink/20241107203000.nc', 'r') + import numpy as np + sst_cspp_all = np.concatenate( + [h5f_a['sst_cspp'][0, :], h5f_b['sst_cspp'][0, :], h5f_c['sst_cspp'][0, :], h5f_d['sst_cspp'][0, :], + h5f_e['sst_cspp'][0, :], h5f_f['sst_cspp'][0, :], h5f_g['sst_cspp'][0, :]]) + sst_oper_all = np.concatenate( + [h5f_a['sst_oper'][0, :], h5f_b['sst_oper'][0, :], h5f_c['sst_oper'][0, :], h5f_d['sst_oper'][0, :], + h5f_e['sst_oper'][0, :], h5f_f['sst_oper'][0, :], h5f_g['sst_oper'][0, :]]) + diff = sst_cspp_all - sst_oper_all + import matplotlib.pyplot as plt + plt.hist(diff, bins=40) + plt.yscale('log') + plt.xlabel('SST (\u00b0K)') + plt.title('ACSPO SST (CSPP - OPER), Clear Sky, 2024-11_07') + import numpy as np + c_a = np.isclose(sst_cspp_all, sst_oper_all, rtol=0.001) + c_a.shape + sst_cspp_all.shape + c_a_i = np.invert(c_a) + plt.scatter(sst_cspp_all[c_a_i], diff[c_a_i]) + plt.close() + plt.scatter(sst_cspp_all[c_a_i], diff[c_a_i], s=1) + plt.title('ACSPO SST (CSPP-OPER) > rel_tol=0.001 vs SST') + plt.xlabel('SST (\u00b0K)') + plt.ylabel('SST (\u00b0K)') + plt.show() \ No newline at end of file