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