[19707] | 1 | from fielddisplay import fielddisplay
|
---|
| 2 | from checkfield import checkfield
|
---|
| 3 | from WriteData import WriteData
|
---|
| 4 | import numpy
|
---|
| 5 |
|
---|
| 6 | class 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]"))
|
---|
[19713] | 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)"))
|
---|
[19707] | 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 | #}}}
|
---|
[19911] | 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
|
---|
[19707] | 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
|
---|
[21049] | 56 | if 'MasstransportAnalysis' in analyses and not (solution=='TransientSolution' and md.transient.ismasstransport==0):
|
---|
[19707] | 57 |
|
---|
[19897] | 58 | md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'Inf',1,'timeseries',1)
|
---|
[19783] | 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])
|
---|
[19707] | 62 |
|
---|
[21049] | 63 | if 'BalancethicknessAnalysis' in analyses:
|
---|
[19707] | 64 |
|
---|
[19897] | 65 | md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
|
---|
[19783] | 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])
|
---|
[19707] | 69 |
|
---|
[21049] | 70 | if 'ThermalAnalysis' in analyses and not (solution=='TransientSolution' and md.transient.isthermal==0):
|
---|
[19707] | 71 |
|
---|
[19897] | 72 | md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'Inf',1,'timeseries',1)
|
---|
[19783] | 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])
|
---|
[19897] | 76 | md = checkfield(md,'fieldname','basalforcings.geothermalflux','NaN',1,'Inf',1,'timeseries',1,'>=',0)
|
---|
[19707] | 77 | return md
|
---|
| 78 | # }}}
|
---|
[20690] | 79 | def marshall(self,prefix,md,fid): # {{{
|
---|
[19707] | 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 |
|
---|
[20916] | 88 | WriteData(fid,prefix,'name','md.basalforcings.model','data',3,'format','Integer')
|
---|
[20902] | 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)
|
---|
[20690] | 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')
|
---|
[19707] | 95 |
|
---|
| 96 | # }}}
|
---|