Changeset 2053


Ignore:
Timestamp:
Nov 24, 2005, 9:36:57 AM (19 years ago)
Author:
ole
Message:

Work on ermapper formats (4 or 8 bytes).

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • inundation/pyvolution/data_manager.py

    r2045 r2053  
    16941694        header['ydimension'] = str(cellsize)
    16951695        header['value'] = '"' + quantity + '"'
     1696        header['celltype'] = 'IEEE8ByteReal'
    16961697
    16971698
     
    17231724
    17241725   
    1725         if verbose: print 'Writing %s' %ascfile
     1726        if verbose: print 'Writing %s' %demfile
    17261727        NODATA_value = -9999
    17271728 
  • inundation/pyvolution/ermapper_grids.py

    r1892 r2053  
    33# from os import open, write, read
    44import Numeric
     5
     6celltype_map = {'IEEE4ByteReal': Numeric.Float32, 'IEEE8ByteReal': Numeric.Float64}
     7
    58
    69def write_ermapper_grid(ofile, data, header = {}):
     
    6063    header['nrofcellsperline'] = str(data_size[1])
    6164
    62     write_ermapper_data(data,data_file)
    63     write_ermapper_header(header_file,header)
     65
     66    header = create_default_header(header)
     67    write_ermapper_header(header_file, header)
     68    write_ermapper_data(data, data_file, data_format = header['celltype'])
     69
    6470   
    6571def read_ermapper_grid(ifile):
    66 
    6772    ers_index = ifile.find('.ers')
    6873    if ers_index > 0:
     
    8489def write_ermapper_header(ofile, header = {}):
    8590   
    86     header = create_default_header(header)
     91    #header = create_default_header(header)
    8792    # Determine if the dataset is in lats/longs or eastings/northings and set header parameters
    8893    # accordingly
     
    159164
    160165def write_ermapper_data(grid, ofile, data_format = Numeric.Float32):
     166
     167
     168    if isinstance(data_format, basestring):
     169        #celltype_map is defined at top of code
     170        if celltype_map.has_key(data_format):
     171            data_format = celltype_map[data_format]
     172        else:
     173            msg = 'Format %s is not yet defined by celltype_map' %data_format
     174            raise msg
     175       
     176   
    161177    # Convert the array to data_format (default format is Float32)
    162178    grid_as_float = grid.astype(data_format)
  • production/karratha_2005/export_results.py

    r1920 r2053  
    22
    33from pyvolution.data_manager import sww2dem
     4from pyvolution.ermapper_grids import read_ermapper_grid
    45
    56
     
    910name = project.outputname
    1011
    11 sww2dem(name, basename_out = name + '_momentum',
    12         #quantity = 'stage-elevation',  #Depth
    13         quantity = '(xmomentum**2 + ymomentum**2)**0.5',  #Absolute momentum
     12sww2dem(name, basename_out = name,
     13        quantity = 'stage-elevation',  #Depth
     14        #quantity = '(xmomentum**2 + ymomentum**2)**0.5',  #Absolute momentum
    1415        cellsize = 50,
     16        #cellsize = 500,
    1517        #cellsize = 10,       
    1618        #easting_min = 465646,
     
    2224        format = 'ers')
    2325
     26
     27#Check
     28
     29#data = read_ermapper_grid(name)
     30#print 'Values from %s are in [%f, %f]' %(name, min(data.flat), max(data.flat))
Note: See TracChangeset for help on using the changeset viewer.