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