Commit 3edcf3a2 authored by Joe Taylor's avatar Joe Taylor
Browse files

minor updates to plotting and wrapper, new sample files

parent 04f6935d
This source diff could not be displayed because it is stored in LFS. You can view the blob instead.
......@@ -41,10 +41,11 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% START: USER INPUT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
sat_name = 'SNPP'; % set to 'J1' or 'SNPP'
l1b_fname = 'SNDR.SNPP.CRIS.20191031T0012.m06.g003.L1B.std.v03_08.G.201219125854.nc'; % set to file name of v3 L1b granule
%sat_name = 'J1'; % set to 'J1' or 'SNPP'
%l1b_fname = 'SNDR.J1.CRIS.20191031T0012.m06.g003.L1B.std.v03_08.G.201204050506.nc'; % set to file name of v3 L1b granule
%sat_name = 'SNPP'; % set to 'J1' or 'SNPP'
%l1b_fname = 'SNDR.SNPP.CRIS.20180401T1306.m06.g132.L1B.std.v03_08.G.201231182944.nc'; % set to file name of v3 L1b granule
%l1b_fname = 'SNDR.SNPP.CRIS.20180401T2206.m06.g222.L1B.std.v03_08.G.201231185850.nc'; % set to file name of v3 L1b granule
sat_name = 'J1'; % set to 'J1' or 'SNPP'
l1b_fname = 'SNDR.J1.CRIS.20180401T2254.m06.g230.L1B.std.v03_08.G.201214201329.nc'; % set to file name of v3 L1b granule
l1b_pname = '/Users/joet/git/cris_l1b_user/RU/TEST_INPUT'; % set to path to v3 L1b granule
ru_code_pname = pwd; % set to path of the RU code
......@@ -58,3 +59,7 @@ mkdir(pname_out)
addpath(ru_code_pname);
RU = cris_gran_RU_ncparam(sat_name,fullfile(l1b_pname,l1b_fname),saveTotalRU_FLAG,pname_out);
%% Generate plot (optional)
[~,fname_out,~] = fileparts(l1b_fname);
f_h = cris_ru_plot(RU,pname_out,fname_out);
function f_h = cris_ru_plot(RU,pname_out,fname_out);
% function f_h = cris_ru_plot(RU,pname_out,fname_out);
%
% This is a function to plot the granule mean (all FOVs, all FORs, all scans) brightness temperature,
% and 3-sigma (k=3 coverage factor) RU in the same format as figure 1 in the
% NASA Cross-track Infrared Sounder (CrIS) Level 1B Radiometric Uncertainty Description Document
%
% Inputs
% RU RU structure generated by cris_gran_RU_ncparam.m
% pname_out full path to output directory where figure will be saved in .png format
% fname_out name of output file that figure will be saved to in .png format (.png extension will be added to fname_out)
%
% Outputs
% f_h handle to figure
%
% JKT 2020-Sep-13
% University of Wisconsin-Madison Space Science and Engineering Center (UW-SSEC)
rucol(1,:) = [0.8431,0.1882,0.1529];
rucol(2,:) = [0.9961,0.8784,0.5451];
rucol(3,:) = [0.6510,0.8510,0.4157];
rucol(4,:) = [0.1020,0.5961,0.3137];
rucol(5,:) = [0.3294,0.1529,0.5608];
rucol(6,:) = [0.8706,0.4667,0.6824];
rucol(7,:) = [0,0,0];
cmap_btscat = parula(128);
%% Fontsize and Fontweight
fs = 8;fw = 'n';
ML = 0.1; % margin left
MR = 0.225; % margin right
MB = 0.2; % margin bottom
MT = 0.1; % margin top
HS = 0.03; % horizontal spacing
VS = 0.08; % vertical spacing
ylims_dbt = [-0.25 0.32];
ylims_dbtscatter = [0 0.32];
bands{1} = 'lw';
bands{2} = 'mw';
bands{3} = 'sw';
f_h = figure;
clf
set(f_h,'Units','inches');
screenpos = get(f_h,'Position');
w = 10;
h = 7.5;
p = 0.01;
set(f_h,...
'Position',[screenpos(1:2) w h],...
'PaperUnits','inches',...
'PaperPosition',[p*w p*h w h],...
'PaperSize',[w*(1+2*p) h*(1+2*p)]);
for ii = 1:length(bands)
clear leg_str
v = RU.(bands{ii}).v;
rad1 = squeeze(nanmean(RU.(bands{ii}).rad,2));
radu.T_ict = squeeze(nanmean(RU.(bands{ii}).ru_rad.dT_ict,2));
leg_str{1} = 'u(T_{ICT})';
radu.e_ict = squeeze(nanmean(RU.(bands{ii}).ru_rad.de_ict,2));
leg_str{2} = 'u(\epsilon_{ICT})';
radu.refl_meas = squeeze(nanmean(RU.(bands{ii}).ru_rad.refl_meas,2));
leg_str{3} = 'u(T_{Refl,meas})';
radu.refl_mod = squeeze(nanmean(RU.(bands{ii}).ru_rad.refl_mod,2));
leg_str{4} = 'u(T_{Refl,model})';
radu.polarization = squeeze(nanmean(RU.(bands{ii}).ru_rad.pol,2));
leg_str{5} = 'u(Pol Corr)';
radu.NLC = squeeze(nanmean(RU.(bands{ii}).ru_rad.dnlc,2));
leg_str{6} = 'u(NLC)';
radu.total = squeeze(nanmean(RU.(bands{ii}).ru_rad.total,2));
leg_str{7} = 'Total RU';
bt1 = rad2bt_l1b(v,rad1);
ru_flds = fieldnames(radu);
for iflds = 1:length(ru_flds)
btu.(ru_flds{iflds}) = rad2bt_l1b(v,rad1+radu.(ru_flds{iflds}))-bt1;
end
ru_ax(ii) = subaxis(3,3,ii,'ML',ML,'MR',MR,'MT',MT,'MB',MB,'SV',VS/2,'SH',HS);
plot(v,nanmean(bt1(:,:),2),'color',[0.1294,0.4431,0.7098],'linewidth',1)
set(gca,'FontSize',fs,'FontWeight',fw,'XLim',[min(v)-20 max(v)+20],'YLim',[180 300])
if ii == 1
ylabel('BT (K)');
else
set(gca,'YTickLabel',[]);
end
if ii == 2
title(sprintf('%s, All FOV mean',strrep(fname_out,'_','\_')));
end
set(gca,'XTickLabel',[]);
grid on
ru_ax(ii+3) = subaxis(3,3,ii+3,'ML',ML,'MR',MR,'MT',MT,'MB',MB,'SV',VS,'SH',HS);
hold on
for iflds = 1:length(ru_flds)
dy = btu.(ru_flds{iflds});
plot(v,nanmean(dy(:,:),2),'color',rucol(iflds,:),'linewidth',1)
end
set(gca,'FontSize',fs,'FontWeight',fw,'XLim',[min(v)-20 max(v)+20],'YLim',ylims_dbt)
xlabel('wavenumber');
if ii == 1
ylabel('3-sigma RU (K)')
else
set(gca,'YTickLabel',[]);
end
grid on
if ii == 2
h_l = legend(leg_str);
h_pos = get(h_l,'Pos');
set(h_l,'Position',[0.85,h_pos(2:4)]);
end
ru_ax(ii+6) = subaxis(3,3,ii+6,'ML',ML,'MR',MR,'MT',MT,'MB',MB,'SV',VS,'SH',HS);
scatter(nanmean(bt1(:,:),2),nanmean(btu.total(:,:),2),5,v,'filled');
set(gca,'FontSize',fs,'FontWeight',fw,'YLim',[ylims_dbtscatter],'Box','on','XLim',[200 300])
xlabel('BT (K)');
if ii == 1
ylabel('3-sigma RU (K)');
else
set(gca,'YTickLabel',[]);
end
grid on
pos = get(gca,'position');
hc = colorbar('hor');set(hc,'FontSize',8,'FontWeight',fw);
set(ru_ax(ii+6),'Position',pos);
set(get(hc,'XLabel'),'String','wavenumber','FontSize',8,'FontWeight','n')
cbpos = get(hc,'Pos');
set(hc,'Position',[cbpos(1) cbpos(2)+0.01 cbpos(3)-0 cbpos(4)])
colormap(cmap_btscat)
end
print('-dpng',fullfile(pname_out,sprintf('RU_%s_%02d.png',fname_out,1)));
return
function bt = rad2bt_l1b(freq,radiance);
%
% function bt = rad2bt_l1b(freq,radiance);
%
% compute brightness temperature given wavenumbers and radiances.
%
% Inputs:
% freq wavenumbers [NCHAN x 1] units: 1/cm
% radiance radiances [NCHAN x NFOV x NFOR x NSCAN] units: mW/(m^2 sr. 1/cm)
% Outputs:
% bt computed brightnes temp [NCHAN x NFOV x NFOR x NSCAN] units: Kelvin
%
% JKT 2020-Sep-13
% University of Wisconsin-Madison Space Science and Engineering Center (UW-SSEC)
% based on rad2bt by DCT 1999-11-11
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% fundamental constants:
% (Cohen, E.R. and B.N. Taylor, The 1986 CODATA recommended values
% of the fundamental physical constants, Journal of Research of
% the National Bureau of Standard, 92(2), March-April 1987.)
h = 6.6260755E-34; % Planck constant in Js
c = 2.99792458E8; % photon speed in m/s
k = 1.380658E-23; % Boltzmann constant in J/K
c1 = 2*h*c*c*1e8;
c2 = h*c/k*1e2;
freq = freq(:); % make sure freq is N x 1 and not 1 x N
[NCHAN,NFOV,NFOR,NSCAN] = size(radiance);
[NCHAN_freq] = length(freq);
if NCHAN_freq ~= NCHAN
error('incompatible wavenumber and radiance dimensions');
end
bt = nan*radiance;
freq = repmat(freq,1,NFOV,NFOR,NSCAN);
bt = c2.*freq./(log(1+(c1.*freq.*freq.*freq)./(radiance/1e3)));
ind_neg = find(radiance <= 0);
ind_imag = find(imag(radiance) ~= 0);
if length(ind_neg) ~= 0
warning('WARNING: negative inputs to RAD2BT');
warning('Setting resulting BT values to NaN');
bt(ind_neg) = NaN;
end
if length(ind_imag) ~= 0
warning('WARNING: imaginary inputs to RAD2BT');
warning('Setting resulting BT values to NaN');
bt(ind_imag) = NaN;
end
return
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment