diff --git a/2a Data Exploration/ExploreData.m b/2a Data Exploration/ExploreData.m new file mode 100644 index 0000000..2226a6f --- /dev/null +++ b/2a Data Exploration/ExploreData.m @@ -0,0 +1,7 @@ +%% This script allows you to open and explore the data in a *.nc file +clear all +close all + +FileName = 'o3_surface_20180701000000.nc'; + +Contents = ncinfo(FileName); diff --git a/2a Data Exploration/LoadAllData.m b/2a Data Exploration/LoadAllData.m new file mode 100644 index 0000000..7fce7b5 --- /dev/null +++ b/2a Data Exploration/LoadAllData.m @@ -0,0 +1,20 @@ + +function [AllDataMem] = LoadAllData(FileName) +%UNTITLED2 Summary of this function goes here +% Detailed explanation goes here +ExploreData; +fprintf('Data Dimension Names: %s, %s, %s\n',... + Contents.Dimensions(1).Name,... + Contents.Dimensions(2).Name,... + Contents.Dimensions(3).Name) +Contents = ncinfo(FileName); % Store the file content information in a variable. +for idx = 1: 8 + AllData(idx,:,:,:) = ncread(FileName, Contents.Variables(idx).Name); + fprintf('Loading %s\n', Contents.Variables(idx).Name); + % display loading information +end + +AllDataMem = whos('AllData').bytes/1000000; +fprintf('Memory used for all data: %.3f MB\n', AllDataMem) +end + diff --git a/2a Data Exploration/LoadAllHours.m b/2a Data Exploration/LoadAllHours.m new file mode 100644 index 0000000..060196a --- /dev/null +++ b/2a Data Exploration/LoadAllHours.m @@ -0,0 +1,30 @@ +%% Selecting data +% We want to load models only, i.e. variables 1, 2, 4, 5, 6, 7, 8 +% and we only want a single hour. We use indexing into our *.nc file: +% To load the variable 'chimere_ozone, starting at lat = 1, lon = 1 and +% hour = 1 we use: +[AllHourMem] = LoadAllHour(FileName); +function [AllHourMem] = LoadAllHour(FileName) +%UNTITLED2 Summary of this function goes here +% Detailed explanation goes here +ExploreData; +StartLat = 1; +NumLat = 400; +StartLon = 1; +NumLon = 700; +StartHour = 1; +NumHour = 1; + +Data = ncread(FileName, 'chimere_ozone', [StartLon, StartLat, StartHour], [NumLon, NumLat, NumHour]); + +Contents = ncinfo(FileName); % Store the file content information in a variable. +for idx = 1 + AllHour(idx,:,:,:) = ncread(FileName, 'chimere_ozone', [StartLon, StartLat, StartHour], [NumLon, NumLat, NumHour]); + fprintf('', [StartLon, StartLat, StartHour], [NumLon, NumLat, NumHour]); + % display loading information +end + +AllHourMem = whos('AllHour').bytes/1000000; +fprintf('Memory used for all data: %.3f MB\n', AllHourMem) +end + diff --git a/2a Data Exploration/LoadHours.m b/2a Data Exploration/LoadHours.m new file mode 100644 index 0000000..4b55265 --- /dev/null +++ b/2a Data Exploration/LoadHours.m @@ -0,0 +1,23 @@ +%% List variable names +% note that variable 3 is an ensemble, we will NOT use this in our project! +% Not each model is 700 x 400 x 12 and we know that lat, lon and time match +% these numbers. +% To visulaise this 3D array think of it as a 700 x 400 grid for each model +% for one hour. These are stacked up 25 high. + +function [AllHorsMem] = LoadAllHors(FileName) +%UNTITLED2 Summary of this function goes here +% Detailed explanation goes here +ExploreData; +Contents = ncinfo(FileName); +NumVariables = size(Contents.Variables,2); +fprintf('Variable names and sizes:\n') +for idx = 1: NumVariables + AllHors(idx,:,:,:) = size(Contents.Variables,2); + fprintf('%i %s %i, %i, %i',... + idx, Contents.Variables(idx).Name, Contents.Variables(idx).Size); + fprintf('\n'); +end +AllHorsMem = whos('AllHors').bytes/1000000; +fprintf('Memory used for Hour: %.3f MB\n', AllHorsMem) +end diff --git a/2a Data Exploration/Main.m b/2a Data Exploration/Main.m new file mode 100644 index 0000000..d0345b1 --- /dev/null +++ b/2a Data Exploration/Main.m @@ -0,0 +1,5 @@ + +%LoadHours; +%LoadAllHours; +%ReportResults; +[AllDataMem] = LoadAllData(FileName); \ No newline at end of file diff --git a/2a Data Exploration/ReportResults.m b/2a Data Exploration/ReportResults.m new file mode 100644 index 0000000..766c9f8 --- /dev/null +++ b/2a Data Exploration/ReportResults.m @@ -0,0 +1,14 @@ +%% Cycling through the variable names +% We only want the models to load + +[ResultsMem] = Results(FileName); +function [ResultsMem] = Results(FileName) +%UNTITLED2 Summary of this function goes here +% Detailed explanation goes here +ExploreData; +Contents = ncinfo(FileName); % Store the file content information in a variable. +for idx = [1, 2, 4, 5, 6, 7, 8] + %Result(idx) = ncread(Contents.Variables(idx).Name); + fprintf('Model %i : %s\n', idx, Contents.Variables(idx).Name); +end +end \ No newline at end of file