source: issm/trunk-jpl/src/m/contrib/larour/mdanalysis.m@ 27796

Last change on this file since 27796 was 27796, checked in by jdquinn, 21 months ago

CHG: Typos; cleanup

File size: 54.9 KB
Line 
1function varargout = mdanalysis(varargin)
2% MDANALYSIS MATLAB code for mdanalysis.fig {{{
3% MDANALYSIS, by itself, creates a new MDANALYSIS or raises the existing
4% singleton*.
5%
6% H = MDANALYSIS returns the handle to a new MDANALYSIS or the handle to
7% the existing singleton*.
8%
9% MDANALYSIS('CALLBACK',hObject,eventData,handles,...) calls the local
10% function named CALLBACK in MDANALYSIS.M with the given input arguments.
11%
12% MDANALYSIS('Property','Value',...) creates a new MDANALYSIS or raises the
13% existing singleton*. Starting from the left, property value pairs are
14% applied to the GUI before mdanalysis_OpeningFcn gets called. An
15% unrecognized property name or invalid value makes property application
16% stop. All inputs are passed to mdanalysis_OpeningFcn via varargin.
17%
18% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
19% instance to run (singleton)".
20%
21% See also: GUIDE, GUIDATA, GUIHANDLES
22%variables: }}}
23%global variables: %{{{
24global md modelname
25if strcmpi(class(varargin{1}),'model') | strcmpi(class(varargin{1}),'sealevelmodel'),
26 md=varargin{1};
27 modelname=inputname(1);
28end
29
30global logvalue
31global solutiontype
32global comparison
33global reload
34global earth
35global whores
36%}}}
37%Initialization code{{{
38% Begin initialization code - DO NOT EDIT
39gui_Singleton = 1;
40gui_State = struct('gui_Name', mfilename, ...
41 'gui_Singleton', gui_Singleton, ...
42 'gui_OpeningFcn', @mdanalysis_OpeningFcn, ...
43 'gui_OutputFcn', @mdanalysis_OutputFcn, ...
44 'gui_LayoutFcn', [] , ...
45 'gui_Callback', []);
46if nargin && ischar(varargin{1})
47 gui_State.gui_Callback = str2func(varargin{1});
48end
49
50if nargout
51 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
52else
53 gui_mainfcn(gui_State, varargin{:});
54end
55% End initialization code - DO NOT EDIT
56
57
58% --- Executes just before mdanalysis is made visible.
59function mdanalysis_OpeningFcn(hObject, eventdata, handles, varargin)
60global md comparison logvalue solutiontype
61% This function has no output args, see OutputFcn.
62% hObject handle to figure
63% eventdata reserved - to be defined in a future version of MATLAB
64% handles structure with handles and user data (see GUIDATA)
65% varargin command line arguments to mdanalysis (see VARARGIN)
66
67% Choose default command line output for mdanalysis
68handles.output = hObject;
69
70% Update handles structure
71guidata(hObject, handles);
72
73% This sets up the initial plot - only do when we are invisible
74% so window can get raised using mdanalysis.
75if strcmp(get(hObject,'Visible'),'off')
76 comparison=0;
77 logvalue=0;
78 reload=0;
79 plotm();
80end
81
82% UIWAIT makes mdanalysis wait for user response (see UIRESUME)
83% uiwait(handles.figure1);
84
85
86% --- Outputs from this function are returned to the command line.
87function varargout = mdanalysis_OutputFcn(hObject, eventdata, handles)
88% varargout cell array for returning output args (see VARARGOUT);
89% hObject handle to figure
90% eventdata reserved - to be defined in a future version of MATLAB
91% handles structure with handles and user data (see GUIDATA)
92
93% Get default command line output from handles structure
94varargout{1} = handles.output;
95%}}}
96%Interp faceting {{{
97% --- Executes on button press in Interp.
98function Interp_Callback(hObject, eventdata, handles)
99% hObject handle to Interp (see GCBO)
100% eventdata reserved - to be defined in a future version of MATLAB
101% handles structure with handles and user data (see GUIDATA)
102plotm();
103% Hint: get(hObject,'Value') returns toggle state of Interp
104
105% --- If Enable == 'on', executes on mouse press in 5 pixel border.
106% --- Otherwise, executes on mouse press in 5 pixel border or over Interp.
107function Interp_ButtonDownFcn(hObject, eventdata, handles)
108% hObject handle to Interp (see GCBO)
109% eventdata reserved - to be defined in a future version of MATLAB
110% handles structure with handles and user data (see GUIDATA)
111% }}}
112%Faceted facting {{{
113% --- Executes on button press in Faceted.
114function Faceted_Callback(hObject, eventdata, handles)
115% hObject handle to Faceted (see GCBO)
116% eventdata reserved - to be defined in a future version of MATLAB
117% handles structure with handles and user data (see GUIDATA)
118plotm();
119% Hint: get(hObject,'Value') returns toggle state of Faceted
120
121% --- If Enable == 'on', executes on mouse press in 5 pixel border.
122% --- Otherwise, executes on mouse press in 5 pixel border or over Faceted.
123function Faceted_ButtonDownFcn(hObject, eventdata, handles)
124% hObject handle to Faceted (see GCBO)
125% eventdata reserved - to be defined in a future version of MATLAB
126% handles structure with handles and user data (see GUIDATA)
127%}}}
128%Flat faceting {{{
129% --- Executes on button press in Flat.
130function Flat_Callback(hObject, eventdata, handles)
131% hObject handle to Flat (see GCBO)
132% eventdata reserved - to be defined in a future version of MATLAB
133% handles structure with handles and user data (see GUIDATA)
134plotm();
135% Hint: get(hObject,'Value') returns toggle state of Flat
136
137% --- If Enable == 'on', executes on mouse press in 5 pixel border.
138% --- Otherwise, executes on mouse press in 5 pixel border or over Flat.
139function Flat_ButtonDownFcn(hObject, eventdata, handles)
140% hObject handle to Flat (see GCBO)
141% eventdata reserved - to be defined in a future version of MATLAB
142% handles structure with handles and user data (see GUIDATA)
143%}}}
144%Step {{{
145% --- Executes on selection change in Step.
146function Step_Callback(hObject, eventdata, handles)
147global grounded ice logvalue
148% hObject handle to Step (see GCBO)
149% eventdata reserved - to be defined in a future version of MATLAB
150% handles structure with handles and user data (see GUIDATA)
151plotm();
152
153% Hints: contents = cellstr(get(hObject,'String')) returns Step contents as cell array
154% contents{get(hObject,'Value')} returns selected item from Step
155
156% --- Executes during object creation, after setting all properties.
157function Step_CreateFcn(hObject, eventdata, handles)
158global md grounded ice logvalue
159% hObject handle to Step (see GCBO)
160% eventdata reserved - to be defined in a future version of MATLAB
161% handles empty - handles not created until after all CreateFcns called
162if issealevel(), if isearth, results=md.earth.results; else results=md.icecaps{1}.results; end; else results=md.results; end;
163if isfield(results,'TransientSolution'),
164 strings=cell(length(results.TransientSolution),1);
165 for i=1:length(results.TransientSolution),
166 strings{i}=sprintf('%4.2f (%i)',results.TransientSolution(i).time,i);
167 end
168 if length(strings)>40,
169 %too many strings, reduce!
170 lt=length(strings);
171 modlt=floor(lt/40);
172 strings=strings(1:modlt:end);
173 end
174 set(hObject,'String',strings);
175 set(hObject,'Value',1);
176else
177 set(hObject,'String',{});
178 set(hObject,'Value',1);
179end
180% Hint: popupmenu controls usually have a white background on Windows.
181% See ISPC and COMPUTER.
182if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
183 set(hObject,'BackgroundColor','white');
184end
185%}}}
186%Log {{{
187% --- Executes on button press in Log.
188function Log_Callback(hObject, eventdata, handles)
189global grounded ice logvalue
190% hObject handle to Log (see GCBO)
191% eventdata reserved - to be defined in a future version of MATLAB
192% handles structure with handles and user data (see GUIDATA)
193plotm();
194% Hint: get(hObject,'Value') returns toggle state of Log
195
196% --- Executes on button press in Lock.
197function Lock_Callback(hObject, eventdata, handles)
198% hObject handle to Lock (see GCBO)
199% eventdata reserved - to be defined in a future version of MATLAB
200% handles structure with handles and user data (see GUIDATA)
201plotm();
202% Hint: get(hObject,'Value') returns toggle state of Lock
203% }}}
204%Collock: not sure whether that one is working anymore: {{{
205% --- Executes on button press in Collock.
206function Collock_Callback(hObject, eventdata, handles)
207% hObject handle to Collock (see GCBO)
208% eventdata reserved - to be defined in a future version of MATLAB
209% handles structure with handles and user data (see GUIDATA)
210plotm();
211% Hint: get(hObject,'Value') returns toggle state of Collock
212% }}}
213%Field {{{
214% --- Executes on selection change in Field.
215function Field_Callback(hObject, eventdata, handles)
216global md
217% hObject handle to Field (see GCBO)
218% eventdata reserved - to be defined in a future version of MATLAB
219% handles structure with handles and user data (see GUIDATA)
220
221strings=get(hObject,'String'); value=get(hObject,'Value');
222string=strings(value);
223
224if strcmpi(string,'IceVolume') | strcmpi(string,'IceVolumeAboveFloatation'),
225 plotv();
226elseif strcmpi(string,'SealevelRSLEustatic'),
227 %display directly:
228 displayscalar();
229else
230 plotm();
231end
232
233
234
235% Hints: contents = cellstr(get(hObject,'String')) returns Field contents as cell array
236% contents{get(hObject,'Value')} returns selected item from Field
237
238% --- Executes during object creation, after setting all properties.
239function Field_CreateFcn(hObject, eventdata, handles)
240global md
241% hObject handle to Field (see GCBO)
242% eventdata reserved - to be defined in a future version of MATLAB
243% handles empty - handles not created until after all CreateFcns called
244if issealevel(), if isearth, results=md.earth.results; else results=md.icecaps{1}.results; end; else results=md.results; end;
245if isfield(results,'TransientSolution'),
246 fields=listfields(results,'TransientSolution');
247 set(hObject,'String',fields);
248 for i=1:length(fields),
249 if ~issealevel & strcmpi(fields{i},'Vel'),
250 set(hObject,'Value',i);
251 break;
252 end
253 if issealevel & isearth & strcmpi(fields{i},'Sealevel'),
254 set(hObject,'Value',i);
255 break;
256 end
257 end
258else
259 set(hObject,'String',{});
260 set(hObject,'Value',0);
261end
262
263% Hint: popupmenu controls usually have a white background on Windows.
264% See ISPC and COMPUTER.
265if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
266 set(hObject,'BackgroundColor','white');
267end
268%}}}
269%Model Loading {{{
270% --- Executes on selection change in ModelChoice.
271function ModelChoice_Callback(hObject, eventdata, handles)
272 % hObject handle to ModelChoice (see GCBO)
273 % eventdata reserved - to be defined in a future version of MATLAB
274 % handles structure with handles and user data (see GUIDATA)
275
276 % Hints: contents = cellstr(get(hObject,'String')) returns ModelChoice contents as cell array
277 % contents{get(hObject,'Value')} returns selected item from ModelChoice
278 global modelname md whores
279
280 %figure out which model is being loaded:
281 strings=cellstr(get(hObject,'String'));
282 counter=get(hObject,'Value');
283 string=strings{counter};
284 counter=findstr(string,'(');
285 newmodelname=string(1:counter-2);
286
287 %load model from base workspace:
288 md= evalin('base', newmodelname);
289
290 %replot:
291 h = findobj('Tag','Field');
292 Field_Callback(h,eventdata,handles);
293
294
295 %eval([newmodelname '=md;']);
296 %close gcbf;
297 %eval(['mdanalysis(' newmodelname ');']);
298
299% --- Executes during object creation, after setting all properties.
300function ModelChoice_CreateFcn(hObject, eventdata, handles)
301% hObject handle to ModelChoice (see GCBO)
302% eventdata reserved - to be defined in a future version of MATLAB
303% handles empty - handles not created until after all CreateFcns called
304global modelname
305
306
307%figure out how many models are in the workspace!
308whores=evalin('base','whos');
309flags=zeros(length(whores),1);
310for i=1:length(whores),
311 if strcmpi(whores(i).class,'model') | strcmpi(whores(i).class,'sealevelmodel'),
312 flags(i)=1;
313 end
314end
315pos=find(flags);
316whores=whores(pos);
317
318strings={};
319for i=1:length(whores),
320 strings{end+1}=[whores(i).name ' (' whores(i).class ')'];
321end
322
323%match with varargin{1}'s name:
324counter=-1;
325for i=1:length(strings),
326 if strcmpi(modelname,whores(i).name),
327 counter=i;
328 break;
329 end
330end
331if counter==-1,
332 error('could not find input model name matching base workspace names!');
333end
334
335set(hObject,'String',strings);
336set(hObject,'Value',counter);
337
338
339% Hint: popupmenu controls usually have a white background on Windows.
340% See ISPC and COMPUTER.
341if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
342 set(hObject,'BackgroundColor','white');
343end
344
345%}}}
346%Cmin {{{
347function Cmin_Callback(hObject, eventdata, handles)
348% hObject handle to Cmin (see GCBO)
349% eventdata reserved - to be defined in a future version of MATLAB
350% handles structure with handles and user data (see GUIDATA)
351plotm();
352% Hints: get(hObject,'String') returns contents of Cmin as text
353% str2double(get(hObject,'String')) returns contents of Cmin as a double
354
355
356% --- Executes during object creation, after setting all properties.
357function Cmin_CreateFcn(hObject, eventdata, handles)
358% hObject handle to Cmin (see GCBO)
359% eventdata reserved - to be defined in a future version of MATLAB
360% handles empty - handles not created until after all CreateFcns called
361set(hObject,'String',num2str(NaN));
362% Hint: edit controls usually have a white background on Windows.
363% See ISPC and COMPUTER.
364if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
365 set(hObject,'BackgroundColor','white');
366end
367%}}}
368%Cmax {{{
369function Cmax_Callback(hObject, eventdata, handles)
370% hObject handle to Cmax (see GCBO)
371% eventdata reserved - to be defined in a future version of MATLAB
372% handles structure with handles and user data (see GUIDATA)
373
374% Hints: get(hObject,'String') returns contents of Cmax as text
375% str2double(get(hObject,'String')) returns contents of Cmax as a double
376plotm();
377
378% --- Executes during object creation, after setting all properties.
379function Cmax_CreateFcn(hObject, eventdata, handles)
380% hObject handle to Cmax (see GCBO)
381% eventdata reserved - to be defined in a future version of MATLAB
382% handles empty - handles not created until after all CreateFcns called
383set(hObject,'String',num2str(NaN));
384% Hint: edit controls usually have a white background on Windows.
385% See ISPC and COMPUTER.
386if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
387 set(hObject,'BackgroundColor','white');
388end
389%}}}
390%Xmin {{{
391function xmin_Callback(hObject, eventdata, handles)
392% hObject handle to xmin (see GCBO)
393% eventdata reserved - to be defined in a future version of MATLAB
394% handles structure with handles and user data (see GUIDATA)
395
396% Hints: get(hObject,'String') returns contents of xmin as text
397% str2double(get(hObject,'String')) returns contents of xmin as a double
398
399% --- Executes during object creation, after setting all properties.
400function xmin_CreateFcn(hObject, eventdata, handles)
401% hObject handle to xmin (see GCBO)
402% eventdata reserved - to be defined in a future version of MATLAB
403% handles empty - handles not created until after all CreateFcns called
404
405% Hint: edit controls usually have a white background on Windows.
406% See ISPC and COMPUTER.
407if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
408 set(hObject,'BackgroundColor','white');
409end
410%}}}
411%Xmax {{{
412function xmax_Callback(hObject, eventdata, handles)
413% hObject handle to xmax (see GCBO)
414% eventdata reserved - to be defined in a future version of MATLAB
415% handles structure with handles and user data (see GUIDATA)
416% Hints: get(hObject,'String') returns contents of xmax as text
417% str2double(get(hObject,'String')) returns contents of xmax as a double
418
419% --- Executes during object creation, after setting all properties.
420function xmax_CreateFcn(hObject, eventdata, handles)
421% hObject handle to xmax (see GCBO)
422% eventdata reserved - to be defined in a future version of MATLAB
423% handles empty - handles not created until after all CreateFcns called
424
425% Hint: edit controls usually have a white background on Windows.
426% See ISPC and COMPUTER.
427if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
428 set(hObject,'BackgroundColor','white');
429end
430% }}}
431%Ymin {{{
432function ymin_Callback(hObject, eventdata, handles)
433% hObject handle to ymin (see GCBO)
434% eventdata reserved - to be defined in a future version of MATLAB
435% handles structure with handles and user data (see GUIDATA)
436% Hints: get(hObject,'String') returns contents of ymin as text
437% str2double(get(hObject,'String')) returns contents of ymin as a double
438
439
440% --- Executes during object creation, after setting all properties.
441function ymin_CreateFcn(hObject, eventdata, handles)
442% hObject handle to ymin (see GCBO)
443% eventdata reserved - to be defined in a future version of MATLAB
444% handles empty - handles not created until after all CreateFcns called
445
446% Hint: edit controls usually have a white background on Windows.
447% See ISPC and COMPUTER.
448if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
449 set(hObject,'BackgroundColor','white');
450end
451%}}}
452%Ymax {{{
453function ymax_Callback(hObject, eventdata, handles)
454% hObject handle to ymax (see GCBO)
455% eventdata reserved - to be defined in a future version of MATLAB
456% handles structure with handles and user data (see GUIDATA)
457% Hints: get(hObject,'String') returns contents of ymax as text
458% str2double(get(hObject,'String')) returns contents of ymax as a double
459
460
461% --- Executes during object creation, after setting all properties.
462function ymax_CreateFcn(hObject, eventdata, handles)
463% hObject handle to ymax (see GCBO)
464% eventdata reserved - to be defined in a future version of MATLAB
465% handles empty - handles not created until after all CreateFcns called
466
467% Hint: edit controls usually have a white background on Windows.
468% See ISPC and COMPUTER.
469if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
470 set(hObject,'BackgroundColor','white');
471end
472%}}}
473%Time lable {{{
474function Time_Callback(hObject, eventdata, handles)
475% hObject handle to Time (see GCBO)
476% eventdata reserved - to be defined in a future version of MATLAB
477% handles structure with handles and user data (see GUIDATA)
478
479% Hints: get(hObject,'String') returns contents of Time as text
480% str2double(get(hObject,'String')) returns contents of Time as a double
481
482
483% --- Executes during object creation, after setting all properties.
484function Time_CreateFcn(hObject, eventdata, handles)
485global md
486% hObject handle to Time (see GCBO)
487% eventdata reserved - to be defined in a future version of MATLAB
488% handles empty - handles not created until after all CreateFcns called
489if issealevel, if isearth, results=md.earth.results; else results=md.icecaps{1}.results; end; else results=md.results; end;
490if isfield(results,'TransientSolution'),
491 set(hObject,'String',sprintf('%4.2f',results.TransientSolution(1).time));
492else
493 set(hObject,'String',sprintf('%4.2f',0));
494end
495% Hint: edit controls usually have a white background on Windows.
496% See ISPC and COMPUTER.
497if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
498 set(hObject,'BackgroundColor','white');
499end
500
501% --- If Enable == 'on', executes on mouse press in 5 pixel border.
502% --- Otherwise, executes on mouse press in 5 pixel border or over Time.
503function Time_ButtonDownFcn(hObject, eventdata, handles)
504% hObject handle to Time (see GCBO)
505% eventdata reserved - to be defined in a future version of MATLAB
506% handles structure with handles and user data (see GUIDATA)
507% }}}
508%Mask: {{{
509% --- Executes on selection change in Masque.
510function Masque_Callback(hObject, eventdata, handles)
511% hObject handle to Masque (see GCBO)
512% eventdata reserved - to be defined in a future version of MATLAB
513% handles structure with handles and user data (see GUIDATA)
514plotm();
515% Hints: contents = cellstr(get(hObject,'String')) returns Masque contents as cell array
516% contents{get(hObject,'Value')} returns selected item from Masque
517
518% --- Executes during object creation, after setting all properties.
519function Masque_CreateFcn(hObject, eventdata, handles)
520global md
521% hObject handle to Masque (see GCBO)
522% eventdata reserved - to be defined in a future version of MATLAB
523% handles empty - handles not created until after all CreateFcns called
524if issealevel,
525 if isearth,
526 mv=md.earth.mask;
527 else
528 mv=md.icecaps{1}.mask;
529 end
530else
531 mv=md.mask;
532end
533strings=fieldnames(mv);
534strings={'all',strings{:}};
535set(hObject,'String',strings);
536% Hint: popupmenu controls usually have a white background on Windows.
537% See ISPC and COMPUTER.
538if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
539 set(hObject,'BackgroundColor','white');
540end
541%}}}
542%DiffStep {{{
543% --- Executes on selection change in DiffStep.
544function DiffStep_Callback(hObject, eventdata, handles)
545% hObject handle to DiffStep (see GCBO)
546% eventdata reserved - to be defined in a future version of MATLAB
547% handles structure with handles and user data (see GUIDATA)
548plotm();
549
550% Hints: contents = cellstr(get(hObject,'String')) returns DiffStep contents as cell array
551% contents{get(hObject,'Value')} returns selected item from DiffStep
552
553% --- Executes during object creation, after setting all properties.
554function DiffStep_CreateFcn(hObject, eventdata, handles)
555global md ;
556% hObject handle to DiffStep (see GCBO)
557% eventdata reserved - to be defined in a future version of MATLAB
558% handles empty - handles not created until after all CreateFcns called
559if issealevel, if isearth, results=md.earth.results; else results=md.icecaps{1}.results; end; else results=md.results; end;
560if isfield(results,'TransientSolution'),
561 strings=cell(length(results.TransientSolution),1);
562 for i=1:length(results.TransientSolution),
563 strings{i}=sprintf('%4.2f (%i)',results.TransientSolution(i).time,i);
564 end
565 if length(strings)>20,
566 %too many strings, reduce!
567 lt=length(strings);
568 modlt=floor(lt/20);
569 strings=strings(1:modlt:end);
570 end
571 set(hObject,'String',strings);
572else
573 set(hObject,'String',{});
574end
575
576% Hint: popupmenu controls usually have a white background on Windows.
577% See ISPC and COMPUTER.
578if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
579 set(hObject,'BackgroundColor','white');
580end
581% --- If Enable == 'on', executes on mouse press in 5 pixel border.
582% --- Otherwise, executes on mouse press in 5 pixel border or over DiffStep.
583function DiffStep_ButtonDownFcn(hObject, eventdata, handles)
584% hObject handle to DiffStep (see GCBO)
585% eventdata reserved - to be defined in a future version of MATLAB
586% handles structure with handles and user data (see GUIDATA)
587% }}}
588%Diff button {{{
589% --- Executes on button press in Diff.
590function Diff_Callback(hObject, eventdata, handles)
591% hObject handle to Diff (see GCBO)
592% eventdata reserved - to be defined in a future version of MATLAB
593% handles structure with handles and user data (see GUIDATA)
594plotm();
595% Hint: get(hObject,'Value') returns toggle state of Diff
596
597% --- Executes during object creation, after setting all properties.
598function Diff_CreateFcn(hObject, eventdata, handles)
599% hObject handle to Diff (see GCBO)
600% eventdata reserved - to be defined in a future version of MATLAB
601% handles empty - handles not created until after all CreateFcns called
602%}}}
603%Model Fields: {{{
604% --- Executes on selection change in ModelFields.
605function ModelFields_Callback(hObject, eventdata, handles)
606% hObject handle to ModelFields (see GCBO)
607% eventdata reserved - to be defined in a future version of MATLAB
608% handles structure with handles and user data (see GUIDATA)
609plotm();
610% Hints: contents = cellstr(get(hObject,'String')) returns ModelFields contents as cell array
611% contents{get(hObject,'Value')} returns selected item from ModelFields
612
613% --- Executes during object creation, after setting all properties.
614function ModelFields_CreateFcn(hObject, eventdata, handles)
615global md
616% hObject handle to ModelFields (see GCBO)
617% eventdata reserved - to be defined in a future version of MATLAB
618% handles empty - handles not created until after all CreateFcns called
619
620
621% fields {{{
622fields={'geometry.thickness',...
623 'geometry.surface',...
624 'geometry.base',...
625 'geometry.bed',...
626 'inversion.vx_obs',...
627 'inversion.vy_obs',...
628 'inversion.vel_obs',...
629 'friction.coefficient',...
630 'materials.rheology_B',...
631 'mask.ice_levelset',...
632 'mask.groundedice_levelset',...
633 'slr.deltathickness'...
634 };
635
636 if issealevel(),
637 if isearth,
638 mask=md.earth.mask;
639 else
640 mask=md.icecaps{1}.mask;
641 end
642 else
643 mask=md.mask;
644 end
645
646 if strcmpi(class(mask),'maskpsl'),
647 fields{end+1}='mask.ocean_levelset';
648 fields{end+1}='mask.land_levelset';
649 end
650
651
652% }}}
653set(hObject,'String',fields);
654% Hint: popupmenu controls usually have a white background on Windows.
655% See ISPC and COMPUTER.
656if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
657 set(hObject,'BackgroundColor','white');
658end
659% }}}
660%Mf button: {{{
661% --- Executes on button press in Mf.
662function Mf_CreateFcn(varargin)
663function Mf_Callback(hObject, eventdata, handles)
664% hObject handle to Mf (see GCBO)
665% eventdata reserved - to be defined in a future version of MATLAB
666% handles structure with handles and user data (see GUIDATA)
667plotm();
668% Hint: get(hObject,'Value') returns toggle state of Mf
669%}}}
670%Solution menu {{{
671% --- Executes on selection change in popupmenu10.
672function popupmenu10_Callback(hObject, eventdata, handles)
673global solutiontype
674% hObject handle to popupmenu10 (see GCBO)
675% eventdata reserved - to be defined in a future version of MATLAB
676% handles structure with handles and user data (see GUIDATA)
677
678%figure out what results we are plotting here:
679value=get(hObject,'Value');
680strings=get(hObject,'String');
681solutiontype=strings(value);
682
683plotm();
684% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu10 contents as cell array
685% contents{get(hObject,'Value')} returns selected item from popupmenu10
686
687% --- Executes during object creation, after setting all properties.
688function popupmenu10_CreateFcn(hObject, eventdata, handles)
689global md solutiontype
690% hObject handle to popupmenu10 (see GCBO)
691% eventdata reserved - to be defined in a future version of MATLAB
692% handles empty - handles not created until after all CreateFcns called
693if issealevel,
694 if isearth,
695 resultfields=fieldnames(md.earth.results);
696 else
697 resultfields=fieldnames(md.icecaps{1}.results);
698 end
699else
700 resultfields=fieldnames(md.results);
701end
702if isempty(resultfields),
703 resultfields={'None'};
704end
705
706%default solution:
707for i=1:length(resultfields),
708 solutiontype=resultfields{i};
709 if strcmpi(solutiontype,'StressbalanceSolution'),
710 i0=i;
711 break;
712 elseif strcmpi(solutiontype,'StressbalanceSolution'),
713 i0=i;
714 break;
715 else
716 i0=1;
717 end
718end
719set(hObject,'String',resultfields);
720set(hObject,'Value',i0);
721
722% Hint: popupmenu controls usually have a white background on Windows.
723% See ISPC and COMPUTER.
724if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
725 set(hObject,'BackgroundColor','white');
726end
727% }}}
728%Icecaps menu: {{{
729% --- Executes on selection change in popupmenu11.
730function popupmenu11_Callback(hObject, eventdata, handles)
731global md
732% hObject handle to popupmenu11 (see GCBO)
733% eventdata reserved - to be defined in a future version of MATLAB
734% handles structure with handles and user data (see GUIDATA)
735strings=get(hObject,'String');
736value=get(hObject,'Value');
737continent=strings{value};
738
739%update basin list:
740basins=md.basinsfromcontinent(continent);
741strings={'All',basins{:}};
742obj=findobj('Tag', 'popupmenu12');
743set(obj,'String',strings');
744set(obj,'Value',1);
745
746plotm();
747% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu11 contents as cell array
748% contents{get(hObject,'Value')} returns selected item from popupmenu11
749
750
751% --- Executes during object creation, after setting all properties.
752function popupmenu11_CreateFcn(hObject, eventdata, handles)
753% hObject handle to popupmenu11 (see GCBO)
754% eventdata reserved - to be defined in a future version of MATLAB
755% handles empty - handles not created until after all CreateFcns called
756global md range;
757
758if issealevel(),
759 strings=md.continents();
760 set(hObject,'String',strings);
761 set(hObject,'Value',1);
762else
763 set(hObject,'String',{});
764 set(hObject,'Value',1);
765end
766
767
768% Hint: popupmenu controls usually have a white background on Windows.
769% See ISPC and COMPUTER.
770if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
771 set(hObject,'BackgroundColor','white');
772end
773% }}}
774%Basins menu{{{
775% --- Executes on selection change in popupmenu12.
776function popupmenu12_Callback(hObject, eventdata, handles)
777global md
778% hObject handle to popupmenu12 (see GCBO)
779% eventdata reserved - to be defined in a future version of MATLAB
780% handles structure with handles and user data (see GUIDATA)
781
782plotm();
783% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu12 contents as cell array
784% contents{get(hObject,'Value')} returns selected item from popupmenu12
785
786% --- Executes during object creation, after setting all properties.
787function popupmenu12_CreateFcn(hObject, eventdata, handles)
788global md
789% hObject handle to popupmenu12 (see GCBO)
790% eventdata reserved - to be defined in a future version of MATLAB
791% handles empty - handles not created until after all CreateFcns called
792
793if issealevel(),
794
795 %need the continent name: default first one.
796 continents=md.continents();
797 basins=md.basinsfromcontinent(continents{1});
798 strings={'All',basins{:}};
799 set(hObject,'String',strings);
800 set(hObject,'Value',1);
801else
802 set(hObject,'String',{});
803 set(hObject,'Value',1);
804end
805% Hint: popupmenu controls usually have a white background on Windows.
806% See ISPC and COMPUTER.
807if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
808 set(hObject,'BackgroundColor','white');
809end
810% }}}
811%Comparison: {{{
812
813% --- Executes on button press in radiobutton17.
814function radiobutton17_Callback(hObject, eventdata, handles)
815global comparison
816% hObject handle to radiobutton17 (see GCBO)
817% eventdata reserved - to be defined in a future version of MATLAB
818% handles structure with handles and user data (see GUIDATA)
819comparison=get(hObject,'Value');
820plotm();
821% Hint: get(hObject,'Value') returns toggle state of radiobutton17
822% }}}
823%Earth button: {{{
824
825% --- Executes on button press in radiobutton18.
826function radiobutton18_Callback(hObject, eventdata, handles)
827% hObject handle to radiobutton18 (see GCBO)
828% eventdata reserved - to be defined in a future version of MATLAB
829% handles structure with handles and user data (see GUIDATA)
830global md earth
831earth=get(hObject,'value');
832
833%Change Field:
834if issealevel, if isearth, results=md.earth.results; else results=md.icecaps{1}.results; end; else results=md.results; end;
835fieldHandle=findobj('Tag', 'Field');
836if isfield(results,'TransientSolution'),
837 fieldss=listfields(results,'TransientSolution');
838 set(fieldHandle,'String',fieldss);
839 set(fieldHandle,'Value',1);
840else
841 set(fieldHandle,'String',{});
842 set(fieldHandle,'Value',1);
843end
844
845%Change Masque:
846if issealevel,
847 if isearth,
848 mv=md.earth.mask;
849 else
850 mv=md.icecaps{1}.mask;
851 end
852else
853 mv=md.mask;
854end
855fieldHandle=findobj('Tag', 'Masque');
856strings=fieldnames(mv);
857strings={'all',strings{:}};
858set(fieldHandle,'String',strings);
859
860plotm();
861% Hint: get(hObject,'Value') returns toggle state of radiobutton18
862% --- Executes during object creation, after setting all properties.
863function radiobutton18_CreateFcn(hObject, eventdata, handles)
864% hObject handle to radiobutton18 (see GCBO)
865% eventdata reserved - to be defined in a future version of MATLAB
866% handles empty - handles not created until after all CreateFcns called
867global earth
868earth=1;
869set(hObject,'Value',earth);
870%}}}
871%Reload model: {{{
872% --- Executes on button press in pushbutton1.
873function pushbutton1_Callback(hObject, eventdata, handles)
874% hObject handle to pushbutton1 (see GCBO)
875% eventdata reserved - to be defined in a future version of MATLAB
876% handles structure with handles and user data (see GUIDATA)
877global reload
878reload=1;
879plotm();
880%}}}
881%Scalar {{{
882function Scalar_Callback(hObject, eventdata, handles)
883% hObject handle to Scalar (see GCBO)
884% eventdata reserved - to be defined in a future version of MATLAB
885% handles structure with handles and user data (see GUIDATA)
886
887% Hints: get(hObject,'String') returns contents of Scalar as text
888% str2double(get(hObject,'String')) returns contents of Scalar as a double
889
890% --- Executes during object creation, after setting all properties.
891function Scalar_CreateFcn(hObject, eventdata, handles)
892% hObject handle to Scalar (see GCBO)
893% eventdata reserved - to be defined in a future version of MATLAB
894% handles empty - handles not created until after all CreateFcns called
895
896% Hint: edit controls usually have a white background on Windows.
897% See ISPC and COMPUTER.
898
899 scalarHandle=findobj('Tag', 'Scalar');
900 set(scalarHandle,'String',sprintf('%4.2f',NaN));
901
902 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
903 set(hObject,'BackgroundColor','white');
904 end
905% }}}
906function plotv() % {{{
907 global md range
908
909 %field: % {{{
910 fieldHandle=findobj('Tag', 'Field');
911 fieldstrings=get(fieldHandle,'String');
912 fieldvalue=get(fieldHandle,'Value');
913 field=fieldstrings{fieldvalue};
914 %}}}
915 %lock limits: % {{{
916 lockHandle=findobj('Tag', 'Lock'); lockvalue=get(lockHandle,'Value');
917 if lockvalue,
918 xl=xlim; yl=ylim;
919 end
920 %}}}
921
922 cla, reset(gca);
923 hold on ;
924 if issealevel,
925 if isearth,
926 %do nothing. no ice volume.
927 else
928 dt=md.earth.timestepping.time_step*md.earth.settings.output_frequency;
929 for j=1:length(range),
930 i=range(j);
931 vols=resultstomatrix(md.icecaps{i},'TransientSolution',field);
932 if j==1,
933 volst=vols;
934 else
935 volst(1,:)=volst(1,:)+vols(1,:);
936 end
937 end
938 s1=subplot(2,1,1);
939 set(s1,'Position',[0.3300 0.6100 0.4750 0.3]);
940 plot(volst(2,:),(volst(1,:)-volst(1,1))*md.icecaps{1}.materials.rho_ice/1e12);
941 xlabel('time (yr)'); ylabel('Mass (Gt)'); colorbar off;
942 if lockvalue, xlim(xl), ylim(yl); end
943
944 s2=subplot(2,1,2);
945 set(s2,'Position',[0.3300 0.1100 0.4750 0.3]);
946 dv=diff(volst(1,:))/dt;
947 plot(volst(2,1:end-1),dv*md.icecaps{1}.materials.rho_ice/1e12);
948 xlabel('time (yr)'); ylabel('Mass (Gt)'); colorbar off;
949 if lockvalue, xlim(xl), ylim(yl); end
950 end
951 else
952 dt=md.timestepping.time_step*md.settings.output_frequency;
953 vols=resultstomatrix(md,'TransientSolution',field);
954 dv=diff(vols(1,:))/dt;
955
956 s1=subplot(2,1,1);
957 set(s1,'Position',[0.3300 0.6100 0.4750 0.3]);
958 xlabel('time (yr)'); ylabel('Mass (Gt)'); colorbar off;
959 plot(vols(2,:),(vols(1,:)-vols(1,1))*md.materials.rho_ice/1e12);
960 if lockvalue, xlim(xl), ylim(yl); end
961
962 s2=subplot(2,1,2);
963 set(s2,'Position',[0.3300 0.1100 0.4750 0.3]);
964 xlabel('time (yr)'); ylabel('Mass (Gt)'); colorbar off;
965 plot(vols(2,1:end-1),dv*md.materials.rho_ice/1e12);
966 if lockvalue, xlim(xl), ylim(yl); end
967 end
968%}}}
969function displayscalar() % {{{
970 global md range
971
972 %field: % {{{
973 fieldHandle=findobj('Tag', 'Field');
974 fieldstrings=get(fieldHandle,'String');
975 fieldvalue=get(fieldHandle,'Value');
976 field=fieldstrings{fieldvalue};
977 %}}}
978 %counter: % {{{
979 stepHandle=findobj('Tag', 'Step');
980 stepstrings=get(stepHandle,'String');
981 stepvalue=get(stepHandle,'Value');
982 if ~isempty(stepstrings),
983 stepstring=stepstrings{stepvalue};
984 %grab second integer:
985 A=sscanf(stepstring,'%g (%i)'); counter=A(2);
986 else
987 counter=1;
988 end
989 %}}}
990
991
992 if issealevel,
993 if isearth,
994 if strcmpi(field,'SealevelRSLEustatic'),
995 dt=md.earth.timestepping.time_step*md.earth.slr.geodetic_run_frequency;
996 eus=md.earth.results.TransientSolution(counter-1).(field)/dt*1000; %in mm/yr
997 scalarHandle=findobj('Tag', 'Scalar');
998 set(scalarHandle,'String',sprintf('%4.5f mm/yr',eus));
999 end
1000 else
1001 error('not supported yet!');
1002 end
1003 end
1004%}}}
1005function plotm() % {{{
1006
1007 %retrieve field:
1008 hObject=findobj('Tag', 'Field');
1009 strings=get(hObject,'String'); value=get(hObject,'Value');
1010
1011 string='';
1012 if value,
1013 if ~isempty(strings),
1014 string=strings(value);
1015 end
1016 end
1017
1018 if strcmpi(string,'IceVolume') | strcmpi(string,'IceVolumeAboveFloatation'),
1019 plotv();
1020 elseif strcmpi(string,'SealevelRSLEustatic'),
1021 displayscalar();
1022 else
1023 if issealevel(),
1024 plotsl();
1025 else
1026 plotmd();
1027 end
1028 end
1029%}}}
1030 function plotmd() % {{{
1031 global logvalue md solutiontype comparison
1032
1033 %counter: % {{{
1034 stepHandle=findobj('Tag', 'Step');
1035 stepstrings=get(stepHandle,'String');
1036 stepvalue=get(stepHandle,'Value');
1037 if ~isempty(stepstrings),
1038 stepstring=stepstrings{stepvalue};
1039 %grab second integer:
1040 A=sscanf(stepstring,'%g (%i)'); counter=A(2);
1041 else
1042 counter=1;
1043 end
1044 %}}}
1045 %log: % {{{
1046 logHandle=findobj('Tag', 'Log'); logvalue=get(logHandle,'Value');
1047 %}}}
1048 %shading: %{{{
1049 interpHandle=findobj('Tag', 'Interp'); interpvalue=get(interpHandle,'Value');
1050 flatHandle=findobj('Tag', 'Flat'); flatvalue=get(flatHandle,'Value');
1051 facetedHandle=findobj('Tag', 'Faceted'); facetedvalue=get(facetedHandle,'Value');
1052 if interpvalue,
1053 shadingv='interp';
1054 elseif flatvalue,
1055 shadingv='flat';
1056 elseif facetedvalue,
1057 shadingv='faceted';
1058 else
1059 shadingv='interp';
1060 end
1061 %}}}
1062 %mask: %{{{
1063 maskfieldHandle=findobj('Tag', 'Masque');
1064 maskfieldstrings=get(maskfieldHandle,'String');
1065 maskfieldvalue=get(maskfieldHandle,'Value');
1066 maskfield=maskfieldstrings(maskfieldvalue);
1067 maskfield=maskfield{:};
1068 if strcmpi(maskfield,'all'),
1069 maskv=ones(md.mesh.numberofvertices,1);
1070 else
1071 maskv=md.mask.(maskfield);
1072 end
1073 if strcmpi(maskfield,'all'),
1074 %do nothing;
1075 elseif strcmpi(maskfield,'groundedice_levelset'),
1076 maskv=maskv>=0;
1077 elseif strcmpi(maskfield,'ice_levelset'),
1078 maskv=maskv<=0;
1079 elseif strcmpi(maskfield,'ocean_levelset'),
1080 maskv=maskv==1;
1081 elseif strcmpi(maskfield,'land_levelset'),
1082 maskv=maskv==1;
1083 elseif strcmpi(maskfield,'glacier_levelset'),
1084 if isnan(maskv),
1085 maskv=ones(md.mesh.numberofvertices,1);
1086 else
1087 maskv=maskv==1;
1088 end
1089 end
1090 maskvalue=0;
1091 %}}}
1092 %lock limits: % {{{
1093 lockHandle=findobj('Tag', 'Lock'); lockvalue=get(lockHandle,'Value');
1094 if lockvalue,
1095 xl=xlim; yl=ylim;
1096 else
1097 xl=[min(md.mesh.x) max(md.mesh.x)];
1098 yl=[min(md.mesh.y) max(md.mesh.y)];
1099 end %}}}
1100 %time: {{{
1101 timeHandle=findobj('Tag','Time');
1102 if strcmpi(solutiontype,'TransientSolution'),
1103 set(timeHandle,'String',sprintf('%4.2f',md.results.TransientSolution(counter).time));
1104 else
1105 set(timeHandle,'String',sprintf('%4.2f',0));
1106 end
1107 %}}}
1108 %diffcounter: % {{{
1109 stepHandle=findobj('Tag', 'DiffStep');
1110 stepstrings=get(stepHandle,'String');
1111 stepvalue=get(stepHandle,'Value');
1112 if ~isempty(stepstrings),
1113 stepstring=stepstrings{stepvalue};
1114 %grab second integer:
1115 A=sscanf(stepstring,'%g (%i)'); diffcounter=A(2);
1116 else
1117 diffcounter=1;
1118 end
1119 diffHandle=findobj('Tag', 'Diff');
1120 diff=get(diffHandle,'Value');
1121 %}}}
1122 %field: % {{{
1123 fieldHandle=findobj('Tag', 'Field');
1124 fieldstrings=get(fieldHandle,'String');
1125 fieldvalue=get(fieldHandle,'Value');
1126 if ~isempty(fieldstrings),
1127 fieldv=fieldstrings{fieldvalue};
1128 else
1129 fieldv=NaN;
1130 end
1131 mfHandle=findobj('Tag', 'Mf');
1132 mf=get(mfHandle,'Value');
1133 if mf | strcmpi(solutiontype,'None'),
1134 fieldHandle=findobj('Tag', 'ModelFields');
1135 fieldstrings=get(fieldHandle,'String');
1136 fieldvalue=get(fieldHandle,'Value');
1137 fieldv=fieldstrings{fieldvalue};
1138 eval(['field=md.' fieldv ';']);
1139 if isnan(field),
1140 field='mesh';
1141 end
1142 else
1143 if strcmpi(solutiontype,'TransientSolution'),
1144 field=md.results.TransientSolution(counter).(fieldv);
1145 dfield=md.results.TransientSolution(diffcounter).(fieldv);
1146 elseif strcmpi(solutiontype,'StressbalanceSolution'),
1147 field=md.results.StressbalanceSolution.(fieldv);
1148 dfield=NaN;
1149 else
1150 error('unknown solution type!');
1151 end
1152 end
1153 if comparison,
1154 if strcmpi(solutiontype,'None'),
1155 error('cannot compare a solution field to model as no solution was run or selected!');
1156 end
1157 %figure out second field:
1158 if strcmpi(fieldv,'Vel'),
1159 field2=md.inversion.vel_obs;
1160 end
1161 end
1162
1163 %}}}
1164 %color limits: % {{{
1165 cminHandle=findobj('Tag','Cmin'); cmin=str2num(get(cminHandle,'String'));
1166 cmaxHandle=findobj('Tag','Cmax'); cmax=str2num(get(cmaxHandle,'String'));
1167
1168 if isnan(cmin)
1169 if logvalue,
1170 cmin=.1;
1171 else
1172 pos=find(maskv);
1173 cmin=min(field(pos));
1174 end
1175 end
1176 if isnan(cmax)
1177 pos=find(maskv);
1178 cmax=max(field(pos));
1179 end
1180 colaxis=[cmin,cmax];
1181 %}}}
1182
1183 cla;
1184 if logvalue,
1185 plotmodel(md,'data',field,'figurestatement','off','clf','off','mask',maskv,'caxis',colaxis,'log',10,'xlim',xl,'ylim',yl,'shading',shadingv);
1186 else
1187 if ~diff,
1188 if comparison,
1189 plotmodel(md,'data',field,'data',field2,'figurestatement','off','clf','off','mask#all',maskv,'caxis#all',colaxis,'xlim#all',xl,'ylim#all',yl,'shading#all',shadingv,'nlines',2,'ncols',1);
1190 else
1191 if ischar(field) & strcmpi(field,'mesh'),
1192 plotmodel(md,'data','mesh','figurestatement','off','clf','off','xlim',xl,'ylim',yl);
1193 else
1194 plotmodel(md,'data',field,'figurestatement','off','clf','off','mask',maskv,'caxis',colaxis,'xlim',xl,'ylim',yl,'shading',shadingv);
1195 end
1196 end
1197 else
1198 plotmodel(md,'data',dfield-field,'figurestatement','off','clf','off','mask',maskv,'caxis',colaxis,'xlim',xl,'ylim',yl,'shading',shadingv);
1199 end
1200
1201 end
1202 set(gca,'Position',[0.2300 0.1100 0.7750 0.8150]);
1203 %}}}
1204function plotsl() % {{{
1205 global logvalue md solutiontype comparison
1206
1207 %counter: % {{{
1208 stepHandle=findobj('Tag', 'Step');
1209 stepstrings=get(stepHandle,'String');
1210 stepvalue=get(stepHandle,'Value');
1211 if ~isempty(stepstrings),
1212 stepstring=stepstrings{stepvalue};
1213 %grab second integer:
1214 A=sscanf(stepstring,'%g (%i)'); counter=A(2);
1215 else
1216 counter=1;
1217 end
1218 %}}}
1219 %log: % {{{
1220 logHandle=findobj('Tag', 'Log'); logvalue=get(logHandle,'Value');
1221 %}}}
1222 %shading: %{{{
1223 interpHandle=findobj('Tag', 'Interp'); interpvalue=get(interpHandle,'Value');
1224 flatHandle=findobj('Tag', 'Flat'); flatvalue=get(flatHandle,'Value');
1225 facetedHandle=findobj('Tag', 'Faceted'); facetedvalue=get(facetedHandle,'Value');
1226 if interpvalue,
1227 shadingv='interp';
1228 elseif flatvalue,
1229 shadingv='flat';
1230 elseif facetedvalue,
1231 shadingv='faceted';
1232 else
1233 shadingv='interp';
1234 end
1235 %}}}
1236 %time: {{{
1237 timeHandle=findobj('Tag','Time');
1238 if strcmpi(solutiontype,'TransientSolution'),
1239 if isearth,
1240 set(timeHandle,'String',sprintf('%4.2f',md.earth.results.TransientSolution(counter).time));
1241 else
1242 set(timeHandle,'String',sprintf('%4.2f',md.icecaps{1}.results.TransientSolution(counter).time));
1243 end
1244 else
1245 set(timeHandle,'String',sprintf('%4.2f',0));
1246 end
1247 %}}}
1248 %diffcounter: % {{{
1249 stepHandle=findobj('Tag', 'DiffStep');
1250 stepstrings=get(stepHandle,'String');
1251 stepvalue=get(stepHandle,'Value');
1252 if ~isempty(stepstrings),
1253 stepstring=stepstrings{stepvalue};
1254 %grab second integer:
1255 A=sscanf(stepstring,'%g (%i)'); diffcounter=A(2);
1256 else
1257 diffcounter=1;
1258 end
1259 diffHandle=findobj('Tag', 'Diff');
1260 diff=get(diffHandle,'Value');
1261 %}}}
1262
1263 if isearth,
1264 %Earth plotting: {{{
1265 %field: % {{{
1266 fieldHandle=findobj('Tag', 'Field');
1267 fieldstrings=get(fieldHandle,'String');
1268 fieldvalue=get(fieldHandle,'Value');
1269 if ~isempty(fieldstrings),
1270 fieldv=fieldstrings{fieldvalue};
1271 else
1272 fieldv=NaN;
1273 end
1274 colorbartitle={fieldv,''};
1275 if strcmpi(fieldv,'SealevelRSLRate'),
1276 colorbartitle={'SealevelRSLRate (mm/yr)',''};
1277 end
1278
1279 mfHandle=findobj('Tag', 'Mf');
1280 mf=get(mfHandle,'Value');
1281 if mf | strcmpi(solutiontype,'None'),
1282 fieldHandle=findobj('Tag', 'ModelFields');
1283 fieldstrings=get(fieldHandle,'String');
1284 fieldvalue=get(fieldHandle,'Value');
1285 fieldv=fieldstrings{fieldvalue};
1286 eval(['field=md.earth.' fieldv ';']);
1287 if isnan(field),
1288 field='mesh';
1289 end
1290 else
1291 if strcmpi(solutiontype,'TransientSolution'),
1292 field=md.earth.results.TransientSolution(counter).(fieldv);
1293 dfield=md.earth.results.TransientSolution(diffcounter).(fieldv);
1294 elseif strcmpi(solutiontype,'StressbalanceSolution'),
1295 field=md.earth.results.StressbalanceSolution.(fieldv);
1296 dfield=NaN;
1297 else
1298 error('unknown solution type!');
1299 end
1300 end
1301 if comparison,
1302 if strcmpi(solutiontype,'None'),
1303 error('cannot compare a solution field to model as no solution was run or selected!');
1304 end
1305 %figure out second field:
1306 if strcmpi(fieldv,'Vel'), field2=md.earth.inversion.vel_obs; end
1307 if strcmpi(fieldv,'Base'), field2=md.earth.geometry.base; end
1308 end
1309 %}}}
1310 %mask: %{{{
1311 maskfieldHandle=findobj('Tag', 'Masque');
1312 maskfieldstrings=get(maskfieldHandle,'String');
1313 maskfieldvalue=get(maskfieldHandle,'Value');
1314 maskfield=maskfieldstrings(maskfieldvalue);
1315 maskfield=maskfield{:};
1316 if strcmpi(maskfield,'all'),
1317 maskv=ones(md.earth.mesh.numberofvertices,1);
1318 else
1319 maskv=md.earth.mask.(maskfield);
1320 end
1321 if strcmpi(maskfield,'all'),
1322 %do nothing;
1323 elseif strcmpi(maskfield,'groundedice_levelset'),
1324 maskv=maskv>=0;
1325 elseif strcmpi(maskfield,'ice_levelset'),
1326 maskv=maskv<=0;
1327 elseif strcmpi(maskfield,'ocean_levelset'),
1328 maskv=maskv==1;
1329 elseif strcmpi(maskfield,'land_levelset'),
1330 maskv=maskv==1;
1331 elseif strcmpi(maskfield,'glacier_levelset'),
1332 if isnan(maskv),
1333 maskv=ones(md.earth.mesh.numberofvertices,1);
1334 else
1335 maskv=maskv==1;
1336 end
1337 end
1338 maskvalue=0;
1339 %}}}
1340 %color limits: % {{{
1341 if ~ischar(field),
1342 cminHandle=findobj('Tag','Cmin'); cmin=str2num(get(cminHandle,'String'));
1343 cmaxHandle=findobj('Tag','Cmax'); cmax=str2num(get(cmaxHandle,'String'));
1344
1345 if isnan(cmin)
1346 if logvalue,
1347 cmin=.1;
1348 else
1349 pos=find(maskv);
1350 cmin=min(field(pos));
1351 end
1352 end
1353 if isnan(cmax)
1354 pos=find(maskv);
1355 cmax=max(field(pos));
1356 end
1357
1358 if cmin==cmax,
1359 colaxis=[cmin-eps,cmax+eps];
1360 else
1361 colaxis=[cmin,cmax];
1362 end
1363 end
1364
1365 %}}}
1366 %lock limits: % {{{
1367 lockHandle=findobj('Tag', 'Lock'); lockvalue=get(lockHandle,'Value');
1368 if lockvalue,
1369 xl=xlim; yl=ylim; zl=zlim;
1370 [az,el]=view; v=[az,el];
1371 else
1372 xl=[min(md.earth.mesh.x) max(md.earth.mesh.x)];
1373 yl=[min(md.earth.mesh.y) max(md.earth.mesh.y)];
1374 zl=[min(md.earth.mesh.z) max(md.earth.mesh.z)];
1375 v=[57,50];
1376 end %}}}
1377
1378 %some quirks:
1379 cla;
1380 if logvalue,
1381 plotmodel(md.earth,'data',field,'figurestatement','off','clf','off','mask',maskv,'caxis',colaxis,'log',10,'xlim',xl,'ylim',yl,'zlim',zl,'shading',shadingv,'colorbar','on','view',v,'colorbartitle',colorbartitle);
1382 else
1383 if ~diff,
1384 if comparison,
1385 plotmodel(md.earth,'data',field,'data',field2,'figurestatement','off','clf','off','mask#all',maskv,'caxis#all',colaxis,'xlim#all',xl,'ylim#all',yl,'zlim#all',zl,'shading#all',shadingv,'nlines',2,'ncols',1,'view#all',v,'colorbartitle',colorbartitle);
1386 else
1387 if ischar(field) & strcmpi(field,'mesh'),
1388 plotmodel(md.earth,'data','mesh','figurestatement','off','clf','off','xlim',xl,'ylim',yl,'zlim',zl,'view#all',v,'colorbartitle',colorbartitle);
1389 else
1390 plotmodel(md.earth,'data',field,'figurestatement','off','clf','off','mask',maskv,'maskvalue',maskvalue,'caxis',colaxis,'xlim',xl,'ylim',yl,'zlim',zl,'shading',shadingv,'axes','equal','colorbarpos',[.95 .5 .01 .15],'view#all',v,'colorbartitle',colorbartitle);
1391 end
1392 end
1393 else
1394 plotmodel(md.earth,'data',dfield-field,'figurestatement','off','clf','off','mask',maskv,'caxis',colaxis,'xlim',xl,'ylim',yl,'zlim',zl,'shading',shadingv,'view#all',v,'colorbartitle',colorbartitle);
1395 end
1396 end
1397
1398 %coastlines and graticule: {{{
1399 load coastlines
1400 [x,y,z]=AboveGround(coastlat,coastlon,md.earth.mesh.r(1),1000);
1401 hold on; p=plot3(x,y,z,'k-'); set(p,'Color','k');
1402
1403 %graticule:
1404 grat=graticule(30,40,1);
1405 [x,y,z]=AboveGround(grat.lat,grat.long,md.earth.mesh.r(1),1000);
1406 hold on, p=plot3(x,y,z,'k.-','MarkerSize',.01); set(p,'Color','k');
1407 %}}}
1408 %}}}
1409 else
1410 %IceCaps plotting: {{{
1411
1412 %counter: % {{{
1413 stepHandle=findobj('Tag', 'Step');
1414 stepstrings=get(stepHandle,'String');
1415 stepvalue=get(stepHandle,'Value');
1416 if ~isempty(stepstrings),
1417 stepstring=stepstrings{stepvalue};
1418 %grab second integer:
1419 A=sscanf(stepstring,'%g (%i)'); counter=A(2);
1420 else
1421 counter=1;
1422 end
1423 %}}}
1424 %log: % {{{
1425 logHandle=findobj('Tag', 'Log'); logvalue=get(logHandle,'Value');
1426 %}}}
1427 %shading: %{{{
1428 interpHandle=findobj('Tag', 'Interp'); interpvalue=get(interpHandle,'Value');
1429 flatHandle=findobj('Tag', 'Flat'); flatvalue=get(flatHandle,'Value');
1430 facetedHandle=findobj('Tag', 'Faceted'); facetedvalue=get(facetedHandle,'Value');
1431 if interpvalue,
1432 shadingv='interp';
1433 elseif flatvalue,
1434 shadingv='flat';
1435 elseif facetedvalue,
1436 shadingv='faceted';
1437 else
1438 shadingv='interp';
1439 end
1440 %}}}
1441 %time: {{{
1442 timeHandle=findobj('Tag','Time');
1443 if strcmpi(solutiontype,'TransientSolution'),
1444 set(timeHandle,'String',sprintf('%4.2f',md.icecaps{1}.results.TransientSolution(counter).time));
1445 else
1446 set(timeHandle,'String',sprintf('%4.2f',0));
1447 end
1448 %}}}
1449 %diffcounter: % {{{
1450 stepHandle=findobj('Tag', 'DiffStep');
1451 stepstrings=get(stepHandle,'String');
1452 stepvalue=get(stepHandle,'Value');
1453 if ~isempty(stepstrings),
1454 stepstring=stepstrings{stepvalue};
1455 %grab second integer:
1456 A=sscanf(stepstring,'%g (%i)'); diffcounter=A(2);
1457 else
1458 diffcounter=1;
1459 end
1460 diffHandle=findobj('Tag', 'Diff');
1461 diff=get(diffHandle,'Value');
1462 %}}}
1463 %range: % {{{
1464 basins=getbasins();
1465 if strcmpi(basins,'All'),
1466 range=md.basinindx('continent',{getcontinent()});
1467 else
1468 range=md.basinindx('basin',basins);
1469 end
1470
1471 %}}}
1472 cla;
1473 for j=1:length(range),
1474 i=range(j);
1475 %mask: %{{{
1476 maskfieldHandle=findobj('Tag', 'Masque');
1477 maskfieldstrings=get(maskfieldHandle,'String');
1478 maskfieldvalue=get(maskfieldHandle,'Value');
1479 maskfield=maskfieldstrings(maskfieldvalue);
1480 maskfield=maskfield{:};
1481 if strcmpi(maskfield,'all'),
1482 maskv=ones(md.icecaps{i}.mesh.numberofvertices,1);
1483 else
1484 maskv=md.icecaps{i}.mask.(maskfield);
1485 end
1486 if strcmpi(maskfield,'all'),
1487 %do nothing;
1488 elseif strcmpi(maskfield,'groundedice_levelset'),
1489 maskv=maskv>=0;
1490 elseif strcmpi(maskfield,'ice_levelset'),
1491 maskv=maskv<=0;
1492 elseif strcmpi(maskfield,'ocean_levelset'),
1493 maskv=maskv==1;
1494 elseif strcmpi(maskfield,'land_levelset'),
1495 maskv=maskv==1;
1496 elseif strcmpi(maskfield,'glacier_levelset'),
1497 if isnan(maskv),
1498 maskv=ones(md.icecaps{i}.mesh.numberofvertices,1);
1499 else
1500 maskv=maskv==1;
1501 end
1502 end
1503 maskvalue=0;
1504 %}}}
1505 %lock limits: % {{{
1506 lockHandle=findobj('Tag', 'Lock'); lockvalue=get(lockHandle,'Value');
1507 if lockvalue,
1508 xl=xlim; yl=ylim;
1509 else
1510 if j==1,
1511 xl=[min(md.icecaps{i}.mesh.x) max(md.icecaps{i}.mesh.x)];
1512 else
1513 xl=[min([md.icecaps{i}.mesh.x;xl(1)]) max([md.icecaps{i}.mesh.x;xl(2)])];
1514 end
1515 if j==1,
1516 yl=[min(md.icecaps{i}.mesh.y) max(md.icecaps{i}.mesh.y)];
1517 else
1518 yl=[min([md.icecaps{i}.mesh.y; yl(1)]) max([md.icecaps{i}.mesh.y; yl(2)])];
1519 end
1520 end %}}}
1521 %field: % {{{
1522 fieldHandle=findobj('Tag', 'Field');
1523 fieldstrings=get(fieldHandle,'String');
1524 fieldvalue=get(fieldHandle,'Value');
1525 if ~isempty(fieldstrings),
1526 fieldv=fieldstrings{fieldvalue};
1527 else
1528 fieldv=NaN;
1529 end
1530 mfHandle=findobj('Tag', 'Mf');
1531 mf=get(mfHandle,'Value');
1532 if mf | strcmpi(solutiontype,'None'),
1533 fieldHandle=findobj('Tag', 'ModelFields');
1534 fieldstrings=get(fieldHandle,'String');
1535 fieldvalue=get(fieldHandle,'Value');
1536 fieldv=fieldstrings{fieldvalue};
1537 eval(['field=md.icecaps{' num2str(i) '}.' fieldv ';']);
1538 if isnan(field),
1539 field='mesh';
1540 end
1541 else
1542 if strcmpi(solutiontype,'TransientSolution'),
1543 field=md.icecaps{i}.results.TransientSolution(counter).(fieldv);
1544 dfield=md.icecaps{i}.results.TransientSolution(diffcounter).(fieldv);
1545 elseif strcmpi(solutiontype,'StressbalanceSolution'),
1546 field=md.icecaps{i}.results.StressbalanceSolution.(fieldv);
1547 dfield=NaN;
1548 else
1549 error('unknown solution type!');
1550 end
1551 end
1552 if comparison,
1553 if strcmpi(solutiontype,'None'),
1554 error('cannot compare a solution field to model as no solution was run or selected!');
1555 end
1556 %figure out second field:
1557 if strcmpi(fieldv,'Vel'), field2=md.icecaps{i}.inversion.vel_obs; end
1558 if strcmpi(fieldv,'Base'), field2=md.icecaps{i}.geometry.base; end
1559 if strcmpi(fieldv,'Bed'), field2=md.icecaps{i}.geometry.bed; end
1560 if strcmpi(fieldv,'Thickness'), field2=md.icecaps{i}.geometry.thickness; end
1561 if strcmpi(fieldv,'Surface'), field2=md.icecaps{i}.geometry.surface; end
1562 end
1563
1564 %}}}
1565 %color limits: % {{{
1566 cminHandle=findobj('Tag','Cmin'); cminfield=str2num(get(cminHandle,'String'));
1567 cmaxHandle=findobj('Tag','Cmax'); cmaxfield=str2num(get(cmaxHandle,'String'));
1568
1569 if isnan(cminfield)
1570 if logvalue,
1571 cmin=.1;
1572 else
1573 pos=find(maskv);
1574 if j==1,
1575 cmin=min(field(pos));
1576 else
1577 cmin=min(min(field(pos)),cmin);
1578 end
1579 end
1580 else
1581 cmin=cminfield;
1582 end
1583 if isnan(cmaxfield)
1584 pos=find(maskv);
1585 if j==1
1586 cmax=max(field(pos));
1587 else
1588 cmax=max(max(field(pos)),cmax);
1589 end
1590 else
1591 cmax=cmaxfield;
1592 end
1593 if cmin==cmax,
1594 cmin=cmin-1e-10; cmax=cmax+1e-10;
1595 end
1596 colaxis=[cmin,cmax];
1597 %}}}
1598 %contour levels? {{{
1599 contourlevels=0;
1600 if strncmpi(fieldv,'Mask',4),
1601 contourexp=[tempname '.exp'];
1602 isoline(md.icecaps{i},field,'output',contourexp);
1603 contourlevels=1;
1604
1605 if diff,
1606 contourdiffexp=[tempname '.exp'];
1607 isoline(md.icecaps{i},dfield,'output',contourdiffexp);
1608 end
1609 end
1610 %}}}
1611 %display : {{{
1612 if logvalue,
1613 plotmodel(md.icecaps{i},'data',field,'figurestatement','off','clf','off','mask',maskv,'caxis',colaxis,'log',10,'xlim',xl,'ylim',yl,'shading',shadingv);
1614 else
1615 if ~diff,
1616 if comparison,
1617 plotmodel(md.icecaps{i},'data',field,'data',field2,'figurestatement','off','clf','off','mask#all',maskv,'caxis#all',colaxis,'xlim#all',xl,'ylim#all',yl,'shading#all',shadingv,'nlines',2,'ncols',1);
1618 else
1619 if ischar(field) & strcmpi(field,'mesh'),
1620 plotmodel(md.icecaps{i},'data','mesh','figurestatement','off','clf','off','xlim',xl,'ylim',yl);
1621 else
1622 plotmodel(md.icecaps{i},'data',field,'figurestatement','off','clf','off','mask',maskv,'caxis',colaxis,'xlim',xl,'ylim',yl,'shading',shadingv);
1623 if contourlevels,
1624 contour=expread(contourexp);
1625 hold on;
1626 for k=1:length(contour),
1627 plot(contour(k).x,contour(k).y,'r-');
1628 end
1629 end
1630 end
1631 end
1632 else
1633 plotmodel(md.icecaps{i},'data',dfield-field,'figurestatement','off','clf','off','mask',maskv,'caxis',colaxis,'xlim',xl,'ylim',yl,'shading',shadingv);
1634 if contourlevels,
1635 contour=expread(contourexp);
1636 hold on;
1637 for k=1:length(contour),
1638 plot(contour(k).x,contour(k).y,'k-');
1639 end
1640 dcontour=expread(contourdiffexp);
1641 hold on;
1642 for k=1:length(dcontour),
1643 plot(dcontour(k).x,dcontour(k).y,'r-');
1644 end
1645 end
1646 end
1647 end
1648 % }}}
1649
1650 end %end for
1651
1652 if ~comparison,
1653 set(gca,'Position',[0.2300 0.1100 0.7750 0.8150]);
1654 end % }}}
1655 end
1656% }}}
1657function result=isearth() % {{{
1658 global earth;
1659 result=earth;
1660%}}}
1661function result=issealevel() % {{{
1662 global md;
1663 if strcmpi(class(md),'sealevelmodel'),
1664 result=1;
1665 else
1666 result=0;
1667 end
1668%}}}
1669function continent=getcontinent() % {{{
1670
1671 continentHandle=findobj('Tag', 'popupmenu11');
1672 strings=get(continentHandle,'String');
1673 value=get(continentHandle,'Value');
1674 continent=strings{value};
1675
1676%}}}
1677function basins=getbasins() % {{{
1678
1679 basinHandle=findobj('Tag', 'popupmenu12');
1680 strings=get(basinHandle,'String');
1681 value=get(basinHandle,'Value');
1682 basins=strings{value};
1683% }}}
Note: See TracBrowser for help on using the repository browser.