Effacer les filtres
Effacer les filtres

I want to store the all values in a single file. I have 5 data files those files are run at a time and i want to store the all data files output files stored in single file. here i am attached input and corresponding matlab functions.

5 vues (au cours des 30 derniers jours)
clear all;
close all;
clc;
count_file = 1;
f1=fopen('input.dat','r'); %%%%%insert input file names in the input.txt
warning on;
while (feof(f1)~=1)
fname=fgetl(f1); %%%%%%reading the file name inside the input.txt
fn=fname(1:length(fname)-4);
fprintf('Processing file:::: %s\n',fname);
fout=fopen(sprintf('SKU_Backscatter_Coefficient_%s.dat',fn(32:41)),'a');
% % % fout_hr=fopen(sprintf('SKU_Flux_Var_hr_%sT.dat',fn(1:4)),'a');
% % % fname=fopen(fname,'r');
% % % fname = 'CAL_LID_L2_05kmAPro-Prov-V3-30.2014-04-26T07-56-49ZD_Subset.hdf';
metadata = hdfread(fname, '/metadata', 'Fields', 'Lidar_Data_Altitudes', 'FirstRecord',1 ,'NumRecords',1);
alts = metadata{1};
numberAlts = length(alts);
latMin = 12;
latMax = 16;
product_name = 'Latitude';
[info, lat] = readHDF(fname,product_name,[0 1],[-9 1]);
latRangeWanted = lat > latMin & lat < latMax;
firstProfile = find(latRangeWanted,1,'first');
lastProfile = find(latRangeWanted,1,'last');
numberProfiles = lastProfile - firstProfile + 1;
product_name = 'Total_Backscatter_Coefficient_532';
[info, sigma] = readHDF(fname,product_name,[firstProfile-1 0],[numberProfiles -9]);
product_name = 'Total_Backscatter_Coefficient_Uncertainty_532';
[info, sigma_uncer] = readHDF(fname,product_name,[firstProfile-1 0],[numberProfiles -9]);
sigma = sigma';
sigma_uncer = sigma_uncer';
product_name = 'Extinction_QC_Flag_532';
[info, extQC] = readHDF(fname,product_name,[firstProfile-1 0 0],[numberProfiles -9 -9]);
product_name = 'CAD_Score';
[info, CAD] = readHDF(fname,product_name,[firstProfile-1 0 0],[numberProfiles -9 -9]);
product_name = 'Atmospheric_Volume_Description';
[info, AVD] = readHDF(fname,product_name,[firstProfile-1 0 0],[numberProfiles -9 -9]);
useSamples = true(numberAlts,numberProfiles);
useSamples(sigma == -9999) = false;
[ftype, subtype] = get_feature_type_and_subtype(AVD);
isAerosol = squeeze(ftype(1,:,:) == 3 | ftype(2,:,:) == 3);
useSamples(~isAerosol) = false;
CAD_fill = -127;
CAD(CAD > 0) = CAD_fill;
goodCAD = squeeze( (CAD(1,:,:) < -20 | CAD(1,:,:) == CAD_fill) &...
(CAD(2,:,:) < -20 | CAD(2,:,:) == CAD_fill) );
useSamples(~goodCAD) = false;
extQCfill = 32768;
extQC(ftype ~= 3) = extQCfill;
goodExtQC = squeeze(...
(extQC(1,:,:) == 0 | extQC(1,:,:) == 1 | extQC(1,:,:) == extQCfill) & ...
(extQC(2,:,:) == 0 | extQC(2,:,:) == 1 | extQC(2,:,:) == extQCfill));
useSamples(~goodExtQC) = false;
useSamples(sigma_uncer > 99.9) = false;
meanSigmaUnscreened = zeros(numberAlts,1);
meanSigmaUnscreened_uncer = zeros(numberAlts,1);
numSamplesUnscreened = zeros(numberAlts,1);
meanSigmaScreened = zeros(numberAlts,1);
meanSigmaScreened_uncer = zeros(numberAlts,1);
numSamplesScreened = zeros(numberAlts,1);
for k = 1:numberAlts
t = sigma(k,:) ~= -9999;
meanSigmaUnscreened(k) = mean(sigma(k,t));
meanSigmaScreened(k) = mean(sigma(k,useSamples(k,:)));
numSamplesUnscreened(k) = sum(t);
if numSamplesUnscreened(k) > 0
meanSigmaUnscreened_uncer(k) = sqrt(sum(sigma_uncer(k,t).^2)./numSamplesUnscreened(k));
end
numSamplesScreened(k) = sum(useSamples(k,:));
if numSamplesScreened(k) > 0
meanSigmaScreened_uncer(k) = sqrt(sum(sigma_uncer(k,useSamples(k,:)).^2)./numSamplesScreened(k));
end
end
fprintf(fout,'%.3f\n',meanSigmaScreened(count_file,1));
count_file = count_file+1;
clear meanSigmaScreened;
end
fclose(fout);

Réponses (0)

Catégories

En savoir plus sur Model Import dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by