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