source: issm/oecreview/Archive/13393-13976/ISSM-13469-13470.diff@ 13980

Last change on this file since 13980 was 13980, checked in by Mathieu Morlighem, 12 years ago

preparing oecreview for 13393-13976'

File size: 17.5 KB
RevLine 
[13980]1Index: ../trunk-jpl/src/m/geometry/FlagElements.py
2===================================================================
3--- ../trunk-jpl/src/m/geometry/FlagElements.py (revision 13469)
4+++ ../trunk-jpl/src/m/geometry/FlagElements.py (revision 13470)
5@@ -40,13 +40,13 @@
6 if not os.path.exists(region):
7 if len(region)>3 and not strcmp(region[-4:],'.exp'):
8 raise IOError("Error: File 'region' not found!" % region)
9- raise RuntimeError("FlagElements -- basinzoom not yet converted.")
10+ raise RuntimeError("FlagElements.py calling basinzoom.py is not complete.")
11 xlim,ylim=basinzoom('basin',region)
12 flag_nodes=numpy.logical_and(numpy.logical_and(md.mesh.x<xlim[1],md.mesh.x>xlim[0]),numpy.logical_and(md.mesh.y<ylim[1],md.mesh.y>ylim[0])).astype(float)
13 flag=numpy.prod(flag_nodes[md.mesh.elements],axis=1)
14 else:
15 #ok, flag elements
16- [flag,fnone]=ContourToMesh(md.mesh.elements[:,0:3],md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),region,'element',1)
17+ [flag,dum]=ContourToMesh(md.mesh.elements[:,0:3],md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),region,'element',1)
18
19 if invert:
20 flag=numpy.logical_not(flag)
21Index: ../trunk-jpl/src/m/mesh/bamg.py
22===================================================================
23--- ../trunk-jpl/src/m/mesh/bamg.py (revision 13469)
24+++ ../trunk-jpl/src/m/mesh/bamg.py (revision 13470)
25@@ -120,7 +120,7 @@
26 raise RuntimeError("one rift has all its points outside of the domain outline")
27
28 elif numpy.any(numpy.logical_not(flags)):
29- raise RuntimeError("bamg.m for rifts is not complete.")
30+ raise RuntimeError("bamg.py for rifts is not complete.")
31 #We LOTS of work to do
32 print("Rift tip outside of or on the domain has been detected and is being processed...")
33 """
34@@ -346,7 +346,7 @@
35
36 def processgeometry(geom,tol,outline): # {{{
37
38- raise RuntimeError("bamg.m/processgeometry is not complete.")
39+ raise RuntimeError("bamg.py/processgeometry is not complete.")
40 #Deal with edges
41 print("Checking Edge crossing...")
42 i=0
43Index: ../trunk-jpl/src/m/classes/model/model.py
44===================================================================
45--- ../trunk-jpl/src/m/classes/model/model.py (revision 13469)
46+++ ../trunk-jpl/src/m/classes/model/model.py (revision 13470)
47@@ -166,6 +166,7 @@
48 def checkmessage(self,string): # {{{
49 print ("model not consistent: %s" % string)
50 self.private.isconsistent=False
51+ return self
52 # }}}
53
54 def extrude(md,*args): # {{{
55Index: ../trunk-jpl/src/m/boundaryconditions/SetMarineIceSheetBC.m
56===================================================================
57--- ../trunk-jpl/src/m/boundaryconditions/SetMarineIceSheetBC.m (revision 13469)
58+++ ../trunk-jpl/src/m/boundaryconditions/SetMarineIceSheetBC.m (revision 13470)
59@@ -52,7 +52,7 @@
60 end
61
62 md.hydrology.spcwatercolumn=zeros(md.mesh.numberofvertices,2);
63-pos=find(md.mesh.vertexonboundary);
64+pos=find(md.mesh.vertexonboundary);
65 md.hydrology.spcwatercolumn(pos,1)=1;
66
67 %segment on Neumann (Ice Front)
68@@ -100,7 +100,7 @@
69 pos=find(md.mesh.vertexonsurface); md.thermal.spctemperature(pos)=md.initialization.temperature(pos); %impose observed temperature on surface
70 if (length(md.basalforcings.geothermalflux)~=md.mesh.numberofvertices),
71 md.basalforcings.geothermalflux=zeros(md.mesh.numberofvertices,1);
72- md.basalforcings.geothermalflux(find(md.mask.vertexongroundedice))=50*10^-3; %50mW/m2
73+ md.basalforcings.geothermalflux(find(md.mask.vertexongroundedice))=50.*10.^-3; %50mW/m2
74 end
75 else
76 disp(' no thermal boundary conditions created: no observed temperature found');
77Index: ../trunk-jpl/src/m/boundaryconditions/SetIceShelfBC.py
78===================================================================
79--- ../trunk-jpl/src/m/boundaryconditions/SetIceShelfBC.py (revision 13469)
80+++ ../trunk-jpl/src/m/boundaryconditions/SetIceShelfBC.py (revision 13470)
81@@ -25,32 +25,32 @@
82 if not os.path.exists(icefrontfile):
83 raise IOError("SetIceShelfBC error message: ice front file '%s' not found." % icefrontfile)
84 [nodeinsideicefront,dum]=ContourToMesh(md.mesh.elements,md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),icefrontfile,'node',2)
85- nodeonicefront=numpy.logical_and(md.mesh.vertexonboundary,nodeinsideicefront).astype(float)
86+ nodeonicefront=numpy.logical_and(md.mesh.vertexonboundary,nodeinsideicefront.reshape(-1)).astype(float)
87 else:
88- nodeonicefront=numpy.zeros((md.mesh.numberofvertices,1))
89+ nodeonicefront=numpy.zeros((md.mesh.numberofvertices))
90
91 # pos=find(md.mesh.vertexonboundary & ~nodeonicefront);
92- pos=[i for i,(vob,noif) in enumerate(zip(md.mesh.vertexonboundary,nodeonicefront)) if vob and not noif]
93- md.diagnostic.spcvx=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
94- md.diagnostic.spcvy=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
95- md.diagnostic.spcvz=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
96+ pos=numpy.nonzero(numpy.logical_and(md.mesh.vertexonboundary,numpy.logical_not(nodeonicefront)))[0]
97+ md.diagnostic.spcvx=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
98+ md.diagnostic.spcvy=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
99+ md.diagnostic.spcvz=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
100 md.diagnostic.spcvx[pos]=0
101 md.diagnostic.spcvy[pos]=0
102 md.diagnostic.spcvz[pos]=0
103- md.diagnostic.referential=float('NaN')*numpy.ones((md.mesh.numberofvertices,6))
104+ md.diagnostic.referential=float('nan')*numpy.ones((md.mesh.numberofvertices,6))
105
106 #Dirichlet Values
107 if isinstance(md.inversion.vx_obs,numpy.ndarray) and numpy.size(md.inversion.vx_obs,axis=0)==md.mesh.numberofvertices and isinstance(md.inversion.vy_obs,numpy.ndarray) and numpy.size(md.inversion.vy_obs,axis=0)==md.mesh.numberofvertices:
108- print ' boundary conditions for diagnostic model: spc set as observed velocities'
109+ print " boundary conditions for diagnostic model: spc set as observed velocities"
110 md.diagnostic.spcvx[pos]=md.inversion.vx_obs[pos]
111 md.diagnostic.spcvy[pos]=md.inversion.vy_obs[pos]
112 else:
113- print ' boundary conditions for diagnostic model: spc set as zero'
114+ print " boundary conditions for diagnostic model: spc set as zero"
115
116 #segment on Ice Front
117 #segment on Neumann (Ice Front)
118 # pos=find(nodeonicefront(md.mesh.segments(:,1)) | nodeonicefront(md.mesh.segments(:,2)));
119- pos=[i for i,(noif1,noif2) in enumerate(zip(nodeonicefront[md.mesh.segments[:,0].astype('int')-1],nodeonicefront[md.mesh.segments[:,1].astype('int')-1])) if noif1 or noif2]
120+ pos=numpy.nonzero(numpy.logical_or(nodeonicefront[md.mesh.segments[:,0].astype(int)-1],nodeonicefront[md.mesh.segments[:,1].astype(int)-1]))[0]
121 if md.mesh.dimension==2:
122 pressureload=md.mesh.segments[pos,:]
123 elif md.mesh.dimension==3:
124@@ -59,11 +59,11 @@
125 pressureload=numpy.zeros((0,5))
126 for i in xrange(1,md.mesh.numberoflayers):
127 # pressureload=[pressureload ;pressureload_layer1(:,1:4)+(i-1)*md.mesh.numberofvertices2d pressureload_layer1(:,5)+(i-1)*md.mesh.numberofelements2d ];
128- pressureload=numpy.vstack((pressureload,numpy.hstack((pressureload_layer1[:,0:3]+(i-1)*md.mesh.numberofvertices2d,pressureload_layer1[:,4]+(i-1)*md.mesh.numberofelements2d))))
129+ pressureload=numpy.vstack((pressureload,numpy.hstack((pressureload_layer1[:,0:4]+(i-1)*md.mesh.numberofvertices2d,pressureload_layer1[:,4]+(i-1)*md.mesh.numberofelements2d))))
130
131 #Add water or air enum depending on the element
132 # pressureload=[pressureload 1*md.mask.elementonfloatingice(pressureload(:,end))];
133- pressureload=numpy.hstack((pressureload,1*md.mask.elementonfloatingice[pressureload[:,-1].astype('int')-1].reshape((-1,1))))
134+ pressureload=numpy.hstack((pressureload,1.*md.mask.elementonfloatingice[pressureload[:,-1].astype('int')-1].reshape(-1,1)))
135
136 #plug onto model
137 md.diagnostic.icefront=pressureload
138@@ -71,29 +71,29 @@
139 #Create zeros basalforcings and surfaceforcings
140 if numpy.all(numpy.isnan(md.surfaceforcings.precipitation)) and (md.surfaceforcings.ispdd==1):
141 md.surfaceforcings.precipitation=numpy.zeros((md.mesh.numberofvertices,1))
142- print ' no surfaceforcings.precipitation specified: values set as zero'
143+ print " no surfaceforcings.precipitation specified: values set as zero"
144 if numpy.all(numpy.isnan(md.surfaceforcings.mass_balance)) and (md.surfaceforcings.ispdd==0):
145 md.surfaceforcings.mass_balance=numpy.zeros((md.mesh.numberofvertices,1))
146- print ' no surfaceforcings.mass_balance specified: values set as zero'
147+ print " no surfaceforcings.mass_balance specified: values set as zero"
148 if numpy.all(numpy.isnan(md.basalforcings.melting_rate)):
149 md.basalforcings.melting_rate=numpy.zeros((md.mesh.numberofvertices,1))
150- print ' no basalforcings.melting_rate specified: values set as zero'
151+ print " no basalforcings.melting_rate specified: values set as zero"
152 if numpy.all(numpy.isnan(md.balancethickness.thickening_rate)):
153 md.balancethickness.thickening_rate=numpy.zeros((md.mesh.numberofvertices,1))
154- print ' no balancethickness.thickening_rate specified: values set as zero'
155+ print " no balancethickness.thickening_rate specified: values set as zero"
156
157- md.prognostic.spcthickness=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
158- md.balancethickness.spcthickness=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
159+ md.prognostic.spcthickness=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
160+ md.balancethickness.spcthickness=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
161
162- if numpy.size(md.initialization.temperature)==md.mesh.numberofvertices:
163- md.thermal.spctemperature=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
164+ if isinstance(md.initialization.temperature,numpy.ndarray) and numpy.size(md.initialization.temperature,axis=0)==md.mesh.numberofvertices:
165+ md.thermal.spctemperature=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
166 # pos=find(md.mesh.vertexonsurface); md.thermal.spctemperature(pos)=md.initialization.temperature(pos); %impose observed temperature on surface
167- pos=[i for i,vos in enumerate(md.mesh.vertexonsurface) if vos]
168- md.thermal.spctemperature[pos]=md.initialization.temperature[pos] # impose observed temperature on surface
169- if not numpy.size(md.basalforcings.geothermalflux)==md.mesh.numberofvertices:
170+ pos=numpy.nonzero(md.mesh.vertexonsurface)[0]
171+ md.thermal.spctemperature[pos]=md.initialization.temperature[pos] #impose observed temperature on surface
172+ if not isinstance(md.basalforcings.geothermalflux,numpy.ndarray) or not numpy.size(md.basalforcings.geothermalflux,axis=0)==md.mesh.numberofvertices:
173 md.basalforcings.geothermalflux=numpy.zeros((md.mesh.numberofvertices,1))
174 else:
175- print ' no thermal boundary conditions created: no observed temperature found'
176+ print " no thermal boundary conditions created: no observed temperature found"
177
178 return md
179
180Index: ../trunk-jpl/src/m/boundaryconditions/SetMarineIceSheetBC.py
181===================================================================
182--- ../trunk-jpl/src/m/boundaryconditions/SetMarineIceSheetBC.py (revision 0)
183+++ ../trunk-jpl/src/m/boundaryconditions/SetMarineIceSheetBC.py (revision 13470)
184@@ -0,0 +1,111 @@
185+import os
186+import numpy
187+from ContourToMesh import *
188+
189+def SetMarineIceSheetBC(md,icefrontfile=''):
190+ """
191+ SETICEMARINESHEETBC - Create the boundary conditions for diagnostic and thermal models for a Marine Ice Sheet with Ice Front
192+
193+ Neumann BC are used on the ice front (an ARGUS contour around the ice front
194+ can be given in input, or it will be deduced as onfloatingice & onboundary)
195+ Dirichlet BC are used elsewhere for diagnostic
196+
197+ Usage:
198+ md=SetMarineIceSheetBC(md,icefrontfile)
199+ md=SetMarineIceSheetBC(md)
200+
201+ Example:
202+ md=SetMarineIceSheetBC(md,'Front.exp')
203+ md=SetMarineIceSheetBC(md)
204+
205+ See also: SETICESHELFBC, SETMARINEICESHEETBC
206+ """
207+
208+ #node on Dirichlet (boundary and ~icefront)
209+ if icefrontfile:
210+ #User provided Front.exp, use it
211+ if not os.path.exists(icefrontfile):
212+ raise IOError("SetMarineIceSheetBC error message: ice front file '%s' not found." % icefrontfile)
213+ [nodeinsideicefront,dum]=ContourToMesh(md.mesh.elements,md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),icefrontfile,'node',2)
214+ vertexonicefront=numpy.logical_and(md.mesh.vertexonboundary,nodeinsideicefront.reshape(-1)).astype(float)
215+ else:
216+ #Guess where the ice front is
217+ vertexonfloatingice=numpy.zeros((md.mesh.numberofvertices))
218+ vertexonfloatingice[md.mesh.elements[numpy.nonzero(md.mask.elementonfloatingice),:].astype(int)-1]=1
219+ vertexonicefront=numpy.logical_and(md.mesh.vertexonboundary,vertexonfloatingice).astype(float)
220+
221+# pos=find(md.mesh.vertexonboundary & ~vertexonicefront);
222+ pos=numpy.nonzero(numpy.logical_and(md.mesh.vertexonboundary,numpy.logical_not(vertexonicefront)))[0]
223+ if not numpy.size(pos):
224+ print("SetMarineIceSheetBC warning: ice front all around the glacier, no dirichlet found. Dirichlet must be added manually.")
225+
226+ md.diagnostic.spcvx=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
227+ md.diagnostic.spcvy=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
228+ md.diagnostic.spcvz=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
229+ md.diagnostic.spcvx[pos]=0
230+ md.diagnostic.spcvy[pos]=0
231+ md.diagnostic.spcvz[pos]=0
232+ md.diagnostic.referential=float('nan')*numpy.ones((md.mesh.numberofvertices,6))
233+
234+ #Dirichlet Values
235+ if isinstance(md.inversion.vx_obs,numpy.ndarray) and numpy.size(md.inversion.vx_obs,axis=0)==md.mesh.numberofvertices and isinstance(md.inversion.vy_obs,numpy.ndarray) and numpy.size(md.inversion.vy_obs,axis=0)==md.mesh.numberofvertices:
236+ print(" boundary conditions for diagnostic model: spc set as observed velocities")
237+ md.diagnostic.spcvx[pos]=md.inversion.vx_obs[pos]
238+ md.diagnostic.spcvy[pos]=md.inversion.vy_obs[pos]
239+ else:
240+ print(" boundary conditions for diagnostic model: spc set as zero")
241+
242+ md.hydrology.spcwatercolumn=numpy.zeros((md.mesh.numberofvertices,2))
243+ pos=numpy.nonzero(md.mesh.vertexonboundary)[0]
244+ md.hydrology.spcwatercolumn[pos,0]=1
245+
246+ #segment on Neumann (Ice Front)
247+# pos=find(vertexonicefront(md.mesh.segments(:,1)) | vertexonicefront(md.mesh.segments(:,2)));
248+ pos=numpy.nonzero(numpy.logical_or(vertexonicefront[md.mesh.segments[:,0].astype(int)-1],vertexonicefront[md.mesh.segments[:,1].astype(int)-1]))[0]
249+ if md.mesh.dimension==2:
250+ pressureload=md.mesh.segments[pos,:]
251+ elif md.mesh.dimension==3:
252+# pressureload_layer1=[md.mesh.segments(pos,1:2) md.mesh.segments(pos,2)+md.mesh.numberofvertices2d md.mesh.segments(pos,1)+md.mesh.numberofvertices2d md.mesh.segments(pos,3)];
253+ pressureload_layer1=numpy.hstack((md.mesh.segments[pos,0:2],md.mesh.segments[pos,1]+md.mesh.numberofvertices2d,md.mesh.segments[pos,0]+md.mesh.numberofvertices2d,md.mesh.segments[pos,2]))
254+ pressureload=numpy.zeros((0,5))
255+ for i in xrange(1,md.mesh.numberoflayers):
256+# pressureload=[pressureload ;pressureload_layer1(:,1:4)+(i-1)*md.mesh.numberofvertices2d pressureload_layer1(:,5)+(i-1)*md.mesh.numberofelements2d ];
257+ pressureload=numpy.vstack((pressureload,numpy.hstack((pressureload_layer1[:,0:4]+(i-1)*md.mesh.numberofvertices2d,pressureload_layer1[:,4]+(i-1)*md.mesh.numberofelements2d))))
258+
259+ #Add water or air enum depending on the element
260+# pressureload=[pressureload 1*md.mask.elementonfloatingice(pressureload(:,end))+ 0*md.mask.elementongroundedice(pressureload(:,end))];
261+ pressureload=numpy.hstack((pressureload,1.*md.mask.elementonfloatingice[pressureload[:,-1].astype('int')-1].reshape(-1,1)+0.*md.mask.elementongroundedice[pressureload[:,-1].astype('int')-1].reshape(-1,1)))
262+
263+ #plug onto model
264+ md.diagnostic.icefront=pressureload
265+
266+ #Create zeros basalforcings and surfaceforcings
267+ if numpy.all(numpy.isnan(md.surfaceforcings.precipitation)) and (md.surfaceforcings.ispdd==1):
268+ md.surfaceforcings.precipitation=numpy.zeros((md.mesh.numberofvertices,1))
269+ print(" no surfaceforcings.precipitation specified: values set as zero")
270+ if numpy.all(numpy.isnan(md.surfaceforcings.mass_balance)) and (md.surfaceforcings.ispdd==0):
271+ md.surfaceforcings.mass_balance=numpy.zeros((md.mesh.numberofvertices,1))
272+ print(" no surfaceforcings.mass_balance specified: values set as zero")
273+ if numpy.all(numpy.isnan(md.basalforcings.melting_rate)):
274+ md.basalforcings.melting_rate=numpy.zeros((md.mesh.numberofvertices,1))
275+ print(" no basalforcings.melting_rate specified: values set as zero")
276+ if numpy.all(numpy.isnan(md.balancethickness.thickening_rate)):
277+ md.balancethickness.thickening_rate=numpy.zeros((md.mesh.numberofvertices,1))
278+ print(" no balancethickness.thickening_rate specified: values set as zero")
279+
280+ md.prognostic.spcthickness=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
281+ md.balancethickness.spcthickness=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
282+
283+ if isinstance(md.initialization.temperature,numpy.ndarray) and numpy.size(md.initialization.temperature,axis=0)==md.mesh.numberofvertices:
284+ md.thermal.spctemperature=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
285+# pos=find(md.mesh.vertexonsurface); md.thermal.spctemperature(pos)=md.initialization.temperature(pos); %impose observed temperature on surface
286+ pos=numpy.nonzero(md.mesh.vertexonsurface)[0]
287+ md.thermal.spctemperature[pos]=md.initialization.temperature[pos] #impose observed temperature on surface
288+ if not isinstance(md.basalforcings.geothermalflux,numpy.ndarray) or not numpy.size(md.basalforcings.geothermalflux,axis=0)==md.mesh.numberofvertices:
289+ md.basalforcings.geothermalflux=numpy.zeros((md.mesh.numberofvertices,1))
290+ md.basalforcings.geothermalflux[numpy.nonzero(md.mask.vertexongroundedice)]=50.*10.**-3; #50mW/m2
291+ else:
292+ print(" no thermal boundary conditions created: no observed temperature found");
293+
294+ return md
295+
Note: See TracBrowser for help on using the repository browser.