source: issm/trunk/src/m/classes/SMBgradients.py@ 17806

Last change on this file since 17806 was 17806, checked in by Mathieu Morlighem, 11 years ago

merged trunk-jpl and trunk for revision 17804

File size: 2.6 KB
Line 
1from fielddisplay import fielddisplay
2from EnumDefinitions import *
3from checkfield import checkfield
4from WriteData import WriteData
5from project3d import project3d
6
7class SMBgradients(object):
8 """
9 SMBgradients Class definition
10
11 Usage:
12 SMBgradients=SMBgradients();
13 """
14
15 def __init__(self): # {{{
16 self.href = float('NaN')
17 self.smbref = float('NaN')
18 self.b_pos = float('NaN')
19 self.b_neg = float('NaN')
20 #}}}
21 def __repr__(self): # {{{
22 string=" surface forcings parameters:"
23
24 string="%s\n%s"%(string,fielddisplay(self,'issmbgradients','is smb gradients method activated (0 or 1, default is 0)'))
25 string="%s\n%s"%(string,fielddisplay(self,'href',' reference elevation from which deviation is used to calculate SMB adjustment in smb gradients method'))
26 string="%s\n%s"%(string,fielddisplay(self,'smbref',' reference smb from which deviation is calculated in smb gradients method'))
27 string="%s\n%s"%(string,fielddisplay(self,'b_pos',' slope of hs - smb regression line for accumulation regime required if smb gradients is activated'))
28 string="%s\n%s"%(string,fielddisplay(self,'b_neg',' slope of hs - smb regression line for ablation regime required if smb gradients is activated'))
29
30 return string
31 #}}}
32 def extrude(self,md): # {{{
33
34 #Nothing for now
35 return self
36 #}}}
37 def initialize(self,md): # {{{
38
39 #Nothing for now
40
41 return self
42 #}}}
43 def checkconsistency(self,md,solution,analyses): # {{{
44
45 if MasstransportAnalysisEnum() in analyses:
46 md = checkfield(md,'fieldname','surfaceforcings.href','forcing',1,'NaN',1)
47 md = checkfield(md,'fieldname','surfaceforcings.smbref','forcing',1,'NaN',1)
48 md = checkfield(md,'fieldname','surfaceforcings.b_pos','forcing',1,'NaN',1)
49 md = checkfield(md,'fieldname','surfaceforcings.b_neg','forcing',1,'NaN',1)
50
51 return md
52 # }}}
53 def marshall(self,md,fid): # {{{
54
55 yts=365.0*24.0*3600.0
56
57 WriteData(fid,'enum',SurfaceforcingsEnum(),'data',SMBgradientsEnum(),'format','Integer');
58 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','href','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1)
59 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','smbref','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1)
60 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','b_pos','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1)
61 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','b_neg','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1)
62 # }}}
Note: See TracBrowser for help on using the repository browser.