| 1 |
#! /usr/bin/octave -qf |
| 2 |
# |
| 3 |
# Component of the D-ITG 2.8.1 (r1023) platform (http://traffic.comics.unina.it/software/ITG) |
| 4 |
# |
| 5 |
# Copyright : (C) 2004-2013 by Alessio Botta, Walter de Donato, Alberto Dainotti, |
| 6 |
# Stefano Avallone, Antonio Pescape' (PI) |
| 7 |
# COMICS (COMputer for Interaction and CommunicationS) Group |
| 8 |
# Department of Electrical Engineering and Information Technologies |
| 9 |
# University of Napoli "Federico II". |
| 10 |
# email : [email protected], [email protected], [email protected], |
| 11 |
# [email protected], [email protected] |
| 12 |
# |
| 13 |
# This program is free software: you can redistribute it and/or modify |
| 14 |
# it under the terms of the GNU General Public License as published by |
| 15 |
# the Free Software Foundation, either version 3 of the License, or |
| 16 |
# (at your option) any later version. |
| 17 |
# |
| 18 |
# This program is distributed in the hope that it will be useful, |
| 19 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 |
# GNU General Public License for more details. |
| 22 |
# |
| 23 |
# You should have received a copy of the GNU General Public License |
| 24 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 25 |
# |
| 26 |
# For commercial use please refer to D-ITG Professional. |
| 27 |
|
| 28 |
# Check the octave version |
| 29 |
ver = version; |
| 30 |
octave3 = str2num(ver(1)) >= 3; |
| 31 |
octave32 = str2num(ver(3)) >= 2; |
| 32 |
|
| 33 |
graphicformat = "epsc2"; |
| 34 |
extension = "eps"; |
| 35 |
|
| 36 |
arg_list = argv (); |
| 37 |
|
| 38 |
if nargin > 0 |
| 39 |
inputf = arg_list{1}; |
| 40 |
else |
| 41 |
printf("%s\n","Input file name missing, exiting..."); |
| 42 |
return; |
| 43 |
endif |
| 44 |
|
| 45 |
if (f = fopen(inputf, "r")) < 0 |
| 46 |
printf("%s%s%s\n", "File ", inputf, " does not exist, exiting..."); |
| 47 |
return; |
| 48 |
endif |
| 49 |
|
| 50 |
if size(s = getenv("DITG_PLOT_TITLE")) |
| 51 |
title(s); |
| 52 |
endif |
| 53 |
|
| 54 |
# read labels |
| 55 |
labels = blanks(0); |
| 56 |
fscanf(f, "%s", 1); # we do not need the first string (Time) |
| 57 |
while !strcmp(s = fscanf(f, "%s", 1), "Aggregate-Flow") |
| 58 |
labels = [labels; strcat("-@;",s,";") ]; |
| 59 |
endwhile |
| 60 |
labels = [labels; strcat("-@;",s,";") ]; # add the last string (Aggregate-Flow) |
| 61 |
|
| 62 |
if nargin > 1 |
| 63 |
mask = intersection(str2num(arg_list{2}),1:size(labels,1)); |
| 64 |
else |
| 65 |
mask = 1:size(labels,1); |
| 66 |
endif |
| 67 |
|
| 68 |
if !size(mask) |
| 69 |
printf("%s\n","No flow selected to be plotted"); |
| 70 |
return; |
| 71 |
endif |
| 72 |
|
| 73 |
# read data |
| 74 |
data = fscanf(f, "%f", [size(labels, 1) + 1, Inf])'; |
| 75 |
|
| 76 |
temp = strsplit(strrep(inputf, "\\", "/"), "/"); |
| 77 |
outputf = strsplit(deblank(temp{size(temp, 1), :}), "."); |
| 78 |
ylbl = outputf{1,:}; |
| 79 |
|
| 80 |
ylbl(1,1) = toupper(ylbl(1,1)); |
| 81 |
ylabel(ylbl); |
| 82 |
xlabel("Time (s)"); |
| 83 |
|
| 84 |
plot(data(:,1), data(:,mask+1), labels(mask,:)); |
| 85 |
|
| 86 |
# Only for Octave 3.0 |
| 87 |
if octave3 |
| 88 |
nlabels = blanks(0); |
| 89 |
for i = 1:size(labels, 1) |
| 90 |
nlabels=[nlabels; labels(i,:)(strfind(labels(i,:),";")(1)+1:strfind(labels(i,:),";")(2)-1)]; |
| 91 |
endfor |
| 92 |
legend(nlabels(mask,:), "location", "southoutside"); |
| 93 |
legend("boxon"); |
| 94 |
endif |
| 95 |
|
| 96 |
if octave32 |
| 97 |
eval(cstrcat("print -d", graphicformat, " ", ylbl, ".", extension)); |
| 98 |
else |
| 99 |
eval(strcat("print -d", graphicformat, " ", ylbl, ".", extension)); |
| 100 |
endif |
| 101 |
|
| 102 |
printf("%s\n","Done!"); |