Changeset 4569


Ignore:
Timestamp:
Jun 28, 2007, 5:29:12 PM (18 years ago)
Author:
ole
Message:

Cosmetics and diagnostics about number of points read from pts files

Location:
anuga_core/source/anuga
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/domain.py

    r4565 r4569  
    960960        # self.timestep is calculated from speed of characteristics
    961961        # Apply CFL condition here
    962         timestep = min(self.CFL*self.timestep,max_timestep)
     962        timestep = min(self.CFL*self.timestep, max_timestep)
    963963
    964964        #Record maximal and minimal values of timestep for reporting
  • anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py

    r4541 r4569  
    692692
    693693
    694         #Call fit_interpolate.fit function
     694        # Call fit_interpolate.fit function
    695695        args = (coordinates, triangles, points, values)
    696696        kwargs = {'data_origin': data_georef.get_origin(),
     
    699699                  'verbose': verbose}
    700700
    701         #print kwargs
    702 
    703         #FIXME(dsg):Why is this catched? fit_to_mesh handles caching.
    704         if use_cache is True:
    705             try:
    706                 from caching import cache
    707             except:
    708                 msg = 'Caching was requested, but caching module'+\
    709                       'could not be imported'
    710                 raise msg
    711 
    712             vertex_attributes = cache(fit_to_mesh,
    713                                       args, kwargs,
    714                                       verbose=verbose,
    715                                       compression=False)
    716         else:
    717             vertex_attributes = apply(fit_to_mesh,
    718                                       args, kwargs)
    719 
    720         #Call underlying method using array values
     701
     702        # FIXME(dsg):Why is this catched? fit_to_mesh handles caching.
     703        # Fair enough - I have commented it out 28/6/7 (Ole)
     704        #if use_cache is True:
     705        #    try:
     706        #        from caching import cache
     707        #    except:
     708        #        msg = 'Caching was requested, but caching module'+\
     709        #              'could not be imported'
     710        #        raise msg
     711        #
     712        #    vertex_attributes = cache(fit_to_mesh,
     713        #                              args, kwargs,
     714        #                              verbose=verbose,
     715        #                              compression=False)
     716        #else:
     717        #    vertex_attributes = apply(fit_to_mesh,
     718        #                              args, kwargs)
     719
     720        vertex_attributes = apply(fit_to_mesh,
     721                                  args, kwargs)       
     722
     723        # Call underlying method using array values
    721724        self.set_values_from_array(vertex_attributes,
    722725                                   location, indices, verbose)
     
    747750        triangles = self.domain.triangles      #FIXME
    748751           
    749         vertex_attributes = fit_to_mesh(coordinates, triangles,filename,
     752        vertex_attributes = fit_to_mesh(coordinates, triangles, filename,
    750753                                        alpha=alpha,
    751754                                        attribute_name=attribute_name,
     
    754757                                        max_read_lines=max_read_lines)
    755758                                           
    756         #Call underlying method using array values
     759        # Call underlying method using array values
    757760        self.set_values_from_array(vertex_attributes,
    758761                                   location, indices, verbose)
  • anuga_core/source/anuga/fit_interpolate/fit.py

    r4535 r4569  
    316316              List of coordinate pairs [x, y] of
    317317              data points or an nx2 Numeric array or a Geospatial_data object
     318              or filename (txt, csv, pts?)
    318319          z: Single 1d vector or array of data at the point_coordinates.
    319320         
     
    324325            assert point_origin is None, msg
    325326            filename = point_coordinates_or_filename
    326             for i,geo_block in enumerate(Geospatial_data(filename,
     327           
     328            for i, geo_block in enumerate(Geospatial_data(filename,
    327329                                              max_read_lines=max_read_lines,
    328330                                              load_file_now=False,
     
    468470
    469471def _fit_to_mesh(vertex_coordinates,
    470                 triangles,
    471                 point_coordinates, # this can also be a .csv/.txt file name
    472                 point_attributes=None,
    473                 alpha=DEFAULT_ALPHA,
    474                 verbose=False,
    475                 acceptable_overshoot=1.01,
    476                 mesh_origin=None,
    477                 data_origin=None,
    478                 max_read_lines=None,
    479                 attribute_name=None,
    480                 use_cache = False):
     472                 triangles,
     473                 point_coordinates, # this can also be a .csv/.txt file name
     474                 point_attributes=None,
     475                 alpha=DEFAULT_ALPHA,
     476                 verbose=False,
     477                 acceptable_overshoot=1.01,
     478                 mesh_origin=None,
     479                 data_origin=None,
     480                 max_read_lines=None,
     481                 attribute_name=None,
     482                 use_cache = False):
    481483    """
    482484    Fit a smooth surface to a triangulation,
     
    495497
    496498          point_coordinates: List of coordinate pairs [x, y] of data points
    497           (or an nx2 Numeric array)
     499          (or an nx2 Numeric array). This can also be a .csv/.txt file name
     500          FIXME (Ole): Can't it be a pts file too?
    498501
    499502          alpha: Smoothing parameter.
  • anuga_core/source/anuga/geospatial_data/geospatial_data.py

    r4549 r4569  
    4949        data_points: x,y coordinates in meters. Type must be either a
    5050        sequence of 2-tuples or an Mx2 Numeric array of floats.  A file name
    51         can also be passed in here.
     51        with extension .txt, .cvs or .pts can also be passed in here.
    5252
    5353        attributes: Associated values for each data point. The type
     
    147147                msg = 'No file specified yet a delimiter is provided!'
    148148                raise ValueError, msg
    149             file_name = None
     149            file_name = None #FIXME (Ole): Isn't this line superfluous
     150           
    150151            if latitudes is not None or longitudes is not None or \
    151152                   points_are_lats_longs:
     
    748749
    749750    def __iter__(self):
    750         """
    751         read in the header and save the file pointer position
     751        """Read in the header, number_of_points and save the
     752        file pointer position
    752753        """
    753754
     
    756757        #FIXME - what to do if the file isn't there
    757758
    758         if self.file_name[-4:]== ".xya":
     759        if self.file_name[-4:] == ".xya":
     760            # FIXME (Ole): shouldn't the xya format be replaced by txt/csv?
     761
    759762            #let's just read it all
    760763            pass
    761         elif self.file_name[-4:]== ".pts":
     764        elif self.file_name[-4:] == ".pts":
    762765           
    763766            # see if the file is there.  Throw a QUIET IO error if it isn't
     
    770773            self.blocking_georef, self.blocking_keys, self.last_row = \
    771774                     _read_pts_file_header(self.fid, self.verbose)
    772             self.start_row=0
     775            self.start_row = 0
    773776            self.show_verbose = 0
    774             self.verbose_block_size =  (self.last_row +10) /10
     777            self.verbose_block_size = (self.last_row + 10)/10
     778           
     779            if self.verbose is True:
     780                print 'Reading %d points (blocking) from file %s'\
     781                      %(self.last_row,
     782                        self.file_name)
     783           
    775784        else:
     785            # It looks like the file is assumed to be a csv file
    776786            file_pointer = open(self.file_name)
    777787            self.header, self.file_pointer = \
    778788                         _read_csv_file_header(file_pointer)
    779789            self.blocking_georef = None # Used for reconciling zones
     790           
    780791        if self.max_read_lines is None:
    781792            self.max_read_lines = MAX_READ_LINES
     
    783794   
    784795    def next(self):
    785         # read a block, instanciate a new geospatial and return it
     796        """ read a block, instanciate a new geospatial and return it"""
     797       
    786798        if self.file_name[-4:]== ".xya" :
     799            # FIXME (Ole): shouldn't the xya format be replaced by txt/csv?
     800           
    787801            if not hasattr(self,'finished_reading') or \
    788802                   self.finished_reading is False:
     
    814828            if self.verbose is True:
    815829                if self.show_verbose >= self.start_row and \
    816                                        self.show_verbose < fin_row:
     830                       self.show_verbose < fin_row:
    817831                 print 'Doing %d of %d' %(self.start_row, self.last_row+10)
    818832                 self.show_verbose += max(self.max_read_lines,
     
    820834            #call stuff
    821835            pointlist, att_dict, = \
    822                    _read_pts_file_blocking( self.fid,
    823                                             self.start_row,
    824                                             fin_row,
    825                                             self.blocking_keys
    826                                             )
     836                   _read_pts_file_blocking(self.fid,
     837                                           self.start_row,
     838                                           fin_row,
     839                                           self.blocking_keys)
     840           
    827841            geo = Geospatial_data(pointlist, att_dict, self.blocking_georef)
    828842            self.start_row = fin_row
     
    923937                                                    longitudes=longitudes)
    924938    return data_points, Geo_reference(zone=zone)
     939
    925940   
    926941def _read_pts_file(file_name, verbose=False):
     
    10891104def _read_pts_file_header(fid, verbose=False):
    10901105
    1091     """
    1092     Read the geo_reference of a .pts file
     1106    """Read the geo_reference and number_of_points from a .pts file
    10931107    """
    10941108   
Note: See TracChangeset for help on using the changeset viewer.