[26252] | 1 | %MISFIT class definition
|
---|
| 2 | %
|
---|
| 3 | % Usage:
|
---|
| 4 | % cflevelsetmisfit=cflevelsetmisfit();
|
---|
| 5 | % cflevelsetmisfit=cflevelsetmisfit('name','CalvingFrontPosition',...
|
---|
| 6 | % 'definitionstring','Outputdefinition1',...
|
---|
| 7 | % 'model_string','MaskIceLevelset',...
|
---|
| 8 | % 'observation_string','LevelsetObservations',...
|
---|
| 9 | % 'observation',md.mask.ice_levelset,...
|
---|
| 10 | % 'weights',ones(md.mesh.numberofvertices,1),...
|
---|
| 11 | % 'weights_string','WeightsLevelsetObservations',...
|
---|
| 12 | % 'datatime',time);
|
---|
| 13 | %
|
---|
| 14 | %
|
---|
| 15 |
|
---|
| 16 | classdef cflevelsetmisfit
|
---|
| 17 | properties (SetAccess=public)
|
---|
| 18 | %cflevelsetmisfit
|
---|
| 19 | name = '';
|
---|
| 20 | definitionstring = ''; %string that identifies this output definition uniquely, from 'Outputdefinition[1-100]'
|
---|
| 21 | model_string = ''; %string for field that is modeled
|
---|
| 22 | observation = NaN; %observed field that we compare the model against
|
---|
| 23 | observation_string = ''; %string for observed field.
|
---|
| 24 | weights = NaN; %weight coefficients for every vertex
|
---|
| 25 | weights_string = ''; %string to identify this particular set of weights
|
---|
| 26 | datatime = 0; %time in years from start that the data is from
|
---|
| 27 | cumulated = NaN; %do we cumulate cflevelsetmisfit through time?
|
---|
| 28 | end
|
---|
| 29 |
|
---|
| 30 | methods
|
---|
| 31 | function self = extrude(self,md) % {{{
|
---|
| 32 | if ~isnan(self.weights)
|
---|
| 33 | self.weights=project3d(md,'vector',self.weights,'type','node');
|
---|
| 34 | end
|
---|
| 35 | if ~isnan(self.observation)
|
---|
| 36 | self.observation=project3d(md,'vector',self.observation,'type','node');
|
---|
| 37 | end
|
---|
| 38 | end % }}}
|
---|
| 39 | function self = cflevelsetmisfit(varargin) % {{{
|
---|
| 40 | if nargin==0,
|
---|
| 41 | self=setdefaultparameters(self);
|
---|
| 42 | else
|
---|
| 43 | %use provided options to change fields
|
---|
| 44 | options=pairoptions(varargin{:});
|
---|
| 45 |
|
---|
| 46 | %get name
|
---|
| 47 | self.name=getfieldvalue(options,'name','');
|
---|
| 48 | self.definitionstring=getfieldvalue(options,'definitionstring');
|
---|
| 49 | self.model_string=getfieldvalue(options,'model_string');
|
---|
| 50 | self.observation=getfieldvalue(options,'observation',NaN);
|
---|
| 51 | self.observation_string=getfieldvalue(options,'observation_string');
|
---|
| 52 | self.weights=getfieldvalue(options,'weights',NaN);
|
---|
| 53 | self.weights_string=getfieldvalue(options,'weights_string','');
|
---|
| 54 | self.datatime = getfieldvalue(options, 'datatime');
|
---|
| 55 |
|
---|
| 56 | end
|
---|
| 57 | end % }}}
|
---|
| 58 | function self = setdefaultparameters(self) % {{{
|
---|
| 59 | self.datatime = 0;
|
---|
| 60 | end % }}}
|
---|
| 61 | function md = checkconsistency(self,md,solution,analyses) % {{{
|
---|
| 62 |
|
---|
| 63 | if ~ischar(self.name),
|
---|
| 64 | error('cflevelsetmisfit error message: ''name'' field should be a string!');
|
---|
| 65 | end
|
---|
| 66 | OutputdefinitionStringArray={};
|
---|
| 67 | for i=1:100
|
---|
| 68 | OutputdefinitionStringArray{i}=strcat('Outputdefinition',num2str(i));
|
---|
| 69 | end
|
---|
| 70 | md = checkfield(md,'fieldname','self.definitionstring','field',self.definitionstring,'values',OutputdefinitionStringArray);
|
---|
| 71 |
|
---|
| 72 | md = checkfield(md,'fieldname','self.observation','field',self.observation,'timeseries',1,'NaN',1,'Inf',1);
|
---|
| 73 | md = checkfield(md,'fieldname','self.weights','field',self.weights,'timeseries',1,'NaN',1,'Inf',1);
|
---|
| 74 | md = checkfield(md,'fieldname','self.datatime','field',self.datatime,'<=',md.timestepping.final_time);
|
---|
| 75 |
|
---|
| 76 | end % }}}
|
---|
| 77 | function md = disp(self) % {{{
|
---|
| 78 |
|
---|
| 79 | disp(sprintf(' TimeMisfit:\n'));
|
---|
| 80 |
|
---|
| 81 | fielddisplay(self,'name','identifier for this cflevelsetmisfit response');
|
---|
| 82 | fielddisplay(self,'definitionstring','string that identifies this output definition uniquely, from ''Outputdefinition[1-10]''');
|
---|
| 83 | fielddisplay(self,'model_string','string for field that is modeled');
|
---|
| 84 | fielddisplay(self,'observation','observed field that we compare the model against');
|
---|
| 85 | fielddisplay(self,'observation_string','observation string');
|
---|
| 86 | fielddisplay(self,'weights','weights (at vertices) to apply to the cflevelsetmisfit');
|
---|
| 87 | fielddisplay(self,'weights_string','string for weights for identification purposes');
|
---|
| 88 | fielddisplay(self,'datatime','time to compare data to model for misfit');
|
---|
| 89 |
|
---|
| 90 | end % }}}
|
---|
| 91 | function md = marshall(self,prefix,md,fid) % {{{
|
---|
| 92 |
|
---|
| 93 | WriteData(fid,prefix,'data',self.name,'name','md.cflevelsetmisfit.name','format','String');
|
---|
| 94 | WriteData(fid,prefix,'data',self.definitionstring,'name','md.cflevelsetmisfit.definitionstring','format','String');
|
---|
| 95 | WriteData(fid,prefix,'data',self.model_string,'name','md.cflevelsetmisfit.model_string','format','String');
|
---|
| 96 | WriteData(fid,prefix,'data',self.observation,'name','md.cflevelsetmisfit.observation','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
|
---|
| 97 | WriteData(fid,prefix,'data',self.observation_string,'name','md.cflevelsetmisfit.observation_string','format','String');
|
---|
| 98 | WriteData(fid,prefix,'data',self.weights,'name','md.cflevelsetmisfit.weights','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
|
---|
| 99 | WriteData(fid,prefix,'data',self.weights_string,'name','md.cflevelsetmisfit.weights_string','format','String');
|
---|
| 100 | WriteData(fid,prefix,'data',round(self.datatime*md.constants.yts),'name','md.cflevelsetmisfit.datatime','format','Double');
|
---|
| 101 | end % }}}
|
---|
| 102 | end
|
---|
| 103 | end
|
---|