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