[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;
|
---|
[18950] | 13 | rlaps = 0;
|
---|
| 14 | rlapslgm = 0;
|
---|
| 15 | Pfac = NaN;
|
---|
| 16 | Tdiff = NaN;
|
---|
| 17 | sealev = NaN;
|
---|
[17078] | 18 | isdelta18o = 0;
|
---|
| 19 | delta18o = NaN;
|
---|
| 20 | delta18o_surface = NaN;
|
---|
| 21 | temperatures_presentday = NaN;
|
---|
| 22 | temperatures_lgm = NaN;
|
---|
| 23 | precipitations_presentday = NaN;
|
---|
[18950] | 24 | precipitations_lgm = NaN;
|
---|
[17078] | 25 | end
|
---|
| 26 | methods
|
---|
| 27 | function obj = SMBpdd(varargin) % {{{
|
---|
| 28 | switch nargin
|
---|
| 29 | case 0
|
---|
| 30 | obj=setdefaultparameters(obj);
|
---|
| 31 | otherwise
|
---|
| 32 | error('constructor not supported');
|
---|
| 33 | end
|
---|
| 34 | end % }}}
|
---|
[17079] | 35 | function self = extrude(self,md) % {{{
|
---|
| 36 |
|
---|
| 37 | self.precipitation=project3d(md,'vector',self.precipitation,'type','node');
|
---|
| 38 | self.monthlytemperatures=project3d(md,'vector',self.monthlytemperatures,'type','node');
|
---|
| 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
|
---|
[17079] | 43 |
|
---|
| 44 |
|
---|
| 45 | end % }}}
|
---|
[17078] | 46 | function self = initialize(self,md) % {{{
|
---|
| 47 |
|
---|
| 48 | if isnan(self.precipitation),
|
---|
| 49 | self.precipitation=zeros(md.mesh.numberofvertices,1);
|
---|
| 50 | disp(' no SMBpdd.precipitation specified: values set as zero');
|
---|
| 51 | end
|
---|
| 52 |
|
---|
| 53 | end % }}}
|
---|
| 54 | function obj = setdefaultparameters(obj) % {{{
|
---|
| 55 |
|
---|
| 56 | obj.isdelta18o = 0;
|
---|
| 57 | obj.desfac = 0.5;
|
---|
| 58 | obj.s0p = 0;
|
---|
[18717] | 59 | obj.s0t = 0;
|
---|
| 60 | obj.rlaps = 6.5;
|
---|
| 61 | obj.rlapslgm = 6.5;
|
---|
| 62 |
|
---|
[17078] | 63 | end % }}}
|
---|
| 64 | function md = checkconsistency(obj,md,solution,analyses) % {{{
|
---|
| 65 |
|
---|
| 66 | if ismember(MasstransportAnalysisEnum(),analyses),
|
---|
| 67 | md = checkfield(md,'fieldname','surfaceforcings.desfac','<=',1,'numel',1);
|
---|
| 68 | md = checkfield(md,'fieldname','surfaceforcings.s0p','>=',0,'numel',1);
|
---|
[18717] | 69 | md = checkfield(md,'fieldname','surfaceforcings.s0t','>=',0,'numel',1);
|
---|
| 70 | md = checkfield(md,'fieldname','surfaceforcings.rlaps','>=',0,'numel',1);
|
---|
| 71 | md = checkfield(md,'fieldname','surfaceforcings.rlapslgm','>=',0,'numel',1);
|
---|
[18724] | 72 | md = checkfield(md,'fieldname','surfaceforcings.Pfac','NaN',1,'size',[2,NaN]);
|
---|
| 73 | md = checkfield(md,'fieldname','surfaceforcings.Tdiff','NaN',1,'size',[2,NaN]);
|
---|
| 74 | md = checkfield(md,'fieldname','surfaceforcings.sealev','NaN',1,'size',[2,NaN]);
|
---|
[17078] | 75 | if(obj.isdelta18o==0)
|
---|
| 76 | md = checkfield(md,'fieldname','surfaceforcings.monthlytemperatures','forcing',1,'NaN',1);
|
---|
| 77 | md = checkfield(md,'fieldname','surfaceforcings.precipitation','forcing',1,'NaN',1);
|
---|
| 78 | else
|
---|
| 79 | md = checkfield(md,'fieldname','surfaceforcings.delta18o','NaN',1);
|
---|
| 80 | md = checkfield(md,'fieldname','surfaceforcings.delta18o_surface','NaN',1);
|
---|
| 81 | md = checkfield(md,'fieldname','surfaceforcings.temperatures_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1);
|
---|
| 82 | md = checkfield(md,'fieldname','surfaceforcings.temperatures_lgm','size',[md.mesh.numberofvertices+1 12],'NaN',1);
|
---|
| 83 | md = checkfield(md,'fieldname','surfaceforcings.precipitations_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1);
|
---|
[18950] | 84 | md = checkfield(md,'fieldname','surfaceforcings.precipitations_lgm','size',[md.mesh.numberofvertices+1 12],'NaN',1);
|
---|
[17078] | 85 | end
|
---|
| 86 | end
|
---|
| 87 | end % }}}
|
---|
| 88 | function disp(obj) % {{{
|
---|
| 89 | disp(sprintf(' surface forcings parameters:'));
|
---|
| 90 |
|
---|
| 91 | disp(sprintf('\n PDD and deltaO18 parameters:'));
|
---|
| 92 | fielddisplay(obj,'isdelta18o','is temperature and precipitation delta18o parametrisation activated (0 or 1, default is 0)');
|
---|
| 93 | fielddisplay(obj,'desfac','desertification elevation factor (between 0 and 1, default is 0.5) [m]');
|
---|
| 94 | fielddisplay(obj,'s0p','should be set to elevation from precip source (between 0 and a few 1000s m, default is 0) [m]');
|
---|
[18717] | 95 | fielddisplay(obj,'s0t','should be set to elevation from temperature source (between 0 and a few 1000s m, default is 0) [m]');
|
---|
| 96 | fielddisplay(obj,'rlaps','present day lapse rate [degree/km]');
|
---|
| 97 | fielddisplay(obj,'rlapslgm','LGM lapse rate [degree/km]');
|
---|
| 98 | fielddisplay(obj,'Pfac','time interpolation parameter for precipitation, 1D(year)');
|
---|
| 99 | fielddisplay(obj,'Tdiff','time interpolation parameter for temperature, 1D(year)');
|
---|
| 100 | fielddisplay(obj,'sealev','sea level [m], 1D(year)');
|
---|
[18950] | 101 | fielddisplay(obj,'monthlytemperatures',['CURRENTLY NOT USED monthly surface temperatures [K], required if pdd is activated and delta18o not activated']);
|
---|
| 102 | fielddisplay(obj,'precipitation',['CURRENTLY NOT USED monthly surface precipitation [m/yr water eq]']);
|
---|
[17078] | 103 | fielddisplay(obj,'temperatures_presentday','monthly present day surface temperatures [K], required if pdd is activated and delta18o activated');
|
---|
| 104 | fielddisplay(obj,'temperatures_lgm','monthly LGM surface temperatures [K], required if pdd is activated and delta18o activated');
|
---|
| 105 | fielddisplay(obj,'precipitations_presentday','monthly surface precipitation [m/yr water eq], required if pdd is activated and delta18o activated');
|
---|
[18950] | 106 | fielddisplay(obj,'precipitations_lgm','monthly surface precipitation [m/yr water eq], required if pdd is activated and delta18o activated');
|
---|
[17078] | 107 | fielddisplay(obj,'delta18o','delta18o, required if pdd is activated and delta18o activated');
|
---|
| 108 | fielddisplay(obj,'delta18o_surface','surface elevation of the delta18o site, required if pdd is activated and delta18o activated');
|
---|
| 109 |
|
---|
| 110 | end % }}}
|
---|
| 111 | function marshall(obj,md,fid) % {{{
|
---|
| 112 |
|
---|
| 113 | yts=365.0*24.0*3600.0;
|
---|
| 114 |
|
---|
| 115 | WriteData(fid,'enum',SurfaceforcingsEnum(),'data',SMBpddEnum(),'format','Integer');
|
---|
| 116 |
|
---|
| 117 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','precipitation','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1);
|
---|
| 118 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','desfac','format','Double');
|
---|
| 119 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','s0p','format','Double');
|
---|
[18717] | 120 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','s0t','format','Double');
|
---|
| 121 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','rlaps','format','Double');
|
---|
| 122 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','rlapslgm','format','Double');
|
---|
[18728] | 123 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','Pfac','format','DoubleMat','mattype',1);
|
---|
| 124 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','Tdiff','format','DoubleMat','mattype',1);
|
---|
| 125 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','sealev','format','DoubleMat','mattype',1);
|
---|
[17078] | 126 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','isdelta18o','format','Boolean');
|
---|
| 127 | if obj.isdelta18o
|
---|
| 128 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','temperatures_presentday','format','DoubleMat','mattype',1);
|
---|
| 129 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','temperatures_lgm','format','DoubleMat','mattype',1);
|
---|
| 130 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','precipitations_presentday','format','DoubleMat','mattype',1);
|
---|
[18950] | 131 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','precipitations_lgm','format','DoubleMat','mattype',1);
|
---|
[17078] | 132 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','delta18o_surface','format','DoubleMat','mattype',1);
|
---|
| 133 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','delta18o','format','DoubleMat','mattype',1);
|
---|
| 134 | else
|
---|
| 135 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','monthlytemperatures','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1);
|
---|
| 136 | end
|
---|
| 137 | end % }}}
|
---|
| 138 | end
|
---|
| 139 | end
|
---|