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

Last change on this file since 11209 was 11130, checked in by stuerze, 4 weeks ago

Some fixes from security point of view

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