Commit dc3fd9d5 authored by RKGarcia's avatar RKGarcia
Browse files

Fix empty attributes

parent b8f89ff6
......@@ -504,19 +504,19 @@ variables:
string rad_local_pcs:description="real spectral radiance as local principal component scores";
double rad_local_pcs_U(localpc, wnum);
string rad_local_pcs_U:long_name="FIXME";
string rad_local_pcs_U:long_name="local PC U matrix for reconstruction";
double rad_local_pcs_U:_FillValue=9.9692099683868690e+36;
string rad_local_pcs_U:units="mW/(m2 sr cm-1)";
string rad_local_pcs_U:description="real spectral radiance local principal component";
string rad_local_pcs_U:description="real spectral radiance local principal components";
double rad_local_pcs_M(wnum);
string rad_local_pcs_M:long_name="FIXME";
string rad_local_pcs_M:long_name="local PC M vector for reconstruction";
double rad_local_pcs_M:_FillValue=9.9692099683868690e+36;
string rad_local_pcs_M:units="mW/(m2 sr cm-1)";
string rad_local_pcs_M:description="real spectral radiance local principal component mean";
double rad_local_pcs_D(wnum);
string rad_local_pcs_D:long_name="FIXME";
string rad_local_pcs_D:long_name="local PC D vector for reconstruction";
double rad_local_pcs_D:_FillValue=9.9692099683868690e+36;
string rad_local_pcs_D:units="1";
string rad_local_pcs_D:description="real spectral radiance local eigenvalues";
......
No preview for this file type
function d = crisL1B_recrad(globalPC_filename,granule_filename,aflag);
%
% function d = crisL1B_recrad(globalPC,filename,aflag);
%
% A function to produce a structure d with fields analogous to the output of rd_crisL1B
% but containing radiance variables containing reconstructed radiances.
%
% Inputs:
% globalPC_filename: Name of the NetCDF file containing the L1B gloabl PCs. E.g.:
% globalPC_filename = 'globalPCs_L1B_version0_20220204.nc';
%
% granule_filename: Name of file of CrISPCA granule level data. E.g.:
% granule_filename = 'CRISPCAv0.J1.CRIS.20210411T0448.m06.g049.L1B.std.v03_08.G.210411135350.nc';
%
% aflag: Flag to remove Hamming apodization (1) or not (0)
%
% Outputs:
% d.rad_lw(717,9,30,45) LW band reconstructed radiances
% d.rad_mw(869,9,30,45) MW band "
% d.rad_sw(637,9,30,45) SW band "
%
% Other:
% - Uses of pca_expandM.m and removeHamming.m (appended at end)
% - Beware of some NaNs and still some bad points at the ends of the band if aflag=1
% - Execution time per granule is about 0.5s per for aflag=0, 11s for aflag=1
%
% DCT, 15 Feb 2022
%
% Load global PC data
ncfile = globalPC_filename;
globalPC.U = ncread(ncfile,'U'); % PCs (hamming apodized)
globalPC.M = ncread(ncfile,'M'); % Mean (noise normalized) spectrum
globalPC.D = ncread(ncfile,'D'); % Eigenvalues
% Also load the wavenumbers (2211), the NEDN values used for noise
% normalization, and the index vector into the full 2233 spectrum
v = ncread(ncfile,'v');
nedn = ncread(ncfile,'nedn');
index = ncread(ncfile,'index');
% Load the granule-specific data for a sample granule. This includes
% the global Coeficients and the local PCs and local coeficients.
ncfile = granule_filename;
globalCoef = ncread(ncfile,'globalCoef');
localPC.U = ncread(ncfile,'U');
localPC.M = ncread(ncfile,'M');
localPC.D = ncread(ncfile,'D');
localCoef = ncread(ncfile,'localCoef');
% Compute reconstructed radiances
sz = size(localCoef);
globalCoef = globalCoef(:,:);
localCoef = localCoef(:,:);
[~,nrec] = size(localCoef);
nednm = repmat(nedn,1,nrec);
RecRad = ( pca_expandM(globalCoef,globalPC) + pca_expandM(localCoef,localPC) ) .* nednm;
% Remove Hamming if desired. Note this corrupts spectral band end-points
if aflag
RecRad = removeHamming(v,RecRad);
end
% Put the reconstructed radiances back into (nChannels,nFovs,nFORs,nScans) array
sz(1) = length(v);
RecRad = reshape(RecRad,sz);
% And store as normal L1B variable names/arrays
d.rad_lw = ones(717,sz(2),sz(3),sz(4))*NaN;
d.rad_lw(3:715,:,:,:) = RecRad(1:713,:,:,:);
d.rad_mw = ones(869,sz(2),sz(3),sz(4))*NaN;
d.rad_mw(3:867,:,:,:) = RecRad(714:1578,:,:,:);
d.rad_sw = ones(637,sz(2),sz(3),sz(4))*NaN;
d.rad_sw(3:635,:,:,:) = RecRad(1579:2211,:,:,:);
function [x,rc] = pca_expandM( coef, PC )
[ntr,nX] = size(coef);
PCM = repmat(PC.M,1,nX);
col = PC.U(:,1:ntr) * coef + PCM;
x = col;
rc = 0;
function RadOut = removeHamming(v,RadIn);
ind1 = find(v <= 1100);n1 = length(ind1);
ind2 = find(v >= 1190 & v <= 1800);n2 = length(ind2);
ind3 = find(v >= 2100);n3 = length(ind3);
e = ones(n1,1);iham1 = inv(spdiags([e*0.23 e*0.54 e*0.23], -1:1, n1, n1));
e = ones(n2,1);iham2 = inv(spdiags([e*0.23 e*0.54 e*0.23], -1:1, n2, n2));
e = ones(n3,1);iham3 = inv(spdiags([e*0.23 e*0.54 e*0.23], -1:1, n3, n3));
RadOut = RadIn*0;
RadOut(ind1,:) = iham1*double(RadIn(ind1,:));
RadOut(ind2,:) = iham2*double(RadIn(ind2,:));
RadOut(ind3,:) = iham3*double(RadIn(ind3,:));
nBad = 8;
RadOut(ind1(1:nBad),:) = NaN;RadOut(ind1(end-nBad+1:end),:) = NaN;
RadOut(ind2(1:nBad),:) = NaN;RadOut(ind2(end-nBad+1:end),:) = NaN;
RadOut(ind3(1:nBad),:) = NaN;RadOut(ind3(end-nBad+1:end),:) = NaN;
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