[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;
|
---|
[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;
|
---|
[17078] | 26 | end
|
---|
| 27 | methods
|
---|
[19040] | 28 | function self = SMBpdd(varargin) % {{{
|
---|
[17078] | 29 | switch nargin
|
---|
| 30 | case 0
|
---|
[19040] | 31 | self=setdefaultparameters(self);
|
---|
[17078] | 32 | otherwise
|
---|
| 33 | error('constructor not supported');
|
---|
| 34 | end
|
---|
| 35 | end % }}}
|
---|
[17079] | 36 | function self = extrude(self,md) % {{{
|
---|
[19200] | 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
|
---|
[17079] | 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
|
---|
[18950] | 42 | if(self.isdelta18o),self.precipitations_lgm=project3d(md,'vector',self.precipitations_lgm,'type','node');end
|
---|
[18968] | 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
|
---|
[17079] | 47 |
|
---|
| 48 | end % }}}
|
---|
[17078] | 49 | function self = initialize(self,md) % {{{
|
---|
[18968] | 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
|
---|
[17078] | 55 |
|
---|
| 56 | end % }}}
|
---|
[19040] | 57 | function self = setdefaultparameters(self) % {{{
|
---|
[17078] | 58 |
|
---|
[19040] | 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;
|
---|
[18717] | 66 |
|
---|
[17078] | 67 | end % }}}
|
---|
[19040] | 68 | function md = checkconsistency(self,md,solution,analyses) % {{{
|
---|
[17078] | 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);
|
---|
[18717] | 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);
|
---|
[19200] | 76 | if(self.isdelta18o==0 & self.ismungsm==0)
|
---|
[19027] | 77 | md = checkfield(md,'fieldname','surfaceforcings.monthlytemperatures','timeseries',1,'NaN',1);
|
---|
| 78 | md = checkfield(md,'fieldname','surfaceforcings.precipitation','timeseries',1,'NaN',1);
|
---|
[19040] | 79 | elseif(self.isdelta18o==1)
|
---|
[18984] | 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);
|
---|
[19040] | 88 | elseif(self.ismungsm==1)
|
---|
[18984] | 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);
|
---|
[17078] | 96 | end
|
---|
[18984] | 97 | end
|
---|
[17078] | 98 | end % }}}
|
---|
[19040] | 99 | function disp(self) % {{{
|
---|
[17078] | 100 | disp(sprintf(' surface forcings parameters:'));
|
---|
| 101 |
|
---|
| 102 | disp(sprintf('\n PDD and deltaO18 parameters:'));
|
---|
[19040] | 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]');
|
---|
[19200] | 110 | if(self.isdelta18o==0 & self.ismungsm==0)
|
---|
[19040] | 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, 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');
|
---|
[19200] | 118 | fielddisplay(self,'precipitations_presentday','monthly surface precipitation [m/yr water eq], required if delta18o/mungsm is activated');
|
---|
[19172] | 119 | fielddisplay(self,'precipitations_lgm','monthly surface precipitation [m/yr water eq], required if delta18o/mungsm is activated');
|
---|
[19040] | 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)
|
---|
[19200] | 123 | fielddisplay(self,'temperatures_presentday','monthly present day surface temperatures [K], required if delta18o/mungsm is activated');
|
---|
[19040] | 124 | fielddisplay(self,'temperatures_lgm','monthly LGM surface temperatures [K], required if delta18o or mungsm is activated');
|
---|
[19200] | 125 | fielddisplay(self,'precipitations_presentday','monthly surface precipitation [m/yr water eq], required if delta18o/mungsm is activated');
|
---|
[19172] | 126 | fielddisplay(self,'precipitations_lgm','monthly surface precipitation [m/yr water eq], required if delta18o/mungsm is activated');
|
---|
[19040] | 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');
|
---|
[18968] | 130 | end
|
---|
[17078] | 131 | end % }}}
|
---|
[19040] | 132 | function marshall(self,md,fid) % {{{
|
---|
[17078] | 133 |
|
---|
| 134 | yts=365.0*24.0*3600.0;
|
---|
| 135 |
|
---|
| 136 | WriteData(fid,'enum',SurfaceforcingsEnum(),'data',SMBpddEnum(),'format','Integer');
|
---|
| 137 |
|
---|
[19040] | 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');
|
---|
[18968] | 145 |
|
---|
[19200] | 146 | if(self.isdelta18o==0 & self.ismungsm==0)
|
---|
[19040] | 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 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','Tdiff','format','DoubleMat','mattype',1);
|
---|
| 158 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','sealev','format','DoubleMat','mattype',1);
|
---|
| 159 | elseif self.ismungsm
|
---|
| 160 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','temperatures_presentday','format','DoubleMat','mattype',1);
|
---|
| 161 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','temperatures_lgm','format','DoubleMat','mattype',1);
|
---|
| 162 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','precipitations_presentday','format','DoubleMat','mattype',1);
|
---|
| 163 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','precipitations_lgm','format','DoubleMat','mattype',1);
|
---|
| 164 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','Pfac','format','DoubleMat','mattype',1);
|
---|
| 165 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','Tdiff','format','DoubleMat','mattype',1);
|
---|
| 166 | WriteData(fid,'object',self,'class','surfaceforcings','fieldname','sealev','format','DoubleMat','mattype',1);
|
---|
[17078] | 167 | end
|
---|
| 168 | end % }}}
|
---|
| 169 | end
|
---|
| 170 | end
|
---|