How to determine dates when aircraft moving northwards or southwards?

조회 수: 1 (최근 30일)
Hello community,
I have a aircraft track dataset name Test.xlsx attached. It contains time, latitude, longitude and height of aircraft tracks. Now I want to find the dates when aircraft was heading towards north and also dates when aircraft heading towards south.
I am at beginner stage of coding, therefore, looking forward to any helps.
Thanks in advance.

채택된 답변

Star Strider
Star Strider 2023년 5월 10일
I am not certain that I understand what you want.
This approach uses day differences to segment the data into individual ‘FlightLeg’ cell arrays (segments of a given flight are referred to as ‘legs’), each cell array being a separate table. It then plots the legs, determines whether it was northbound or southbound, retains that information, as well as the start and end times of each ‘FlightLeg’ in the ‘DateRange’ cell array, and plots them with specific colours. (It almost takes longer to describe what the code does than it took to write it!)
Try this —
T1 = readtable('Test.xlsx', 'VariableNamingRule','preserve')
T1 = 16059×4 table
Var1 Obs_Lat Obs_Lon Alt(m) ____________________ _______ _______ ______ 24-Mar-2010 18:01:00 40.39 -104.96 5088.6 24-Mar-2010 18:01:00 40.4 -104.95 5164.1 24-Mar-2010 18:01:00 40.42 -104.95 5238.8 24-Mar-2010 18:01:00 40.44 -104.95 5314.9 24-Mar-2010 18:02:00 40.46 -104.94 5390.5 24-Mar-2010 18:02:00 40.47 -104.94 5466.1 24-Mar-2010 18:02:00 40.49 -104.93 5541.8 24-Mar-2010 18:02:00 40.51 -104.93 5617.5 24-Mar-2010 18:02:00 40.53 -104.93 5693.2 24-Mar-2010 18:02:00 40.54 -104.92 5770.1 24-Mar-2010 18:03:00 40.56 -104.92 5846.9 24-Mar-2010 18:03:00 40.58 -104.91 5922.5 24-Mar-2010 18:03:00 40.6 -104.91 5998.4 24-Mar-2010 18:03:00 40.62 -104.9 6073.9 24-Mar-2010 18:03:00 40.64 -104.9 6149.5 24-Mar-2010 18:03:00 40.65 -104.9 6226
Time = day(T1{:,1}, 'dayofyear'); % Assumes All Flights In Same Year
TimeG = cumsum(diff([0; Time]) ~= 0); % Mark Non-Consecutive Days As Groups
FlightLegs = accumarray(TimeG, (1:size(T1,1)).', [], @(x){T1(x,:)}) % Use 'TimeG' (Non-Consecutive Day Groups) To Segment Flight Legs
FlightLegs = 13×1 cell array
{1852×4 table} { 255×4 table} {2084×4 table} { 734×4 table} {2090×4 table} { 819×4 table} {1245×4 table} { 144×4 table} {1169×4 table} {1319×4 table} {1577×4 table} {2055×4 table} { 716×4 table}
figure
hold on
for k = 1:numel(FlightLegs)
hFL{k} = plot3(FlightLegs{k}{:,3}, FlightLegs{k}{:,2}, FlightLegs{k}{:,1}, 'LineWidth',2); % Plot Flight Leg
if FlightLegs{k}{end,2} > FlightLegs{k}{1,2} % End Latitude > Start Latitude => 'N'
DateRange{k} = [FlightLegs{k}{1,2}; FlightLegs{k}{end,2}]; % Flight Leg: Start & End Times
FLDir{k} = 'N'; % Mark: 'N'
hFL{k}.Color = 'b'; % Color: Blue
else % Same Data For Southbound Legs
DateRange{k} = [FlightLegs{k}{1,2}; FlightLegs{k}{end,2}];
FLDir{k} = 'S';
hFL{k}.Color = 'r';
end
end
hold off
xlabel('Lon')
ylabel('Lat')
zlabel('Time')
grid on
view(30,30)
legend([hFL{1} hFL{4}],'Northbound','Southbound')
I did not plot it on a map because I do not know what map you are using, and lacking the Mapping Toolbox (so I have very little experience with it), am not certain how to do that anyway.
.
  댓글 수: 4

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Selena Mastrodonato
Selena Mastrodonato 2023년 5월 10일
I would do it in this way
Test = readtimetable("Test.xlsx","VariableNamingRule","preserve"); % to import data (or using Import Data tool)
d = diff(Test.Obs_Lat); % difference between latitudes
south = Test.Time(find(d<0)); % if the right element is lower than left element the aircraft heads south
north = Test.Time(find(d>0)); % otherwise tha aicraft heads north
  댓글 수: 3
William Rose
William Rose 2023년 5월 10일
편집: William Rose 2023년 5월 10일
@Selena Mastrodonato, excellent answer!
[Edit: change red and blue colors in plot, to match the colors used by @Subhodh Sharma. Add comments about the plotting code.]
You can also leave out the "find()" function and get the exact same results:
Test = readtimetable("Test.xlsx","VariableNamingRule","preserve"); % to import data (or using Import Data tool)
d = diff(Test.Obs_Lat); % difference between latitudes
south = Test.Time(d<0); % if the right element is lower than left element the aircraft heads south
north = Test.Time(d>0); % otherwise tha aicraft heads north
Or you could eliminate d entirely.
Test = readtimetable("Test.xlsx","VariableNamingRule","preserve"); % to import data (or using Import Data tool)
south = Test.Time(diff(Test.Obs_Lat)<0); % if the right element is lower than left element the aircraft heads south
north = Test.Time(diff(Test.Obs_Lat)>0); % otherwise tha aicraft heads north
@Selena Mastrodonato uses many comments to explain her code. May we all follow her good example.
"otherwise the aircraft heads north" suggests an aircraft must have non-zero north/ south velocity at all times. However, the north-south velocity could be zero, and sometimes is, in this example. The code correctly find the times when the norh-south velocity is non-zero.
Make a plot:
plot(Test.Obs_Lon,Test.Obs_Lat,'-k',...
Test.Obs_Lon(d>0),Test.Obs_Lat(d>0),'-r',...
Test.Obs_Lon(d<0),Test.Obs_Lat(d<0),'-b')
legend('Entire Track','Northbound','Southbound') %add legend
grid on; xlabel('Longitude'); ylabel('Latitude') %grid, axis titles
The plotting code above does not attempt to identify separate flight segments. Therefore the plot includes straight lines connecting the end of one segent to the start of a separate segment. You could identify separate flight segments by finding where the time or the position changes by a large amount from one row to the next.
Good luck.
William Rose
William Rose 2023년 5월 10일
@Subhodh Sharma, The difference between Coming.png and Expected.png may be due to the order in which the north and south plots were done, since they overlap one another.
Provide the code you used to make Coming.png, if you want further assistance.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Calendar에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by