[25688] | 1 | import numpy as np
|
---|
| 2 |
|
---|
| 3 | from checkfield import checkfield
|
---|
[19707] | 4 | from fielddisplay import fielddisplay
|
---|
[21271] | 5 | from project3d import project3d
|
---|
[19707] | 6 | from WriteData import WriteData
|
---|
| 7 |
|
---|
[24213] | 8 |
|
---|
[19707] | 9 | class mismipbasalforcings(object):
|
---|
[25688] | 10 | """MISMIP Basal Forcings class definition
|
---|
[19707] | 11 |
|
---|
[24213] | 12 | Usage:
|
---|
[25688] | 13 | mismipbasalforcings = mismipbasalforcings()
|
---|
[24213] | 14 | """
|
---|
[19707] | 15 |
|
---|
[24213] | 16 | def __init__(self): # {{{
|
---|
[25688] | 17 | self.groundedice_melting_rate = np.nan
|
---|
[25775] | 18 | self.meltrate_factor = np.nan
|
---|
| 19 | self.threshold_thickness = 0.
|
---|
| 20 | self.upperdepth_melt = 0.
|
---|
| 21 | self.geothermalflux = np.nan
|
---|
[24213] | 22 | self.setdefaultparameters()
|
---|
| 23 | #}}}
|
---|
| 24 | def __repr__(self): # {{{
|
---|
[25688] | 25 | s = ' MISMIP + basal melt parameterization\n'
|
---|
| 26 | s += '{}\n'.format(fielddisplay(self, "groundedice_melting_rate", "basal melting rate (positive if melting) [m / yr]"))
|
---|
| 27 | s += '{}\n'.format(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)"))
|
---|
| 28 | s += '{}\n'.format(fielddisplay(self, "threshold_thickness", "Threshold thickness for saturation of basal melting [m]"))
|
---|
| 29 | s += '{}\n'.format(fielddisplay(self, "upperdepth_melt", "Depth above which melt rate is zero [m]"))
|
---|
| 30 | s += '{}\n'.format(fielddisplay(self, "geothermalflux", "Geothermal heat flux [W / m^2]"))
|
---|
| 31 | return s
|
---|
[24213] | 32 | #}}}
|
---|
| 33 | def extrude(self, md): # {{{
|
---|
| 34 | self.groundedice_melting_rate = project3d(md, 'vector', self.groundedice_melting_rate, 'type', 'node', 'layer', 1)
|
---|
| 35 | self.geothermalflux = project3d(md, 'vector', self.geothermalflux, 'type', 'node', 'layer', 1) #bedrock only gets geothermal flux
|
---|
| 36 | return self
|
---|
| 37 | #}}}
|
---|
| 38 | def initialize(self, md): # {{{
|
---|
| 39 | if np.all(np.isnan(self.groundedice_melting_rate)):
|
---|
| 40 | self.groundedice_melting_rate = np.zeros((md.mesh.numberofvertices))
|
---|
[25688] | 41 | print('no basalforcings.groundedice_melting_rate specified: values set as zero')
|
---|
[24213] | 42 | if np.all(np.isnan(self.geothermalflux)):
|
---|
| 43 | self.geothermalflux = np.zeros((md.mesh.numberofvertices))
|
---|
| 44 | print(" no basalforcings.geothermalflux specified: values set as zero")
|
---|
| 45 | return self
|
---|
| 46 | #}}}
|
---|
| 47 | def setdefaultparameters(self): # {{{
|
---|
| 48 | # default values for melting parameterization
|
---|
| 49 | self.meltrate_factor = 0.2
|
---|
| 50 | self.threshold_thickness = 75.
|
---|
[24261] | 51 | self.upperdepth_melt = -100.
|
---|
[24213] | 52 | return self
|
---|
| 53 | #}}}
|
---|
| 54 | def checkconsistency(self, md, solution, analyses): # {{{
|
---|
[25688] | 55 | # Early return
|
---|
| 56 | if 'MasstransportAnalysis' in analyses and not solution == 'TransientSolution' and not md.transient.ismasstransport:
|
---|
[24213] | 57 | md = checkfield(md, 'fieldname', 'basalforcings.groundedice_melting_rate', 'NaN', 1, 'Inf', 1, 'timeseries', 1)
|
---|
| 58 | md = checkfield(md, 'fieldname', 'basalforcings.meltrate_factor', '>=', 0, 'numel', [1])
|
---|
| 59 | md = checkfield(md, 'fieldname', 'basalforcings.threshold_thickness', '>=', 0, 'numel', [1])
|
---|
| 60 | md = checkfield(md, 'fieldname', 'basalforcings.upperdepth_melt', '<=', 0, 'numel', [1])
|
---|
| 61 | if 'BalancethicknessAnalysis' in analyses:
|
---|
| 62 | md = checkfield(md, 'fieldname', 'basalforcings.groundedice_melting_rate', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices])
|
---|
| 63 | md = checkfield(md, 'fieldname', 'basalforcings.meltrate_factor', '>=', 0, 'numel', [1])
|
---|
| 64 | md = checkfield(md, 'fieldname', 'basalforcings.threshold_thickness', '>=', 0, 'numel', [1])
|
---|
| 65 | md = checkfield(md, 'fieldname', 'basalforcings.upperdepth_melt', '<=', 0, 'numel', [1])
|
---|
[25688] | 66 | if 'ThermalAnalysis' in analyses and not (solution == 'TransientSolution' and not md.transient.isthermal):
|
---|
[24213] | 67 | md = checkfield(md, 'fieldname', 'basalforcings.groundedice_melting_rate', 'NaN', 1, 'Inf', 1, 'timeseries', 1)
|
---|
| 68 | md = checkfield(md, 'fieldname', 'basalforcings.meltrate_factor', '>=', 0, 'numel', [1])
|
---|
| 69 | md = checkfield(md, 'fieldname', 'basalforcings.threshold_thickness', '>=', 0, 'numel', [1])
|
---|
| 70 | md = checkfield(md, 'fieldname', 'basalforcings.upperdepth_melt', '<=', 0, 'numel', [1])
|
---|
| 71 | md = checkfield(md, 'fieldname', 'basalforcings.geothermalflux', 'NaN', 1, 'Inf', 1, 'timeseries', 1, '>=', 0)
|
---|
| 72 | return md
|
---|
[19707] | 73 | # }}}
|
---|
[24213] | 74 | def marshall(self, prefix, md, fid): # {{{
|
---|
| 75 | yts = md.constants.yts
|
---|
| 76 | if yts != 365.2422 * 24. * 3600.:
|
---|
| 77 | print('WARNING: value of yts for MISMIP + runs different from ISSM default!')
|
---|
| 78 | WriteData(fid, prefix, 'name', 'md.basalforcings.model', 'data', 3, 'format', 'Integer')
|
---|
| 79 | 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', yts)
|
---|
| 80 | WriteData(fid, prefix, 'object', self, 'fieldname', 'geothermalflux', 'name', 'md.basalforcings.geothermalflux', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)
|
---|
| 81 | WriteData(fid, prefix, 'object', self, 'fieldname', 'meltrate_factor', 'format', 'Double', 'scale', 1. / yts)
|
---|
| 82 | WriteData(fid, prefix, 'object', self, 'fieldname', 'threshold_thickness', 'format', 'Double')
|
---|
| 83 | WriteData(fid, prefix, 'object', self, 'fieldname', 'upperdepth_melt', 'format', 'Double')
|
---|
| 84 | # }}}
|
---|