source: issm/trunk-jpl/src/m/classes/mismipbasalforcings.py@ 21049

Last change on this file since 21049 was 21049, checked in by agscott1, 9 years ago

CHG: Replaced Enums with Strings in matlab and python. Updated corresponding cpp code.

File size: 5.2 KB
Line 
1from fielddisplay import fielddisplay
2from checkfield import checkfield
3from WriteData import WriteData
4import numpy
5
6class mismipbasalforcings(object):
7 """
8 MISMIP Basal Forcings class definition
9
10 Usage:
11 mismipbasalforcings=mismipbasalforcings()
12 """
13
14 def __init__(self,md): # {{{
15
16 self.groundedice_melting_rate = float('NaN')
17 self.meltrate_factor = float('NaN')
18 self.threshold_thickness = float('NaN')
19 self.upperdepth_melt = float('NaN')
20 self.geothermalflux = float('NaN')
21
22 if numpy.all(numpy.isnan(self.groundedice_melting_rate)):
23 self.groundedice_melting_rate=numpy.zeros(md.mesh.numberofvertices)
24 print ' no basalforcings.groundedice_melting_rate specified: values set as zero'
25
26 self.setdefaultparameters()
27
28 #}}}
29 def __repr__(self): # {{{
30 string=" MISMIP+ basal melt parameterization\n"
31 string="%s\n%s"%(string,fielddisplay(self,"groundedice_melting_rate","basal melting rate (positive if melting) [m/yr]"))
32 string="%s\n%s"%(string,fielddisplay(self,"meltrate_factor","Melt-rate rate factor [1/yr] (sign is opposite to MISMIP+ benchmark to remain consistent with ISSM convention of positive values for melting)"))
33 string="%s\n%s"%(string,fielddisplay(self,"threshold_thickness","Threshold thickness for saturation of basal melting [m]"))
34 string="%s\n%s"%(string,fielddisplay(self,"upperdepth_melt","Depth above which melt rate is zero [m]"))
35 string="%s\n%s"%(string,fielddisplay(self,"geothermalflux","Geothermal heat flux [W/m^2]"))
36
37 return string
38 #}}}
39 def extrude(self,md): # {{{
40 self.groundedice_melting_rate=project3d(md,'vector',self.groundedice_melting_rate,'type','node','layer',1)
41 self.geothermalflux=project3d(md,'vector',self.geothermalflux,'type','node','layer',1) #bedrock only gets geothermal flux
42 return self
43 #}}}
44 def setdefaultparameters(self): # {{{
45
46 # default values for melting parameterization
47 self.meltrate_factor = 0.2
48 self.threshold_thickness = 75.
49 self.upperdepth_melt = -100.
50
51 return self
52 #}}}
53 def checkconsistency(self,md,solution,analyses): # {{{
54
55 #Early return
56 if 'MasstransportAnalysis' in analyses and not (solution=='TransientSolution' and md.transient.ismasstransport==0):
57
58 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'Inf',1,'timeseries',1)
59 md = checkfield(md,'fieldname','basalforcings.meltrate_factor','>=',0,'numel',[1])
60 md = checkfield(md,'fieldname','basalforcings.threshold_thickness','>=',0,'numel',[1])
61 md = checkfield(md,'fieldname','basalforcings.upperdepth_melt','<=',0,'numel',[1])
62
63 if 'BalancethicknessAnalysis' in analyses:
64
65 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
66 md = checkfield(md,'fieldname','basalforcings.meltrate_factor','>=',0,'numel',[1])
67 md = checkfield(md,'fieldname','basalforcings.threshold_thickness','>=',0,'numel',[1])
68 md = checkfield(md,'fieldname','basalforcings.upperdepth_melt','<=',0,'numel',[1])
69
70 if 'ThermalAnalysis' in analyses and not (solution=='TransientSolution' and md.transient.isthermal==0):
71
72 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'Inf',1,'timeseries',1)
73 md = checkfield(md,'fieldname','basalforcings.meltrate_factor','>=',0,'numel',[1])
74 md = checkfield(md,'fieldname','basalforcings.threshold_thickness','>=',0,'numel',[1])
75 md = checkfield(md,'fieldname','basalforcings.upperdepth_melt','<=',0,'numel',[1])
76 md = checkfield(md,'fieldname','basalforcings.geothermalflux','NaN',1,'Inf',1,'timeseries',1,'>=',0)
77 return md
78 # }}}
79 def marshall(self,prefix,md,fid): # {{{
80
81 yts=md.constants.yts
82 if yts!=365.2422*24.*3600.:
83 print 'WARNING: value of yts for MISMIP+ runs different from ISSM default!'
84
85 floatingice_melting_rate = numpy.zeros((md.mesh.numberofvertices,1))
86 floatingice_melting_rate = md.basalforcings.meltrate_factor*numpy.tanh((md.geometry.base-md.geometry.bed)/md.basalforcings.threshold_thickness)*numpy.amax(md.basalforcings.upperdepth_melt-md.geometry.base,0)
87
88 WriteData(fid,prefix,'name','md.basalforcings.model','data',3,'format','Integer')
89 WriteData(fid,prefix,'data',floatingice_melting_rate,'format','DoubleMat','name','md.basalforcings.floatingice_melting_rate','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
90 WriteData(fid,prefix,'object',self,'fieldname','groundedice_melting_rate','format','DoubleMat','name','md.basalforcings.groundedice_melting_rate','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
91 WriteData(fid,prefix,'object',self,'fieldname','geothermalflux','name','md.basalforcings.geothermalflux','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
92 WriteData(fid,prefix,'object',self,'fieldname','meltrate_factor','format','Double','scale',1./yts)
93 WriteData(fid,prefix,'object',self,'fieldname','threshold_thickness','format','Double')
94 WriteData(fid,prefix,'object',self,'fieldname','upperdepth_melt','format','Double')
95
96 # }}}
Note: See TracBrowser for help on using the repository browser.