-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwrite_GL_Ice2a_SS_Restarts.py
109 lines (96 loc) · 3.68 KB
/
write_GL_Ice2a_SS_Restarts.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import netCDF4
import sys
import os
import glob
import numpy as np
sys.path.append('/usr/local/lib/python2.7/site-packages/')
import vtk
from vtk.util.numpy_support import vtk_to_numpy
rhow=1.028
rhoi=0.918
ncfile = netCDF4.Dataset('/home/users/merino4i/output_files_MISMIP/output_files_MISMIP-/Ice2ra.nc','a')
xGL= ncfile.variables['xGL']
yGL= ncfile.variables['yGL']
iceThicknessGL = ncfile.variables['iceThicknessGL']
uBaseGL = ncfile.variables['uBaseGL']
vBaseGL = ncfile.variables['vBaseGL']
#vSurfaceGL = ncfile.variables['vSurfaceGL']
#uSurfaceGL = ncfile.variables['uSurfaceGL']
#uMeanGL = ncfile.variables['uMeanGL']
#vMeanGL = ncfile.variables['vMeanGL']
caseFirst='Test500m_Schoof_SSAStar_Repeated'
cases=['Test500m_Schoof_SSAStar_Repeated']
runs=['Ice2r9','Ice2a','Ice2a1','Ice2a2','Ice2a3','Ice2a4','Ice2a5','Ice2a6','Ice2a7','Ice2a8','Ice2a9',
'Ice2a10','Ice2a11','Ice2a12','Ice2a13','Ice2a14','Ice2a15','Ice2a16','Ice2a17']
indexCases=0
time=[100.0,110.0,120.0,130.0,140.0,150.0,160.0,170.0,180.0,190.0,200.0,
300.0,400.0,500.0,600.0,700.0,800.0,900.0,1000.0]
#Integrales
Voldata=[]
VolSubdata=[]
AreaGdata=[]
XGL=[]
indexTime=0
for case in cases:
for run in runs:
indexFile=0
if run==runs[0]: #First data comes from previous Run
path='/home/users/merino4i/MISMIP+/'+caseFirst+'/'+run+'/'
filesIce=glob.glob(path+'*.pvtu')
filesIce.sort()
for fileTest in filesIce:
file1=fileTest
else:
path='/home/users/merino4i/MISMIP+/'+case+'/'+run+'/'
filesIce=glob.glob(path+'*.pvtu')
filesIce.sort()
for fileTest in filesIce:
file1=fileTest
reader = vtk.vtkXMLPUnstructuredGridReader()
print file1
reader.SetFileName(file1)
reader.Update()
output=reader.GetOutput()
Coords=vtk_to_numpy(output.GetPoints().GetData())
PointData=output.GetPointData()
numArrays=PointData.GetNumberOfArrays()
for i in np.arange(numArrays):
if PointData.GetArrayName(i)=='ssavelocity':
VarIndex=i
break
Vel=vtk_to_numpy(PointData.GetArray(VarIndex))
for i in np.arange(numArrays):
if PointData.GetArrayName(i)=='groundedmask':
VarIndex=i
break
Gl=vtk_to_numpy(PointData.GetArray(VarIndex))
for i in np.arange(numArrays):
if PointData.GetArrayName(i)=='zb':
VarIndex=i
break
Zb=vtk_to_numpy(PointData.GetArray(VarIndex))
for i in np.arange(numArrays):
if PointData.GetArrayName(i)=='zs':
VarIndex=i
break
Zs=vtk_to_numpy(PointData.GetArray(VarIndex))
for i in np.arange(numArrays):
if PointData.GetArrayName(i)=='h':
VarIndex=i
break
H=vtk_to_numpy(PointData.GetArray(VarIndex))
cellData=output.GetCellData()
GeometryIDS=vtk_to_numpy(cellData.GetArray(0))
indexGL=np.where(Gl==0.0)
xGL[:,indexTime]=Coords[indexGL,0][0]
yGL[:,indexTime]=Coords[indexGL,1][0]
iceThicknessGL[:,indexTime]=H[indexGL]
uBaseGL[:,indexTime]=Vel[indexGL,0][0]
vBaseGL[:,indexTime]=Vel[indexGL,1][0]
#uMeanGL[:,indexTime]=velGL[indexGL,0][0]
#vMeanGL[:,indexTime]=velGL[indexGL,1][0]
#uSurfaceGL[:,indexTime]=velGL[indexGL,0][0]
#vSurfaceGL[:,indexTime]=velGL[indexGL,1][0]
indexFile=indexFile+1
indexTime=indexTime+1
ncfile.close()