source: issm/trunk-jpl/src/m/classes/SMBpdd.m@ 22448

Last change on this file since 22448 was 22448, checked in by schlegel, 7 years ago

CHG: add pdd factor input field

File size: 13.4 KB
RevLine 
[17078]1%SMBpdd Class definition
2%
3% Usage:
4% SMBpdd=SMBpdd();
5
6classdef SMBpdd
7 properties (SetAccess=public)
8 precipitation = NaN;
9 monthlytemperatures = NaN;
[18724]10 desfac = 0;
[19309]11 s0p = NaN;
12 s0t = NaN;
[18984]13 rlaps = 0;
[19172]14 rlapslgm = 0;
[18984]15 Pfac = NaN;
16 Tdiff = NaN;
17 sealev = NaN;
[17078]18 isdelta18o = 0;
[18968]19 ismungsm = 0;
[22448]20 issetpddfac = 0;
[17078]21 delta18o = NaN;
22 delta18o_surface = NaN;
23 temperatures_presentday = NaN;
24 temperatures_lgm = NaN;
25 precipitations_presentday = NaN;
[18950]26 precipitations_lgm = NaN;
[19527]27 requested_outputs = {};
[17078]28 end
29 methods
[19040]30 function self = SMBpdd(varargin) % {{{
[17078]31 switch nargin
32 case 0
[19040]33 self=setdefaultparameters(self);
[17078]34 otherwise
35 error('constructor not supported');
36 end
37 end % }}}
[17079]38 function self = extrude(self,md) % {{{
[19200]39 if(self.isdelta18o==0 & self.ismungsm==0),self.precipitation=project3d(md,'vector',self.precipitation,'type','node');end
40 if(self.isdelta18o==0 & self.ismungsm==0),self.monthlytemperatures=project3d(md,'vector',self.monthlytemperatures,'type','node');end
[17079]41 if(self.isdelta18o),self.temperatures_lgm=project3d(md,'vector',self.temperatures_lgm,'type','node');end
42 if(self.isdelta18o),self.temperatures_presentday=project3d(md,'vector',self.temperatures_presentday,'type','node');end
43 if(self.isdelta18o),self.precipitations_presentday=project3d(md,'vector',self.precipitations_presentday,'type','node');end
[18950]44 if(self.isdelta18o),self.precipitations_lgm=project3d(md,'vector',self.precipitations_lgm,'type','node');end
[18968]45 if(self.ismungsm),self.temperatures_lgm=project3d(md,'vector',self.temperatures_lgm,'type','node');end
46 if(self.ismungsm),self.temperatures_presentday=project3d(md,'vector',self.temperatures_presentday,'type','node');end
47 if(self.ismungsm),self.precipitations_presentday=project3d(md,'vector',self.precipitations_presentday,'type','node');end
48 if(self.ismungsm),self.precipitations_lgm=project3d(md,'vector',self.precipitations_lgm,'type','node');end
[19309]49 self.s0p=project3d(md,'vector',self.s0p,'type','node');
50 self.s0t=project3d(md,'vector',self.s0t,'type','node');
[17079]51
52 end % }}}
[19527]53 function list = defaultoutputs(self,md) % {{{
54 list = {''};
55 end % }}}
[17078]56 function self = initialize(self,md) % {{{
[18968]57
[19309]58 if isnan(self.s0p),
59 self.s0p=zeros(md.mesh.numberofvertices,1);
60 disp(' no SMBpdd.s0p specified: values set as zero');
61 end
62 if isnan(self.s0t),
63 self.s0t=zeros(md.mesh.numberofvertices,1);
64 disp(' no SMBpdd.s0t specified: values set as zero');
65 end
[17078]66
67 end % }}}
[19040]68 function self = setdefaultparameters(self) % {{{
[17078]69
[19040]70 self.isdelta18o = 0;
71 self.ismungsm = 0;
72 self.desfac = 0.5;
73 self.rlaps = 6.5;
74 self.rlapslgm = 6.5;
[18717]75
[17078]76 end % }}}
[19040]77 function md = checkconsistency(self,md,solution,analyses) % {{{
[17078]78
[21049]79 if ismember('MasstransportAnalysis',analyses),
[19527]80 md = checkfield(md,'fieldname','smb.desfac','<=',1,'numel',1);
[19897]81 md = checkfield(md,'fieldname','smb.s0p','>=',0,'NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1]);
82 md = checkfield(md,'fieldname','smb.s0t','>=',0,'NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1]);
[19527]83 md = checkfield(md,'fieldname','smb.rlaps','>=',0,'numel',1);
84 md = checkfield(md,'fieldname','smb.rlapslgm','>=',0,'numel',1);
[19200]85 if(self.isdelta18o==0 & self.ismungsm==0)
[19897]86 md = checkfield(md,'fieldname','smb.monthlytemperatures','timeseries',1,'NaN',1,'Inf',1);
87 md = checkfield(md,'fieldname','smb.precipitation','timeseries',1,'NaN',1,'Inf',1);
[19040]88 elseif(self.isdelta18o==1)
[19897]89 md = checkfield(md,'fieldname','smb.delta18o','NaN',1,'Inf',1,'size',[2,NaN],'singletimeseries',1);
90 md = checkfield(md,'fieldname','smb.delta18o_surface','NaN',1,'Inf',1,'size',[2,NaN],'singletimeseries',1);
91 md = checkfield(md,'fieldname','smb.temperatures_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1,'Inf',1,'timeseries',1);
92 md = checkfield(md,'fieldname','smb.temperatures_lgm','size',[md.mesh.numberofvertices+1 12],'NaN',1,'Inf',1,'timeseries',1);
93 md = checkfield(md,'fieldname','smb.precipitations_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1,'Inf',1,'timeseries',1);
94 md = checkfield(md,'fieldname','smb.precipitations_lgm','size',[md.mesh.numberofvertices+1 12],'NaN',1,'Inf',1,'timeseries',1);
95 md = checkfield(md,'fieldname','smb.Tdiff','NaN',1,'Inf',1,'size',[2,NaN],'singletimeseries',1);
96 md = checkfield(md,'fieldname','smb.sealev','NaN',1,'Inf',1,'size',[2,NaN],'singletimeseries',1);
[19040]97 elseif(self.ismungsm==1)
[19897]98 md = checkfield(md,'fieldname','smb.temperatures_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1,'Inf',1,'timeseries',1);
99 md = checkfield(md,'fieldname','smb.temperatures_lgm','size',[md.mesh.numberofvertices+1 12],'NaN',1,'Inf',1,'timeseries',1);
100 md = checkfield(md,'fieldname','smb.precipitations_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1,'Inf',1,'timeseries',1);
101 md = checkfield(md,'fieldname','smb.precipitations_lgm','size',[md.mesh.numberofvertices+1 12],'NaN',1,'Inf',1,'timeseries',1);
102 md = checkfield(md,'fieldname','smb.Pfac','NaN',1,'Inf',1,'size',[2,NaN],'singletimeseries',1);
103 md = checkfield(md,'fieldname','smb.Tdiff','NaN',1,'Inf',1,'size',[2,NaN],'singletimeseries',1);
104 md = checkfield(md,'fieldname','smb.sealev','NaN',1,'Inf',1,'size',[2,NaN],'singletimeseries',1);
[17078]105 end
[18984]106 end
[19527]107 md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1);
108
[17078]109 end % }}}
[19040]110 function disp(self) % {{{
[17078]111 disp(sprintf(' surface forcings parameters:'));
112
113 disp(sprintf('\n PDD and deltaO18 parameters:'));
[19040]114 fielddisplay(self,'isdelta18o','is temperature and precipitation delta18o parametrisation activated (0 or 1, default is 0)');
115 fielddisplay(self,'ismungsm','is temperature and precipitation mungsm parametrisation activated (0 or 1, default is 0)');
116 fielddisplay(self,'desfac','desertification elevation factor (between 0 and 1, default is 0.5) [m]');
117 fielddisplay(self,'s0p','should be set to elevation from precip source (between 0 and a few 1000s m, default is 0) [m]');
118 fielddisplay(self,'s0t','should be set to elevation from temperature source (between 0 and a few 1000s m, default is 0) [m]');
119 fielddisplay(self,'rlaps','present day lapse rate [degree/km]');
120 fielddisplay(self,'rlapslgm','LGM lapse rate [degree/km]');
[19264]121 if(self.isdelta18o==0 & self.ismungsm==0)
122 fielddisplay(self,'monthlytemperatures',['monthly surface temperatures [K], required if pdd is activated and delta18o not activated']);
123 fielddisplay(self,'precipitation',['monthly surface precipitation [m/yr water eq], required if pdd is activated and delta18o or mungsm not activated']);
124 elseif(self.isdelta18o==1)
125 fielddisplay(self,'delta18o','delta18o [per mil], required if pdd is activated and delta18o activated');
126 fielddisplay(self,'delta18o_surface','surface elevation of the delta18o site, required if pdd is activated and delta18o activated');
127 fielddisplay(self,'temperatures_presentday','monthly present day surface temperatures [K], required if delta18o/mungsm is activated');
128 fielddisplay(self,'temperatures_lgm','monthly LGM surface temperatures [K], required if delta18o or mungsm is activated');
129 fielddisplay(self,'precipitations_presentday','monthly surface precipitation [m/yr water eq], required if delta18o/mungsm is activated');
130 fielddisplay(self,'precipitations_lgm','monthly surface precipitation [m/yr water eq], required if delta18o/mungsm is activated');
131 fielddisplay(self,'Tdiff','time interpolation parameter for temperature, 1D(year), required if mungsm is activated');
132 fielddisplay(self,'sealev','sea level [m], 1D(year), required if mungsm is activated');
133 elseif(self.ismungsm==1)
134 fielddisplay(self,'temperatures_presentday','monthly present day surface temperatures [K], required if delta18o/mungsm is activated');
135 fielddisplay(self,'temperatures_lgm','monthly LGM surface temperatures [K], required if delta18o or mungsm is activated');
136 fielddisplay(self,'precipitations_presentday','monthly surface precipitation [m/yr water eq], required if delta18o/mungsm is activated');
137 fielddisplay(self,'precipitations_lgm','monthly surface precipitation [m/yr water eq], required if delta18o/mungsm is activated');
138 fielddisplay(self,'Pfac','time interpolation parameter for precipitation, 1D(year), required if mungsm is activated');
139 fielddisplay(self,'Tdiff','time interpolation parameter for temperature, 1D(year), required if mungsm is activated');
140 fielddisplay(self,'sealev','sea level [m], 1D(year), required if mungsm is activated');
141 end
[19527]142 fielddisplay(self,'requested_outputs','additional outputs requested');
[17078]143 end % }}}
[20690]144 function marshall(self,prefix,md,fid) % {{{
[17078]145
[20896]146 yts=md.constants.yts;
[17078]147
[20889]148 WriteData(fid,prefix,'name','md.smb.model','data',4,'format','Integer');
[17078]149
[20690]150 WriteData(fid,prefix,'object',self,'class','smb','fieldname','isdelta18o','format','Boolean');
[22448]151 WriteData(fid,prefix,'object',self,'class','smb','fieldname','issetpddfac','format','Boolean');
[20690]152 WriteData(fid,prefix,'object',self,'class','smb','fieldname','ismungsm','format','Boolean');
153 WriteData(fid,prefix,'object',self,'class','smb','fieldname','desfac','format','Double');
154 WriteData(fid,prefix,'object',self,'class','smb','fieldname','s0p','format','DoubleMat','mattype',1);
155 WriteData(fid,prefix,'object',self,'class','smb','fieldname','s0t','format','DoubleMat','mattype',1);
156 WriteData(fid,prefix,'object',self,'class','smb','fieldname','rlaps','format','Double');
157 WriteData(fid,prefix,'object',self,'class','smb','fieldname','rlapslgm','format','Double');
[18968]158
[19200]159 if(self.isdelta18o==0 & self.ismungsm==0)
[20690]160 %WriteData(fid,prefix,'object',self,'class','smb','fieldname','monthlytemperatures','format','DoubleMat','mattype',1);
[20902]161 WriteData(fid,prefix,'object',self,'class','smb','fieldname','monthlytemperatures','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
162 WriteData(fid,prefix,'object',self,'class','smb','fieldname','precipitation','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
[19040]163 elseif self.isdelta18o
[20902]164 WriteData(fid,prefix,'object',self,'class','smb','fieldname','temperatures_presentday','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
165 WriteData(fid,prefix,'object',self,'class','smb','fieldname','temperatures_lgm','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
166 WriteData(fid,prefix,'object',self,'class','smb','fieldname','precipitations_presentday','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
167 WriteData(fid,prefix,'object',self,'class','smb','fieldname','precipitations_lgm','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
168 WriteData(fid,prefix,'object',self,'class','smb','fieldname','delta18o_surface','format','DoubleMat','mattype',1,'timeserieslength',2,'yts',md.constants.yts);
169 WriteData(fid,prefix,'object',self,'class','smb','fieldname','delta18o','format','DoubleMat','mattype',1,'timeserieslength',2,'yts',md.constants.yts);
170 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Tdiff','format','DoubleMat','mattype',1,'timeserieslength',2,'yts',md.constants.yts);
171 WriteData(fid,prefix,'object',self,'class','smb','fieldname','sealev','format','DoubleMat','mattype',1,'timeserieslength',2,'yts',md.constants.yts);
[19040]172 elseif self.ismungsm
[20902]173 WriteData(fid,prefix,'object',self,'class','smb','fieldname','temperatures_presentday','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
174 WriteData(fid,prefix,'object',self,'class','smb','fieldname','temperatures_lgm','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
175 WriteData(fid,prefix,'object',self,'class','smb','fieldname','precipitations_presentday','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
176 WriteData(fid,prefix,'object',self,'class','smb','fieldname','precipitations_lgm','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
177 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Pfac','format','DoubleMat','mattype',1,'timeserieslength',2,'yts',md.constants.yts);
178 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Tdiff','format','DoubleMat','mattype',1,'timeserieslength',2,'yts',md.constants.yts);
179 WriteData(fid,prefix,'object',self,'class','smb','fieldname','sealev','format','DoubleMat','mattype',1,'timeserieslength',2,'yts',md.constants.yts);
[17078]180 end
[19527]181
182 %process requested outputs
183 outputs = self.requested_outputs;
184 pos = find(ismember(outputs,'default'));
185 if ~isempty(pos),
186 outputs(pos) = []; %remove 'default' from outputs
187 outputs = [outputs defaultoutputs(self,md)]; %add defaults
188 end
[20690]189 WriteData(fid,prefix,'data',outputs,'name','md.smb.requested_outputs','format','StringArray');
[19527]190
[17078]191 end % }}}
192 end
193end
Note: See TracBrowser for help on using the repository browser.