source: issm/trunk/src/m/classes/mask.py@ 22758

Last change on this file since 22758 was 22758, checked in by Mathieu Morlighem, 7 years ago

merged trunk-jpl and trunk for revision 22757

File size: 1.6 KB
RevLine 
[21341]1import numpy as np
[12038]2from fielddisplay import fielddisplay
[19105]3from project3d import project3d
[17806]4from checkfield import checkfield
5from WriteData import WriteData
[20500]6import MatlabFuncs as m
[12038]7
[13395]8class mask(object):
9 """
10 MASK class definition
11
12 Usage:
13 mask=mask();
14 """
15
[15396]16 def __init__(self): # {{{
[16137]17 self.ice_levelset = float('NaN')
18 self.groundedice_levelset = float('NaN')
[12123]19
20 #set defaults
21 self.setdefaultparameters()
22
[12038]23 #}}}
[15396]24 def __repr__(self): # {{{
[14310]25 string=" masks:"
[12038]26
[16137]27 string="%s\n%s"%(string,fielddisplay(self,"groundedice_levelset","is ice grounded ? grounded ice if > 0, grounding line position if = 0, floating ice if < 0"))
[17806]28 string="%s\n%s"%(string,fielddisplay(self,"ice_levelset","presence of ice if < 0, icefront position if = 0, no ice if > 0"))
[12038]29 return string
30 #}}}
[19105]31 def extrude(self,md): # {{{
32 self.ice_levelset=project3d(md,'vector',self.ice_levelset,'type','node')
33 self.groundedice_levelset=project3d(md,'vector',self.groundedice_levelset,'type','node')
34 return self
35 #}}}
[15396]36 def setdefaultparameters(self): # {{{
[13395]37 return self
[12123]38 #}}}
[13395]39 def checkconsistency(self,md,solution,analyses): # {{{
[22758]40 if(solution=='LoveSolution'):
41 return
[13395]42
[17806]43 md = checkfield(md,'fieldname','mask.ice_levelset' ,'size',[md.mesh.numberofvertices])
[21341]44 isice=np.array(md.mask.ice_levelset<=0,int)
45 if np.sum(isice)==0:
[18301]46 raise TypeError("no ice present in the domain")
[13395]47
48 return md
49 # }}}
[21341]50 def marshall(self,prefix,md,fid): # {{{
51 WriteData(fid,prefix,'object',self,'fieldname','groundedice_levelset','format','DoubleMat','mattype',1)
52 WriteData(fid,prefix,'object',self,'fieldname','ice_levelset','format','DoubleMat','mattype',1)
[13395]53 # }}}
Note: See TracBrowser for help on using the repository browser.