Skip to content

Commit

Permalink
Initial commit of traffic density database files
Browse files Browse the repository at this point in the history
  • Loading branch information
cserres committed Dec 11, 2020
1 parent 3b30836 commit 9e2a756
Show file tree
Hide file tree
Showing 65 changed files with 33,138 additions and 0 deletions.
108 changes: 108 additions & 0 deletions @TrafficDensity/LoadData.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
function obj = LoadData(obj)
% Copyright 2019 - 2020, MIT Lincoln Laboratory
% SPDX-License-Identifier: X11
%
% Load density, coverage, airspace, and terrain data
%
% Do not automatically load data when constructing object so that
% properties can be set and explored without the time to load the data

% Return if data has been previously loaded
if ~isempty(obj.cell)
return;
end

%% Check whether user has sufficient memory
[userview, systemView] = memory; % Get available memory
reqMemory_GB = 5.5; % 5.26 GB is required load data table (round to 5.5 GB)
reqRAM_GB = 18; % Up to 18GB RAM is required for processing
if userview.MaxPossibleArrayBytes/1e9 <= reqMemory_GB
warning('At least %i GB of memory is required to load the traffic density tables', reqMemory_GB);
end
if systemView.PhysicalMemory.Total/1e9 <= reqRAM_GB
warning('At least %i GB of memory is required to run the traffic density tool', reqRAM_GB);
end

a = tic;
if obj.verbose; disp('Loading traffic density data (this may take some time)'); end

%% Load density data
if ~exist(obj.filenames.cell,'file')
error('Cell (traffic density) file does not exist on Matlab path');
end
tmp = load(obj.filenames.cell,'cell');
if isempty(strfind(obj.filenames.cell,'lowh'))
if any(size(tmp.cell)~=[337086522, 7]) % Check data has expected size
warning('Size of traffic density cell is different than expected (Expected: 301017469x7 table)');
end
else
if any(size(tmp.cell)~=[410100649, 7]) % Check data has expected size (low-altitude table)
warning('Size of traffic density cell is different than expected (Expected: 410100649x7 table)');
end
end
obj.cell = tmp.cell;

%% Load radar coverage data
if ~exist(obj.filenames.cellCoverage,'file')
error('Radar coverage file does not exist on Matlab path');
end
tmp = load(obj.filenames.cellCoverage,'cellcoverage');
if isempty(strfind(obj.filenames.cell,'lowh'))
if any(size(tmp.cellcoverage)~=[163, 373, 9]) % Check data has expected size
warning('Size of radar coverage data is different than expected (Expected: 163x373x9)');
end
else
if any(size(tmp.cellcoverage)~=[652, 1492, 4]) % Check data has expected size (low-altitude table)
warning('Size of radar coverage data is different than expected (Expected: 652x1492x4)');
end
end
obj.cellcoverage = tmp.cellcoverage;

%% Load NOAA GLOBE terrain data
tmp = load('globe.mat');
if any(size(tmp.Z)~=[3481, 7681]) || numel(tmp.refvec)~=3 % Check data has expected size
warning('Size of GLOBE terrain is different than expected (Expected Z: 3481x7681, Expected refvec: 1x3)');
end
obj.globe = tmp;

%% Load encounter model characteristics
obj = obj.loadEncModel;

%% Load airport information
tmp = load(obj.filenames.airport);
if any(size(tmp.APT)~=[2643, 5]) % Check data has expected size
warning('Size of airport data is different than expected (Expected: 2643x5)');
end
obj.airport = tmp.APT;

%% Load airspace information
tmp = load(obj.filenames.airspace);
if any(size(tmp.airspace)~=[1249, 11]) % Check data has expected size
warning('Size of airspace information is different than expected (Expected: 1249x11)');
end
obj.airspace = tmp.airspace;
tmp = load(obj.filenames.cellAirspace);
if isempty(strfind(obj.filenames.cellAirspace,'lowh'))
if any(size(tmp.cellAirspace.A)~=[163, 373, 9]) || any(size(tmp.cellAirspace.B)~=[163, 373, 9]) ...
|| any(size(tmp.cellAirspace.C)~=[163, 373, 9]) || any(size(tmp.cellAirspace.D)~=[163, 373, 9])...
|| any(size(tmp.cellAirspace.O)~=[163, 373, 9]) % Check data has expected size
warning('Size of cell airspace information is different than expected (Expected for all airspaces: 163x373x9)');
end
else
if any(size(tmp.cellAirspace.A)~=[652, 1492, 4]) || any(size(tmp.cellAirspace.B)~=[652, 1492, 4]) ...
|| any(size(tmp.cellAirspace.C)~=[652, 1492, 4]) || any(size(tmp.cellAirspace.D)~=[652, 1492, 4])...
|| any(size(tmp.cellAirspace.O)~=[652, 1492, 4]) % Check data has expected size (low-altitude table)
warning('Size of cell airspace information is different than expected (Expected for all airspaces: 652x1492x4)');
end
end
obj.cellAirspace = tmp.cellAirspace;

