Opened 18 years ago

Closed 15 years ago

#113 closed enhancement (fixed)

Output data for the centroid of the triangle NOT just the interpolated results

Reported by: Nick Owned by: hudson
Priority: high Milestone: ANUGA enhancements
Component: Functionality and features Version: 1.0
Severity: normal Keywords:
Cc: Duncan

Description

Currently if exporting gauges the resolution of the mesh and orientation of the triangles will effect the results, this is not always desired. Having the values at the centroid will increase speed in trouble shooting model errors or problems

It would be great to provide the gauge location and recieve either the interpolated results or the values at the triangle's centroid and the position of the centroid.

look in sww2dem

Change History (9)

comment:1 Changed 18 years ago by ole

  • Owner changed from Ole to ole
  • Status changed from new to assigned

comment:2 Changed 15 years ago by ole

  • Owner changed from ole to steve
  • Status changed from assigned to new
  • Type changed from defect to enhancement

comment:3 Changed 15 years ago by ole

  • Milestone set to ANUGA enhancements

comment:4 Changed 15 years ago by hudson

  • Owner changed from steve to hudson

As this is my first task, I'll start reviewing the functions that I'll need to use.

comment:5 Changed 15 years ago by hudson

  • Status changed from new to assigned

Currently, sww2csv_gauges uses file_function to intersect the mesh at the given gauge points and return values interpolated for stage height, momentum, etc. The interpolation functions already return the triangle index of the intersected triangle, so it should be easy to return the centroid, and take the average of all values.

I think the code concerned with gauges should be refactored before work begins - gauge code is scattered throughout util.py, and would benefit from being given its own file.

A less immediate and more ambitious refactoring suggestion: netcdf access code is scattered throughout util.py and interpolate.py - it would be nice if this could be hidden behind a nice API, similar to the ANUGA viewer code. For example we could have an sww class:

sww_file = SWWFile("patong.sww")

for gauge_point in gauge_list:
    point, tri = sww_file.intersect(gauge_point)
    plot("interpolated timeseries", sww_file.get_timeseries(point))
    plot("centroid timeseries", sww_file.get_timeseries(tri))

Also, as a step on from this, it could be cool to have bindings for the ANUGA viewer swwreader.lib and use that instead of the Python libs. I'm sure I could write a pretty lean and fast mesh intersection method in C++. Bit of overkill for the moment, though.

comment:6 Changed 15 years ago by hudson

Revision 7673 - added an output_centroids parameter to allow centroid data to be written to gauges, rather than the data at the sampled point.

Added 2 new unit tests for this functionality.

comment:7 Changed 15 years ago by hudson

Proposed API for getting the centroids

gauge_sww2csv('filename.sww', 'gauges.csv', quantities=['stage', 'xcentroid', 'ycentroid'], output_centroids=True)

Param output_centroids means that all samples are taken from the centroid. The extra quantities "xcentroid" and "ycentroid" can be specified to return extra quantity columns in the output csv file.

Under the hood

If centroids are requested, gauge_sww2csv calls callable_sww, which will return the centroids as a separate list. The centroids are then appended to the csv file as an extra column.

comment:8 Changed 15 years ago by hudson

Task has been completed - after the functionality has been reviewed and tested, this ticket can be closed.

comment:9 Changed 15 years ago by hudson

  • Resolution set to fixed
  • Status changed from assigned to closed

Task done, and tests pass.

Note: See TracTickets for help on using tickets.