Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
%% Script to examine NetCDF data formats and check for NaN
% Note, you would carry out this test each time you load data.
% You should NOT test the whole file at the start
clear all
close all
%% Test a good file
NaNErrors = 0;
%% Set file to test
FileName = '/Users/juhildungrani/Desktop/Sem 4/Big Data/work/5011CEM2021-dungranij/2a Data Exploration/Model 2/TestFileNaN.nc'; % define our test file
Contents = ncinfo(FileName); % Store the file content information in a variable.
StartLat = 1;
StartLon = 1;
for idxHour = 1:25
for idxModel = 1:8
Data(idxModel,:,:) = ncread(FileName, Contents.Variables(idxModel).Name,...
[StartLat, StartLon, idxHour], [inf, inf, 1]);
end
% check for NaNs
if any(isnan(Data), 'All')
fprintf('NaNs present\n')
NaNErrors = 1;
end
end
fprintf('Testing files: %s\n', FileName)
if NaNErrors
fprintf('NaN errors present!\n')
else
fprintf('No errors!\n')
end
%% Test File with Errors
NaNErrors = 0;
%% Set file to test
FileName = '../Model/TestFileNaN.nc'; % define our test file
Contents = ncinfo(FileName); % Store the file content information in a variable.
StartLat = 1;
StartLon = 1;
fprintf('Testing files: %s\n', FileName)
for idxHour = 1:25
for idxModel = 1:8
Data(idxModel,:,:) = ncread(FileName, Contents.Variables(idxModel).Name,...
[StartLat, StartLon, idxHour], [inf, inf, 1]);
end
% check for NaNs
if any(isnan(Data), 'All')
fprintf('NaNs present during hour %i\n', idxHour)
NaNErrors = 1;
end
end
if NaNErrors
fprintf('NaN errors present!\n')
else
fprintf('No errors!\n')
end