source: issm/trunk-jpl/src/m/classes/SMBforcing.py@ 19527

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

CHG: moved md.surfaceforcings to md.smb.
By doing so, had to rename the SMB class to SMBforcing class (it's just that, a mass_balance forcing inside
a SMB class, hence the name).
We also now have an smb_core solution, taken out of the mass transport core. Makes more sense long term.
Synced all enums according to the new changes, and operated the adjustments in all the test decks.

In addition, progressing in terms of GEMB integration into ISSM, specifically at the SMBgemb level (which
is spurring all the changes described above). Brought the class up to the level of the GEMB.m call in Alex's
code. Starting the C integration now.

File size: 2.2 KB
Line 
1import numpy
2from fielddisplay import fielddisplay
3from EnumDefinitions import *
4from checkfield import checkfield
5from WriteData import WriteData
6from project3d import project3d
7
8class SMBforcing(object):
9 """
10 SMBforcing Class definition
11
12 Usage:
13 SMB=SMBforcing();
14 """
15
16 def __init__(self): # {{{
17 self.mass_balance = float('NaN')
18 self.requested_outputs = []
19 #}}}
20 def __repr__(self): # {{{
21 string=" surface forcings parameters:"
22 string="%s\n%s"%(string,fielddisplay(self,'mass_balance','surface mass balance [m/yr ice eq]'))
23 string="%s\n%s"%(string,fielddisplay(self,'requested_outputs','additional outputs requested'))
24 return string
25 #}}}
26 def extrude(self,md): # {{{
27
28 self.mass_balance=project3d(md,'vector',self.mass_balance,'type','node');
29 return self
30 #}}}
31 def defaultoutputs(self,md): # {{{
32 return []
33 #}}}
34 def initialize(self,md): # {{{
35
36 if numpy.all(numpy.isnan(self.mass_balance)):
37 self.mass_balance=numpy.zeros((md.mesh.numberofvertices,1))
38 print " no SMBforcing.mass_balance specified: values set as zero"
39
40 return self
41 #}}}
42 def checkconsistency(self,md,solution,analyses): # {{{
43
44 if MasstransportAnalysisEnum() in analyses:
45 md = checkfield(md,'fieldname','smb.mass_balance','timeseries',1,'NaN',1)
46
47 if BalancethicknessAnalysisEnum() in analyses:
48 md = checkfield(md,'fieldname','smb.mass_balance','size',[md.mesh.numberofvertices],'NaN',1)
49
50 md = checkfield(md,'fieldname','masstransport.requested_outputs','stringrow',1)
51 return md
52 # }}}
53 def marshall(self,md,fid): # {{{
54
55 yts=365.0*24.0*3600.0
56
57 WriteData(fid,'enum',SmbEnum(),'data',SMBforcingEnum(),'format','Integer');
58 WriteData(fid,'object',self,'class','smb','fieldname','mass_balance','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1)
59
60 #process requested outputs
61 outputs = self.requested_outputs
62 indices = [i for i, x in enumerate(outputs) if x == 'default']
63 if len(indices) > 0:
64 outputscopy=outputs[0:max(0,indices[0]-1)]+self.defaultoutputs(md)+outputs[indices[0]+1:]
65 outputs =outputscopy
66 WriteData(fid,'data',outputs,'enum',SmbRequestedOutputsEnum(),'format','StringArray')
67
68 # }}}
Note: See TracBrowser for help on using the repository browser.