source: issm/trunk-jpl/src/m/classes/mask.py@ 16764

Last change on this file since 16764 was 16764, checked in by Eric.Larour, 11 years ago

CHG: checkfield could not run for massatfluggate or misfit classes, because these classes do not
have access to their own fields through the model! So we modified checkfield.m and checkfield.py to accept
either directly a field, or indirectly a fieldname which then is used to retrieve from the model.

File size: 1.5 KB
RevLine 
[12038]1from fielddisplay import fielddisplay
[12949]2from EnumDefinitions import *
3from checkfield import *
4from WriteData import *
[12038]5
[12958]6class mask(object):
7 """
8 MASK class definition
9
10 Usage:
11 mask=mask();
12 """
13
[14640]14 def __init__(self): # {{{
[15961]15 self.ice_levelset = float('NaN')
16 self.groundedice_levelset = float('NaN')
[12123]17
18 #set defaults
19 self.setdefaultparameters()
20
[12038]21 #}}}
[14640]22 def __repr__(self): # {{{
[14141]23 string=" masks:"
[12038]24
[15942]25 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"))
26 string="%s\n%s"%(string,fielddisplay(self,"ice_levelset","presence of ice if > 0, icefront position if = 0, no ice if < 0"))
[12038]27 return string
28 #}}}
[14640]29 def setdefaultparameters(self): # {{{
[12958]30 return self
[12123]31 #}}}
[12949]32 def checkconsistency(self,md,solution,analyses): # {{{
33
[16764]34 md = checkfield(md,'fieldname','mask.ice_levelset' ,'size',[md.mesh.numberofvertices])
[15943]35 isice=numpy.array(md.mask.ice_levelset>0,int)
[15600]36 totallyicefree=(numpy.sum(isice[md.mesh.elements-1],axis=1)==0).astype(int)
37 if any(totallyicefree):
[15943]38 raise TypeError("elements with no ice not implemented yet, each element should have at least one vertex with md.mask.ice_levelset > 0")
[12949]39
40 return md
41 # }}}
[15131]42 def marshall(self,md,fid): # {{{
[15942]43 WriteData(fid,'object',self,'fieldname','groundedice_levelset','format','DoubleMat','mattype',1)
44 WriteData(fid,'object',self,'fieldname','ice_levelset','format','DoubleMat','mattype',1)
[12949]45 # }}}
Note: See TracBrowser for help on using the repository browser.