if obj.verbose
GetSize(obj);
fprintf('Time required to load data: %.2f s\n',toc(a));
end

%% Load mapping states data
obj.states = shaperead('usastatelo','UseGeoCoords',true,'Selector',{@(name) ~any(strcmp(name,{'Alaska','Hawaii'})),'Name'});

end
12 changes: 12 additions & 0 deletions @TrafficDensity/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# TrafficDensity Class

This directory contains the TrafficDensity class definition. The software utilizes Matlab's built-in documentation generation for custom classes, which will generate documentation based on comments in the code. For documentation for the entire class, including all properties and methods, the user can execute `doc TrafficDensity` from the Matlab command window (presuming that the class is on the current path). The user may also access help for specific methods and properties using a similar syntax&mdash;e.g., `doc TrafficDensity.run` for the run method or `doc TrafficDensity.ownspeed` for the ownspeed property. The documentation can also be accessed using the instantiated object rather than the class.

## <a name="diststatement"></a> Distribution Statement
DISTRIBUTION STATEMENT A. Approved for public release. Distribution is unlimited.

This material is based upon work supported by the National Aeronautics and Space Administration under Air Force Contract No. FA8702-15-D-0001. Any opinions, findings, conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Aeronautics and Space Administration.

© 2019-2020 Massachusetts Institute of Technology.

Delivered to the U.S. Government with Unlimited Rights, as defined in DFARS Part 252.227-7013 or 7014 (Feb 2014). Notwithstanding any copyright notice, U.S. Government rights in this work are defined by DFARS 252.227-7013 or DFARS 252.227-7014 as detailed above. Use of this work other than as specifically authorized by the U.S. Government may violate any copyrights that exist in this work.
60 changes: 60 additions & 0 deletions @TrafficDensity/SummarizeData.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
function obj = SummarizeData(obj)
% Copyright 2019 - 2020, MIT Lincoln Laboratory
% SPDX-License-Identifier: X11
%
% Summarize the loaded data, including data span and aggregate map
toplot = length(dbstack)==1; % Determine if called from command line (rather than another function/method) for plotting
if isempty(obj.cell)
warning('Must load data before summarizing; loading now');
obj = LoadData(obj);
end

ncells = obj.jobdata.GRID_Y_NUM*obj.jobdata.GRID_X_NUM;

udates = unique(obj.cell.Date); % Get unique dates
ndates = max(udates)-min(udates)+1; % Get theoretical date span

% Get cells per day
flightHoursPerDay = accumarray(obj.cell.Date-min(udates)+1,obj.cell.TotalTime,[ndates,1]);

% Plot
if toplot
figure;
plot(1:ndates,flightHoursPerDay/obj.hr2s,'.')
title('Flight Hours Per Day')
xlabel('Day from Start')
ylabel('Flight Hours Per Day');
grid on;
end

% Plot flight hours on map
flightHoursPerCell = accumarray(obj.cell.Cell,obj.cell.TotalTime,[ncells,1]);
if toplot
m = zeros(obj.jobdata.GRID_Y_NUM, obj.jobdata.GRID_X_NUM);

m(1:ncells) = flightHoursPerCell ./ obj.hr2s; % convert to hours
m(m == 0) = nan;

m(~isnan(m)) = log10(m(~isnan(m)));

states=shaperead('usastatelo','UseGeoCoords',true, ...
'Selector', ...
{@(name) ~any(strcmp(name,{'Alaska','Hawaii'})),'Name'});

figure;
usamap(m, obj.termaplegend);
clmo surface
cm = jet(256);
cm(1,:) = [1,1,1];
colormap(cm);
meshm(m,obj.termaplegend)
hold on
h = colorbar;
geoshow([states.Lat],[states.Lon],'Color','white');
set(gca,'CLim',[-1,4])
htick = get(h,'YTick');
set(h,'YTickLabel',num2cell(10.^htick'),'YTick',htick);
ylabel(h,'Flight Hours')
title('Total Flight Time Observed')
end
end
Loading

0 comments on commit 9e2a756

Please sign in to comment.