1 | import numpy as np
|
---|
2 |
|
---|
3 | from checkfield import checkfield
|
---|
4 | from fielddisplay import fielddisplay
|
---|
5 | from project3d import project3d
|
---|
6 | from WriteData import WriteData
|
---|
7 |
|
---|
8 |
|
---|
9 | class mismipbasalforcings(object):
|
---|
10 | """MISMIP Basal Forcings class definition
|
---|
11 |
|
---|
12 | Usage:
|
---|
13 | mismipbasalforcings = mismipbasalforcings()
|
---|
14 | """
|
---|
15 |
|
---|
16 | def __init__(self): # {{{
|
---|
17 | self.groundedice_melting_rate = np.nan
|
---|
18 | self.meltrate_factor = np.nan
|
---|
19 | self.threshold_thickness = 0.
|
---|
20 | self.upperdepth_melt = 0.
|
---|
21 | self.geothermalflux = np.nan
|
---|
22 | self.setdefaultparameters()
|
---|
23 | #}}}
|
---|
24 | def __repr__(self): # {{{
|
---|
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
|
---|
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))
|
---|
41 | print('no basalforcings.groundedice_melting_rate specified: values set as zero')
|
---|
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.
|
---|
51 | self.upperdepth_melt = -100.
|
---|
52 | return self
|
---|
53 | #}}}
|
---|
54 | def checkconsistency(self, md, solution, analyses): # {{{
|
---|
55 | # Early return
|
---|
56 | if 'MasstransportAnalysis' in analyses and not solution == 'TransientSolution' and not md.transient.ismasstransport:
|
---|
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])
|
---|
66 | if 'ThermalAnalysis' in analyses and not (solution == 'TransientSolution' and not md.transient.isthermal):
|
---|
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
|
---|
73 | # }}}
|
---|
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 | # }}}
|
---|