source: trunk/anuga_core/source/anuga/file_conversion/urs2txt.py @ 8879

Last change on this file since 8879 was 8149, checked in by wilsonr, 14 years ago

Removed '@brief' comments.

File size: 2.4 KB
Line 
1from anuga.file.urs import Read_urs
2
3def urs2txt(basename_in, location_index=None):
4    """
5    Not finished or tested
6    """
7
8    files_in = [basename_in + WAVEHEIGHT_MUX_LABEL,
9                basename_in + EAST_VELOCITY_LABEL,
10                basename_in + NORTH_VELOCITY_LABEL]
11    quantities = ['HA','UA','VA']
12
13    d = ","
14
15    # instantiate urs_points of the three mux files.
16    mux = {}
17    for quantity, file in map(None, quantities, files_in):
18        mux[quantity] = Read_urs(file)
19
20    # Could check that the depth is the same. (hashing)
21
22    # handle to a mux file to do depth stuff
23    a_mux = mux[quantities[0]]
24
25    # Convert to utm
26    latitudes = a_mux.lonlatdep[:,1]
27    longitudes = a_mux.lonlatdep[:,0]
28    points_utm, zone = \
29        convert_from_latlon_to_utm(latitudes=latitudes, longitudes=longitudes)
30    depths = a_mux.lonlatdep[:,2]
31
32    # open the output text file, start writing.
33    fid = open(basename_in + '.txt', 'w')
34
35    fid.write("zone: " + str(zone) + "\n")
36
37    if location_index is not None:
38        #Title
39        li = location_index
40        fid.write('location_index' + d + 'lat' + d + 'long' + d +
41                  'Easting' + d + 'Northing' + '\n')
42        fid.write(str(li) + d + str(latitudes[li]) + d +
43                  str(longitudes[li]) + d + str(points_utm[li][0]) + d +
44                  str(points_utm[li][01]) + '\n')
45
46    # the non-time dependent stuff
47    #Title
48    fid.write('location_index' + d + 'lat' + d + 'long' + d +
49              'Easting' + d + 'Northing' + d + 'depth m' + '\n')
50    i = 0
51    for depth, point_utm, lat, long in map(None, depths, points_utm,
52                                           latitudes, longitudes):
53
54        fid.write(str(i) + d + str(lat) + d + str(long) + d +
55                  str(point_utm[0]) + d + str(point_utm[01]) + d +
56                  str(depth) + '\n')
57        i += 1
58
59    #Time dependent
60    if location_index is not None:
61        time_step = a_mux.time_step
62        i = 0
63        #Title
64        fid.write('time' + d + 'HA depth m' + d + 'UA momentum East x m/sec' +
65                  d + 'VA momentum North y m/sec' + '\n')
66        for HA, UA, VA in map(None, mux['HA'], mux['UA'], mux['VA']):
67            fid.write(str(i*time_step) + d + str(HA[location_index]) + d +
68                      str(UA[location_index]) + d +
69                      str(VA[location_index]) + '\n')
70            i += 1
71
Note: See TracBrowser for help on using the repository browser.