Attachment 'dlt.pl'

Download

   1 #!/usr/local/bin/perl
   2 #  dlt.pl
   3 #  produce tables and plots of average density, lapse rate, and temperature
   4 #  v0.1   Keith Lofstrom   2014 Oct 27
   5 
   6 use strict;
   7 use List::Util qw(sum min max);
   8 
   9 my  $s         = 4 ; # half altitude span
  10 
  11 my  @densfile  = ( "dens070", "dens120", "dens200" ) ; # density      g/cm^3
  12 my  @tempfile  = ( "temp070", "temp120", "temp200" ) ; # temperature  K
  13 my  @f107      = ( 70, 120, 200                    ) ; # e-22 W/Hz-m^2
  14 
  15 my  @alt ;   # single dimensional altitude array
  16 my  @den ;   # density array of arrays   
  17 my  @lap ;   # lapse rate array of arrays
  18 my  @tem ;   # temperature array of arrays
  19 
  20 foreach my $i ( 0..$#f107 ) {
  21    my @alt1 = () ;  # altitude km
  22    my @den1 = () ;  # density kg/m^3
  23    my @tem1 = () ;  # temperature K
  24    
  25    # create temperature by averaging over a day
  26    open( IN, $tempfile[$i] ) ;
  27    while (<IN>) {
  28       next if /^#/ ;
  29       my @innum = split ;
  30       shift @innum                         ; # first value is altitude
  31       push @tem1 , sum( @innum ) / @innum  ; # average of temperatures
  32    }
  33 
  34    # create density and altitude arrays by averaging over a day
  35    open( IN, $densfile[$i] ) ;
  36    while (<IN>) {
  37       next if /^#/ ;
  38       my @innum = split ;
  39       push @alt1 , shift @innum            ; # first value is altitude
  40       push @den1 , sum( @innum ) / @innum  ; # average of densities
  41    }
  42    close( IN );
  43 
  44    if ( $#alt1 !=  $#den1 ) {
  45       die( "density ", $f107[$i]," ", $#alt1," ",$#den1  )
  46    }
  47 
  48    if ( $#alt1 !=  $#tem1 ) {
  49       die( "temperature ", $f107[$i]," ", $#alt1," ",$#tem1  )
  50    }
  51 
  52    # compute lapse rate array and copy altitude (redundant)
  53    foreach my $j ( 0..$#alt1 ) {
  54       my $n0 = max( 0,      $j-$s );
  55       my $n1 = min( $#alt1, $j+$s );
  56       $lap[$i][$j] = ($alt1[$n1]-$alt1[$n0])/log($den1[$n0]/$den1[$n1]);
  57       $alt[ $j]    =  $alt1[ $j]   ; # probably can do this with a  push
  58       $tem[$i][$j] =  $tem1[ $j]   ;
  59       $den[$i][$j] =  $den1[ $j] * 1000.0 ; # convert from g/cm3 to kg/m3
  60    }
  61 }
  62 
  63 print "#f107";
  64 foreach my $i ( 0..$#f107 ) { printf "|%15.0f         ", $f107[ $i ] ; }
  65 print "\n# alt";
  66 foreach my $i ( 0..$#f107 ) { printf "|  density  lapse   temp "; }
  67 print "\n" ;
  68 
  69 
  70 foreach my $j ( 0..$#alt  ) {
  71    printf "%4.0f", $alt[$j] ;
  72    foreach my $i( 0..$#f107 ) {
  73       printf "%11.3e%7.2f%7.1f", $den[$i][$j], $lap[$i][$j], $tem[$i][$j] ;
  74    }
  75    print "\n" ;
  76 }
  77 
  78 exit ;

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2014-10-20 22:54:14, 10.3 KB) [[attachment:call]]
  • [get | view] (2014-11-03 20:47:51, 10.3 KB) [[attachment:call.sh]]
  • [get | view] (2014-10-30 17:12:53, 20.5 KB) [[attachment:dens0-1K.png]]
  • [get | view] (2014-10-20 22:54:15, 123.2 KB) [[attachment:dens070]]
  • [get | view] (2014-10-20 22:54:15, 123.2 KB) [[attachment:dens120]]
  • [get | view] (2014-10-20 22:54:16, 123.2 KB) [[attachment:dens200]]
  • [get | view] (2014-10-30 17:13:20, 20.9 KB) [[attachment:dens200-1K.png]]
  • [get | view] (2014-10-30 17:12:16, 78.3 KB) [[attachment:dlt.dat]]
  • [get | view] (2014-10-31 14:18:02, 3.5 KB) [[attachment:dlt.gp]]
  • [get | view] (2014-11-03 20:45:26, 2.3 KB) [[attachment:dlt.pl]]
  • [get | view] (2014-10-30 17:13:41, 18.0 KB) [[attachment:lapse0-1K.png]]
  • [get | view] (2014-10-30 17:14:17, 19.9 KB) [[attachment:lapse200-1K.png]]
  • [get | view] (2014-10-20 22:54:24, 3668.7 KB) [[attachment:msis86helin.pdf]]
  • [get | view] (2014-10-31 14:17:00, 0.5 KB) [[attachment:pm.sh]]
  • [get | view] (2014-10-30 17:15:01, 16.8 KB) [[attachment:temp0-1K.png]]
  • [get | view] (2014-10-20 22:54:17, 76.3 KB) [[attachment:temp070]]
  • [get | view] (2014-10-20 22:54:17, 79.1 KB) [[attachment:temp120]]
  • [get | view] (2014-10-20 22:54:18, 84.2 KB) [[attachment:temp200]]
  • [get | view] (2014-10-30 17:26:07, 15.1 KB) [[attachment:temp200-1K.png]]
 All files | Selected Files: delete move to page

You are not allowed to attach a file to this page.