Changeset 9405
- Timestamp:
- Jan 15, 2015, 1:07:49 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/__init__.py
r9379 r9405 162 162 from anuga.file_conversion.esri2sww import esri2sww 163 163 from anuga.file_conversion.sww2dem import sww2dem, sww2dem_batch 164 from anuga.file_conversion.asc2dem import asc2dem 164 from anuga.file_conversion.asc2dem import asc2dem 165 from anuga.file_conversion.xya2pts import xya2pts 165 166 from anuga.file_conversion.ferret2sww import ferret2sww 166 167 from anuga.file_conversion.dem2dem import dem2dem -
trunk/anuga_core/source/anuga/file_conversion/xya2pts.py
r9324 r9405 1 1 2 2 3 def xya2pts( filename, verbose=False):3 def xya2pts(name_in, name_out=None, verbose=False): 4 4 """Convert a file with xy and elevation data to NetCDF pts file. 5 5 """ 6 6 7 7 from anuga.geospatial_data import Geospatial_data 8 9 root = name_in[:-4] 10 11 if name_out is None: name_out = root + '.pts' 8 12 9 if verbose: print 'Creating', filename13 if verbose: print 'Creating', name_out 10 14 11 15 # Read the ascii (.xya) version of this file, 12 16 # make it comma separated and invert the bathymetry 13 17 # (Below mean sea level should be negative) 14 infile = open(filename[:-4] + '.xya') 15 out_filename = filename[:-4] + '.pts' 18 infile = open(name_in) 16 19 17 20 points = [] 18 21 attribute = [] 22 19 23 for line in infile.readlines()[1:]: #Skip first line (the header) 20 24 fields = line.strip().split(',') … … 31 35 G = Geospatial_data(data_points=points, 32 36 attributes=attribute) 33 G.export_points_file( out_filename)37 G.export_points_file(name_out) 34 38 35 39 -
trunk/anuga_core/validation_tests/experimental_data/okushiri/create_okushiri.py
r9403 r9405 185 185 186 186 if verbose: print 'Reading pts from xya' 187 anuga.xya2pts(project.bathymetry_filename_stem+'.pts', verbose = verbose) 187 anuga.xya2pts(project.bathymetry_filename_stem+'.xya',\ 188 verbose = verbose) 188 189 189 190 fit_to_mesh_file(project.mesh_filename, project.bathymetry_filename, -
trunk/anuga_user_manual/source/anuga_user_manual.tex
r9402 r9405 344 344 345 345 \label{ref:runup_py_code} 346 \verbatiminput {../../demos/runup.py}346 \verbatiminputunderscore{../../anuga_core/demos/runup.py} 347 347 348 348 … … 656 656 when this example is run: 657 657 658 \verbatiminput {examples/runupoutput.txt}658 \verbatiminputunderscore{examples/runupoutput.txt} 659 659 660 660 … … 731 731 Here is the code for the first version of the channel flow \file{channel1.py}: 732 732 733 \verbatiminput {demos/channel1.py}733 \verbatiminputunderscore{demos/channel1.py} 734 734 735 735 In discussing the details of this example, we follow the outline … … 774 774 %\end{verbatim} 775 775 776 776 %========================================= 777 777 \section{Model Output} 778 778 … … 787 787 \end{figure} 788 788 789 \subsection{Changing boundary conditions on the fly} 789 790 791 %========================================= 792 \section{Changing boundary conditions on the fly} 790 793 \label{sec:change boundary} 791 794 792 795 Here is the code for the second version of the channel flow \file{channel2.py}: 793 796 794 \verbatiminput {demos/channel2.py}797 \verbatiminputunderscore{demos/channel2.py} 795 798 796 799 This example differs from the first version in that a constant outflow boundary condition has … … 845 848 Here is the code for the third version of the channel flow \file{channel3.py}: 846 849 847 \verbatiminput {demos/channel3.py}850 \verbatiminputunderscore{demos/channel3.py} 848 851 849 852 This example differs from the first two versions in that the topography … … 886 889 887 890 888 \section{An Example with Real Data} 891 %========================================================== 892 \chapter{An Example with Real Data} 889 893 890 894 \label{sec:realdataexample} The following discussion builds on the … … 905 909 } 906 910 907 \s ubsection{Overview}911 \section{Overview} 908 912 As in the case of \file{runup.py}, the actions carried 909 913 out by the program can be organised according to this outline: … … 925 929 \end{enumerate} 926 930 927 \s ubsection{The Code}931 \section{The Code} 928 932 929 933 Here is the code for \file{runcairns.py}: 930 934 931 \verbatiminput {../../demos/cairns/runcairns.py}935 \verbatiminputunderscore{../../anuga_core/demos/cairns/runcairns.py} 932 936 933 937 In discussing the details of this example, we follow the outline 934 938 given above, discussing each major step of the code in turn. 935 939 936 \s ubsection{Establishing the Mesh}\index{mesh, establishing}940 \section{Establishing the Mesh}\index{mesh, establishing} 937 941 938 942 One obvious way that the present example differs from … … 990 994 \file{project.py}: 991 995 992 \verbatiminput {../../demos/cairns/project.py}996 \verbatiminputunderscore{../../anuga_core/demos/cairns/project.py} 993 997 994 998 Figure \ref{fig:cairns3d} illustrates the landscape of the region … … 1074 1078 Make sure points on polygons are spaced to be no closer than the smallest resolution requested. 1075 1079 1076 \s ubsection{Initialising the Domain}1080 \section{Initialising the Domain} 1077 1081 1078 1082 Since we used \code{create_domain_from_regions} to create the mesh file, we do not need to … … 1089 1093 \end{verbatim} 1090 1094 1091 \s ubsection{Initial Conditions}1095 \section{Initial Conditions} 1092 1096 1093 1097 Quantities for \file{runcairns.py} are set … … 1097 1101 auxiliary points file. 1098 1102 1099 \subs ubsection{Stage}1103 \subsection{Stage} 1100 1104 1101 1105 The stage is initially set to 0.0 (i.e.\ Mean Sea Level) by the following statements: … … 1123 1127 %large amplitude tsunami which would inundate the Cairns region.} 1124 1128 1125 \subs ubsection{Friction}1129 \subsection{Friction} 1126 1130 1127 1131 We assign the friction exactly as we did for \file{runup.py}: … … 1131 1135 \end{verbatim} 1132 1136 1133 \subs ubsection{Elevation}1137 \subsection{Elevation} 1134 1138 1135 1139 The elevation is specified by reading data from a file with a name derived from … … 1153 1157 the screen. 1154 1158 1155 \s ubsection{Boundary Conditions}\index{boundary conditions}1159 \section{Boundary Conditions}\index{boundary conditions} 1156 1160 1157 1161 Setting boundaries follows a similar pattern to the one used for … … 1190 1194 how the script can take different actions depending on a variable. 1191 1195 1192 \s ubsection{Evolution}1196 \section{Evolution} 1193 1197 1194 1198 With the basics established, the running of the 'evolve' step is … … 1253 1257 \file{ExportResults.py} demonstrates how this function can be used: 1254 1258 1255 \verbatiminput {demos/cairns/ExportResults.py}1259 \verbatiminputunderscore{demos/cairns/ExportResults.py} 1256 1260 1257 1261 The script generates a maximum water depth ASCII grid at a defined … … 1308 1312 the gauges shown in Figure \ref{fig:cairnsgauges} is \file{gauges.csv}: 1309 1313 1310 \verbatiminput {demos/cairns/gauges.csv}1314 \verbatiminputunderscore{demos/cairns/gauges.csv} 1311 1315 1312 1316 Header information has been included to identify the location in terms of eastings and … … 1318 1322 of the standard \code{anuga} release, however it can be downloaded and installed from \code{http://matplotlib.sourceforge.net/} 1319 1323 1320 \verbatiminput {demos/cairns/GetTimeseries.py}1324 \verbatiminputunderscore{demos/cairns/GetTimeseries.py} 1321 1325 1322 1326 Here, the time series for the quantities stage, depth and speed will be generated for … … 1347 1351 1348 1352 %================================= 1349 \section{A Parallel Simulation} 1350 1351 The previous examples were run just using one processor. \anuga also has the option of running in parallel using \mpi. 1353 \chapter{Parallel Simulation} 1354 1355 The examples from the previous chapters were run just using one processor. As you will have noticed, the simulations can take a long time to run, especially if you are using a fine mesh. Indeed as you halve the spacing of the mesh, the number of triangles goes up by a factor of 4 and the timestep halves, so generally halving the spacing of the mesh increases the run time by approximately a factor of 8. 1356 1357 One way to alleviate this is to run your simulation in parallel and use more processors to spread the computational cost. 1358 1359 1360 \anuga has the option of running in parallel using \mpi. A description of the method used to parallelize \anuga is given in section~\ref{theory:parallel}. 1352 1361 1353 1362 Such jobs are run using the command 1354 1363 1355 1364 \begin{verbatim} 1356 mpirun -np n python run ParallelCairns.py1365 mpirun -np n python runscript.py 1357 1366 \end{verbatim} 1358 1367 where \code{n} is the total number of processors being used for the parallel run. 1359 1368 1360 Essentially we can expect speedups comparable to the number of cores available. This is measured via scalablity. We can expect scalability of 70\% when using up to the number of processors so that the local partitioned domains contain around 2000 triangles. 1361 1362 \subsection{The Code} 1363 1364 Here is the code for \file{runParallelCairns.py}: 1369 Essentially we can expect speedups comparable to the number of cores available. This is measured via scalability. Our current experiments have demonstrated a scalability of 70\% or above when the number of processors are chosen so that the local partitioned meshes contain around 2000 triangles. 1370 1371 For instance, suppose we have a problem with a mesh of 500,000 triangles, and use 250 processors. Then the mesh will be partitioned into sub meshes of approximately 2000 triangles. 1372 We would expect 70\% scalability, and so expect a speedup of $250 \times 0.7 = 175$. 1373 1374 \section{The Code} 1375 1376 Here is the code for \file{runParallelCairns.py} which is found in the \file{demos/cairns} directory: 1365 1377 1366 1378 \verbatiminputunderscore{../../anuga_core/demos/cairns/runParallelCairns.py} 1367 1379 1368 1380 1369 \s ubsection{Structure of the Code}1381 \section{Structure of the Code} 1370 1382 1371 1383 The code is very similar to the sequential code. The same procedures are used to setup the domain, setup the inital conditions, boundary conditions and evolve. 1372 1384 1373 1385 1374 We first import a few procedures need for the parallel code.1386 We first import a few procedures need for the parallel code. 1375 1387 \begin{verbatim} 1376 1388 from anuga import distribute, myid, numprocs, finalize, barrier … … 1436 1448 1437 1449 1438 1439 \ section{Checkpointing}1440 1441 When running large and long running simulations, it is useful to provide a mechanism to allow the simulation to restarted if it is inter upted mid simulation. Maybe there is a power cut, or when using batch queues there may be a time restriction on the length of any one running job. Then the use of checkpointing becomes useful.1442 1443 The idea is that at regular intervals the system makes a copy of the current state of the computation. Then if there is an interruption the computation can be started from the last checkpoint time and not or ginal start time.1444 1445 \s ubsection{The Code}1450 %================================= 1451 \chapter{Checkpointing} 1452 1453 When running large and long running simulations, it is useful to provide a mechanism to allow the simulation to restarted if it is interrupted mid simulation. Maybe there is a power cut, or when using batch queues there may be a time restriction on the length of any one running job. Then the use of checkpointing becomes useful. 1454 1455 The idea is that at regular intervals the system makes a copy of the current state of the computation. Then if there is an interruption the computation can be started from the last checkpoint time and not original start time. 1456 1457 \section{The Code} 1446 1458 1447 1459 Here is the code for \file{runCheckpoint.py}: 1448 1460 1449 \verbatiminput {../../anuga_core/demos/checkpointing/runCheckpoint.py}1450 1451 \s ubsection{Structure of the Code}1461 \verbatiminputunderscore{../../anuga_core/demos/checkpointing/runCheckpoint.py} 1462 1463 \section{Structure of the Code} 1452 1464 1453 1465 As usual the code needs to import the required modules, and setup parameters and in this case procedures for setting up the stage and elevation. … … 1489 1501 will run the tests in verbose mode (produces output) and in parallel using 6 processors (if parallel version of anuga has been setup). 1490 1502 1491 A subset of these validation tests can be run using \code{run_auto_validat oin_tests.py} from the \module{anuga_core} directory.1503 A subset of these validation tests can be run using \code{run_auto_validation_tests.py} from the \module{anuga_core} directory. 1492 1504 1493 1505 … … 3767 3779 3768 3780 %FIXME (Ole): Should put in example with nonzero xllcorner, yllcorner 3769 \verbatiminput {examples/bedslopeexcerpt.cdl}3781 \verbatiminputunderscore{examples/bedslopeexcerpt.cdl} 3770 3782 3771 3783 The SWW format is used not only for output but also serves as input … … 3820 3832 \subsection{Formats for Storing Arbitrary Points and Attributes} 3821 3833 3822 A CSV/TXT file is used to store data representing3834 A CSV/TXT/XYA file is used to store data representing 3823 3835 arbitrary numerical attributes associated with a set of points. 3824 3836 3825 The format for an CSV/TXT file is:\\3837 The format for an CSV/TXT/XYA file is:\\ 3826 3838 \\ 3827 3839 first line: \code{[column names]}\\ … … 4242 4254 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4243 4255 \section{Parallel Implementation} 4256 \label{theory:parallel} 4244 4257 4245 4258 … … 5913 5926 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 5914 5927 5915 \chapter{Frequently Asked Questions}5916 5917 The Frequently Asked Questions have been move to the online FAQ at: \\5918 \url{https://anuga.anu.edu.au/wiki/FrequentlyAskedQuestions}5928 %\chapter{Frequently Asked Questions} 5929 % 5930 %The Frequently Asked Questions have been move to the online FAQ at: \\ 5931 %\url{https://anuga.anu.edu.au/wiki/FrequentlyAskedQuestions} 5919 5932 5920 5933 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note: See TracChangeset
for help on using the changeset viewer.