File size: 7,199 Bytes
5ab75a9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | function Pcrem_images(L10PremImage,L10Premmd,L10Premlo,L10Premhi, ...
YvalImage,Yval0,PcumImage,RmvrImage,Ylabl,Titl)
% Pcrem_images - Render images of Pcum and Nmvr as a function of L10Prem
% (x-axis) and a y-axis variable (e.g., Tmis, Fred, or Tcom)
%
% Syntax: Pcrem_images(L10PremImage,L10Premmd,L10Premlo,L10Premhi, ...
% YvalImage,Yval0,PcumImage,RmvrImage,Ylabl,Titl)
%
% =========================================================================
%
% Copyright (c) 2025 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% All Rights Reserved.
%
% =========================================================================
%
% Description: Render images of Pcum and Nmvr as a function of L10Prem
% (x-axis) and a y-axis variable (e.g., Tmis, Fred, or Tcom)
%
% =========================================================================
%
% Input:
%
% L10PremImage - Array of Log10 Pc values to plot [Np x 1]
%
% L10Premmd - median Pc value at nominal solution
%
% L10Premlo - low percentile Pc value at nominal solution
%
% L10Premhi - high percentile Pc value at nominal solution
%
% YvalImage - Array of y-values to plot [Ny x 1]
%
% Yval0 - Nominal y-value
%
% PcumImage - Array of Pc values corresponding to each [Np x Ny]
% Prem-Fred combination
%
% RmvrImage - Array of RMM values corresponding to each [Np x Ny]
% Prem-Fred combination. Can be set as empty
% to skip RMM rate plotting
%
% Ylabl - y-axis label
%
% Titl - Plot title
% =========================================================================
%
% Output:
%
% None
%
% =========================================================================
%
% Dependencies:
%
% None
%
% =========================================================================
%
% Subfunctions:
%
% None
%
% =========================================================================
%
% Initial version: Apr 2022; Latest update: Apr 2022
%
% ----------------- BEGIN CODE -----------------
% Initialize plot
clf;
xfsz = 11;
yfsz = xfsz;
xfwt = 'bold';
yfwt = xfwt;
tfsz = xfsz;
tfwt = 'bold';
tfan = 'italic';
lfsz = xfsz;
lfwt = 'bold';
afsz = xfsz;
afwt = 'bold';
alwd = 1;
% Contour and solution-point colors
contcolr = [0 0 0];
solncolr = 'b';
solnmrkr = 'o';
solnmsiz = 6;
% Yellow-to-red colormap
Nmap = 256;
cmap = zeros(Nmap,3);
cmap(:,1) = 1;
cmap(:,3) = 0;
cmap(:,2) = cmap(:,3)+(1-cmap(:,3)).*((0:Nmap-1)'/(Nmap-1));
cmap = flipud(cmap);
colormap(cmap);
% Determine if plotting RMM rate or not
plotRMMrates = ~isempty(RmvrImage);
% Image: x=L10Prem, y=Yval, z=Pcum
if plotRMMrates
subplot(3,1,2,'replace');
else
subplot(3,1,[2 3],'replace');
end
xrng = [L10PremImage(1) L10PremImage(end)];
yrng = [YvalImage(1) YvalImage(end)];
img = log10(PcumImage)';
imagesc(L10PremImage,YvalImage,img);
axis xy;
hold on;
% Overplot contours of log10(Pcum)
mincon = min(-1,floor(L10PremImage(1)));
maxcon = -1;
% Plot 1e-N solid-line contours with labels
seqcon = (mincon:1:maxcon);
contour(L10PremImage,YvalImage,img,seqcon, ...
'LineStyle','-','LineColor',contcolr,'ShowText','On');
% Plot 3e-N dotted-line contours without labels
seqcon = seqcon + log10(3);
contour(L10PremImage,YvalImage,img,seqcon, ...
'LineStyle',':','LineColor',contcolr,'ShowText','Off');
% Mark nominal solution
if ~isempty(L10Premmd)
plot(L10Premmd,Yval0,solnmrkr,'MarkerSize',solnmsiz, ...
'MarkerFaceColor',solncolr,'MarkerEdgeColor',solncolr);
plot([L10Premlo L10Premhi],[Yval0 Yval0],'-','Color',solncolr);
end
hold off;
xlim(xrng);
ylim(yrng);
xlabl = 'Log_{10}[Remediation Threshold Pc]';
ylabl = Ylabl;
xlabel(xlabl,'FontSize',xfsz,'FontWeight',xfwt);
ylabel(ylabl,'FontSize',yfsz,'FontWeight',yfwt);
set(gca,'LineWidth',alwd,'FontSize',afsz,'FontWeight',afwt);
cb = colorbar;
cb.Label.String = 'Log_{10}[Cumulative Pc]';
cb.FontSize = yfsz;
crng = [min(img(:)),max(img(:))];
if crng(1) == crng(2)
crng(1) = crng(1)-1e-3;
crng(2) = crng(2)+1e-3;
end
caxis(crng);
% Image: x=L10Prem, y=Yval, z=Nmvr
if plotRMMrates
subplot(3,1,3,'replace');
img = log10(RmvrImage)';
imAlpha = ones(size(img));
ndx = isinf(img);
imAlpha(ndx) = 0;
imagesc(L10PremImage,YvalImage,img,'AlphaData',imAlpha);
gscl = (1+max(sum(cmap,2))/3)/2;
set(gca,'color',gscl*[1 1 1]);
axis xy;
hold on;
% Overplot contours of log10(Nmvr)
ndx = ~ndx;
if any(ndx)
crng = [min(img(ndx)) max(img(ndx))];
if crng(1) > 0
crng(1) = 0;
else
crng(1) = max(crng(2)-2,crng(1));
end
else
crng = [-1 1];
end
mincon = floor(crng(1));
maxcon = ceil(crng(2));
seqcon = (mincon:1:maxcon);
contour(L10PremImage,YvalImage,img,seqcon, ...
'LineStyle','-','LineColor',contcolr,'ShowText','On');
seqcon = seqcon + log10(3);
contour(L10PremImage,YvalImage,img,seqcon, ...
'LineStyle',':','LineColor',contcolr,'ShowText','Off');
if ~isempty(L10Premmd)
plot(L10Premmd,Yval0,solnmrkr,'MarkerSize',solnmsiz, ...
'MarkerFaceColor',solncolr,'MarkerEdgeColor',solncolr);
if (L10Premlo ~= L10Premmd)
plot([L10Premlo L10Premmd],[Yval0 Yval0],'-','Color',solncolr);
end
if (L10Premhi ~= L10Premmd)
plot([L10Premhi L10Premmd],[Yval0 Yval0],'-','Color',solncolr);
end
end
hold off;
xlim(xrng);
ylim(yrng);
xlabel(xlabl,'FontSize',xfsz,'FontWeight',xfwt);
ylabel(ylabl,'FontSize',yfsz,'FontWeight',yfwt);
set(gca,'LineWidth',alwd,'FontSize',afsz,'FontWeight',afwt);
cb = colorbar;
cb.Label.String = 'Log_{10}[RMM Rate (yr^{-1})]';
cb.FontSize = yfsz;
% caxis([0,max(img(:))]);
caxis(crng);
end
% Title
subplot(3,1,1,'replace');
axpos = get(gca,'OuterPosition');
axpos(2) = axpos(2)-0.025;
axpos(4) = 0.001;
set(gca,'OuterPosition',axpos)
axis off;
title(Titl,'FontSize',tfsz,'FontWeight',tfwt,'FontAngle',tfan);
drawnow;
return;
end
% ----------------- END OF CODE ------------------
%
% Please record any changes to the software in the change history
% shown below:
%
% ----------------- CHANGE HISTORY ------------------
% Developer | Date | Description
% ---------------------------------------------------
% D. Hall | 2022-Apr-11 | Initial version.
% =========================================================================
%
% Copyright (c) 2025 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% All Rights Reserved.
%
% ========================================================================= |