Adapt scripts_v6/CM7_figs.ipynb
to look at the scripts_v7 data, which ran during the ERS meeting. If this doesn't work, use v6 for the Remote Sensing special issue.
from astropy.io import fits as pyfits
CM7 = pyfits.open('output/CM7_v7_cube.fits')
CM7.info()
# overall output structure:
# primary - I/F hypercube + description of axes
# ext 1 - lat 2D array
# ext 2 - dlon 2D array
# ext 3 - mu (cos(emi)) 2D array
# ext 4 - mu0 (cos(inc)) 2D array
# ext 5 - g_eff 2D array
# ext 6 - table of parameter values for non-spatial dimensions 3-7
print('')
print('')
print('EXT 6: the BinTable --')
print('')
pvals = CM7[6].data
print(CM7[6].columns)
print('cube_dim: ', pvals['cube_dim'])
print('dim_name: ', pvals['dim_name'])
print('{:s}: '.format(CM7[6].columns[2].name))
for i in range(5):
print(i, pvals.field(2)[i])
print('{:s}: '.format(CM7[6].columns[3].name), pvals.field(3))
print('{:s}: '.format(CM7[6].columns[4].name), pvals.field(4))
Filename: output/CM7_v7_cube.fits No. Name Ver Type Cards Dimensions Format 0 PRIMARY 1 PrimaryHDU 48 (16, 16, 3, 3, 3, 5, 4) float64 1 LAT 1 ImageHDU 9 (16, 16) float64 2 DLON 1 ImageHDU 9 (16, 16) float64 3 MU 1 ImageHDU 8 (16, 16) float64 4 MU0 1 ImageHDU 8 (16, 16) float64 5 G_EFF 1 ImageHDU 9 (16, 16) float64 6 1 BinTableHDU 19 5R x 5C [I, 10A, 40A, I, 6D] EXT 6: the BinTable -- ColDefs( name = 'cube_dim'; format = 'I' name = 'dim_name'; format = '10A' name = 'dim_comment'; format = '40A' name = 'dim_len'; format = 'I' name = 'values_float'; format = '6D'; dim = '(6)' ) cube_dim: [3 4 5 6 7] dim_name: ['CENWAVE' 'r_H' 'tau_H' 'P_W' 'tau_W'] dim_comment: 0 Filter central wavelength (micron) 1 Upper trop. haze particle radius (micron 2 Upper trop. haze optical depth 3 Deep cloud base pressure (bar) 4 Deep cloud optical depth dim_len: [3 3 3 5 4] values_float: [[ 0.631 0.727 0.75 0. 0. 0. ] [ 0.2 0.5 2. 0. 0. 0. ] [ 3. 10. 15. 0. 0. 0. ] [ 2. 3. 4. 5. 6. 0. ] [ 0. 5. 25. 100. 0. 0. ]]
Follows example from https://matplotlib.org/stable/plot_types/arrays/imshow.html#sphx-glr-plot-types-arrays-imshow-py
import matplotlib.pyplot as plt
import numpy as np
import numpy.ma as ma
import matplotlib.cm as cm
import copy
#print(plt.style.available)
plt.style.use('default')
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = ['Helvetica', 'Roboto', 'Verdana', 'Arial']
plt.rcParams['pdf.fonttype'] = 42
plt.rcParams["axes.grid"] = False
plt.rcParams['axes.facecolor'] = 'white'
plt.rcParams['font.size'] = 14
# prepare data with masked corners
planet = np.where(CM7[5].data < 1000., np.ones(CM7[5].data.shape), np.zeros(CM7[5].data.shape))
# nice bounds
vmin_geo = [-70, -90, 0, 0, 2200]
vmax_geo = [70, 90, 1, 1, 2800]
# plot
fig,ax = plt.subplots(figsize=(15, 2), ncols=5, gridspec_kw={'wspace': 0.35})
for i in range(5):
ax[i].axes.xaxis.set_ticklabels([])
ax[i].axes.yaxis.set_ticklabels([])
panel_data = ma.masked_array(CM7[i+1].data, mask=planet)
panel = ax[i].imshow(panel_data, origin='lower', cmap='turbo',
vmin=vmin_geo[i], vmax=vmax_geo[i])
fig.colorbar(panel, ax=ax[i], ticks=np.linspace(vmin_geo[i], vmax_geo[i], 5))
# notes: panel = ... saves the color "mappable" object returned by ax[i].imshow.
# add the colorbar using the figure's method, telling which mappable we're
# talking about and which axes object it should be near.
# https://matplotlib.org/3.5.0/gallery/color/colorbar_basics.html
fig.patch.set_facecolor('white')
ax[0].set_axis_off()
ax[1].set_axis_off()
ax[2].set_axis_off()
ax[3].set_axis_off()
ax[4].set_axis_off()
ax[0].set_title('Latitude')
ax[1].set_title('CML offset')
ax[2].set_title('$\mu$')
ax[3].set_title('$\mu_0$')
ax[4].set_title('$g_{\mathrm{eff}}$')
plt.savefig('CM7_geometry_grid_ipy.pdf')
1 extra bytes in post.stringData array 'created' timestamp seems very low; regarding as unix timestamp Zapf NOT subset; don't know how to subset; dropped feat NOT subset; don't know how to subset; dropped meta NOT subset; don't know how to subset; dropped morx NOT subset; don't know how to subset; dropped
Make grid of images showing how I/F and CM7 vary with deep cloud pressure level. Each grid array depends on the values for tau_haze and tau_deep. Set those all in a top cell and output as part of the upper left title.
There could be 12 of these plots, n_tauhaze * n_taucloud.
# setup
#
cmap_str_C = 'turbo' # 'viridis' # 'jet'
cmap_str_727 = 'turbo' # 'cool' # 'jet' 'plasma'
cmap_str_CM7 = 'turbo' # 'jet'
n_pcloud = pvals['dim_len'][3]
p_1C = pvals['values_float'][3][0:n_pcloud]
n_x = 16
n_y = 16
#if631_1C = ma.zeros((n_pcloud, n_x, n_y)) # I/F at continuum wavelength 631 nm / this doesn't make the mask right
if631_1C = ma.array(np.zeros((n_pcloud, n_x, n_y)), mask=np.zeros((n_pcloud, n_x, n_y))) # I/F at continuum wavelength 631 nm
if750_1C = copy.deepcopy(if631_1C) # I/F at continuum wavelength 750 nm
if727_1C = copy.deepcopy(if631_1C) # I/F at CH4-band wavelength 727 nm
cm7_6_1C = copy.deepcopy(if631_1C) # CM7 ratio (631 nm continuum)
cm7_7_1C = copy.deepcopy(if631_1C) # CM7 ratio (750 nm continuum)
# setup scale limits, can be adjusted if necessary or set to uniform
vmin_631 = [0, 0, 0, 0, 0, 0, 0]
vmin_727 = [0, 0, 0, 0, 0, 0, 0]
vmin_750 = [0, 0, 0, 0, 0, 0, 0]
vmax_631 = [1, 1, 1, 1, 1, 1, 1]
vmax_727 = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]
vmax_750 = [1, 1, 1, 1, 1, 1, 1]
vmin_cm7_6 = [1., 1, 1, 1, 1, 1, 1]
vmin_cm7_7 = [1., 1, 1, 1, 1, 1, 1]
vmax_cm7_6 = [3., 3, 3, 3, 3, 3, 3]
vmax_cm7_7 = [3., 3, 3, 3, 3, 3, 3]
# pick a set to examine... should we loop over all these?
#
i_phaze = 0 # [ 0.5 0. 0. 0. 0. 0. ]
i_rhaze = 1 # [ 0.2 0.5 2. 0. 0. 0. ]
i_tauhaze = 0 # [ 3. 10. 15. 0. 0. 0. ]
i_taucloud = 3 # [ 0. 5. 25. 100. 0. 0.]
out_filename = 'CM7_globes_H{:02.0f}R{:02.0f}_WT{:03.0f}_ipy.pdf'.format(pvals['values_float'][2,i_tauhaze], \
10*pvals['values_float'][1,i_rhaze], \
pvals['values_float'][4,i_taucloud])
top_title = ' $\\tau_{{\mathrm{{haze}}}}$ = {:2.0f}, '.format(pvals['values_float'][2,i_tauhaze]) + \
'$r_{{\mathrm{{haze}}}}$ = {:3.1f}, '.format(pvals['values_float'][1,i_rhaze]) + \
'$\\tau_{{\mathrm{{cloud}}}}$ = {:3.0f}\n'.format(pvals['values_float'][4,i_taucloud])
fig,ax = plt.subplots(figsize=(15, 15), ncols=5, nrows=5, gridspec_kw={'wspace': 0.2, 'hspace': 0.35})
fig.patch.set_facecolor('white')
#0 Filter central wavelength (micron)
#1 Upper trop. haze particle radius (micron
#2 Upper trop. haze optical depth
#3 Deep cloud base pressure (bar)
#4 Deep cloud optical depth
# ONE SET: all deep cloud pressure levels
#
for i_pcloud in range(5): # [ 2. 3. 4. 5. 6. ]
# select data and make ratios, mask out space in the corners,
# save the results for later use
#
if631_1C[i_pcloud][:][:] = ma.masked_array(np.squeeze(CM7[0].data[i_taucloud,i_pcloud,i_tauhaze,
i_rhaze,0,:,:]),mask=planet)
if750_1C[i_pcloud][:][:] = ma.masked_array(np.squeeze(CM7[0].data[i_taucloud,i_pcloud,i_tauhaze,
i_rhaze,2,:,:]),mask=planet)
if727_1C[i_pcloud][:][:] = ma.masked_array(np.squeeze(CM7[0].data[i_taucloud,i_pcloud,i_tauhaze,
i_rhaze,1,:,:]), mask=planet)
cm7_6_1C[i_pcloud][:][:] = if631_1C[i_pcloud][:][:] / if727_1C[i_pcloud][:][:]
cm7_7_1C[i_pcloud][:][:] = if750_1C[i_pcloud][:][:] / if727_1C[i_pcloud][:][:]
# this row: col 0, continuum 631
panel = ax[i_pcloud,0].imshow(if631_1C[i_pcloud][:][:], origin='lower', cmap=cmap_str_C, \
vmin=vmin_631[i_pcloud], vmax=vmax_631[i_pcloud])
fig.colorbar(panel, ax=ax[i_pcloud,0],
ticks=np.linspace(vmin_631[i_pcloud], vmax_631[i_pcloud], 5))
# this row: col 1, CH4-band 727
panel = ax[i_pcloud,1].imshow(if727_1C[i_pcloud][:][:], origin='lower', cmap=cmap_str_727, \
vmin=vmin_727[i_pcloud], vmax=vmax_727[i_pcloud])
fig.colorbar(panel, ax=ax[i_pcloud,1],
ticks=np.linspace(vmin_727[i_pcloud], vmax_727[i_pcloud], 5))
# this row: col 2, continuum 750
panel = ax[i_pcloud,2].imshow(if750_1C[i_pcloud][:][:], origin='lower', cmap=cmap_str_C, \
vmin=vmin_750[i_pcloud], vmax=vmax_750[i_pcloud])
fig.colorbar(panel, ax=ax[i_pcloud,2],
ticks=np.linspace(vmin_750[i_pcloud], vmax_750[i_pcloud], 5))
# this row: col 3, CM7 ratio (631 continuum)
panel = ax[i_pcloud,3].imshow(cm7_6_1C[i_pcloud][:][:], origin='lower', cmap=cmap_str_CM7, \
vmin=vmin_cm7_6[i_pcloud], vmax=vmax_cm7_6[i_pcloud])
fig.colorbar(panel, ax=ax[i_pcloud,3],
ticks=np.linspace(vmin_cm7_6[i_pcloud], vmax_cm7_6[i_pcloud], 5))
# this row: col 4, CM7 ratio (750 continuum)
panel = ax[i_pcloud,4].imshow(cm7_7_1C[i_pcloud][:][:], origin='lower', cmap=cmap_str_CM7, \
vmin=vmin_cm7_7[i_pcloud], vmax=vmax_cm7_7[i_pcloud])
fig.colorbar(panel, ax=ax[i_pcloud,4],
ticks=np.linspace(vmin_cm7_7[i_pcloud], vmax_cm7_7[i_pcloud], 5))
# this row: y-axis on col 1 says the 1-cloud pressure level
ax[i_pcloud,0].set_ylabel('$P_{{\mathrm{{cloud}}}}$ = {:1.0f} bar'.format(pvals['values_float'][3,i_pcloud]))
for i in range(5):
for j in range(5):
ax[j,i].set_xticks([]) #axes.xaxis.set_ticklabels([])
ax[j,i].set_yticks([])
ax[j,i].set_frame_on(False)
ax[0,0].set_title(top_title +
'{:3.0f} nm'.format(pvals['values_float'][0,0] *1000))
ax[0,1].set_title('{:3.0f} nm'.format(pvals['values_float'][0,1] *1000))
ax[0,2].set_title('{:3.0f} nm'.format(pvals['values_float'][0,2] *1000))
ax[0,3].set_title('631/727 ratio')
ax[0,4].set_title('750/727 ratio')
plt.savefig(out_filename)
1 extra bytes in post.stringData array 'created' timestamp seems very low; regarding as unix timestamp Zapf NOT subset; don't know how to subset; dropped feat NOT subset; don't know how to subset; dropped meta NOT subset; don't know how to subset; dropped morx NOT subset; don't know how to subset; dropped
There could be 9 of these plots, n_tauhaze * n_rhaze.
# read in actual data points for comparison
#
hst_631 = np.loadtxt("PJ42_631_minmax_mu0curve.txt", skiprows=6, usecols=(0,1,2,3))
hst_727 = np.loadtxt("PJ42_727_minmax_mu0curve.txt", skiprows=6, usecols=(0,1,2,3))
hst_750 = np.loadtxt("PJ42_750_minmax_mu0curve.txt", skiprows=6, usecols=(0,1,2,3))
plt.rcParams["font.size"] = 12
cstep = 45 #33
fullcolor = cm.get_cmap('turbo')
# pick a set to examine... should we loop over all these?
#
i_phaze = 0 # [ 0.5 0. 0. 0. 0. 0. ]
i_rhaze = 2 # [ 0.2 0.5 2. 0. 0. 0. ]
i_tauhaze = 1 # [ 3. 10. 15. 0. 0. 0. ]
out_fileroot = 'IF_CTL_tau_H{:02.0f}R{:02.0f}_ipy'.format(pvals['values_float'][2,i_tauhaze], \
10*pvals['values_float'][1,i_rhaze])
top_title = ' $\\tau_{{\mathrm{{haze}}}}$ = {:2.0f}, '.format(pvals['values_float'][2,i_tauhaze]) + \
'$r_{{\mathrm{{haze}}}}$ = {:3.1f}\n'.format(pvals['values_float'][1,i_rhaze])
fig,ax = plt.subplots(figsize=(12,16), ncols=3, nrows=4, gridspec_kw={'wspace': 0.2})
fig.patch.set_facecolor('white')
for i_taucloud in range(4): # [ 0. 5. 25. 100. 0. 0.]
# setup the new I/F and ratio arrays for the selected tau_cloud:
if631_tautest = ma.array(np.zeros((n_pcloud, n_x, n_y)), mask=np.zeros((n_pcloud, n_x, n_y))) # I/F at continuum wavelength 631 nm
if750_tautest = if631_tautest.copy() # I/F at continuum wavelength 750 nm
if727_tautest = if631_tautest.copy() # I/F at CH4-band wavelength 727 nm
# load the I/F data arrays
#
for i_pcloud in range(5): # [ 2 3. 4. 5. 6. ]
if631_tautest[i_pcloud][:][:] = ma.masked_array(np.squeeze(CM7[0].data[i_taucloud,i_pcloud,
i_tauhaze,i_rhaze,0,:,:]), mask=planet)
if750_tautest[i_pcloud][:][:] = ma.masked_array(np.squeeze(CM7[0].data[i_taucloud,i_pcloud,
i_tauhaze,i_rhaze,2,:,:]), mask=planet)
if727_tautest[i_pcloud][:][:] = ma.masked_array(np.squeeze(CM7[0].data[i_taucloud,i_pcloud,
i_tauhaze,i_rhaze,1,:,:]), mask=planet)
# estimate CM7 from known P and mu values
#
for i_pcloud in range(5):
p_mu = ma.array(np.zeros((2, n_x, n_y)), mask=np.zeros((2, n_x, n_y)))
p_mu[0][:][:] = p_1C[i_pcloud]
p_mu[1][:][:] = CM7[4].data
p_flat = p_mu[0][:][:].flatten()
mu_flat = p_mu[1][:][:].flatten() # ?????
p_mu_flat = np.stack((p_flat, mu_flat), axis=0)
# plot this tau in a row
for i_pcloud in range(5): # [ 2 3. 4. 5. 6. ]
i_color = i_pcloud *cstep + 10
# show fits
ax[i_taucloud,0].plot(CM7[4].data.flatten(), if631_tautest[i_pcloud][:][:].flatten(), 'o',
markerfacecolor='none', color=fullcolor(i_color),
label='{:1.0f} bar'.format(pvals['values_float'][3,i_pcloud]))
ax[i_taucloud,1].plot(CM7[4].data.flatten(), if727_tautest[i_pcloud][:][:].flatten(), 'o',
markerfacecolor='none', color=fullcolor(i_color),
label='{:1.0f} bar'.format(pvals['values_float'][3,i_pcloud]))
ax[i_taucloud,2].plot(CM7[4].data.flatten(), if750_tautest[i_pcloud][:][:].flatten(), 'o',
markerfacecolor='none', color=fullcolor(i_color),
label='{:1.0f} bar'.format(pvals['values_float'][3,i_pcloud]))
ax[i_taucloud,0].set_ylabel('I/F reflectivity', size=15)
ax[i_taucloud,0].set_title('$\\tau_{{\mathrm{{cloud}}}}$ = {:0.0f} (631 nm)'.format(pvals['values_float'][4,i_taucloud]))
ax[i_taucloud,1].set_title('$\\tau_{{\mathrm{{cloud}}}}$ = {:0.0f} (727 nm)'.format(pvals['values_float'][4,i_taucloud]))
ax[i_taucloud,2].set_title('$\\tau_{{\mathrm{{cloud}}}}$ = {:0.0f} (750 nm)'.format(pvals['values_float'][4,i_taucloud]))
ax[i_taucloud,0].set_ylim([0,0.9])
ax[i_taucloud,1].set_ylim([0,0.9])
ax[i_taucloud,2].set_ylim([0,0.9])
# also show the HST data
ax[i_taucloud,0].plot(hst_631[:,0], hst_631[:,1], '-', linewidth=3, color=fullcolor(0))
ax[i_taucloud,0].plot(hst_631[:,0], hst_631[:,2], '--', linewidth=1, color=fullcolor(0))
ax[i_taucloud,0].plot(hst_631[:,0], hst_631[:,3], '--', linewidth=1, color=fullcolor(0))
ax[i_taucloud,1].plot(hst_727[:,0], hst_727[:,1], '-', linewidth=3, color=fullcolor(0))
ax[i_taucloud,1].plot(hst_727[:,0], hst_727[:,2], '--', linewidth=1, color=fullcolor(0))
ax[i_taucloud,1].plot(hst_727[:,0], hst_727[:,3], '--', linewidth=1, color=fullcolor(0))
ax[i_taucloud,2].plot(hst_750[:,0], hst_750[:,1], '-', linewidth=3, color=fullcolor(0))
ax[i_taucloud,2].plot(hst_750[:,0], hst_750[:,2], '--', linewidth=1, color=fullcolor(0))
ax[i_taucloud,2].plot(hst_750[:,0], hst_750[:,3], '--', linewidth=1, color=fullcolor(0))
# x-label, legend only on bottom row
ax[3,0].set_xlabel('Incident angle cosine, $\mu_0$', size=15)
ax[3,1].set_xlabel('Incident angle cosine, $\mu_0$', size=15)
ax[3,2].set_xlabel('Incident angle cosine, $\mu_0$', size=15)
ax[3,1].legend(fontsize=12)
for axi in ax.flat:
axi.minorticks_on()
axi.tick_params(which='major', length=8, direction='in', right=True, top=True)
axi.tick_params(which='minor', length=4, direction='in', right=True, top=True)
axi.set_xlim([0.2,1])
ax[0,0].set_title(top_title +
'$\\tau_{{\mathrm{{cloud}}}}$ = {:0.0f} (631 nm)'.format(pvals['values_float'][4,0]))
plt.savefig(out_fileroot + '.pdf')
plt.savefig(out_fileroot + '.png')
1 extra bytes in post.stringData array 'created' timestamp seems very low; regarding as unix timestamp Zapf NOT subset; don't know how to subset; dropped feat NOT subset; don't know how to subset; dropped meta NOT subset; don't know how to subset; dropped morx NOT subset; don't know how to subset; dropped
Compute fits and plot results (CM7).
from numpy.polynomial import polynomial as Poly
import scipy
from scipy.optimize import curve_fit
mu_cut = 0.3 # 0.2
mu_mask = np.where((CM7[4].data < mu_cut) | (CM7[5].data < 1000.),
np.ones(CM7[4].data.shape), np.zeros(CM7[4].data.shape))
if631_tautest = ma.array(np.zeros((n_pcloud, n_x, n_y)), mask=np.zeros((n_pcloud, n_x, n_y))) # I/F at continuum wavelength 631 nm
if750_tautest = copy.deepcopy(if631_tautest) # I/F at continuum wavelength 750 nm
if727_tautest = copy.deepcopy(if631_tautest) # I/F at CH4-band wavelength 727 nm
cm7_6_tautest = copy.deepcopy(if631_tautest) # CM7 ratio (631 nm continuum)
cm7_7_tautest = copy.deepcopy(if631_tautest) # CM7 ratio (750 nm continuum)
def CM7_fn(p_mu, r_00, r_01, r_02, m_0, m_1, m_2):
p, mu = p_mu
xr = r_00 + r_01 * p**0.5 + r_02 * p
xm = m_0 * mu + m_1 * p**0.5 * mu + m_2 * p * mu
return xr + xm
def invP_(fitparam, cm7, mu_0, mu_cut, quadsign):
# solve for p using new multivariate function
denom = fitparam[2] + fitparam[5]*mu_0
quad_c = (fitparam[0] + fitparam[3]*mu_0 - cm7) / denom
quad_b = (fitparam[1] + fitparam[4]*mu_0) / denom
discriminant = np.clip(quad_b**2 - 4*quad_c, 0, 999.)
return 0.5*quad_b**2 - quad_c + quadsign * 0.5*quad_b * discriminant**0.5
cmap_str = 'turbo' # 'jet'
plt.rcParams["font.size"] = 12
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = ['Helvetica', 'Roboto', 'Verdana', 'Arial']
plt.rcParams['pdf.fonttype'] = 42
# read in actual data points for comparison
#
hst_CM7_6 = np.loadtxt("PJ42_CM7-631_minmax_mu0curve.txt", skiprows=6, usecols=(0,1,2,3))
hst_CM7_7 = np.loadtxt("PJ42_CM7-750_minmax_mu0curve.txt", skiprows=6, usecols=(0,1,2,3))
# pick a set to examine... should we loop over all these?
#
i_phaze = 0 # [ 0.5 0. 0. 0. 0. 0. ]
i_rhaze = 2 # [ 0.2 0.5 2. 0. 0. 0. ]
i_tauhaze = 2 # [ 3. 10. 15. 0. 0. 0. ]
out_fileroot = 'CM7_CTL_tau_H{:02.0f}R{:02.0f}_ipy'.format(pvals['values_float'][2,i_tauhaze], \
10*pvals['values_float'][1,i_rhaze])
top_title = ' $\\tau_{{\mathrm{{haze}}}}$ = {:2.0f}, '.format(pvals['values_float'][2,i_tauhaze]) + \
'$r_{{\mathrm{{haze}}}}$ = {:3.1f}\n'.format(pvals['values_float'][1,i_rhaze])
fig,ax = plt.subplots(figsize=(12,16), ncols=2, nrows=4, gridspec_kw={'wspace': 0.2})
fig.patch.set_facecolor('white')
for i_taucloud in range(4): # [ 0. 5. 25. 100. 0. 0.]
# setup data arrays
#
for i_pcloud in range(5): # [ 2 3. 4. 5. 6. ]
if631_tautest[i_pcloud][:][:] = ma.masked_array(np.squeeze(CM7[0].data[i_taucloud,i_pcloud,
i_tauhaze,i_rhaze,0,:,:]), mask=planet)
if750_tautest[i_pcloud][:][:] = ma.masked_array(np.squeeze(CM7[0].data[i_taucloud,i_pcloud,
i_tauhaze,i_rhaze,2,:,:]), mask=planet)
if727_tautest[i_pcloud][:][:] = ma.masked_array(np.squeeze(CM7[0].data[i_taucloud,i_pcloud,
i_tauhaze,i_rhaze,1,:,:]), mask=planet)
cm7_6_tautest[i_pcloud][:][:] = if631_tautest[i_pcloud][:][:] / if727_tautest[i_pcloud][:][:]
cm7_7_tautest[i_pcloud][:][:] = if750_tautest[i_pcloud][:][:] / if727_tautest[i_pcloud][:][:]
# determine fit coefficients
#
p_mu = ma.array(np.zeros((2, n_pcloud, n_x, n_y)), mask=np.zeros((2, n_pcloud, n_x, n_y)))
rat_6_tautest = ma.array(np.zeros((n_pcloud, n_x, n_y)), mask=np.zeros((n_pcloud, n_x, n_y)))
rat_7_tautest = ma.array(np.zeros((n_pcloud, n_x, n_y)), mask=np.zeros((n_pcloud, n_x, n_y)))
for i in range(n_pcloud):
p_mu[0][i][:][:] = ma.array(np.full((n_x, n_y), p_1C[i]), mask=mu_mask)
p_mu[1][i][:][:] = ma.array(CM7[4].data, mask=mu_mask)
rat_6_tautest[i][:][:] = ma.array(cm7_6_tautest[i][:][:], mask=mu_mask)
rat_7_tautest[i][:][:] = ma.array(cm7_7_tautest[i][:][:], mask=mu_mask)
p_flat = ma.compressed(p_mu[0])
mu_flat = ma.compressed(p_mu[1])
p_mu_flat = np.stack((p_flat, mu_flat), axis=0)
fitparam_guess = [1.5, 1, -0.3, 0.01, 0.6, -0.01]
fitparam_CM7_6_tautest, fitcovar_CM7_6_tautest = curve_fit(CM7_fn, p_mu_flat,
ma.compressed(rat_6_tautest), fitparam_guess)
fitparam_CM7_7_tautest, fitcovar_CM7_7_tautest = curve_fit(CM7_fn, p_mu_flat,
ma.compressed(rat_7_tautest), fitparam_guess)
# get fitted values
#
fit_CM7_6_tautest = ma.array(np.zeros((n_pcloud, n_x, n_y)),
mask=np.zeros((n_pcloud, n_x, n_y)))
fit_CM7_7_tautest = copy.deepcopy(fit_CM7_6_tautest)
invP_6_tautest = copy.deepcopy(fit_CM7_6_tautest)
invP_7_tautest = copy.deepcopy(fit_CM7_6_tautest)
quadsign_6 = [1, 1, 1, 1, 1, 1, 1]
quadsign_7 = [1, 1, 1, 1, 1, 1, 1]
# estimate CM7 from known P and mu values
#
for i_pcloud in range(n_pcloud):
p_mu = ma.array(np.zeros((2, n_x, n_y)), mask=np.zeros((2, n_x, n_y)))
p_mu[0][:][:] = p_1C[i_pcloud]
p_mu[1][:][:] = CM7[4].data
p_flat = p_mu[0][:][:].flatten()
mu_flat = p_mu[1][:][:].flatten()
p_mu_flat = np.stack((p_flat, mu_flat), axis=0)
raw = np.reshape(CM7_fn(p_mu_flat, *fitparam_CM7_6_tautest), (n_x, n_y))
fit_CM7_6_tautest[i_pcloud][:][:] = ma.array(raw, mask=planet)
raw = np.reshape(CM7_fn(p_mu_flat, *fitparam_CM7_7_tautest), (n_x, n_y))
fit_CM7_7_tautest[i_pcloud][:][:] = ma.array(raw, mask=planet)
# , plot this tau in a row
for i_pcloud in range(n_pcloud):
i_color = i_pcloud *cstep + 10
# show fits
ax[i_taucloud,0].plot(CM7[4].data.flatten(), cm7_7_tautest[i_pcloud][:][:].flatten(), 'o',
markerfacecolor='none', color=fullcolor(i_color),
label='{:3.1f} bar'.format(pvals['values_float'][3,i_pcloud]))
ax[i_taucloud,0].plot(CM7[4].data.flatten(), fit_CM7_7_tautest[i_pcloud][:][:].flatten(),
'-', color=fullcolor(i_color))
ax[i_taucloud,1].plot(CM7[4].data.flatten(), cm7_6_tautest[i_pcloud][:][:].flatten(), 'o',
markerfacecolor='none', color=fullcolor(i_color),
label='{:3.1f} bar'.format(pvals['values_float'][3,i_pcloud]))
ax[i_taucloud,1].plot(CM7[4].data.flatten(), fit_CM7_6_tautest[i_pcloud][:][:].flatten(),
'-', color=fullcolor(i_color))
ax[i_taucloud,0].set_ylabel('CM7 reflectivity ratios', size=15)
ax[i_taucloud,0].set_title('$\\tau$ = {:0.0f} (750 / 727 ratio)'.format(pvals['values_float'][4,i_taucloud]))
ax[i_taucloud,1].set_title('$\\tau$ = {:0.0f} (631 / 727 ratio)'.format(pvals['values_float'][4,i_taucloud]))
ax[i_taucloud,0].set_ylim([1.,3.5]) #[0.,10]) #[1.25,2.75])
ax[i_taucloud,1].set_ylim([1.,3.5]) #[0.,10]) #[1.25,3.25])
# also show the HST data
ax[i_taucloud,0].plot(hst_CM7_7[:,0], hst_CM7_7[:,1], '-', linewidth=3, color=fullcolor(0))
ax[i_taucloud,0].plot(hst_CM7_7[:,0], hst_CM7_7[:,2], '--', linewidth=1, color=fullcolor(0))
ax[i_taucloud,0].plot(hst_CM7_7[:,0], hst_CM7_7[:,3], '--', linewidth=1, color=fullcolor(0))
ax[i_taucloud,1].plot(hst_CM7_6[:,0], hst_CM7_6[:,1], '-', linewidth=3, color=fullcolor(0))
ax[i_taucloud,1].plot(hst_CM7_6[:,0], hst_CM7_6[:,2], '--', linewidth=1, color=fullcolor(0))
ax[i_taucloud,1].plot(hst_CM7_6[:,0], hst_CM7_6[:,3], '--', linewidth=1, color=fullcolor(0))
# x-label, legend only on bottom row
ax[3,0].set_xlabel('Incident angle cosine, $\mu_0$', size=15)
ax[3,1].set_xlabel('Incident angle cosine, $\mu_0$', size=15)
ax[3,1].legend(fontsize=12)
for axi in ax.flat:
axi.minorticks_on()
axi.tick_params(which='major', length=8, direction='in', right=True, top=True)
axi.tick_params(which='minor', length=4, direction='in', right=True, top=True)
axi.set_xlim([0.2,1])
ax[0,0].set_title(top_title + '$\\tau$ = 0 (750 / 727 ratio)')
plt.savefig(out_fileroot + '.png')
plt.savefig(out_fileroot + '.pdf')
1 extra bytes in post.stringData array 'created' timestamp seems very low; regarding as unix timestamp Zapf NOT subset; don't know how to subset; dropped feat NOT subset; don't know how to subset; dropped meta NOT subset; don't know how to subset; dropped morx NOT subset; don't know how to subset; dropped
(see scripts_v6/CM7_figs.ipynb
)
Conclusion is going to be that mostly you just see effects of the upper cloud/haze layer opacity variation. Only in specific situations is there sensitivity to deeper clouds and their specific pressure levels.
What are the corresponding CM7 for these models?
In all cases, CM7 vs mu_0 is positive/flat in the model and negative in the data. It's flatter for the 0.2-micron particles. Should it be even smaller? But see tau_haze=3, r=0.2, there is no sensitivity to deep cloud level and the CM7_750 is way too low.
What are the conditions where there is good sensitivity to cloud depth? Consider showing tau_cloud=25 cases for several tau_haze values:
import pickle
tmp = pickle.load(open(str('output/CM7_H4T9_W3T02.pickle'),'rb'))
tmp.keys()
dict_keys(['run_id', 'inp', 'if631', 'if727', 'if750'])
dogs = 43.2
print(dogs > 50)
False