[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;
|
---|
| 10 | desfac = 0.5;
|
---|
| 11 | s0p = 0;
|
---|
| 12 | isdelta18o = 0;
|
---|
| 13 | delta18o = NaN;
|
---|
| 14 | delta18o_surface = NaN;
|
---|
| 15 | temperatures_presentday = NaN;
|
---|
| 16 | temperatures_lgm = NaN;
|
---|
| 17 | precipitations_presentday = NaN;
|
---|
| 18 | end
|
---|
| 19 | methods
|
---|
| 20 | function obj = SMBpdd(varargin) % {{{
|
---|
| 21 | switch nargin
|
---|
| 22 | case 0
|
---|
| 23 | obj=setdefaultparameters(obj);
|
---|
| 24 | otherwise
|
---|
| 25 | error('constructor not supported');
|
---|
| 26 | end
|
---|
| 27 | end % }}}
|
---|
[17079] | 28 | function self = extrude(self,md) % {{{
|
---|
| 29 |
|
---|
| 30 | self.precipitation=project3d(md,'vector',self.precipitation,'type','node');
|
---|
| 31 | self.monthlytemperatures=project3d(md,'vector',self.monthlytemperatures,'type','node');
|
---|
| 32 | if(self.isdelta18o),self.temperatures_lgm=project3d(md,'vector',self.temperatures_lgm,'type','node');end
|
---|
| 33 | if(self.isdelta18o),self.temperatures_presentday=project3d(md,'vector',self.temperatures_presentday,'type','node');end
|
---|
| 34 | if(self.isdelta18o),self.precipitations_presentday=project3d(md,'vector',self.precipitations_presentday,'type','node');end
|
---|
| 35 |
|
---|
| 36 |
|
---|
| 37 | end % }}}
|
---|
[17078] | 38 | function self = initialize(self,md) % {{{
|
---|
| 39 |
|
---|
| 40 | if isnan(self.precipitation),
|
---|
| 41 | self.precipitation=zeros(md.mesh.numberofvertices,1);
|
---|
| 42 | disp(' no SMBpdd.precipitation specified: values set as zero');
|
---|
| 43 | end
|
---|
| 44 |
|
---|
| 45 | end % }}}
|
---|
| 46 | function obj = setdefaultparameters(obj) % {{{
|
---|
| 47 |
|
---|
| 48 | obj.isdelta18o = 0;
|
---|
| 49 | obj.desfac = 0.5;
|
---|
| 50 | obj.s0p = 0;
|
---|
| 51 | end % }}}
|
---|
| 52 | function md = checkconsistency(obj,md,solution,analyses) % {{{
|
---|
| 53 |
|
---|
| 54 | if ismember(MasstransportAnalysisEnum(),analyses),
|
---|
| 55 | md = checkfield(md,'fieldname','surfaceforcings.desfac','<=',1,'numel',1);
|
---|
| 56 | md = checkfield(md,'fieldname','surfaceforcings.s0p','>=',0,'numel',1);
|
---|
| 57 | if(obj.isdelta18o==0)
|
---|
| 58 | md = checkfield(md,'fieldname','surfaceforcings.monthlytemperatures','forcing',1,'NaN',1);
|
---|
| 59 | md = checkfield(md,'fieldname','surfaceforcings.precipitation','forcing',1,'NaN',1);
|
---|
| 60 | else
|
---|
| 61 | md = checkfield(md,'fieldname','surfaceforcings.delta18o','NaN',1);
|
---|
| 62 | md = checkfield(md,'fieldname','surfaceforcings.delta18o_surface','NaN',1);
|
---|
| 63 | md = checkfield(md,'fieldname','surfaceforcings.temperatures_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1);
|
---|
| 64 | md = checkfield(md,'fieldname','surfaceforcings.temperatures_lgm','size',[md.mesh.numberofvertices+1 12],'NaN',1);
|
---|
| 65 | md = checkfield(md,'fieldname','surfaceforcings.precipitations_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1);
|
---|
| 66 | end
|
---|
| 67 | end
|
---|
| 68 | end % }}}
|
---|
| 69 | function disp(obj) % {{{
|
---|
| 70 | disp(sprintf(' surface forcings parameters:'));
|
---|
| 71 |
|
---|
| 72 | disp(sprintf('\n PDD and deltaO18 parameters:'));
|
---|
| 73 | fielddisplay(obj,'isdelta18o','is temperature and precipitation delta18o parametrisation activated (0 or 1, default is 0)');
|
---|
| 74 | fielddisplay(obj,'desfac','desertification elevation factor (between 0 and 1, default is 0.5) [m]');
|
---|
| 75 | fielddisplay(obj,'s0p','should be set to elevation from precip source (between 0 and a few 1000s m, default is 0) [m]');
|
---|
| 76 | fielddisplay(obj,'monthlytemperatures','monthly surface temperatures [K], required if pdd is activated and delta18o not activated');
|
---|
| 77 | fielddisplay(obj,'precipitation','surface precipitation [m/yr water eq]');
|
---|
| 78 | fielddisplay(obj,'temperatures_presentday','monthly present day surface temperatures [K], required if pdd is activated and delta18o activated');
|
---|
| 79 | fielddisplay(obj,'temperatures_lgm','monthly LGM surface temperatures [K], required if pdd is activated and delta18o activated');
|
---|
| 80 | fielddisplay(obj,'precipitations_presentday','monthly surface precipitation [m/yr water eq], required if pdd is activated and delta18o activated');
|
---|
| 81 | fielddisplay(obj,'delta18o','delta18o, required if pdd is activated and delta18o activated');
|
---|
| 82 | fielddisplay(obj,'delta18o_surface','surface elevation of the delta18o site, required if pdd is activated and delta18o activated');
|
---|
| 83 |
|
---|
| 84 | end % }}}
|
---|
| 85 | function marshall(obj,md,fid) % {{{
|
---|
| 86 |
|
---|
| 87 | yts=365.0*24.0*3600.0;
|
---|
| 88 |
|
---|
| 89 | WriteData(fid,'enum',SurfaceforcingsEnum(),'data',SMBpddEnum(),'format','Integer');
|
---|
| 90 |
|
---|
| 91 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','precipitation','format','DoubleMat','mattype',1,'scale',1./yts,'forcinglength',md.mesh.numberofvertices+1);
|
---|
| 92 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','desfac','format','Double');
|
---|
| 93 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','s0p','format','Double');
|
---|
| 94 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','isdelta18o','format','Boolean');
|
---|
| 95 | if obj.isdelta18o
|
---|
| 96 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','temperatures_presentday','format','DoubleMat','mattype',1);
|
---|
| 97 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','temperatures_lgm','format','DoubleMat','mattype',1);
|
---|
| 98 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','precipitations_presentday','format','DoubleMat','mattype',1);
|
---|
| 99 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','delta18o_surface','format','DoubleMat','mattype',1);
|
---|
| 100 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','delta18o','format','DoubleMat','mattype',1);
|
---|
| 101 | else
|
---|
| 102 | WriteData(fid,'object',obj,'class','surfaceforcings','fieldname','monthlytemperatures','format','DoubleMat','mattype',1,'forcinglength',md.mesh.numberofvertices+1);
|
---|
| 103 | end
|
---|
| 104 | end % }}}
|
---|
| 105 | end
|
---|
| 106 | end
|
---|