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

Last change on this file since 19105 was 19105, checked in by Mathieu Morlighem, 10 years ago

merged trunk-jpl and trunk for revision 19103

File size: 2.6 KB
RevLine 
[17078]1from fielddisplay import fielddisplay
2from EnumDefinitions import *
[17497]3from checkfield import checkfield
4from WriteData import WriteData
5from project3d import project3d
[17078]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 #}}}
[17079]32 def extrude(self,md): # {{{
33
34 #Nothing for now
35 return self
36 #}}}
[17078]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:
[19105]46 md = checkfield(md,'fieldname','surfaceforcings.href','timeseries',1,'NaN',1)
47 md = checkfield(md,'fieldname','surfaceforcings.smbref','timeseries',1,'NaN',1)
48 md = checkfield(md,'fieldname','surfaceforcings.b_pos','timeseries',1,'NaN',1)
49 md = checkfield(md,'fieldname','surfaceforcings.b_neg','timeseries',1,'NaN',1)
[17078]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');
[19105]58 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','href','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1)
59 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','smbref','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1)
60 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','b_pos','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1)
61 WriteData(fid,'object',self,'class','surfaceforcings','fieldname','b_neg','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1)
[17078]62 # }}}
Note: See TracBrowser for help on using the repository browser.