Adapt scripts_v5/CM7_figs.ipynb
to look at the scripts_v6 data, which ran the week before ERS meeting. If this doesn't work, the paper will not make the Remote Sensing special issue.
from astropy.io import fits as pyfits
CM7 = pyfits.open('output/CM7_v6_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_v6_cube.fits No. Name Ver Type Cards Dimensions Format 0 PRIMARY 1 PrimaryHDU 48 (16, 16, 3, 1, 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' 'P_H' 'tau_H' 'P_W' 'tau_W'] dim_comment: 0 Filter central wavelength (micron) 1 Upper trop. haze base pressure (bar) 2 Upper trop. haze optical depth 3 Deep cloud base pressure (bar) 4 Deep cloud optical depth dim_len: [3 1 3 5 4] values_float: [[ 0.631 0.727 0.75 0. 0. 0. ] [ 0.5 0. 0. 0. 0. 0. ] [ 1. 5. 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))
# 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')
fig.colorbar(panel, ax=ax[i], ticks=np.linspace(panel_data.min(), panel_data.max(), 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 P_haze, tau_haze, and tau_deep. Set those all in a top cell and output as part of the upper left title.
There could be 45 of these plots, n_tauhaze n_phaze n_taucloud.
# setup
#
cmap_str_C = 'turbo' # 'viridis' # 'jet'
cmap_str_727 = 'turbo' # 'cool' # 'jet' 'plasma'
cmap_str_CM7 = 'turbo' # 'jet'
p_1C = pvals['values_float'][3][0:5]
n_pcloud = pvals['dim_len'][3]
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_727 = [0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4]
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]
vmin_cm7_6 = [1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5]
vmin_cm7_7 = [1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5]
vmax_cm7_6 = [2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7]
vmax_cm7_7 = [2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7]
# pick a set to examine... should we loop over all these?
#
i_phaze = 0 # [ 0.5 0. 0. 0. 0. 0. ]
i_tauhaze = 1 # [ 1. 5. 15. 0. 0. 0. ]
i_taucloud = 2 # [ 0. 5. 25. 100. 0. 0. ]
out_filename = 'CM7_globes_H{:1.0f}T{:1.0f}_WT{:02.0f}_ipy.pdf'.format(pvals['values_float'][1,i_phaze] *10.,
pvals['values_float'][2,i_tauhaze],
pvals['values_float'][4,i_taucloud])
top_title = ' $P_{{\mathrm{{haze}}}}$ = {:1.1f}, '.format(pvals['values_float'][1,i_phaze]) + \
'$\\tau_{{\mathrm{{haze}}}}$ = {:1.0f}, '.format(pvals['values_float'][2,i_tauhaze]) + \
'$\\tau_{{\mathrm{{cloud}}}}$ = {:2.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')
# 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_phaze,0,:,:]),mask=planet)
if750_1C[i_pcloud][:][:] = ma.masked_array(np.squeeze(CM7[0].data[i_taucloud,i_pcloud,i_tauhaze,
i_phaze,2,:,:]),mask=planet)
if727_1C[i_pcloud][:][:] = ma.masked_array(np.squeeze(CM7[0].data[i_taucloud,i_pcloud,i_tauhaze,
i_phaze,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_phaze.
# 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.4 0.6 0.8 0. 0. 0. ]
i_tauhaze = 2 # [ 1. 3. 9. 0. 0. 0. ]
out_fileroot = 'IF_CTL_tau_H{:1.0f}T{:1.0f}_ipy'.format(pvals['values_float'][1,i_phaze] *10.,
pvals['values_float'][2,i_tauhaze])
top_title = ' $P_{{\mathrm{{haze}}}}$ = {:1.1f}, '.format(pvals['values_float'][1,i_phaze]) + \
'$\\tau_{{\mathrm{{haze}}}}$ = {:1.0f}\n'.format(pvals['values_float'][2,i_tauhaze])
fig,ax = plt.subplots(figsize=(12,20), ncols=3, nrows=5, gridspec_kw={'wspace': 0.2})
fig.patch.set_facecolor('white')
for i_taucloud in range(5): # [ 0. 2. 5. 15. 50. ]
# 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_phaze,0,:,:]), mask=planet)
if750_tautest[i_pcloud][:][:] = ma.masked_array(np.squeeze(CM7[0].data[i_taucloud,i_pcloud,
i_tauhaze,i_phaze,2,:,:]), mask=planet)
if727_tautest[i_pcloud][:][:] = ma.masked_array(np.squeeze(CM7[0].data[i_taucloud,i_pcloud,
i_tauhaze,i_phaze,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[4,0].set_xlabel('Incident angle cosine, $\mu_0$', size=15)
ax[4,1].set_xlabel('Incident angle cosine, $\mu_0$', size=15)
ax[4,2].set_xlabel('Incident angle cosine, $\mu_0$', size=15)
ax[4,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.4 0.6 0.8 0. 0. 0. ]
i_tauhaze = 1 # [ 1. 3. 9. 0. 0. 0. ]
out_fileroot = 'CM7_CTL_tau_H{:1.0f}T{:1.0f}_ipy'.format(pvals['values_float'][1,i_phaze] *10.,
pvals['values_float'][2,i_tauhaze])
top_title = ' $P_{{\mathrm{{haze}}}}$ = {:1.1f}, '.format(pvals['values_float'][1,i_phaze]) + \
'$\\tau_{{\mathrm{{haze}}}}$ = {:1.0f}\n'.format(pvals['values_float'][2,i_tauhaze])
fig,ax = plt.subplots(figsize=(12,20), ncols=2, nrows=5, gridspec_kw={'wspace': 0.2})
fig.patch.set_facecolor('white')
for i_taucloud in range(5): # [ 0. 2. 5. 15. 50. ]
# 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_phaze,0,:,:]), mask=planet)
if750_tautest[i_pcloud][:][:] = ma.masked_array(np.squeeze(CM7[0].data[i_taucloud,i_pcloud,
i_tauhaze,i_phaze,2,:,:]), mask=planet)
if727_tautest[i_pcloud][:][:] = ma.masked_array(np.squeeze(CM7[0].data[i_taucloud,i_pcloud,
i_tauhaze,i_phaze,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[4,0].set_xlabel('Incident angle cosine, $\mu_0$', size=15)
ax[4,1].set_xlabel('Incident angle cosine, $\mu_0$', size=15)
ax[4,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
Initial thoughts (CM7):
Checklist for 16-17 Oct 2022:
template_v6
for new structure and valuesgenerate_v6
for new structure and output filenamesscratch.pro
to call the new generate with the right codesModel so far does not capture the full variability of cloud/haze structure, but shows useful trends. There are clearly still deficiencies in the model cloud/haze structure.
Majority of reflectivity modulation is from variability of $\tau_{\mathrm{haze}}$.
Majority of CM7 modulation is also from variability of $\tau_{\mathrm{haze}}$.
To find the deepest clouds: High continuum, low 727. This is really best in the CH4-composite display, because CM7 itself is so sensitive to haze opacity. Maybe RGB should be R=cont, G=727, and B=M7C (727/cont) ratio?
CM7 is sensitive to $P_{\mathrm{cloud}}$ ONLY when $\tau_{\mathrm{haze}}$ is very small.
Overall planetary CTL curves for both I/F and CM7 are best fit by $\tau_{\mathrm{haze}}$ = 5, $\tau_{\mathrm{cloud}}$ = 25. But slope of 727 (and thus CM7) does not match the data.
Slope of 727 (and thus CM7) is best fit for $\tau_{\mathrm{haze}}$ = 15, but this gives too-low CM7, too-high I/F for 727, and chronically too-low I/F for 750.
Things to think about changing if we did another run:
Checklist for 22 2022: (at SFO Mustard, trying to start next batch before departure)
template_v7
for new structure and values. Safest in a rush: duplicate x3 for the different particle sizes.generate_v7
for new structure and output filenamesscratch.pro
to call the new generate with the right input paramsimport 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