source: issm/trunk/src/m/classes/mmeofflinesolidearthsolution.m@ 26744

Last change on this file since 26744 was 26744, checked in by Mathieu Morlighem, 3 years ago

merged trunk-jpl and trunk for revision 26742

File size: 4.6 KB
Line 
1%MMEOFFLINESOLIDEARTHSOLUTION class definition
2%
3% Usage:
4% addsol=mmeofflinesolidearthsolution(); where the offline solid earth solutions % are based on a multi-model ensemble (ex: Caron et al 2017 statistics)
5
6classdef mmeofflinesolidearthsolution < offlinesolidearthsolution
7 properties (SetAccess=public)
8 modelid; %index into the multi-model ensemble, each ensemble variable being defined
9 %in the father class.
10 end
11 methods
12 function self = mmeofflinesolidearthsolution(varargin) % {{{
13 switch nargin
14 case 0
15 self=setdefaultparameters(self);
16 otherwise
17 error('constructor not supported');
18 end
19 end % }}}
20 function self = setdefaultparameters(self) % {{{
21 self.setdefaultparameters@offlinesolidearthsolution();
22 self.modelid=0;
23 end % }}}
24 function md = checkconsistency(self,md,solution,analyses) % {{{
25
26 if ~ismember('SealevelchangeAnalysis',analyses) | (strcmp(solution,'TransientSolution') & md.solidearth.settings.isgrd==1),
27 error('mmeofflinesolidearthsolution checkconsistency error message: trying to run GRD patterns while supplying an offline solution for those patterns!');
28 end
29
30 seast=length(self.displacementeast);
31 snorth=length(self.displacementnorth);
32 sup=length(self.displacementup);
33 sgeoid=length(self.geoid);
34
35 if (seast-snorth)~=0,
36 error('mmeofflinesolidearthsolution checkconsistency error message: displacementeast and displacementnorth should be the same size');
37 end
38
39 if (seast-sup)~=0,
40 error('mmeofflinesolidearthsolution checkconsistency error message: displacementeast and displacementup should be the same size');
41 end
42
43 if (seast-sgeoid)~=0,
44 error('mmeofflinesolidearthsolution checkconsistency error message: displacementeast and geoid should be the same size');
45 end
46
47 md = checkfield(md,'field',self.modelid,'NaN',1,'Inf',1,'>=',1,'<=',length(self.displacementeast));
48
49 for i=1:seast,
50 md = checkfield(md,'field',self.displacementeast{i},'NaN',1,'Inf',1,'timeseries',1);
51 md = checkfield(md,'field',self.displacementup{i},'NaN',1,'Inf',1,'timeseries',1);
52 md = checkfield(md,'field',self.displacementnorth{i},'NaN',1,'Inf',1,'timeseries',1);
53 md = checkfield(md,'field',self.geoid{i},'NaN',1,'Inf',1,'timeseries',1);
54 end
55
56
57 end % }}}
58 function disp(self) % {{{
59 disp(sprintf(' external: mmeofflinesolidearth solution:'));
60 self.disp@solidearthsolution();
61 fielddisplay(self,'modelid','index into the multi-model ensemble, determines which field will be used.');
62 end % }}}
63 function marshall(self,prefix,md,fid) % {{{
64 WriteData(fid,prefix,'data',4,'name','md.solidearth.external.nature','format','Integer'); %code 4 for mmeofflinesolidearthsolution class
65 WriteData(fid,prefix,'object',self,'fieldname','modelid','format','Double');
66 nummodels=length(self.displacementeast);
67 WriteData(fid,prefix,'name','md.solidearth.external.nummodels','data',nummodels,'format','Integer');
68
69 %transform our cell array of time series into cell array of time series of rates
70 for i=1:nummodels,
71 displacementeast=self.displacementeast{i};
72 displacementnorth=self.displacementnorth{i};
73 displacementup=self.displacementup{i};
74 geoid=self.geoid{i};
75
76 time=displacementeast(end,:);
77 dt=diff(time,1,2);
78
79 displacementeast_rate=diff(displacementeast(1:end-1,:),1,2)./dt;
80 displacementnorth_rate=diff(displacementnorth(1:end-1,:),1,2)./dt;
81 displacementup_rate=diff(displacementup(1:end-1,:),1,2)./dt;
82 geoid_rate=diff(geoid(1:end-1,:),1,2)./dt;
83 barystaticsealevel_rate=diff(barystaticsealevel(1:end-1,:),1,2)./dt;
84
85 self.displacementeast{i}=displacementeast_rate;
86 self.displacementnorth{i}=displacementnorth_rate;
87 self.displacementup{i}=displacementup_rate;
88 self.geoid{i}=geoid_rate;
89 end
90
91 WriteData(fid,prefix,'object',self,'fieldname','displacementeast','format','MatArray','timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts,'scale',1/yts);
92 WriteData(fid,prefix,'object',self,'fieldname','displacementup','format','MatArray','timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts,'scale',1/yts);
93 WriteData(fid,prefix,'object',self,'fieldname','displacementnorth','format','MatArray','timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts,'scale',1/yts);
94 WriteData(fid,prefix,'object',self,'fieldname','geoid','format','MatArray','timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts,'scale',1/yts);
95
96 end % }}}
97 function savemodeljs(self,fid,modelname) % {{{
98 error('mmeofflinesolidearthsolution error message: not implemented yet');
99 end % }}}
100 function self = extrude(self,md) % {{{
101 end % }}}
102 end
103end
Note: See TracBrowser for help on using the repository browser.