<jupyter_start><jupyter_text>Compare observations (Kay 2012 vs. 2021)<jupyter_code>import sys
# Add common resources folder to path
sys.path.append('/glade/u/home/jonahshaw/Scripts/git_repos/CESM2_analysis')
sys.path.append('/glade/u/home/jonahshaw/Scripts/git_repos/CESM2_analysis/Common/')
# sys.path.append("/home/jonahks/git_repos/netcdf_analysis/Common/")

from imports import (
    pd, np, xr, mpl, plt, sns, os, 
    datetime, sys, crt, gridspec,
    ccrs, metrics, Iterable, cmaps
    )

from functions import (
    masked_average, add_weights, sp_map,
    season_mean, get_dpm, leap_year, share_ylims,
    to_png
    )

from cloud_metric import Cloud_Metric
# from collections import deque
%matplotlib inline<jupyter_output>The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload<jupyter_text>CERES-EBAF<jupyter_code>obs2012_dir = '/glade/u/home/jonahshaw/w/kay2012_OGfiles'
newobs_ceresebaf = '/glade/u/home/jonahshaw/obs/CERES_EBAF/'
old_swcf = xr.open_dataset('%s/CERES-EBAF.SWCF.nc' % (obs2012_dir))
old_lwcf = xr.open_dataset('%s/CERES-EBAF.LWCF.nc' % (obs2012_dir))
new_ceres = xr.open_dataset('%s/CERES_EBAF-TOA_Ed4.1_Subset_200003-202002.nc' % (newobs_ceresebaf))
new_ceres_ss = new_ceres.sel(time=slice('2000-03-15','2010-02-16'))
new_ceres_ss['SWCF'] = (new_ceres_ss['toa_sw_clr_c_mon'] - new_ceres_ss['toa_sw_all_mon']).assign_attrs(
            {'units': 'W/m2','long_name': 'Shortwave cloud forcing'})

new_ceres_ss['LWCF'] = (new_ceres_ss['toa_lw_clr_c_mon'] - new_ceres_ss['toa_lw_all_mon']).assign_attrs(
            {'units': 'W/m2','long_name': 'Longwave cloud forcing'})
sw_2012 = add_weights(old_swcf['SWCFTOA'])
lw_2012 = add_weights(old_lwcf['LWCFTOA'])
sw_2012j = add_weights(new_ceres_ss['SWCF'])
lw_2012j = add_weights(new_ceres_ss['LWCF'])
sw_avg = masked_average(sw_2012,weights=sw_2012['cell_weight'])
print('CERES-EBAF SWCF (2012) avg: %s' % sw_avg.values)

lw_avg = masked_average(lw_2012,weights=lw_2012['cell_weight'])
print('CERES-EBAF LWCF (2012) avg: %s' % lw_avg.values)

sw_avg = masked_average(sw_2012j,weights=sw_2012j['cell_weight'])
print('CERES-EBAF SWCF (2021) avg: %s' % sw_avg.values)

lw_avg = masked_average(lw_2012j,weights=lw_2012j['cell_weight'])
print('CERES-EBAF LWCF (2021) avg: %s' % lw_avg.values)<jupyter_output>CERES-EBAF SWCF (2012) avg: -47.071148
CERES-EBAF LWCF (2012) avg: 26.475805
CERES-EBAF SWCF (2021) avg: -45.839622
CERES-EBAF LWCF (2021) avg: 28.09088<jupyter_text>Differences between cloud forcing observations from 2012 (CERES-EBAF v?) and 2021 (CERES-EBAF v4). Same time period (2000-03 through 2010-02)<jupyter_code>(new_ceres_ss['SWCF'].mean('time') - old_swcf['SWCFTOA']).plot(robust=True)
(new_ceres_ss['LWCF'].mean('time') - old_lwcf['LWCFTOA']).plot(robust='True')<jupyter_output><empty_output><jupyter_text>MISR  Load original data as a cross-check<jupyter_code>og_misr = xr.open_dataset('%s/MISR.CLDTOT_MISR.nc' % (obs2012_dir))
og_misr_cam4 = xr.open_dataset('%s/CAM4.CLDTOT_MISR.nc' % (obs2012_dir))
og_misrthick_cam4 = xr.open_dataset('%s/CAM4.CLDLOW_THICK_MISR.nc' % (obs2012_dir))

new_cltmisr = xr.open_dataset('%s/%s' % ('/glade/u/home/jonahshaw/w/obs/MISR','clt_MISR_20000301_20200531.nc'))
og_cltmisr = add_weights(og_misr['CLDTOT_MISR'])
new_cltmisr = add_weights(new_cltmisr['clMISR'])
new_cltmisr_tavg= new_cltmisr.groupby('time.month').mean('time').mean('month')
og_cltmisr.shape
new_cltmisr_tavg.shape<jupyter_output><empty_output><jupyter_text>Very different here because I haven't masked the new observations. Nor do I entirely know how.<jupyter_code>new_cltmisr_tavg.plot(cmap=cmaps.ncl_default,levels=np.arange(0,100,5))
og_cltmisr.plot(cmap=cmaps.ncl_default,levels=np.arange(0,100,5))
og_cltmisr
og_misr_cam4['CLDTOT_MISR'].mean()<jupyter_output><empty_output><jupyter_text>This is how to process the CAM outputs to total cloud<jupyter_code>misr_clttest = og_misr_cam4['CLMISR'].where(og_misr_cam4['CLMISR'].misr_tau>0.3).sum(dim=['misr_tau','misr_cth'])
misr_clttest.mean()
og_misrthick_cam4['CLDLOW_THICK_MISR'].mean()<jupyter_output><empty_output><jupyter_text>This is how to process the CAM outputs to thick cloud<jupyter_code>cells = np.bitwise_and((og_misrthick_cam4['CLMISR'].misr_tau > 23),(og_misrthick_cam4['CLMISR'].misr_cth < 3))
misrthick = og_misrthick_cam4['CLMISR'].where(cells).sum(dim=['misr_tau','misr_cth'])
misrthick.mean()
cells5 = np.bitwise_and((cam5_da['CLMODIS'].cosp_tau_modis > 23),(cam5_da['CLMODIS'].cosp_prs < 440))
proc_modis5 = cam5_da['CLMODIS'].where(cells5).sum(['cosp_tau_modis','cosp_prs'])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15416394868449662, 'fraction_numerical': 0.055446836268754074, 'mean_word_length': 7.679245283018868, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '322606', 'license': 'MIT', 'n_tokens_mistral': 2268, 'n_tokens_neox': 2027, 'n_words': 254, 'path': 'CESM2_COSP/compare_obs.ipynb', 'repo_name': 'jshaw35/CESM2_analysis', 'size': '4599'}