Opened 14 years ago

Closed 14 years ago

#351 closed enhancement (fixed)

New tool: csv2sts

Reported by: horspool Owned by: ole
Priority: highest Milestone:
Component: Functionality and features Version:
Severity: normal Keywords: csv sts boundary file
Cc:

Description (last modified by horspool)

It would be great to have a tool that converted a time series in csv format into sts (NetCDF) format. This would enhance the functionality of tsunami models in ANUGA by allowing any deep water model (with csv output) to be coupled with ANUGA. This should be able to be run on windows and linux - command line only.

I would imagine having a text file with a list of 'offshore gauges' files. With an associated lat lon for each gauge.

eg. of gauge_list.txt

gauge_1.csv <lon> <lat>
gauge_2.csv <lon> <lat>
......

eg. gauge_1.csv

<time>,<waveHeight>
.......

Change History (2)

comment:1 Changed 14 years ago by horspool

  • Description modified (diff)

comment:2 Changed 14 years ago by hudson

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

I've written a module called csv2sts.py, which can be used either as a python module, or a command line tool. Use this module to convert an arbitrary csv file to an sts file. The csv file must have a header containing the column names. This will be converted to a NetCDF .sts file containing the same data, with the addition of optional latitude and longitude values.

For example, the following .csv file:

time stage 0 4 1 150.66667 2 150.83334 3 151. 4 151.16667 5 -34. 6 -34.16667 7 -34.33333 8 -34.5 9 -1. 10 -5. 11 -9. 12 -13.

Using this command:

python csv2sts --lat 14 --lon 56 infile.csv foo.sts

Will be converted to the following .sts file:

netcdf foo { dimensions:

number_of_timesteps = 13 ;

variables:

double stage(number_of_timesteps) ; double time(number_of_timesteps) ;

global attributes:

:latitude = 14. ; :longitude = 56. ;

data:

stage = 4, 150.66667, 150.83334, 151, 151.16667, -34, -34.16667, -34.33333,

-34.5, -1, -5, -9, -13 ;

time = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ;

}

Note: See TracTickets for help on using tickets.