Changeset 812

Show
Ignore:
Timestamp:
08/11/07 00:20:56 (13 months ago)
Author:
mankoff
Message:

read_rain moved out of clouds to own file.

clouds.pro made considerably less memory hungry.

  • arrconcat is useful but inefficient for large arrays
  • arrconcat still okay in current context for 'time'.
  • precompute array size, and then fill it directly in the structure
  • don't calculate rain

Still plenty of work to do to make xyztn more memory efficient.

Location:
misc/clouds
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • misc/clouds/clouds.pro

    r811 r812  
    11 
    2 function read_rain, yr_in, mo_in, dy_in, hr_in, mn_in 
    3  
    4 year = STRING(yr_in,FORMAT='(I4.4)') 
    5 month = STRING(mo_in,FORMAT='(I2.2)') 
    6 day = STRING(dy_in,FORMAT='(I2.2)') 
    7 hour = STRING(hr_in,FORMAT='(I2.2)') 
    8 minute = STRING(mn_in,FORMAT='(I2.2)') 
    9  
    10 fname = 'data/'+'twpcpoldarX1.00.'+year+month+day+'.'+hour+minute+ '00.raw.asc' 
    11 if file_exist( fname+'.sav' ) then begin 
    12     restore, fname+'.sav' 
    13     print, "Loading from cache: " + fname 
    14     return, s 
    15 end 
    16 openr, lun, fname, /GET_LUN 
    17 print, "Reading and caching: " + fname 
    18  
    19 datetime = '' 
    20 readf, lun, datetime 
    21 if datetime ne year+month+day+' '+hour+minute then $ 
    22   MESSAGE, "Requested data/time do not match file internals", /CONTINUE 
    23 readf, lun, lat, lon, xmin, xmax, nx, ymin, ymax, ny, zmin, zmax, nz 
    24  
    25 data = fltarr( nx*2, ny, nz ) 
    26 readf, lun, data 
    27  
    28 class = data[ makex( 1, (nx*2)-1, 2 ), *, * ] 
    29 data = TEMPORARY( data[ makex( 0, (nx*2)-1, 2 ), *, * ] ) 
    30  
    31 s = {data: data, $ 
    32      class: class, $ 
    33      classtype: INDGEN(11), $ 
    34      classname: ['unclassified', 'drizzle', 'rain', 'dry low density snow', $ 
    35                  'dry high density snow', 'melting snow', 'dry graupel', $ 
    36                  'wet graupel', 'small hail lt 2 cms', 'large hail gt 2 cms', $ 
    37                  'rain hail mix' ], $ 
    38      date: year+month+day, $ 
    39      time: hour+minute, $ 
    40      lat: lat, $ 
    41      lon: lon } 
    42 save, s, filename=fname+'.sav' 
    43 free_lun, lun 
    44 return, s 
    45 end 
    46  
    47  
    48  
    49 pro clouds, h0,h1, filename=filename 
     2pro clouds, h0,h1 
    503 
    514if n_params() eq 0 then begin 
    525    print, " " 
    536    print, "  CLOUDS, H0, H1" 
    54     print, "  CLOUDS, FILENAME=<cached_file.sav>" 
    557    print, " " 
    568    print, "  H0 is 1st hour, H1 is 2nd hour" 
    57     print, "  Examples: " 
     9    print, "  Example: " 
    5810    print, "  idl> CLOUDS, 18, 22                ; load data from 6 to 10PM" 
    59     print, "  idl> CLOUDS, file='everything.sav' ; load a save file of EVERYTHING." 
    6011    print, " " 
    61     print, "  hint: CLOUDS,00,23 then copy tmp.sav to everything.sav" 
    62     print, "  Question/Bugs: mankoff@giss.nasa.gov" 
    6312    return 
    6413end 
    65 if keyword_set( filename ) then begin 
    66    xyztn, loaddata=filename 
    67    return 
    68 endif 
    6914 
     15arr = fltarr( 121, 121, 40, (h1-h0+1)*6 ) 
     16data = { dbZ: arr, class: arr } 
     17idx = 0 
    7018for hr=h0,h1 do begin 
    7119    for min=0,50,10 do begin 
    72         d = read_rain(2006,01,22,hr,min) 
    73          
    74         dd = d.data 
    75         gd = where( dd ne -99.9, complement=bad ) 
    76         dd[bad] = 0 ;-999.99 
    77          
    78         cc = d.class 
    79         gd = where( cc ne -9, complement=bad ) 
    80         cc[bad] = 0 ;-999.99 
     20        rec = read_rain(2006,01,22,hr,min) 
    8121 
    82         rr = d.data * (d.class eq 2)  
    83          
    84         data0 = arrconcat( data0, dd ) 
    85         data1 =arrconcat( data1, cc ) 
    86         rain = arrconcat( rain, rr ) 
    87         time = arrconcat( time, d.time ) 
     22        d = rec.data 
     23        bad = where( d eq -99.9, nbad ) 
     24        if nbad ne 0 then d[bad] = 0 
     25        data.dbz[ *,*,*, idx ] = d 
     26 
     27        c = rec.class 
     28        bad = where( c eq -9, nbad ) 
     29        if nbad ne 0 then c[bad] = 0 
     30        data.class[ *,*,*, idx ] = c 
     31 
     32        time = arrconcat( time, rec.time ) 
     33 
     34        idx = idx+1 
    8835   endfor 
    8936endfor 
    90 data = { $ 
    91        dbZ: data0, $ 
    92        class: data1, $ 
    93        rain: rain } 
    9437 
    9538meta = { time: time, $