Ignore:
Timestamp:
Jul 12, 2009, 10:53:38 PM (15 years ago)
Author:
ole
Message:

Tested ANUGA/numpy for Python2.6 on Ubuntu 9.04 and fixed up remaining errors.
In short, they had to do with hasattr, which now can raise a proper exception and the rest
was situations where numpy.int32 had to be converted to a proper int.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/data_manager.py

    r7276 r7308  
    30833083    else:
    30843084        jmin = num.searchsorted(times, mint)
     3085       
     3086        # numpy.int32 didn't work in slicing of amplitude below
     3087        jmin = int(jmin)
    30853088
    30863089    if maxt is None:
     
    30893092    else:
    30903093        jmax = num.searchsorted(times, maxt)
     3094       
     3095        # numpy.int32 didn't work in slicing of amplitude below
     3096        jmax = int(jmax)       
    30913097
    30923098    kmin, kmax, lmin, lmax = _get_min_max_indexes(latitudes[:],
     
    31233129    #        'print hmmm'
    31243130
    3125     #Get missing values
     3131    # Get missing values
    31263132    nan_ha = file_h.variables['HA'].missing_value[0]
    31273133    nan_ua = file_u.variables['UA'].missing_value[0]
     
    31323138        nan_e = None
    31333139
    3134     #Cleanup
     3140    # Cleanup
    31353141    missing = (amplitudes == nan_ha)
    31363142    if num.sometrue (missing):
     
    38283834    if verbose: print 'Reading DEM from %s' % inname
    38293835
    3830     #Read metadata
    3831     ncols = infile.ncols[0]
    3832     nrows = infile.nrows[0]
     3836    # Read metadata (convert from numpy.int32 to int where appropriate)
     3837    ncols = int(infile.ncols[0])
     3838    nrows = int(infile.nrows[0])
    38333839    xllcorner = infile.xllcorner[0]
    38343840    yllcorner = infile.yllcorner[0]
    3835     cellsize = infile.cellsize[0]
    3836     NODATA_value = infile.NODATA_value[0]
    3837     zone = infile.zone[0]
     3841    cellsize = int(infile.cellsize[0])
     3842    NODATA_value = int(infile.NODATA_value[0])
     3843    zone = int(infile.zone[0])
    38383844    false_easting = infile.false_easting[0]
    38393845    false_northing = infile.false_northing[0]
     
    38603866    nrows_new = 1 + (nrows - nrows_stencil) / cellsize_ratio
    38613867
     3868    #print type(ncols_new), ncols_new
     3869   
    38623870    #Open netcdf file for output
    38633871    outfile = NetCDFFile(outname, netcdf_mode_w)
     
    38853893
    38863894    # dimension definition
     3895    #print nrows_new, ncols_new, nrows_new*ncols_new
     3896    #print type(nrows_new), type(ncols_new), type(nrows_new*ncols_new)
    38873897    outfile.createDimension('number_of_points', nrows_new*ncols_new)
    38883898
     
    61026112        Maybe make this general, but the viewer assumes these quantities,
    61036113        so maybe we don't want it general - unless the viewer is general
    6104 
    6105         precon
    6106         triangulation and
    6107         header have been called.
     6114       
     6115        The argument sww_precision allows for storing as either
     6116        * single precision (default): num.float32
     6117        * double precision: num.float64 or num.float
     6118
     6119        Precondition:
     6120            triangulation and
     6121            header have been called.
    61086122        """
    61096123
     
    61126126            slice_index = len(file_time)
    61136127            file_time[slice_index] = time
     6128        else:
     6129            slice_index = int(slice_index) # In case it was numpy.int   
    61146130
    61156131        # Write the conserved quantities from Domain.
     
    61246140            else:
    61256141                q_values = quant[q]
    6126                 outfile.variables[q][slice_index] = \
    6127                                 q_values.astype(sww_precision)
     6142               
     6143                x = q_values.astype(sww_precision)
     6144                outfile.variables[q][slice_index] = x
     6145                   
    61286146       
    61296147                # This updates the _range values
Note: See TracChangeset for help on using the changeset viewer.