source: ntrip/trunk/BNC/scripts/pppPlot.pl@ 9836

Last change on this file since 9836 was 9836, checked in by wiese, 19 months ago

remove lib from import

  • Property svn:executable set to *
  • Property svn:keywords set to Header
File size: 34.0 KB
Line 
1#!/usr/bin/env perl
2
3# ========================================================================
4# pppPlot.pl - plot BNC's PPP results using gnuplot
5# ========================================================================
6#
7# Plot metrics:
8# - code and phase residuals in [m],
9# - receiver clock errors in [m],
10# - a-priori and correction values of tropospheric zenith delay in [m],
11# - time offset between GPS time and Galileo/GLONASS/BDS time in [m],
12# - ambiguities, given per satellite
13# - elevations, given per satellite
14#
15# Author : Andrea Stuerze
16# Revision: $Header: trunk/BNC/scripts/pppPlot.pl 9836 2022-09-26 20:29:54Z wiese $
17# Changes :
18# ========================================================================
19
20# Uses
21use strict;
22use warnings;
23
24BEGIN {
25 use FindBin qw($Bin);
26 use lib "$Bin";
27}
28
29use diagnostics;
30use PDL;
31use FindBin qw($Bin);
32use Getopt::Long;
33use Chart::Gnuplot;
34use Data::Dumper qw(Dumper);
35use File::Basename;
36use Date::Manip;
37use Log::Log4perl qw(:easy);
38use PDF::API2;
39
40use Bnc;
41use Common;
42
43use constant {
44 mm => 25.4 / 72,
45 inch => 1 / 72,
46 pt => 1,
47}; # There are 72 postscript points in an inch and there are 25.4 millimeters in an inch.
48
49
50# Logging
51Log::Log4perl->easy_init(
52 {
53
54 #file => "plotPPP.log",
55 layout => '%d [%c l%L] %p: %m%n',
56 level => $TRACE
57 }
58);
59
60# Options
61my ($prog) = fileparse($0);
62my $help = 0;
63my @plotTypes = ();
64my @logFiles = ();
65my $sampling = 1;
66
67GetOptions(
68 'help' => \$help,
69 'plotTypes=s' => \@plotTypes,
70 'logFiles=s' => \@logFiles,
71 'sampling=s' => \$sampling,
72);
73
74HELP_MESSAGE() if $help;
75@plotTypes = qw(NEU) unless (@plotTypes);
76@plotTypes = map {uc} split ( /[, ]/, join ( ',', @plotTypes ) );
77@logFiles = split ( /[, ]/, join ( ',', @logFiles ) );
78unless (@logFiles) { ERROR "logfiles missing"; HELP_MESSAGE() }
79DEBUG("\n plotTpes: @plotTypes\n logfiles: @logFiles\n sampling: $sampling");
80
81# -----------------------------------------------------------------------------
82# Generate data sets for gnuplot
83# -----------------------------------------------------------------------------
84# for pdf gerneration
85my ( $png, $page, $headline, $headline_text );
86my $y0 = 180 / mm;
87my ( $x, $y, $width, $height ) = ( 40 / mm, $y0, 130 / mm, 80 / mm );
88my $dy = $height + 10 / mm;
89
90# Loop over logfiles
91foreach my $file (@logFiles) {
92 DEBUG "Parse logfile $file";
93
94 # -----------------------------------------------------------------------------
95 # Create pdf for plot results
96 # -----------------------------------------------------------------------------
97 my ( $inputFilename, $inputDir, $inputSuffix ) = fileparse( $file, '\..*' );
98 my $pdf_name = sprintf ( "%s.pdf", $inputFilename );
99 my $pdf = PDF::API2->new( -file => "$inputDir$pdf_name" );
100 my $font1 = $pdf->corefont('Helvetica-Bold');
101
102 # -----------------------------------------------------------------------------
103 # Read logfile
104 # -----------------------------------------------------------------------------
105 my ( $station, $file ) = Bnc::parsePPPLogfile( $file, $sampling );
106 my $EPOCHS = $file->{'EPOCHS'};
107 my $EPOCHS_OGR = $file->{'EPOCHS_OGR'};
108 my $EPOCHS_OGE = $file->{'EPOCHS_OGE'};
109 my $EPOCHS_OGC = $file->{'EPOCHS_OGC'};
110 my $EPOCHS_G_CLK = $file->{'EPOCHS_G_CLK'};
111 my $EPOCHS_R_CLK = $file->{'EPOCHS_R_CLK'};
112 my $EPOCHS_E_CLK = $file->{'EPOCHS_E_CLK'};
113 my $EPOCHS_C_CLK = $file->{'EPOCHS_C_CLK'};
114 my %AMB = %{ $file->{'AMB'} };
115 my %RES = %{ $file->{'RES'} };
116 my %ELE = %{ $file->{'ELE'} };
117 my %ION = %{ $file->{'ION'} };
118 my %BIA = %{ $file->{'BIA'} };
119
120 # -----------------------------------------------------------------------------
121 # RMS computation
122 # -----------------------------------------------------------------------------
123 my ( $mean, $prms, $median, $min, $max, $adev, $rms_n, $rms_e, $rms_u, $rms_trp );
124 my ( $n, $e, $u, $trp, $str_rms_n, $str_rms_e, $str_rms_u, $str_rms_trp );
125 $n = pdl( $file->{'N'} );
126 ( $mean, $prms, $median, $min, $max, $adev, $rms_n ) = stats($n);
127 $e = pdl( $file->{'E'} );
128 ( $mean, $prms, $median, $min, $max, $adev, $rms_e ) = stats($e);
129 $u = pdl( $file->{'U'} );
130 ( $mean, $prms, $median, $min, $max, $adev, $rms_u ) = stats($u);
131 $trp = pdl( $file->{'TRPs'} );
132 ( $mean, $prms, $median, $min, $max, $adev, $rms_trp ) = stats($trp);
133 $str_rms_n = sprintf ( " %.2f ", $rms_n );
134 $str_rms_e = sprintf ( " %.2f ", $rms_e );
135 $str_rms_u = sprintf ( " %.2f ", $rms_u );
136 $str_rms_trp = sprintf ( " %.2f ", $rms_trp );
137 DEBUG("RMS: North: $str_rms_n, East: $str_rms_e, Up: $str_rms_u, TRP: $str_rms_trp");
138
139 # -----------------------------------------------------------------------------
140 # Plot several data sets
141 # -----------------------------------------------------------------------------
142 my $dataset;
143 ######### NEU #####################
144 DEBUG "Plot NEU";
145 $page = $pdf->page();
146 $page->mediabox('A4');
147 $headline = sprintf ( "PPP results for station %s", $station );
148 $headline_text = $page->text;
149 $headline_text->font( $font1, 11 / pt );
150 $headline_text->translate( 15 / mm, 280 / mm );
151 $headline_text->text($headline);
152 $y = $y0;
153 my $pngName = sprintf ( "%s_NEU.png", $station );
154 my $chartNEU = newChart($station);
155 $chartNEU->set( output => $pngName );
156 $chartNEU->set( ylabel => "Displacements [m]", yrange => [ " -0.5 ", " 0.5 " ] );
157
158 #y2label => "Number of Satellites [-]", y2range => [" 0 ", " 20 "], y2tics => 'on',
159
160 my $dataN = Chart::Gnuplot::DataSet->new(
161 xdata => $EPOCHS,
162 ydata => $file->{'N'},
163 title => "Displacements N, RMS + -$str_rms_n m",
164 timefmt => '%s',
165 style => "linespoints",
166 );
167 my $dataE = Chart::Gnuplot::DataSet->new(
168 xdata => $EPOCHS,
169 ydata => $file->{'E'},
170 title => "Displacements E, RMS + -$str_rms_e m",
171 timefmt => '%s',
172 style => "linespoints",
173 );
174 my $dataU = Chart::Gnuplot::DataSet->new(
175 xdata => $EPOCHS,
176 ydata => $file->{'U'},
177 title => "Displacements U, RMS + -$str_rms_u m",
178 timefmt => '%s',
179 style => "linespoints",
180 );
181 my @datasets = ( $dataN, $dataE, $dataU );
182 $chartNEU->plot2d(@datasets);
183
184 $png = $page->gfx();
185 LOGDIE("could not find image file: $!\n") unless -e $pngName;
186 $png->image( $pdf->image_png($pngName), $x, $y, $width, $height ); #print "y= : $y \n"
187
188 ######### TRP #####################
189 if ( grep ( $_ eq "ALL", @plotTypes ) ) {
190 DEBUG "Plot TRPs";
191 my $pngName = sprintf ( "%s_TRP.png", $station );
192 my $chartTRP = newChart($station);
193 $chartTRP->set( output => $pngName );
194 $chartTRP->set( ylabel => "Tropospheric Delay[m]", yrange => [ " 2.0 ", " 2.6 " ] );
195
196 my $dataTRP = Chart::Gnuplot::DataSet->new(
197 xdata => $EPOCHS,
198 ydata => $file->{'TRPs'},
199 title => "Tropospheric Delay, RMS + -$str_rms_trp m",
200 timefmt => '%s',
201 style => "linespoints",
202 );
203 $chartTRP->plot2d($dataTRP);
204 $y = $y - $dy;
205
206 if ( $y < 30 / mm ) {
207 $page = $pdf->page();
208 $page->mediabox('A4');
209 $y = $y0;
210 }
211 $png = $page->gfx();
212 LOGDIE("could not find image file: $!\n") unless -e $pngName;
213 $png->image( $pdf->image_png($pngName), $x, $y, $width, $height );
214
215 ######### CLK #####################
216 if ( scalar @{ $file->{'CLKs'} } < 1 ) {
217 DEBUG "No CLKs found";
218 }
219 else {
220 DEBUG "Plot CLKs";
221 $pngName = sprintf ( "%s_CLK.png", $station );
222 my $chartCLK = newChart($station);
223 $chartCLK->set( output => $pngName );
224 $chartCLK->set( ylabel => "CLK [m]" );
225
226 $dataset = Chart::Gnuplot::DataSet->new(
227 xdata => $EPOCHS,
228 ydata => $file->{'CLKs'},
229 title => "Receiver clock",
230 timefmt => '%s',
231 style => "linespoints",
232 );
233 $chartCLK->plot2d($dataset);
234 $y = $y - $dy;
235
236 if ( $y < 30 / mm ) {
237 $page = $pdf->page();
238 $page->mediabox('A4');
239 $y = $y0;
240 }
241 $png = $page->gfx();
242 LOGDIE("could not find image file: $!\n") unless -e $pngName;
243 $png->image( $pdf->image_png($pngName), $x, $y, $width, $height );
244 }
245 ######### GPS CLK #####################
246 if ( scalar @{ $file->{'G_CLKs'} } < 1 ) {
247 DEBUG "No GPS CLKs found";
248 }
249 else {
250 DEBUG "Plot GPS CLKs";
251 $pngName = sprintf ( "%s_CLK_G.png", $station );
252 my $chartCLK = newChart($station);
253 $chartCLK->set( output => $pngName );
254 $chartCLK->set( ylabel => "CLK [m]" );
255
256 $dataset = Chart::Gnuplot::DataSet->new(
257 xdata => $EPOCHS_G_CLK,
258 ydata => $file->{'G_CLKs'},
259 title => "GPS Receiver clock",
260 timefmt => '%s',
261 style => "linespoints",
262 );
263 $chartCLK->plot2d($dataset);
264 $y = $y - $dy;
265
266 if ( $y < 30 / mm ) {
267 $page = $pdf->page();
268 $page->mediabox('A4');
269 $y = $y0;
270 }
271 $png = $page->gfx();
272 LOGDIE("could not find image file: $!\n") unless -e $pngName;
273 $png->image( $pdf->image_png($pngName), $x, $y, $width, $height );
274 }
275 ######### GLONASS CLK #####################
276 if ( scalar @{ $file->{'R_CLKs'} } < 1 ) {
277 DEBUG "No GLONASS CLKs found";
278 }
279 else {
280 DEBUG "Plot GLONASS CLKs";
281 $pngName = sprintf ( "%s_CLK_R.png", $station );
282 my $chartCLK = newChart($station);
283 $chartCLK->set( output => $pngName );
284 $chartCLK->set( ylabel => "CLK [m]" );
285
286 $dataset = Chart::Gnuplot::DataSet->new(
287 xdata => $EPOCHS_R_CLK,
288 ydata => $file->{'R_CLKs'},
289 title => "GLONASS Receiver clock",
290 timefmt => '%s',
291 style => "linespoints",
292 );
293 $chartCLK->plot2d($dataset);
294 $y = $y - $dy;
295
296 if ( $y < 30 / mm ) {
297 $page = $pdf->page();
298 $page->mediabox('A4');
299 $y = $y0;
300 }
301 $png = $page->gfx();
302 LOGDIE("could not find image file: $!\n") unless -e $pngName;
303 $png->image( $pdf->image_png($pngName), $x, $y, $width, $height );
304 }
305 ######### Galileo CLK #####################
306 if ( scalar @{ $file->{'E_CLKs'} } < 1 ) {
307 DEBUG "No Galileo CLKs found";
308 }
309 else {
310 DEBUG "Plot Galileo CLKs";
311 $pngName = sprintf ( "%s_CLK_E.png", $station );
312 my $chartCLK = newChart($station);
313 $chartCLK->set( output => $pngName );
314 $chartCLK->set( ylabel => "CLK [m]" );
315
316 $dataset = Chart::Gnuplot::DataSet->new(
317 xdata => $EPOCHS_E_CLK,
318 ydata => $file->{'E_CLKs'},
319 title => "Galileo Receiver clock",
320 timefmt => '%s',
321 style => "linespoints",
322 );
323 $chartCLK->plot2d($dataset);
324 $y = $y - $dy;
325
326 if ( $y < 30 / mm ) {
327 $page = $pdf->page();
328 $page->mediabox('A4');
329 $y = $y0;
330 }
331 $png = $page->gfx();
332 LOGDIE("could not find image file: $!\n") unless -e $pngName;
333 $png->image( $pdf->image_png($pngName), $x, $y, $width, $height );
334 }
335
336 ######### Beidou CLK #####################
337 if ( scalar @{ $file->{'C_CLKs'} } < 1 ) {
338 DEBUG "No BDS CLKs found";
339 }
340 else {
341 DEBUG "Plot BDS CLKs";
342 $pngName = sprintf ( "%s_CLK_C.png", $station );
343 my $chartCLK = newChart($station);
344 $chartCLK->set( output => $pngName );
345 $chartCLK->set( ylabel => "CLK [m]" );
346
347 $dataset = Chart::Gnuplot::DataSet->new(
348 xdata => $EPOCHS_C_CLK,
349 ydata => $file->{'C_CLKs'},
350 title => "BDS Receiver clock",
351 timefmt => '%s',
352 style => "linespoints",
353 );
354 $chartCLK->plot2d($dataset);
355 $y = $y - $dy;
356
357 if ( $y < 30 / mm ) {
358 $page = $pdf->page();
359 $page->mediabox('A4');
360 $y = $y0;
361 }
362 $png = $page->gfx();
363 LOGDIE("could not find image file: $!\n") unless -e $pngName;
364 $png->image( $pdf->image_png($pngName), $x, $y, $width, $height );
365 }
366
367 ######### OGR #####################
368 if ( grep ( $_ eq "ALL", @plotTypes ) ) {
369 if ( scalar @{ $file->{'OGRs'} } < 1 ) {
370 DEBUG "No OGRs found";
371 }
372 else {
373 DEBUG "Plot OGRs";
374 my $pngName = sprintf ( "%s_OGR.png", $station );
375 my $chartOGR = newChart($station);
376 $chartOGR->set( output => $pngName );
377 $chartOGR->set( ylabel => "OGR [m]" );
378
379 $dataset = Chart::Gnuplot::DataSet->new(
380 xdata => $EPOCHS_OGR,
381 ydata => $file->{'OGRs'},
382 title => "Offset GPS - GLONASS",
383 timefmt => '%s',
384 style => "linespoints",
385 );
386 $chartOGR->plot2d($dataset); #system ("display $pngName&");
387 $y = $y - $dy;
388
389 if ( $y < 30 / mm ) {
390 $page = $pdf->page();
391 $page->mediabox('A4');
392 $y = $y0;
393 }
394 $png = $page->gfx();
395 LOGDIE("could not find image file: $!\n") unless -e $pngName;
396 $png->image( $pdf->image_png($pngName), $x, $y, $width, $height );
397 }
398 }
399
400 ######### OGE #####################
401 if ( grep ( $_ eq "ALL", @plotTypes ) ) {
402 if ( scalar @{ $file->{'OGEs'} } < 1 ) {
403 DEBUG "No OGEs found";
404 }
405 else {
406 DEBUG "Plot OGEs";
407 my $pngName = sprintf ( "%s_OGE.png", $station );
408 my $chartOGE = newChart($station);
409 $chartOGE->set( output => $pngName );
410 $chartOGE->set( ylabel => "OGE [m]" );
411
412 $dataset = Chart::Gnuplot::DataSet->new(
413 xdata => $EPOCHS_OGE,
414 ydata => $file->{'OGEs'},
415 title => "Offset GPS - Galileo",
416 timefmt => '%s',
417 style => "linespoints",
418 );
419 $chartOGE->plot2d($dataset); #system ("display $pngName&");
420 $y = $y - $dy;
421
422 if ( $y < 30 / mm ) {
423 $page = $pdf->page();
424 $page->mediabox('A4');
425 $y = $y0;
426 }
427 $png = $page->gfx();
428 LOGDIE("could not find image file: $!\n") unless -e $pngName;
429 $png->image( $pdf->image_png($pngName), $x, $y, $width, $height );
430 }
431 }
432
433 ######### OGC #####################
434 if ( grep ( $_ eq "ALL", @plotTypes ) ) {
435 if ( scalar @{ $file->{'OGCs'} } < 1 ) {
436 DEBUG "No OGCs found";
437 }
438 else {
439 DEBUG "Plot OGCs";
440 my $pngName = sprintf ( "%s_OGC.png", $station );
441 my $chartOGC = newChart($station);
442 $chartOGC->set( output => $pngName );
443 $chartOGC->set( ylabel => "OGC [m]" );
444
445 $dataset = Chart::Gnuplot::DataSet->new(
446 xdata => $EPOCHS_OGC,
447 ydata => $file->{'OGCs'},
448 title => "Offset GPS - BDS",
449 timefmt => '%s',
450 style => "linespoints",
451 );
452 $chartOGC->plot2d($dataset); #system ("display $pngName&");
453 $y = $y - $dy;
454
455 if ( $y < 30 / mm ) {
456 $page = $pdf->page();
457 $page->mediabox('A4');
458 $y = $y0;
459 }
460 $png = $page->gfx();
461 LOGDIE("could not find image file: $!\n") unless -e $pngName;
462 $png->image( $pdf->image_png($pngName), $x, $y, $width, $height );
463 }
464 }
465
466 ######### ELE #####################
467 DEBUG "Plot Elevations";
468 $page = $pdf->page();
469 $page->mediabox('A4');
470 $y = $y0 + $dy;
471 $headline = sprintf ( "Satellite Elevations for station %s", $station );
472 $headline_text = $page->text;
473 $headline_text->font( $font1, 11 / pt );
474 $headline_text->translate( 15 / mm, 280 / mm );
475 $headline_text->text($headline);
476
477 my $chartELE = newChart($station);
478 $chartELE->set( legend => { position => "outside right" } );
479
480 # SYSTEM #print Dumper \%ELE;
481 foreach my $key_sys ( sort keys %ELE ) {
482
483 # print "$key_sys \n"; #print Dumper $ELE{$key_sys};
484 my @datasets = (); # init datasets
485 my $pngName = sprintf ( "%s_ELE_%s.png", $station, $key_sys );
486 $chartELE->set( output => $pngName );
487 $chartELE->set( ylabel => "Elevation [°]", yrange => [ " 0.0 ", " 90.0 " ] );
488
489 # SATELLITE
490 foreach my $key_sat ( sort keys %{ $ELE{$key_sys} } ) {
491
492 # print "$key_sat = $ELE{$key_sys}{$key_sat} \n";
493 $dataset = Chart::Gnuplot::DataSet->new(
494 xdata => \@{ $ELE{$key_sys}{$key_sat}{EPOCH} }, # array of epochs
495 ydata => \@{ $ELE{$key_sys}{$key_sat}{DATA} }, # array of elevations of one satellite
496 title => "$key_sat",
497 timefmt => '%s',
498
499 #style => "linespoints",
500 style => "linespoints",
501 );
502 push ( @datasets, $dataset );
503 }
504 $chartELE->plot2d(@datasets);
505
506 # system ("display $pngName&");
507 $y = $y - $dy;
508 if ( $y < 30 / mm ) {
509 $page = $pdf->page();
510 $page->mediabox('A4');
511 $y = $y0;
512 }
513 $png = $page->gfx();
514 die ("could not find image file: $!") unless -e $pngName;
515 $png->image( $pdf->image_png($pngName), $x, $y, $width, $height );
516 }
517
518 ######### AMB #####################
519 DEBUG "Plot Ambiguities";
520 $page = $pdf->page();
521 $page->mediabox('A4');
522 $y = $y0 + $dy;
523 $headline = sprintf ( "Ambiguities for station %s", $station );
524 $headline_text = $page->text;
525 $headline_text->font( $font1, 11 / pt );
526 $headline_text->translate( 15 / mm, 280 / mm );
527 $headline_text->text($headline);
528
529 # AMBIGUITY_TYPE #print Dumper \%AMB;
530 foreach my $key_ambType (%AMB) { #print "$key_ambType \n"; ??????
531 foreach my $key_sys ( sort keys %{ $AMB{$key_ambType} } ) {
532
533 #print "$key_sys \n"; print Dumper $AMB{$key_ambType};
534 my ( @datasets_amb, @datasets_epo ); # init datasets
535 my $pngName_amb = sprintf ( "%s_AMB_%s_%s.png", $station, $key_ambType, $key_sys );
536 my $pngName_epo = sprintf ( "%s_EPO_%s_%s.png", $station, $key_ambType, $key_sys );
537 my $chartAMB = Chart::Gnuplot->new(
538 output => $pngName_amb,
539 terminal => 'png',
540 title => $station,
541 ylabel => "Ambiguities $key_ambType [m]",
542
543 # yrange => [" 0.0 ", " 90.0 "],
544 xlabel => "Time [h]",
545 timeaxis => 'x',
546 xtics => { labelfmt => '%H:%M', rotate => '-270', },
547 legend => { position => "outside right", },
548 grid => 'on',
549 );
550 my $chartEPO = Chart::Gnuplot->new(
551 output => $pngName_epo,
552 terminal => 'png',
553 title => $station,
554 ylabel => "Number of Epochs $key_ambType [-]",
555
556 # yrange => [" 0.0 ", " 90.0 "],
557 xlabel => "Time [h]",
558 timeaxis => 'x',
559 xtics => { labelfmt => '%H:%M', rotate => '-270', },
560 legend => { position => "outside right", },
561 grid => 'on',
562 );
563
564 # SATELLITE
565 foreach my $key_sat ( sort keys %{ $AMB{$key_ambType}{$key_sys} } ) {
566
567 #print "$key_sat = $AMB{$key_ambType}{$key_sys}{$key_sat} \n";
568 # ambiguities
569 my $dataset_amb = Chart::Gnuplot::DataSet->new(
570 xdata => $AMB{$key_ambType}{$key_sys}{$key_sat}{EPOCH}, # array of epochs
571 ydata => $AMB{$key_ambType}{$key_sys}{$key_sat}{DATA}, # array of ambiguities of one satellite
572 title => "$key_sat",
573 timefmt => '%s',
574 style => "linespoints",
575
576 #style => "linespoints",
577 );
578 push ( @datasets_amb, $dataset_amb );
579
580 # number of epochs used for ambiguity
581 my $dataset_epo = Chart::Gnuplot::DataSet->new(
582 xdata => $AMB{$key_ambType}{$key_sys}{$key_sat}{EPOCH}, # array of epochs
583 ydata => $AMB{$key_ambType}{$key_sys}{$key_sat}{NUMEPO}, # array of ambiguities of one satellite
584 title => "$key_sat",
585 timefmt => '%s',
586
587 #style => "linespoints",
588 style => "linespoints",
589 );
590 push ( @datasets_epo, $dataset_epo );
591 }
592
593 # ambiguities
594 $chartAMB->plot2d(@datasets_amb);
595
596 # system ("display $pngName_amb&");
597 $y = $y - $dy;
598 if ( $y < 30 / mm ) {
599 $page = $pdf->page();
600 $page->mediabox('A4');
601 $y = $y0;
602 }
603 $png = $page->gfx();
604 LOGDIE("could not find image file: $!\n") unless -e $pngName_amb;
605 $png->image( $pdf->image_png($pngName_amb), $x, $y, $width, $height );
606
607 # number of epochs used for ambiguity
608 $chartEPO->plot2d(@datasets_epo);
609
610 # system ("display $pngName_epo&");
611 $y = $y - $dy;
612 if ( $y < 30 / mm ) {
613 $page = $pdf->page();
614 $page->mediabox('A4');
615 $y = $y0;
616 }
617 $png = $page->gfx();
618 LOGDIE("could not find image file $pngName_epo: $!\n") unless -e $pngName_epo;
619 $png->image( $pdf->image_png($pngName_epo), $x, $y, $width, $height );
620 }
621 }
622
623 ######### RES #####################
624 DEBUG "Plot Residuals";
625 $page = $pdf->page();
626 $page->mediabox('A4');
627 $y = $y0 + $dy;
628 $headline = sprintf ( "Residuals for station %s", $station );
629 $headline_text = $page->text;
630 $headline_text->font( $font1, 11 / pt );
631 $headline_text->translate( 15 / mm, 280 / mm );
632 $headline_text->text($headline);
633
634 my $chartRES = newChart($station);
635 $chartRES->set( legend => { position => "outside right" } );
636
637 # RESIDUAL_TYPE #print Dumper \%RES;
638 foreach my $key_resType ( sort keys %RES ) { #print "key_resType: $key_resType \n";
639 #SYSTEM
640 foreach my $key_sys ( sort keys %{ $RES{$key_resType} } ) {
641
642 #print "key_sys: $key_sys \n"; #print Dumper $RES{$key_resType};
643 my @datasets;
644 my $pngName = sprintf ( "%s_RES_%s_%s.png", $station, $key_resType, $key_sys );
645 $chartRES->set( output => $pngName );
646 $chartRES->set( ylabel => "Residuals $key_resType [m]" );
647
648 if ( $key_resType =~ /^c/ ) {
649 $chartRES->set( yrange => [ " -6.0 ", " 6.0 " ] );
650 }
651 elsif ( $key_resType =~ /^l/ ) {
652 $chartRES->set( yrange => [ " -0.06 ", " 0.06 " ] );
653 }
654
655 elsif ( $key_resType =~ /^GIM/ ) {
656 $chartRES->set( yrange => [ " -6.0 ", " 6.0 " ] );
657 }
658
659 # SATELLITE
660 foreach my $key_sat ( sort keys %{ $RES{$key_resType}{$key_sys} } ) {
661
662 #print "$key_sat = $RES{$key_resType}{$key_sys}{$key_sat} \n";
663 $dataset = Chart::Gnuplot::DataSet->new(
664 xdata => $RES{$key_resType}{$key_sys}{$key_sat}{EPOCH}, # array of epochs
665 ydata => $RES{$key_resType}{$key_sys}{$key_sat}{DATA}, # array of residuals of one satellite
666 title => "$key_sat",
667 timefmt => '%s',
668
669 #style => "linespoints",
670 style => "linespoints",
671 );
672 push ( @datasets, $dataset );
673 }
674 $chartRES->plot2d(@datasets);
675 $y = $y - $dy;
676 if ( $y < 30 / mm ) {
677 $page = $pdf->page();
678 $page->mediabox('A4');
679 $y = $y0;
680 }
681 $png = $page->gfx();
682 LOGDIE("could not find image file: $!\n") unless -e $pngName;
683 $png->image( $pdf->image_png($pngName), $x, $y, $width, $height );
684 }
685 }
686
687 ######### ION #####################
688 if ( grep ( $_ eq "ALL", @plotTypes ) ) {
689 DEBUG "Plot ION";
690 $page = $pdf->page();
691 $page->mediabox('A4');
692 $y = $y0 + $dy;
693 $headline = sprintf ( "Ionosphere Delay for station %s", $station );
694 $headline_text = $page->text;
695 $headline_text->font( $font1, 11 / pt );
696 $headline_text->translate( 15 / mm, 280 / mm );
697 $headline_text->text($headline);
698
699 my $chartION = newChart($station);
700 $chartION->set( ylabel => "Ionophere Delay [m]" );
701 $chartION->set( legend => { position => "outside right" } );
702
703 # SYSTEM
704 foreach my $ksys ( sort keys %ION ) { #print "$key_sys \n"; #print Dumper $ION{$key_sys};
705 my @datasets; # init datasets
706 my $pngName = sprintf ( "%s_ION_%s.png", $station, $ksys );
707 $chartION->set( output => $pngName );
708
709 # SATELLITE
710 foreach my $sat ( sort keys %{ $ION{$ksys} } ) { #print "$key_sat = $ION{$key_sys}{$key_sat} \n";
711 my $dataset = Chart::Gnuplot::DataSet->new(
712 xdata => $ION{$ksys}{$sat}{EPOCH}, # array of epochs
713 ydata => $ION{$ksys}{$sat}{DATA}, # array of ionvations of one satellite
714 title => "$sat",
715 timefmt => '%s',
716
717 #style => " linespoints ",
718 style => "linespoints",
719 );
720 push ( @datasets, $dataset );
721 }
722
723 $chartION->plot2d(@datasets); #system ("display $pngName&");
724 $y = $y - $dy;
725 if ( $y < 30 / mm ) {
726 $page = $pdf->page();
727 $page->mediabox('A4');
728 $y = $y0;
729 }
730 $png = $page->gfx();
731 die ("could not find image file: $!") unless -e $pngName;
732 $png->image( $pdf->image_png($pngName), $x, $y, $width, $height );
733 }
734 }
735
736 ######### BIAS #####################
737 if ( grep ( $_ eq "ALL", @plotTypes ) ) {
738 DEBUG "Plot BIAS";
739 $page = $pdf->page();
740 $page->mediabox('A4');
741 $y = $y0 + $dy;
742 $headline = sprintf ( "Receiver Biases for station %s", $station );
743 $headline_text = $page->text;
744 $headline_text->font( $font1, 11 / pt );
745 $headline_text->translate( 15 / mm, 280 / mm );
746 $headline_text->text($headline);
747
748 my $chartBIAS = newChart($station);
749 $chartBIAS->set( legend => { position => "outside right" } );
750
751 # BIAS_TYPE #print Dumper \%BIA;
752 foreach my $key_biasType ( sort keys %BIA ) { #print "key_biasType: $key_biasType \n";
753 foreach my $key_sys ( sort keys %{ $BIA{$key_biasType} } ) {
754
755 #print "key_sys: $key_sys \n"; #print Dumper $BIA{$key_biasType};
756 my @datasets; # init datasets
757 my $pngName = sprintf ( "%s_BIAS_%s_%s.png", $station, $key_biasType, $key_sys );
758 $chartBIAS->set( output => $pngName );
759 $chartBIAS->set( ylabel => "Receiver Bias $key_biasType [m]" );
760
761 my $dataset =
762 Chart::Gnuplot::DataSet->new(
763 xdata => $BIA{$key_biasType}{$key_sys}{EPOCH},
764 ydata => $BIA{$key_biasType}{$key_sys}{DATA},
765 title => "$key_sys",
766 timefmt => '%s',
767 style => "linespoints",
768 );
769 push ( @datasets, $dataset );
770
771 $chartBIAS->plot2d(@datasets);
772 $y = $y - $dy;
773 if ( $y < 30 / mm ) {
774 $page = $pdf->page();
775 $page->mediabox('A4');
776 $y = $y0;
777 }
778 $png = $page->gfx();
779 die ("could not find image file: $!") unless -e $pngName;
780 $png->image( $pdf->image_png($pngName), $x, $y, $width, $height );
781 }
782 }
783 }
784 } # end if ALL @plotTypes
785
786 $pdf->save();
787 $pdf->end();
788
789 #system ("rm *.png");
790 if (Common::amInteractiv ) {
791 system ("evince $inputDir/$pdf_name");
792 }
793} # ----- next logfile -----
794
795# newChart returns a default chart.
796sub newChart {
797 my $title = shift;
798 return Chart::Gnuplot->new(
799 terminal => 'png',
800 title => $title,
801 xlabel => "Time [h]",
802 timeaxis => 'x',
803 xtics => { labelfmt => '%H:%M', rotate => '-270' },
804 grid => 'on',
805 );
806}
807
808sub HELP_MESSAGE {
809 print <<EOI_HILFE;
810$prog - plot BNC's PPP results using gnuplot
811
812USAGE:
813 $prog [OPTIONS]
814
815OPTIONS:
816 -p,--plotTypes ALL or NEU (default)
817 -l,--logFiles comma separated list of BNC's PPP logfiles
818 -s,--sampling sampling interval in seconds for the logfile data (default: 1); for a daily logfile <30> seconds should be usefull
819 -h,--help show help contents
820
821EXAMPLES:
822 $prog --plotTypes ALL -s 30 -l /path/to/FFMJ186730.ppp
823
8242021 andrea.stuerze\@bkg.bund.de
825EOI_HILFE
826 exit;
827}
Note: See TracBrowser for help on using the repository browser.