Ticket #113 (closed enhancement: fixed)

Opened 10 years ago

Last modified 7 years ago

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

Changed 10 years ago by ole

  • owner changed from Ole to ole
  • status changed from new to assigned

Changed 8 years ago by ole

  • owner changed from ole to steve
  • status changed from assigned to new
  • type changed from defect to enhancement

Changed 8 years ago by ole

  • milestone set to ANUGA enhancements

Changed 7 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.

Changed 7 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.

Changed 7 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.

Changed 7 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.

Changed 7 years ago by hudson

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

Changed 7 years ago by hudson

  • status changed from assigned to closed
  • resolution set to fixed

Task done, and tests pass.

Note: See TracTickets for help on using tickets.