Skip to content

Commit

Permalink
debug the albedofb POD (#416)
Browse files Browse the repository at this point in the history
* make areacella optional for albedofb and add pod_env_vars for cell_area file and variable name to settings file
add logic to check for areacella file and substitute cell area variable and file defined by pod_env_vars if it is not present
add some test code to try and work around gfdl data that is of a different type than the test data used for the POD

* fix data array type check in albedofb_calcs

* reassign rsds and rsus to temporary arrays, and the results of assign_coords on temp arrays to the ds and us variables in albedofb_calcs.py

* fix array manipulation for albedo computations and averaging for plots

* remove debugging lines from albedofb.py

* remove more debugging lines

* remove unused import

* revert changes to albedo computation and extra time averaging in plots in scripts
replace the varname.time.dt.month calls with varname.time.dt.month.data to resolve issues with dataarray type being ambiguous
replace hardcoded rsus and rsds with environment variables
add instructions for defining pod_env_vars for cell area to the albedofb documentation

* fix name of example cell area file in settings.jsonc
try adding albedofb POD back to CI tests
redfine areacella file using the path env variable in albedofb_calcs.py

* revert albedofb tests from CI-still having file not found issues
add comments to albedofb settings file and albedofb_calcs.py

Co-authored-by: Jessica.Liptak <[email protected]>
  • Loading branch information
wrongkindofdoctor and Jessica.Liptak authored Oct 21, 2022
1 parent 5c0db2f commit 5f06ec3
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mdtf_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ jobs:
curl --verbose --ipv4 --connect-timeout 8 --max-time 1200 --retry 128 --ftp-ssl --ftp-pasv -u "anonymous:anonymous" ftp://ftp.gfdl.noaa.gov/perm/oar.gfdl.mdtf/tropical_pacific_sea_level_obs_data.tar.gz --output tropical_pacific_sea_level_obs_data.tar.gz
curl --verbose --ipv4 --connect-timeout 8 --max-time 1200 --retry 128 --ftp-ssl --ftp-pasv -u "anonymous:anonymous" ftp://ftp.gfdl.noaa.gov/perm/oar.gfdl.mdtf/mixed_layer_depth_obs_data.tar --output mixed_layer_depth_obs_data.tar
curl --verbose --ipv4 --connect-timeout 8 --max-time 1200 --retry 128 --ftp-ssl --ftp-pasv -u "anonymous:anonymous" ftp://ftp.gfdl.noaa.gov/perm/oar.gfdl.mdtf/ocn_surf_flux_diag_obs_data.tar --output ocn_surf_flux_diag_obs_data.tar
#curl --verbose --ipv4 --connect-timeout 8 --max-time 1200 --retry 128 --ftp-ssl --ftp-pasv -u "anonymous:anonymous" ftp://ftp.gfdl.noaa.gov/perm/oar.gfdl.mdtf/albedofb_obs_data.tar --output albedofb_obs_data.tar
# curl --verbose --ipv4 --connect-timeout 8 --max-time 1200 --retry 128 --ftp-ssl --ftp-pasv -u "anonymous:anonymous" ftp://ftp.gfdl.noaa.gov/perm/oar.gfdl.mdtf/albedofb_obs_data.tar --output albedofb_obs_data.tar
curl --verbose --ipv4 --connect-timeout 8 --max-time 1200 --retry 128 --ftp-ssl --ftp-pasv -u "anonymous:anonymous" ftp://ftp.gfdl.noaa.gov/perm/oar.gfdl.mdtf/seaice_suite_obs_data.tar --output seaice_suite_obs_data.tar
curl --verbose --ipv4 --connect-timeout 8 --max-time 1200 --retry 128 --ftp-ssl --ftp-pasv -u "anonymous:anonymous" ftp://ftp.gfdl.noaa.gov/perm/oar.gfdl.mdtf/stc_eddy_heat_fluxes_obs_data.tar --output stc_eddy_heat_fluxes_obs_data.tar
echo "Untarring set 3 CMIP standard test files"
Expand Down
92 changes: 45 additions & 47 deletions diagnostics/albedofb/albedofb.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,8 @@
import cartopy.feature as cfeature
import albedofb_calcs


# In[2]:


# In[3]:


podname = 'albedofb'

# these yrs only refer to the hist period for comparing kernel of mod to CERES
Expand All @@ -80,7 +75,7 @@
# In[4]:


### model and obs data files and varnames: ###############################################
# model and obs data files and varnames: ###############################################

# obs processed files, provided
kernel_obs_file = obs_dir+'CERES40_surface_albedo_kernel_2000-2018_MJJA.nc'
Expand Down Expand Up @@ -120,31 +115,32 @@

# read in sensitivity, which is albedo trend per global mean temperature trend
obs_dataset2 = xr.open_dataset(sensitivity_obs_file)
obssensitivity=100.*obs_dataset2.OBS_ice_sensitivity # convert to percent per K
obssensitivity = 100.*obs_dataset2.OBS_ice_sensitivity # convert to percent per K

mod_dataset2 = xr.open_dataset(sensitivity_histmod_file)
modregrid2=regridder(mod_dataset2) # regrid model to obs grid
histmodregridsensitivity=100.*modregrid2.sensitivity # convert to percent per K
modregrid2 = regridder(mod_dataset2) # regrid model to obs grid
histmodregridsensitivity = 100.*modregrid2.sensitivity # convert to percent per K


# In[7]:


# info about the 3 panel figs
figsize=(12,4.5)
leftcbarposition=[0.18, 0.15, 0.4, 0.04] #[left, bottom, width, height]
rightcbarposition=[0.69, 0.15, 0.18, 0.04]
figsize = (12, 4.5)
leftcbarposition = [0.18, 0.15, 0.4, 0.04] # [left, bottom, width, height]
rightcbarposition = [0.69, 0.15, 0.18, 0.04]

# info about the 2 panel figs
figsize2=(9,4.5)
cbarposition=[0.31, 0.15, 0.4, 0.04]
figsize2 = (9, 4.5)
cbarposition = [0.31, 0.15, 0.4, 0.04]


def pltpanel(field,title=None,subs=(1,3,1),cmap_c='plasma'):
ax = plt.subplot(subs,projection = ccrs.NorthPolarStereo())
ax.add_feature(cfeature.COASTLINE,zorder=100,edgecolor='k')
def pltpanel(field, title=None, subs=(1, 3, 1), cmap_c='plasma'):
ax = plt.subplot(subs, projection=ccrs.NorthPolarStereo())
ax.add_feature(cfeature.COASTLINE, zorder=100, edgecolor='k')
ax.set_extent([0.005, 360, 50, 90], crs=ccrs.PlateCarree())
pl = field.plot(x='lon', y='lat', transform=ccrs.PlateCarree(),cmap=cmap_c,add_colorbar=False)
ax.set_title(title,fontsize=14)
pl = field.plot(x='lon', y='lat', transform=ccrs.PlateCarree(), cmap=cmap_c, add_colorbar=False)
ax.set_title(title, fontsize=14)
return pl


Expand All @@ -157,10 +153,10 @@ def pltpanel(field,title=None,subs=(1,3,1),cmap_c='plasma'):
fig.suptitle('Surface Albedo Kernel from Isotropic Model MJJA', fontsize=18)

cmap_c = 'plasma'
pl=pltpanel(histmodkernel.sel(month=slice(4,7)).mean(dim='month'), modelname +' 1996-2014',subs=131,cmap_c = cmap_c)
pl.set_clim([0,3.1])
pl=pltpanel(obskernel.sel(month=slice(4,7)).mean(dim='month'),'CERES EBAF 2000-2018',subs=132,cmap_c = cmap_c)
pl.set_clim([0,3.1])
pl = pltpanel(histmodkernel.sel(month=slice(4, 7)).mean(dim='month'), modelname +' 1996-2014',subs=131,cmap_c = cmap_c)
pl.set_clim([0, 3.1])
pl = pltpanel(obskernel.sel(month=slice(4, 7)).mean(dim='month'),'CERES EBAF 2000-2018',subs=132,cmap_c = cmap_c)
pl.set_clim([0, 3.1])

cbar_ax = fig.add_axes(leftcbarposition)
cbar = fig.colorbar(pl, cax=cbar_ax, orientation='horizontal')
Expand All @@ -169,16 +165,16 @@ def pltpanel(field,title=None,subs=(1,3,1),cmap_c='plasma'):
# their difference
cmap_c = 'PiYG'
diff = histmodregridkernel-obskernel
df=pltpanel(diff.sel(month=slice(4,7)).mean(dim='month'),'Difference',subs=133,cmap_c = cmap_c)
df.set_clim([-1,1])
df = pltpanel(diff.sel(month=slice(4, 7)).mean(dim='month'), 'Difference', subs=133, cmap_c=cmap_c)
df.set_clim([-1, 1])

cbar_ax = fig.add_axes(rightcbarposition)
cbar = fig.colorbar(df, cax=cbar_ax, orientation='horizontal')
cbar.set_label('Radiative Sensitivity (W m$^{-2}$ per 1%)', fontsize=14)

plt.subplots_adjust(bottom=0.21,top=0.85)
plt.subplots_adjust(bottom=0.21, top=0.85)

plt.savefig(figures_dir+'historical_albedo_kernel_'+modelname+'.png', format='png',dpi=300)
plt.savefig(figures_dir+'historical_albedo_kernel_'+modelname+'.png', format='png', dpi=300)


# In[9]:
Expand All @@ -190,10 +186,11 @@ def pltpanel(field,title=None,subs=(1,3,1),cmap_c='plasma'):
fig.suptitle('Surface Albedo MJJA', fontsize=18)

cmap_c = 'PuBu_r'
pl = pltpanel(100.*obsalbedo.sel(month=slice(4,7)).mean(dim='month'),'Observed 2000-2018',subs=131,cmap_c = cmap_c)
pl.set_clim([5,85])
pl = pltpanel(100.*histmodalbedo.sel(month=slice(4,7)).mean(dim='month'),modelname+' 1996-2014',subs=132,cmap_c = cmap_c)
pl.set_clim([5,85])
pl = pltpanel(100.*obsalbedo.sel(month=slice(4, 7)).mean(dim='month'), 'Observed 2000-2018', subs=131, cmap_c=cmap_c)
pl.set_clim([5, 85])
pl = pltpanel(100.*histmodalbedo.sel(month=slice(4, 7)).mean(dim='month'),
modelname + ' ' + firstyr + '-' + lastyr, subs=132, cmap_c=cmap_c)
pl.set_clim([5, 85])

cbar_ax = fig.add_axes(leftcbarposition)
cbar = fig.colorbar(pl, cax=cbar_ax, orientation='horizontal')
Expand All @@ -202,14 +199,14 @@ def pltpanel(field,title=None,subs=(1,3,1),cmap_c='plasma'):
# their difference
cmap_c = 'PiYG'
diff = (histmodregridalbedo-obsalbedo)*100.
df = pltpanel(diff.sel(month=slice(4,7)).mean(dim='month'),'Difference',subs=133,cmap_c = cmap_c)
df.set_clim([-30,30])
df = pltpanel(diff.sel(month=slice(4, 7)).mean(dim='month'), 'Difference', subs=133,cmap_c=cmap_c)
df.set_clim([-30, 30])

cbar_ax = fig.add_axes(rightcbarposition)
cbar = fig.colorbar(df, cax=cbar_ax, orientation='horizontal')
cbar.set_label('Albedo (%)', fontsize=14)

plt.subplots_adjust(bottom=0.21,top=0.85)
plt.subplots_adjust(bottom=0.21, top=0.85)

plt.savefig(figures_dir+'historical_surface_albedo_'+modelname+'.png', format='png',dpi=300)

Expand All @@ -223,17 +220,18 @@ def pltpanel(field,title=None,subs=(1,3,1),cmap_c='plasma'):
fig.suptitle('Albedo Sensitivity MJJA', fontsize=18)

cmap_c = 'PiYG'
df = pltpanel(obssensitivity,'Observed 2000-2018',subs=121,cmap_c = cmap_c)
df.set_clim([-15,15])
df = pltpanel(obssensitivity, 'Observed 2000-2018', subs=121, cmap_c=cmap_c)
df.set_clim([-15, 15])

df = pltpanel(histmodregridsensitivity.sel(month=slice(4,7)).mean(dim='month'),modelname+' 1996-2014',subs=122,cmap_c = cmap_c)
df.set_clim([-15,15])
df = pltpanel(histmodregridsensitivity.sel(month=slice(4, 7)).mean(dim='month'), modelname + ' '
+ firstyr + '-' + lastyr, subs=122, cmap_c=cmap_c)
df.set_clim([-15, 15])

cbar_ax = fig.add_axes(cbarposition) #[left, bottom, width, height]
cbar_ax = fig.add_axes(cbarposition) # [left, bottom, width, height]
cbar = fig.colorbar(df, cax=cbar_ax, orientation='horizontal')
cbar.set_label('Albedo Change (%) per K', fontsize=14)

plt.subplots_adjust(bottom=0.21,top=0.85)
plt.subplots_adjust(bottom=0.21, top=0.85)

plt.savefig(figures_dir+'historical_albedo_sensitivity_'+modelname+'.png', format='png',dpi=300)

Expand All @@ -248,20 +246,20 @@ def pltpanel(field,title=None,subs=(1,3,1),cmap_c='plasma'):

cmap_c = 'PiYG'

fb = obskernel.sel(month=slice(4,7)).mean(dim='month')*obssensitivity
df = pltpanel(fb, 'Observed 2000-2018', subs=121,cmap_c = cmap_c)
df.set_clim([-30,30])
fb = obskernel.sel(month=slice(4, 7)).mean(dim='month')*obssensitivity
df = pltpanel(fb, 'Observed 2000-2018', subs=121, cmap_c=cmap_c)
df.set_clim([-30, 30])

fb = histmodregridkernel.sel(month=slice(4,7)).mean(dim='month')*histmodregridsensitivity.sel(month=slice(4,7)).mean(dim='month')
df = pltpanel(fb, modelname+' 1996-2014', subs=122,cmap_c = cmap_c)
df.set_clim([-30,30])
fb = histmodregridkernel.sel(month=slice(4, 7)).mean(dim='month')*histmodregridsensitivity.sel(month=slice(4, 7)).mean(dim='month')
df = pltpanel(fb, modelname + '' + firstyr + '' + lastyr, subs=122, cmap_c=cmap_c)
df.set_clim([-30, 30])


cbar_ax = fig.add_axes(cbarposition)
cbar = fig.colorbar(df, cax=cbar_ax, orientation='horizontal')
cbar.set_label('Albedo Sensitivity (W m$^{-2}$ per K)', fontsize=14)

plt.subplots_adjust(bottom=0.21,top=0.85)
plt.subplots_adjust(bottom=0.21, top=0.85)

plt.savefig(figures_dir+'historical_surface_albedo_FB_'+modelname+'.png', format='png',dpi=300)

Expand Down
Loading

0 comments on commit 5f06ec3

Please sign in to comment.