[26744] | 1 | # -*- coding: utf-8 -*-
|
---|
| 2 |
|
---|
| 3 | import numpy as np
|
---|
| 4 |
|
---|
[23658] | 5 | from checkfield import checkfield
|
---|
| 6 | from WriteData import WriteData
|
---|
[24213] | 7 | from fielddisplay import fielddisplay
|
---|
[23658] | 8 |
|
---|
[24213] | 9 |
|
---|
[23658] | 10 | class frontalforcingsrignot(object):
|
---|
[26744] | 11 | """FRONTALFORCINGSRIGNOT class definition
|
---|
[23658] | 12 |
|
---|
[26744] | 13 | Usage:
|
---|
| 14 | frontalforcingsrignot = frontalforcingsrignot()
|
---|
[24213] | 15 | """
|
---|
[23658] | 16 |
|
---|
[26744] | 17 | def __init__(self, *args): # {{{
|
---|
| 18 | self.basin_id = np.nan
|
---|
| 19 | self.num_basins = 0
|
---|
| 20 | self.subglacial_discharge = np.nan
|
---|
| 21 | self.thermalforcing = np.nan
|
---|
[23658] | 22 |
|
---|
[26744] | 23 | if len(args) == 0:
|
---|
| 24 | self.setdefaultparameters()
|
---|
| 25 | else:
|
---|
| 26 | error('constructor not supported')
|
---|
[23658] | 27 |
|
---|
[28013] | 28 | # }}}
|
---|
[23658] | 29 |
|
---|
[24213] | 30 | def __repr__(self): # {{{
|
---|
[26744] | 31 | s = ' Frontalforcings parameters:\n'
|
---|
| 32 | s += '{}\n'.format(fielddisplay(self, 'basin_id', 'basin ID for elements'))
|
---|
| 33 | s += '{}\n'.format(fielddisplay(self, 'num_basins', 'number of basins'))
|
---|
| 34 | s += '{}\n'.format(fielddisplay(self, 'subglacial_discharge', 'sum of subglacial discharge for each basin [m/d]'))
|
---|
| 35 | s += '{}\n'.format(fielddisplay(self, 'thermalforcing', 'thermal forcing [∘C]'))
|
---|
| 36 | return s
|
---|
[28013] | 37 | # }}}
|
---|
[23658] | 38 |
|
---|
[28013] | 39 | def setdefaultparameters(self): # {{{
|
---|
[26744] | 40 | self.basin_id = np.nan
|
---|
| 41 | self.num_basins = 0
|
---|
| 42 | self.subglacial_discharge = np.nan
|
---|
| 43 | self.thermalforcing = np.nan
|
---|
| 44 |
|
---|
[24213] | 45 | return self
|
---|
[28013] | 46 | # }}}
|
---|
[23658] | 47 |
|
---|
[26744] | 48 | def extrude(self, md): # {{{
|
---|
[24213] | 49 | return self
|
---|
[28013] | 50 | # }}}
|
---|
[23658] | 51 |
|
---|
[24213] | 52 | def checkconsistency(self, md, solution, analyses): # {{{
|
---|
[26744] | 53 | # Early return
|
---|
[24213] | 54 | if (solution != 'TransientSolution') or (not md.transient.ismovingfront):
|
---|
| 55 | return md
|
---|
[23658] | 56 |
|
---|
[26744] | 57 | md = checkfield(md, 'fieldname', 'frontalforcings.num_basins', 'numel', [1], 'NaN', 1, 'Inf', 1, '>', 0)
|
---|
| 58 | md = checkfield(md, 'fieldname', 'frontalforcings.basin_id', 'Inf', 1, '>=', 0, '<=', md.frontalforcings.num_basins, 'size', [md.mesh.numberofelements])
|
---|
| 59 | md = checkfield(md, 'fieldname', 'frontalforcings.subglacial_discharge', '>=', 0, 'NaN', 1, 'Inf', 1, 'timeseries', 1)
|
---|
| 60 | md = checkfield(md, 'fieldname', 'frontalforcings.thermalforcing', 'NaN', 1, 'Inf', 1, 'timeseries', 1)
|
---|
[24213] | 61 | return md
|
---|
| 62 | # }}}
|
---|
[23658] | 63 |
|
---|
[24213] | 64 | def marshall(self, prefix, md, fid): # {{{
|
---|
| 65 | WriteData(fid, prefix, 'name', 'md.frontalforcings.parameterization', 'data', 2, 'format', 'Integer')
|
---|
[27035] | 66 | WriteData(fid, prefix, 'object', self, 'fieldname', 'basin_id', 'data', self.basin_id - 1, 'name', 'md.frontalforcings.basin_id', 'format', 'IntMat', 'mattype', 2) # 0-indexed
|
---|
[26744] | 67 | WriteData(fid, prefix, 'object', self, 'fieldname', 'num_basins', 'format', 'Integer')
|
---|
| 68 | WriteData(fid, prefix, 'object', self, 'fieldname', 'subglacial_discharge', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts)
|
---|
| 69 | WriteData(fid, prefix, 'object', self, 'fieldname', 'thermalforcing', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts)
|
---|
[24213] | 70 | # }}}
|
---|