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

Last change on this file since 21303 was 21303, checked in by bdef, 8 years ago

CHG: major cosmetic clean up we now ask shape (N,) rather than (N,1) also uniformised numpy imports

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