[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;
|
---|
[17078] | 11 | s0p = 0;
|
---|
[18717] | 12 | s0t = 0;
|
---|
[18984] | 13 | rlaps = 0;
|
---|
[19172] | 14 | rlapslgm = 0;
|
---|
| 15 | dpermil = 0;
|
---|
[18984] | 16 | Pfac = NaN;
|
---|
| 17 | Tdiff = NaN;
|
---|
| 18 | sealev = NaN;
|
---|
[17078] | 19 | isdelta18o = 0;
|
---|
[18968] | 20 | ismungsm = 0;
|
---|
[19172] | 21 | isd18opd = 0;
|
---|
[17078] | 22 | delta18o = NaN;
|
---|
| 23 | delta18o_surface = NaN;
|
---|
| 24 | temperatures_presentday = NaN;
|
---|
| 25 | temperatures_lgm = NaN;
|
---|
| 26 | precipitations_presentday = NaN;
|
---|
[18950] | 27 | precipitations_lgm = NaN;
|
---|
[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) % {{{
|
---|
[19172] | 39 | if(self.isdelta18o==0 & self.ismungsm==0 & self.isd18opd==0),self.precipitation=project3d(md,'vector',self.precipitation,'type','node');end
|
---|
| 40 | if(self.isdelta18o==0 & self.ismungsm==0 & self.isd18opd==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
|
---|
[19172] | 49 | if(self.isd18opd),self.temperatures_presentday=project3d(md,'vector',self.temperatures_presentday,'type','node');end
|
---|
| 50 | if(self.isd18opd),self.precipitations_presentday=project3d(md,'vector',self.precipitations_presentday,'type','node');end
|
---|
[17079] | 51 |
|
---|
| 52 | end % }}}
|
---|
[17078] | 53 | function self = initialize(self,md) % {{{
|
---|
[18968] | 54 |
|
---|
| 55 | % if isnan(self.precipitation),
|
---|
| 56 | % self.precipitation=zeros(md.mesh.numberofvertices,1);
|
---|
| 57 | % disp(' no SMBpdd.precipitation specified: values set as zero');
|
---|
| 58 | % end
|
---|
[17078] | 59 |
|
---|
| 60 | end % }}}
|
---|
[19040] | 61 | function self = setdefaultparameters(self) % {{{
|
---|
[17078] | 62 |
|
---|
[19040] | 63 | self.isdelta18o = 0;
|
---|
| 64 | self.ismungsm = 0;
|
---|
[19172] | 65 | self.isd18opd = 0;
|
---|
[19040] | 66 | self.desfac = 0.5;
|
---|
| 67 | self.s0p = 0;
|
---|
| 68 | self.s0t = 0;
|
---|
| 69 | self.rlaps = 6.5;
|
---|
| 70 | self.rlapslgm = 6.5;
|
---|
[19172] | 71 | self.dpermil = 2.4;
|
---|
[18717] | 72 |
|
---|
[17078] | 73 | end % }}}
|
---|
[19040] | 74 | function md = checkconsistency(self,md,solution,analyses) % {{{
|
---|
[17078] | 75 |
|
---|
| 76 | if ismember(MasstransportAnalysisEnum(),analyses),
|
---|
| 77 | md = checkfield(md,'fieldname','surfaceforcings.desfac','<=',1,'numel',1);
|
---|
| 78 | md = checkfield(md,'fieldname','surfaceforcings.s0p','>=',0,'numel',1);
|
---|
[18717] | 79 | md = checkfield(md,'fieldname','surfaceforcings.s0t','>=',0,'numel',1);
|
---|
| 80 | md = checkfield(md,'fieldname','surfaceforcings.rlaps','>=',0,'numel',1);
|
---|
| 81 | md = checkfield(md,'fieldname','surfaceforcings.rlapslgm','>=',0,'numel',1);
|
---|
[19172] | 82 | if(self.isdelta18o==0 & self.ismungsm==0 & self.isd18opd==0)
|
---|
[19027] | 83 | md = checkfield(md,'fieldname','surfaceforcings.monthlytemperatures','timeseries',1,'NaN',1);
|
---|
| 84 | md = checkfield(md,'fieldname','surfaceforcings.precipitation','timeseries',1,'NaN',1);
|
---|
[19040] | 85 | elseif(self.isdelta18o==1)
|
---|
[18984] | 86 | md = checkfield(md,'fieldname','surfaceforcings.delta18o','NaN',1);
|
---|
| 87 | md = checkfield(md,'fieldname','surfaceforcings.delta18o_surface','NaN',1);
|
---|
| 88 | md = checkfield(md,'fieldname','surfaceforcings.temperatures_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1);
|
---|
| 89 | md = checkfield(md,'fieldname','surfaceforcings.temperatures_lgm','size',[md.mesh.numberofvertices+1 12],'NaN',1);
|
---|
| 90 | md = checkfield(md,'fieldname','surfaceforcings.precipitations_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1);
|
---|
| 91 | md = checkfield(md,'fieldname','surfaceforcings.precipitations_lgm','size',[md.mesh.numberofvertices+1 12],'NaN',1);
|
---|
| 92 | md = checkfield(md,'fieldname','surfaceforcings.Tdiff','NaN',1);
|
---|
| 93 | md = checkfield(md,'fieldname','surfaceforcings.sealev','NaN',1);
|
---|
[19040] | 94 | elseif(self.ismungsm==1)
|
---|
[18984] | 95 | md = checkfield(md,'fieldname','surfaceforcings.temperatures_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1);
|
---|
| 96 | md = checkfield(md,'fieldname','surfaceforcings.temperatures_lgm','size',[md.mesh.numberofvertices+1 12],'NaN',1);
|
---|
| 97 | md = checkfield(md,'fieldname','surfaceforcings.precipitations_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1);
|
---|
| 98 | md = checkfield(md,'fieldname','surfaceforcings.precipitations_lgm','size',[md.mesh.numberofvertices+1 12],'NaN',1);
|
---|
| 99 | md = checkfield(md,'fieldname','surfaceforcings.Pfac','NaN',1,'size',[2,NaN]);
|
---|
| 100 | md = checkfield(md,'fieldname','surfaceforcings.Tdiff','NaN',1);
|
---|
| 101 | md = checkfield(md,'fieldname','surfaceforcings.sealev','NaN',1);
|
---|
[19172] | 102 | elseif(self.isd18opd==1)
|
---|
| 103 | md = checkfield(md,'fieldname','surfaceforcings.temperatures_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1);
|
---|
| 104 | md = checkfield(md,'fieldname','surfaceforcings.precipitations_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1);
|
---|
| 105 | md = checkfield(md,'fieldname','surfaceforcings.delta18o','NaN',1);
|
---|
| 106 | md = checkfield(md,'fieldname','surfaceforcings.dpermil','>=',0,'numel',1);
|
---|
[17078] | 107 | end
|
---|
[18984] | 108 | end
|
---|
[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)');
|
---|
[19172] | 116 | fielddisplay(self,'isd18opd','is delta18o parametrisation from present day temperature and precipitation activated (0 or 1, default is 0)');
|
---|
[19040] | 117 | fielddisplay(self,'desfac','desertification elevation factor (between 0 and 1, default is 0.5) [m]');
|
---|
| 118 | fielddisplay(self,'s0p','should be set to elevation from precip source (between 0 and a few 1000s m, default is 0) [m]');
|
---|
| 119 | fielddisplay(self,'s0t','should be set to elevation from temperature source (between 0 and a few 1000s m, default is 0) [m]');
|
---|
| 120 | fielddisplay(self,'rlaps','present day lapse rate [degree/km]');
|
---|
| 121 | fielddisplay(self,'rlapslgm','LGM lapse rate [degree/km]');
|
---|
[19172] | 122 | if(self.isdelta18o==0 & self.ismungsm==0 & self.isd18opd==0)
|
---|
[19040] | 123 | fielddisplay(self,'monthlytemperatures',['monthly surface temperatures [K], required if pdd is activated and delta18o not activated']);
|
---|
| 124 | fielddisplay(self,'precipitation',['monthly surface precipitation [m/yr water eq], required if pdd is activated and delta18o or mungsm not activated']);
|
---|
| 125 | elseif(self.isdelta18o==1)
|
---|
| 126 | fielddisplay(self,'delta18o','delta18o, required if pdd is activated and delta18o activated');
|
---|
| 127 | fielddisplay(self,'delta18o_surface','surface elevation of the delta18o site, required if pdd is activated and delta18o activated');
|
---|
| 128 | fielddisplay(self,'temperatures_presentday','monthly present day surface temperatures [K], required if delta18o/mungsm is activated');
|
---|
| 129 | fielddisplay(self,'temperatures_lgm','monthly LGM surface temperatures [K], required if delta18o or mungsm is activated');
|
---|
[19172] | 130 | fielddisplay(self,'precipitations_presentday','monthly surface precipitation [m/yr water eq], required if delta18o/mungsm/d18opd is activated');
|
---|
| 131 | fielddisplay(self,'precipitations_lgm','monthly surface precipitation [m/yr water eq], required if delta18o/mungsm is activated');
|
---|
[19040] | 132 | fielddisplay(self,'Tdiff','time interpolation parameter for temperature, 1D(year), required if mungsm is activated');
|
---|
| 133 | fielddisplay(self,'sealev','sea level [m], 1D(year), required if mungsm is activated');
|
---|
| 134 | elseif(self.ismungsm==1)
|
---|
[19172] | 135 | fielddisplay(self,'temperatures_presentday','monthly present day surface temperatures [K], required if delta18o/mungsm/d18opd is activated');
|
---|
[19040] | 136 | fielddisplay(self,'temperatures_lgm','monthly LGM surface temperatures [K], required if delta18o or mungsm is activated');
|
---|
[19172] | 137 | fielddisplay(self,'precipitations_presentday','monthly surface precipitation [m/yr water eq], required if delta18o/mungsm/d18opd is activated');
|
---|
| 138 | fielddisplay(self,'precipitations_lgm','monthly surface precipitation [m/yr water eq], required if delta18o/mungsm is activated');
|
---|
[19040] | 139 | fielddisplay(self,'Pfac','time interpolation parameter for precipitation, 1D(year), required if mungsm is activated');
|
---|
| 140 | fielddisplay(self,'Tdiff','time interpolation parameter for temperature, 1D(year), required if mungsm is activated');
|
---|
| 141 | fielddisplay(self,'sealev','sea level [m], 1D(year), required if mungsm is activated');
|
---|
[19172] | 142 | elseif(self.isd18opd==1)
|
---|
| 143 | fielddisplay(self,'temperatures_presentday','monthly present day surface temperatures [K], required if delta18o/mungsm/d18opd is activated');
|
---|
| 144 | fielddisplay(self,'precipitations_presentday','monthly surface precipitation [m/yr water eq], required if delta18o/mungsm/d18opd is activated');
|
---|
| 145 | fielddisplay(self,'delta18o','delta18o, required if pdd is activated and d18opd activated');
|
---|
| 146 | fielddisplay(self,'dpermil','degree per mil, required if d18opd is activated');
|
---|
[18968] | 147 | end
|
---|
[17078] | 148 | end % }}}
|
---|
[19040] | 149 | function marshall(self,md,fid) % {{{
|
---|
[17078] | 150 |
|
---|
| 151 | yts=365.0*24.0*3600.0;
|
---|
| 152 |
|
---|
| 153 | WriteData(fid,'enum',SurfaceforcingsEnum(),'data',SMBpddEnum(),'format','Integer');
|
---|
| 154 |
|
---|
[19040] | 155 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','isdelta18o','format','Boolean');
|
---|
| 156 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','ismungsm','format','Boolean');
|
---|
[19172] | 157 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','isd18opd','format','Boolean');
|
---|
[19040] | 158 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','desfac','format','Double');
|
---|
| 159 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','s0p','format','Double');
|
---|
| 160 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','s0t','format','Double');
|
---|
| 161 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','rlaps','format','Double');
|
---|
| 162 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','rlapslgm','format','Double');
|
---|
[18968] | 163 |
|
---|
[19172] | 164 | if(self.isdelta18o==0 & self.ismungsm==0 & self.isd18opd==0)
|
---|
[19040] | 165 | %WriteData(fid,'object',self,'class','surfaceforcings','fieldname','monthlytemperatures','format','DoubleMat','mattype',1);
|
---|
| 166 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','monthlytemperatures','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1);
|
---|
| 167 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','precipitation','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1);
|
---|
| 168 | elseif self.isdelta18o
|
---|
| 169 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','temperatures_presentday','format','DoubleMat','mattype',1);
|
---|
| 170 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','temperatures_lgm','format','DoubleMat','mattype',1);
|
---|
| 171 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','precipitations_presentday','format','DoubleMat','mattype',1);
|
---|
| 172 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','precipitations_lgm','format','DoubleMat','mattype',1);
|
---|
| 173 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','delta18o_surface','format','DoubleMat','mattype',1);
|
---|
| 174 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','delta18o','format','DoubleMat','mattype',1);
|
---|
| 175 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','Tdiff','format','DoubleMat','mattype',1);
|
---|
| 176 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','sealev','format','DoubleMat','mattype',1);
|
---|
| 177 | elseif self.ismungsm
|
---|
| 178 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','temperatures_presentday','format','DoubleMat','mattype',1);
|
---|
| 179 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','temperatures_lgm','format','DoubleMat','mattype',1);
|
---|
| 180 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','precipitations_presentday','format','DoubleMat','mattype',1);
|
---|
| 181 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','precipitations_lgm','format','DoubleMat','mattype',1);
|
---|
| 182 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','Pfac','format','DoubleMat','mattype',1);
|
---|
| 183 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','Tdiff','format','DoubleMat','mattype',1);
|
---|
| 184 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','sealev','format','DoubleMat','mattype',1);
|
---|
[19172] | 185 | elseif self.isd18opd
|
---|
| 186 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','temperatures_presentday','format','DoubleMat','mattype',1);
|
---|
| 187 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','precipitations_presentday','format','DoubleMat','mattype',1);
|
---|
| 188 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','delta18o','format','DoubleMat','mattype',1);
|
---|
| 189 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','dpermil','format','Double');
|
---|
[17078] | 190 | end
|
---|
| 191 | end % }}}
|
---|
| 192 | end
|
---|
| 193 | end
|
---|