1 #!/usr/bin/perl |
1 #!/usr/bin/perl |
2 #====================================================================== |
2 #====================================================================== |
3 # L I S T E N S |
3 # L I S T E N S |
4 # doc: Sat Jan 18 18:41:49 2003 |
4 # doc: Sat Jan 18 18:41:49 2003 |
5 # dlm: Thu Feb 13 10:36:50 2020 |
5 # dlm: Sun Feb 28 15:46:21 2021 |
6 # (c) 2003 A.M. Thurnherr |
6 # (c) 2003 A.M. Thurnherr |
7 # uE-Info: 96 54 NIL 0 0 72 2 2 4 NIL ofnI |
7 # uE-Info: 351 1 NIL 0 0 72 2 2 4 NIL ofnI |
8 #====================================================================== |
8 #====================================================================== |
9 |
9 |
10 $synopsis = 'list ensemble summaries (default), dump ensembles (-E), time-average ensembles (-T)'; |
10 $synopsis = 'list ensemble summaries (default), dump ensembles (-E), time-average ensembles (-T)'; |
11 |
11 |
12 # HISTORY: |
12 # HISTORY: |
59 # Apr 4, 2018: - added support for first_ens and last_ens in [RDI_PD0_IO.pl] |
59 # Apr 4, 2018: - added support for first_ens and last_ens in [RDI_PD0_IO.pl] |
60 # - removed support for multiple input files |
60 # - removed support for multiple input files |
61 # Apr 10, 2018: - added -l)ast bin |
61 # Apr 10, 2018: - added -l)ast bin |
62 # May 31, 2018: - BUG: -A was disabled by default |
62 # May 31, 2018: - BUG: -A was disabled by default |
63 # Feb 13, 2020: - added support for $readDataProgress |
63 # Feb 13, 2020: - added support for $readDataProgress |
|
64 # Feb 19, 2021: - BUG: -T did not handle new years correctly |
64 |
65 |
65 # Notes: |
66 # Notes: |
66 # - -E/-B outputs data in earth coordinates, unless -b is set also |
67 # - -E/-B outputs data in earth coordinates, unless -b is set also |
67 # - -E/-T output is always in ANTS format |
68 # - -E/-T output is always in ANTS format |
68 |
69 |
309 } |
310 } |
310 |
311 |
311 } elsif (defined($opt_T)) { # time-average ensembles |
312 } elsif (defined($opt_T)) { # time-average ensembles |
312 |
313 |
313 my(@tmp) = split(',',$opt_T); # decode -T |
314 my(@tmp) = split(',',$opt_T); # decode -T |
314 my($Tstart,$deltaT,$Tend,$month,$day,$year); |
315 my($Tstart,$deltaT,$Tend,$month,$day); # NB: $yearbase needs to be global! |
315 if (@tmp == 3) { |
316 if (@tmp == 3) { |
316 ($Tstart,$deltaT,$Tend) = @tmp; |
317 ($Tstart,$deltaT,$Tend) = @tmp; |
317 } elsif (@tmp == 2) { |
318 } elsif (@tmp == 2) { |
318 ($Tstart,$deltaT) = @tmp; |
319 ($Tstart,$deltaT) = @tmp; |
319 ($month,$day,$year) = split('/',$dta{ENSEMBLE}[$#{$dta{ENSEMBLE}}]->{DATE}); |
320 ($month,$day,$yearbase) = split('/',$dta{ENSEMBLE}[0]->{DATE}); |
320 $Tend = str2dec_time($dta{ENSEMBLE}[$#{$dta{ENSEMBLE}}]->{DATE},$dta{ENSEMBLE}[$#{$dta{ENSEMBLE}}]->{TIME},$year); |
321 $Tend = str2dec_time($dta{ENSEMBLE}[0]->{DATE},$dta{ENSEMBLE}[$#{$dta{ENSEMBLE}}]->{TIME},$yearbase); |
321 } else { |
322 } else { |
322 ($month,$day,$year) = split('/',$dta{ENSEMBLE}[0]->{DATE}); |
323 ($month,$day,$yearbase) = split('/',$dta{ENSEMBLE}[0]->{DATE}); |
323 $Tstart = str2dec_time($dta{ENSEMBLE}[0]->{DATE},$dta{ENSEMBLE}[0]->{TIME},$year); |
324 $Tstart = str2dec_time($dta{ENSEMBLE}[0]->{DATE},$dta{ENSEMBLE}[0]->{TIME},$yearbase); |
324 ($deltaT) = @tmp; |
325 ($deltaT) = @tmp; |
325 ($month,$day,$year) = split('/',$dta{ENSEMBLE}[$#{$dta{ENSEMBLE}}]->{DATE}); |
326 $Tend = str2dec_time($dta{ENSEMBLE}[$#{$dta{ENSEMBLE}}]->{DATE},$dta{ENSEMBLE}[$#{$dta{ENSEMBLE}}]->{TIME},$yearbase); |
326 $Tend = str2dec_time($dta{ENSEMBLE}[$#{$dta{ENSEMBLE}}]->{DATE},$dta{ENSEMBLE}[$#{$dta{ENSEMBLE}}]->{TIME},$year); |
|
327 } |
327 } |
328 $Tstart = &{&antsCompileConstExpr($')} if ($Tstart =~ m{^=}); |
328 $Tstart = &{&antsCompileConstExpr($')} if ($Tstart =~ m{^=}); |
329 $deltaT = &{&antsCompileConstExpr($')} if ($deltaT =~ m{^=}); |
329 $deltaT = &{&antsCompileConstExpr($')} if ($deltaT =~ m{^=}); |
330 $Tend = &{&antsCompileConstExpr($')} if ($Tend =~ m{^=}); |
330 $Tend = &{&antsCompileConstExpr($')} if ($Tend =~ m{^=}); |
331 $deltaT = 9e99 unless ($deltaT > 0); |
331 $deltaT = 9e99 unless ($deltaT > 0); |
344 $dumpEns = sub ($) # time average and output when next bin is started |
344 $dumpEns = sub ($) # time average and output when next bin is started |
345 { |
345 { |
346 my($e) = @_; |
346 my($e) = @_; |
347 my($b,$i); |
347 my($b,$i); |
348 |
348 |
349 my($month,$day,$year) = ($e >= 0) ? split('/',$dta{ENSEMBLE}[$e]->{DATE}) : (undef,undef,undef); |
349 my($dn) = ($e >= 0) ? str2dec_time($dta{ENSEMBLE}[$e]->{DATE},$dta{ENSEMBLE}[$e]->{TIME},$yearbase) : undef; |
350 my($dn) = ($e >= 0) ? str2dec_time($dta{ENSEMBLE}[$e]->{DATE},$dta{ENSEMBLE}[$e]->{TIME},$year) : undef; |
350 |
351 |
351 # print(STDERR "ens#$e at $dn (cbin = $cbin)\n"); |
352 if ($e<0 || $dn>=$Tstart+$cbin*$deltaT) { # dump full bin |
352 if ($e<0 || $dn>=$Tstart+$cbin*$deltaT) { # dump full bin |
353 my($file) = sprintf("$basename.T$fnfmt",$cbin); # file name: <basename>.T0001 |
353 my($file) = sprintf("$basename.T$fnfmt",$cbin); # file name: <basename>.T0001 |
|
354 # print(STDERR "dumping average to $file...\n"); |
354 |
355 |
355 do { # skip empy bins |
356 do { # skip empy bins |
356 $cbin++; |
357 $cbin++; |
357 } while ($dn>=$Tstart+$cbin*$deltaT); |
358 } while ($dn>=$Tstart+$cbin*$deltaT); |
358 |
359 |
528 if defined($dta{ENSEMBLE}[$e]->{BUILT_IN_TEST_ERROR}); |
529 if defined($dta{ENSEMBLE}[$e]->{BUILT_IN_TEST_ERROR}); |
529 print("\n"); |
530 print("\n"); |
530 } |
531 } |
531 } # define output format |
532 } # define output format |
532 |
533 |
|
534 die("$yearbase") unless ($yearbase > 1900); |
|
535 |
533 #---------------------------------------------------------------------- |
536 #---------------------------------------------------------------------- |
534 # Loop Over Ensembles |
537 # Loop Over Ensembles |
535 #---------------------------------------------------------------------- |
538 #---------------------------------------------------------------------- |
536 |
539 |
537 for ($e=0; $e<=$#{$dta{ENSEMBLE}}; $e++) { |
540 for ($e=0; $e<=$#{$dta{ENSEMBLE}}; $e++) { |