-
Notifications
You must be signed in to change notification settings - Fork 13
/
adcirc_to_2dm.py
executable file
·55 lines (50 loc) · 1.66 KB
/
adcirc_to_2dm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
#
#+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!
# #
# adcirc_to_2dm.py #
# #
#+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!+!
#
# Author: Pat Prodanovic, Ph.D., P.Eng.
#
# Date: Apr 19, 2020
#
# Purpose: Script takes in a mesh in adcirc format, and writes it to a
# *.2dm file format.
#
# Uses: Python 2 or 3, Numpy
#
# Example:
#
# python adcirc_to_2dm.py -i -out.grd -o out.2dm
# where:
# -i input adcirc mesh file
# -o output 2dm mesh file
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Global Imports
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import os,sys,time # system parameters
import numpy as np # numpy
from ppmodules.readMesh import * # to get all readMesh functions
from ppmodules.writeMesh import * # to get all readMesh functions
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# MAIN
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
curdir = os.getcwd()
#
# I/O
if len(sys.argv) != 5 :
print('Wrong number of Arguments, stopping now...')
print('Usage:')
print('python adcirc_to_2dm.py -i out.grd -o out.2dm')
sys.exit()
adcirc_file = sys.argv[2]
two_dm_file = sys.argv[4]
# read the adcirc file
n,e,x,y,z,ikle = readAdcirc(adcirc_file)
# write the 2dm file
write2dm(n,e,x,y,z,ikle,two_dm_file)
print('All done!')