Changeset 26744 for issm/trunk/src/m/classes/solidearth.py
- Timestamp:
- 12/22/21 10:39:44 (3 years ago)
- Location:
- issm/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
- Property svn:mergeinfo changed
/issm/trunk-jpl merged: 25837-25866,25868-25993,25995-26330,26332-26733,26736-26739,26741
- Property svn:mergeinfo changed
-
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/m/classes/solidearth.py
r25836 r26744 4 4 from fielddisplay import fielddisplay 5 5 from lovenumbers import lovenumbers 6 from MatlabFuncs import * 6 7 from planetradius import planetradius 7 8 from project3d import project3d 8 9 from rotational import rotational 9 10 from solidearthsettings import solidearthsettings 10 from s urfaceload import surfaceload11 from solidearthsolution import solidearthsolution 11 12 from WriteData import WriteData 12 13 … … 17 18 Usage: 18 19 solidearth = solidearth() 20 solidearth = solidearth('earth') 21 22 TODO: 23 - Update translation from solidearth.m 19 24 """ 20 25 21 def __init__(self, *args): #{{{ 22 self.initialsealevel = np.nan 26 def __init__(self, *args): # {{{ 23 27 self.settings = solidearthsettings() 24 self.external = [] 25 self.surfaceload = surfaceload() 28 self.external = None 26 29 self.lovenumbers = lovenumbers() 27 30 self.rotational = rotational() … … 31 34 self.partitionice = [] 32 35 self.partitionhydro = [] 36 self.partitionocean = [] 33 37 34 38 nargs = len(args) 35 36 39 if nargs == 0: 37 40 self.setdefaultparameters('earth') … … 40 43 else: 41 44 raise Exception('solidearth constructor error message: zero or one argument only!') 42 #}}} 43 45 # }}} 44 46 def __repr__(self): # {{{ 45 47 s = ' solidearthinputs, forcings and settings:\n' 46 s += '{}\n'.format(fielddisplay(self, 'initialsealevel', 'sea level at the start of computation [m]'))47 48 s += '{}\n'.format(fielddisplay(self, 'planetradius', 'planet radius [m]')) 48 49 s += '{}\n'.format(fielddisplay(self, 'transitions', 'indices into parts of the mesh that will be icecaps')) … … 50 51 s += '{}\n'.format(fielddisplay(self, 'partitionice', 'ice partition vector for barystatic contribution')) 51 52 s += '{}\n'.format(fielddisplay(self, 'partitionhydro', 'hydro partition vector for barystatic contribution')) 53 s += '{}\n'.format(fielddisplay(self, 'partitionocean', 'ocean partition vector for barystatic contribution')) 52 54 if not self.external: 53 55 s += '{}\n'.format(fielddisplay(self, 'external', 'external solution, of the type solidearthsolution')) 54 56 print(self.settings) 55 print(self.surfaceload)56 57 print(self.lovenumbers) 57 58 print(self.rotational) 58 if self.external:59 if len(self.external): 59 60 print(self.external) 60 61 return s 61 #}}} 62 62 # }}} 63 63 def setdefaultparameters(self, planet): # {{{ 64 # Default output64 # Output default 65 65 self.requested_outputs = ['default'] 66 66 … … 71 71 self.partitionice = [] 72 72 self.partitionhydro = [] 73 self.partitionocean = [] 73 74 74 # No external solutions by defa lt75 self.external = []75 # No external solutions by default 76 self.external = None 76 77 77 # Earthradius78 # Planet radius 78 79 self.planetradius = planetradius(planet) 79 #}}} 80 # }}} 81 def checkconsistency(self, md, solution, analyses): # {{{ 82 if ('SealevelchangeAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.isslc): 83 return md 80 84 81 def checkconsistency(self, md, solution, analyses): # {{{82 if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.isslr):83 return md84 md = checkfield(md, 'fieldname', 'solidearth.initialsealevel', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices])85 85 md = checkfield(md, 'fieldname', 'solidearth.requested_outputs', 'stringrow', 1) 86 86 87 87 self.settings.checkconsistency(md, solution, analyses) 88 self.surfaceload.checkconsistency(md, solution, analyses)89 88 self.lovenumbers.checkconsistency(md, solution, analyses) 90 89 self.rotational.checkconsistency(md, solution, analyses) 91 90 if self.external: 92 if not is instance(self.external,'solidearthsolution'):91 if not isa(self.external, solidearthsolution): 93 92 raise Exception('solidearth consistency check: external field should be a solidearthsolution') 94 end 95 self.external.checkconsistency(md,solution,analyses) 93 self.external.checkconsistency(md, solution, analyses) 96 94 return md 97 #}}} 98 99 def defaultoutputs(self, md): #{{{ 95 # }}} 96 def defaultoutputs(self, md): # {{{ 100 97 return ['Sealevel'] 101 #}}} 102 103 def marshall(self, prefix, md, fid): #{{{ 104 WriteData(fid, prefix, 'object', self, 'fieldname', 'initialsealevel', 'mattype', 1, 'format', 'DoubleMat', 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts) 98 # }}} 99 def marshall(self, prefix, md, fid): # {{{ 105 100 WriteData(fid, prefix, 'object', self, 'fieldname', 'planetradius', 'format', 'Double') 106 101 WriteData(fid, prefix, 'object', self, 'fieldname', 'transitions', 'format', 'MatArray') … … 116 111 nparthydro = 0 117 112 113 if len(self.partitionocean): 114 npartocean = np.max(self.partitionocean) + 2 115 else: 116 npartocean = 0 117 118 118 WriteData(fid, prefix, 'object', self, 'fieldname', 'partitionice', 'mattype', 1, 'format', 'DoubleMat'); 119 119 WriteData(fid, prefix, 'data', npartice, 'format', 'Integer', 'name', 'md.solidearth.npartice'); 120 120 WriteData(fid, prefix, 'object', self, 'fieldname', 'partitionhydro', 'mattype', 1, 'format', 'DoubleMat'); 121 121 WriteData(fid, prefix, 'data', nparthydro,'format', 'Integer', 'name','md.solidearth.nparthydro'); 122 WriteData(fid, prefix, 'object', self, 'fieldname', 'partitionocean', 'mattype', 1, 'format', 'DoubleMat'); 123 WriteData(fid, prefix, 'data', npartocean,'format', 'Integer', 'name','md.solidearth.npartocean'); 122 124 123 125 self.settings.marshall(prefix, md, fid) 124 self.surfaceload.marshall(prefix, md, fid)125 126 self.lovenumbers.marshall(prefix, md, fid) 126 127 self.rotational.marshall(prefix, md, fid) 127 128 if self.external: 129 WriteData(fid, prefix, 'data', 1, 'format', 'Integer', 'name', 'md.solidearth.isexternal') 128 130 self.external.marshall(prefix, md, fid) 131 else: 132 WriteData(fid, prefix, 'data', 0, 'format', 'Integer', 'name', 'md.solidearth.isexternal') 129 133 130 # process requested outputs134 # Process requested outputs 131 135 outputs = self.requested_outputs 132 136 pos = np.where(np.asarray(outputs) == 'default')[0] 133 137 if len(pos): 134 outputs = np.delete(outputs, pos) #remove 'default' from outputs135 outputs = np.append(outputs, self.defaultoutputs(md)) #add defaults138 outputs = np.delete(outputs, pos) # remove 'default' from outputs 139 outputs = np.append(outputs, self.defaultoutputs(md)) # add defaults 136 140 WriteData(fid, prefix, 'data', outputs, 'name', 'md.solidearth.requested_outputs', 'format', 'StringArray') 137 #}}} 138 139 def extrude(self, md): #{{{ 140 self.initialsealevel = project3d(md, 'vector', self.initialsealevel, 'type', 'node') 141 # }}} 142 def extrude(self, md): # {{{ 141 143 return self 142 # }}}144 # }}}
Note:
See TracChangeset
for help on using the changeset viewer.