| 1 | from checkfield import checkfield
|
|---|
| 2 | from WriteData import WriteData
|
|---|
| 3 | from fielddisplay import fielddisplay
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 | class frontalforcingsrignot(object):
|
|---|
| 7 | """
|
|---|
| 8 | FRONTAL FORCINGS Rignot class definition
|
|---|
| 9 |
|
|---|
| 10 | Usage:
|
|---|
| 11 | frontalforcingsrignot = frontalforcingsrignot()
|
|---|
| 12 | """
|
|---|
| 13 |
|
|---|
| 14 | def __init__(self): # {{{
|
|---|
| 15 | self.basin = float('NaN')
|
|---|
| 16 | self.numberofbasins = 0.
|
|---|
| 17 | self.subglacial_discharge = float('NaN')
|
|---|
| 18 | self.thermalforcing = float('NaN')
|
|---|
| 19 |
|
|---|
| 20 | #set defaults
|
|---|
| 21 | self.setdefaultparameters()
|
|---|
| 22 |
|
|---|
| 23 | #}}}
|
|---|
| 24 |
|
|---|
| 25 | def __repr__(self): # {{{
|
|---|
| 26 | string = ' Frontalforcings parameters:'
|
|---|
| 27 | string = "%s\n%s" % (string, fielddisplay(self, 'basin', 'basin ID for vertices'))
|
|---|
| 28 | string = "%s\n%s" % (string, fielddisplay(self, 'numberofbasins', 'number of basins'))
|
|---|
| 29 | string = "%s\n%s" % (string, fielddisplay(self, 'subglacial_discharge', 'sum of subglacial discharge for each basin [m / d]'))
|
|---|
| 30 | string = "%s\n%s" % (string, fielddisplay(self, 'thermalforcing', 'thermal forcing [C]'))
|
|---|
| 31 |
|
|---|
| 32 | return string
|
|---|
| 33 | #}}}
|
|---|
| 34 |
|
|---|
| 35 | def extrude(self, md): # {{{
|
|---|
| 36 | return self
|
|---|
| 37 | #}}}
|
|---|
| 38 |
|
|---|
| 39 | def setdefaultparameters(self): # {{{
|
|---|
| 40 |
|
|---|
| 41 | return self
|
|---|
| 42 | #}}}
|
|---|
| 43 |
|
|---|
| 44 | def checkconsistency(self, md, solution, analyses): # {{{
|
|---|
| 45 | #Early return
|
|---|
| 46 | if (solution != 'TransientSolution') or (not md.transient.ismovingfront):
|
|---|
| 47 | return md
|
|---|
| 48 |
|
|---|
| 49 | md = checkfield(md, 'fieldname', 'frontalforcings.basin', '>', 0, 'nan', 1, 'Inf', 1)
|
|---|
| 50 | md = checkfield(md, 'fieldname', 'frontalforcings.numberofbasins', 'numel', [1])
|
|---|
| 51 | md = checkfield(md, 'fieldname', 'frontalforcings.subglacial_discharge', '>=', 0, 'nan', 1, 'Inf', 1, 'timeseries', 1)
|
|---|
| 52 | md = checkfield(md, 'fieldname', 'frontalforcings.thermalforcing', 'nan', 1, 'Inf', 1, 'timeseries', 1)
|
|---|
| 53 | return md
|
|---|
| 54 | # }}}
|
|---|
| 55 |
|
|---|
| 56 | def marshall(self, prefix, md, fid): # {{{
|
|---|
| 57 | WriteData(fid, prefix, 'name', 'md.frontalforcings.parameterization', 'data', 2, 'format', 'Integer')
|
|---|
| 58 | WriteData(fid, prefix, 'object', self, 'fieldname', 'basin', 'format', 'DoubleMat', 'mattype', 1)
|
|---|
| 59 | WriteData(fid, prefix, 'object', self, 'fieldname', 'numberofbasins', 'format', 'Integer')
|
|---|
| 60 | WriteData(fid, prefix, 'object', self, 'fieldname', 'subglacial_discharge', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1)
|
|---|
| 61 | WriteData(fid, prefix, 'object', self, 'fieldname', 'thermalforcing', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1)
|
|---|
| 62 |
|
|---|
| 63 | # }}}
|
|---|