Changeset 4776


Ignore:
Timestamp:
Nov 1, 2007, 11:12:32 AM (17 years ago)
Author:
ole
Message:

Cosmetics according to style guide.

Location:
anuga_core/source/anuga
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/geospatial_data/geospatial_data.py

    r4745 r4776  
    655655        new_size = round(factor*self_size)
    656656       
    657         #find unique random numbers
     657        # Find unique random numbers
    658658        if verbose: print "make unique random number list and get indices"
    659659
     
    662662        if verbose: print "total list len",len(total_list)
    663663               
    664         #there will be repeated random numbers however will not be a
    665         #problem as they are being 'pop'ed out of array so if there
    666         #are two numbers the same they will pop different indicies,
    667         #still basically random
     664        # There will be repeated random numbers however will not be a
     665        # problem as they are being 'pop'ed out of array so if there
     666        # are two numbers the same they will pop different indicies,
     667        # still basically random
    668668        ## create list of non-unquie random numbers
    669669        if verbose: print "create random numbers list %s long" %new_size
    670670       
    671         #set seed if provided, mainly important for unit test!
     671        # Set seed if provided, mainly important for unit test!
    672672        if seed_num != None:
    673673            seed(seed_num,seed_num)
     
    684684        k=1
    685685        remainder_list = total_list[:]
    686         #pops array index (random_num) from remainder_list
     686        # pops array index (random_num) from remainder_list
    687687        # (which starts as the
    688         #total_list and appends to random_list 
     688        # total_list and appends to random_list 
    689689        random_num_len = len(random_num)
    690690        for i in random_num:
     
    696696                k+=1
    697697       
    698         #FIXME: move to tests, it might take a long time
    699         #then create an array of random lenght between 500 and 1000,
    700         #and use a random factor between 0 and 1
    701         #setup for assertion
     698        # FIXME: move to tests, it might take a long time
     699        # then create an array of random lenght between 500 and 1000,
     700        # and use a random factor between 0 and 1
     701        # setup for assertion
    702702        test_total = random_list[:]
    703703        test_total.extend(remainder_list)
     
    707707        assert (total_list==test_total),msg
    708708
    709         #get new samples
     709        # Get new samples
    710710        if verbose: print "get values of indices for random list"
    711711        G1 = self.get_sample(random_list)
     
    733733        if self.file_name[-4:] == ".pts":
    734734           
    735             # see if the file is there.  Throw a QUIET IO error if it isn't
     735            # See if the file is there.  Throw a QUIET IO error if it isn't
    736736            fd = open(self.file_name,'r')
    737737            fd.close()
    738738   
    739             #throws prints to screen if file not present
     739            # Throws prints to screen if file not present
    740740            self.fid = NetCDFFile(self.file_name, 'r')
    741741           
     
    761761           
    762762        else:
    763             # assume the file is a csv file
     763            # Assume the file is a csv file
    764764            file_pointer = open(self.file_name)
    765765            self.header, self.file_pointer = \
     
    775775        if self.file_name[-4:] == ".pts":
    776776            if self.start_row == self.last_row:
    777                 # read the end of the file last iteration
    778                 # remove blocking attributes
     777                # Read the end of the file last iteration
     778                # Remove blocking attributes
    779779                self.fid.close()
    780780                del self.max_read_lines
     
    822822           
    823823        else:
    824             # assume the file is a csv file
     824            # Assume the file is a csv file
    825825            try:
    826826                pointlist, att_dict, geo_ref, self.file_pointer = \
     
    859859                raise SyntaxError, msg
    860860        return geo
     861
     862   
    861863##################### Error messages ###########
    862864Error_message = {}
     
    933935   
    934936       
    935     # see if the file is there.  Throw a QUIET IO error if it isn't
     937    # See if the file is there.  Throw a QUIET IO error if it isn't
    936938    fd = open(file_name,'r')
    937939    fd.close()
    938940   
    939     #throws prints to screen if file not present
     941    # Throws prints to screen if file not present
    940942    fid = NetCDFFile(file_name, 'r')
    941943   
     
    10161018    att_dict = {}
    10171019
    1018     #This is to remove the x and y headers.
     1020    # This is to remove the x and y headers.
    10191021    header = header[:]
    10201022    try:
     
    10631065        att_dict[key] = array(att_dict[key]).astype(Float)
    10641066
    1065     #Do stuff here so the info is in lat's and longs
     1067    # Do stuff here so the info is in lat's and longs
    10661068    geo_ref = None
    10671069    x_header = lower(x_header[:3])
     
    11461148    outfile = NetCDFFile(file_name, 'w')
    11471149   
    1148     #Create new file
     1150    # Create new file
    11491151    outfile.institution = 'Geoscience Australia'
    11501152    outfile.description = 'NetCDF format for compact and portable storage ' +\
    11511153                          'of spatial point data'
    11521154   
    1153     # dimension definitions
     1155    # Dimension definitions
    11541156    shape = write_data_points.shape[0]
    11551157    outfile.createDimension('number_of_points', shape) 
    11561158    outfile.createDimension('number_of_dimensions', 2) #This is 2d data
    11571159   
    1158     # variable definition
     1160    # Variable definition
    11591161    outfile.createVariable('points', Float, ('number_of_points',
    11601162                                             'number_of_dimensions'))
  • anuga_core/source/anuga/shallow_water/data_manager.py

    r4775 r4776  
    12901290    """
    12911291
    1292     #FIXME: Can this be written feasibly using write_pts?
     1292    # FIXME: Can this be written feasibly using write_pts?
    12931293
    12941294    import os
     
    12981298    root = basename_in
    12991299
    1300     #Get NetCDF
    1301     infile = NetCDFFile(root + '.dem', 'r')  #Open existing netcdf file for read
     1300    # Get NetCDF
     1301    infile = NetCDFFile(root + '.dem', 'r')  # Open existing netcdf file for read
    13021302
    13031303    if verbose: print 'Reading DEM from %s' %(root + '.dem')
     
    13051305    ncols = infile.ncols[0]
    13061306    nrows = infile.nrows[0]
    1307     xllcorner = infile.xllcorner[0]  #Easting of lower left corner
    1308     yllcorner = infile.yllcorner[0]  #Northing of lower left corner
     1307    xllcorner = infile.xllcorner[0]  # Easting of lower left corner
     1308    yllcorner = infile.yllcorner[0]  # Northing of lower left corner
    13091309    cellsize = infile.cellsize[0]
    13101310    NODATA_value = infile.NODATA_value[0]
     
    13151315    false_northing = infile.false_northing[0]
    13161316
    1317     #Text strings
     1317    # Text strings
    13181318    projection = infile.projection
    13191319    datum = infile.datum
     
    13211321
    13221322
    1323     #Get output file
     1323    # Get output file
    13241324    if basename_out == None:
    13251325        ptsname = root + '.pts'
     
    13311331    outfile = NetCDFFile(ptsname, 'w')
    13321332
    1333     #Create new file
     1333    # Create new file
    13341334    outfile.institution = 'Geoscience Australia'
    13351335    outfile.description = 'NetCDF pts format for compact and portable storage ' +\
    13361336                      'of spatial point data'
    1337     #assign default values
     1337    # Assign default values
    13381338    if easting_min is None: easting_min = xllcorner
    13391339    if easting_max is None: easting_max = xllcorner + ncols*cellsize
     
    13411341    if northing_max is None: northing_max = yllcorner + nrows*cellsize
    13421342
    1343     #compute offsets to update georeferencing
     1343    # Compute offsets to update georeferencing
    13441344    easting_offset = xllcorner - easting_min
    13451345    northing_offset = yllcorner - northing_min
    13461346
    1347     #Georeferencing
     1347    # Georeferencing
    13481348    outfile.zone = zone
    1349     outfile.xllcorner = easting_min #Easting of lower left corner
    1350     outfile.yllcorner = northing_min #Northing of lower left corner
     1349    outfile.xllcorner = easting_min # Easting of lower left corner
     1350    outfile.yllcorner = northing_min # Northing of lower left corner
    13511351    outfile.false_easting = false_easting
    13521352    outfile.false_northing = false_northing
     
    13571357
    13581358
    1359     #Grid info (FIXME: probably not going to be used, but heck)
     1359    # Grid info (FIXME: probably not going to be used, but heck)
    13601360    outfile.ncols = ncols
    13611361    outfile.nrows = nrows
     
    13641364    totalnopoints = nrows*ncols
    13651365
    1366     # calculating number of NODATA_values for each row in clipped region
    1367     #FIXME: use array operations to do faster
     1366    # Calculating number of NODATA_values for each row in clipped region
     1367    # FIXME: use array operations to do faster
    13681368    nn = 0
    13691369    k = 0
     
    13901390    index2 = thisj
    13911391
    1392     # dimension definitions
     1392    # Dimension definitions
    13931393    nrows_in_bounding_box = int(round((northing_max-northing_min)/cellsize))
    13941394    ncols_in_bounding_box = int(round((easting_max-easting_min)/cellsize))
     
    14071407    outfile.createDimension('number_of_dimensions', 2) #This is 2d data
    14081408
    1409     # variable definitions
     1409    # Variable definitions
    14101410    outfile.createVariable('points', Float, ('number_of_points',
    14111411                                             'number_of_dimensions'))
     
    14171417
    14181418    lenv = index2-index1+1
    1419     #Store data
     1419    # Store data
    14201420    global_index = 0
    1421     #for i in range(nrows):
     1421    # for i in range(nrows):
    14221422    for i in range(i1_0,thisi+1,1):
    14231423        if verbose and i%((nrows+10)/10)==0:
     
    14291429        no_NODATA = sum(v == NODATA_value)
    14301430        if no_NODATA > 0:
    1431             newcols = lenv - no_NODATA #ncols_in_bounding_box - no_NODATA
     1431            newcols = lenv - no_NODATA # ncols_in_bounding_box - no_NODATA
    14321432        else:
    1433             newcols = lenv #ncols_in_bounding_box
     1433            newcols = lenv # ncols_in_bounding_box
    14341434
    14351435        telev = zeros(newcols, Float)
Note: See TracChangeset for help on using the changeset viewer.