source: issm/oecreview/Archive/12041-12060/ISSM-12041-12042.diff

Last change on this file was 12325, checked in by Eric.Larour, 13 years ago

11990 to 12321 oec compliance

File size: 3.9 KB
RevLine 
[12325]1Index: /proj/ice/larour/issm-uci-clean/trunk-jpl/src/py/model/display/fielddisplay.rest
2===================================================================
3--- /proj/ice/larour/issm-uci-clean/trunk-jpl/src/py/model/display/fielddisplay.rest (revision 12041)
4+++ /proj/ice/larour/issm-uci-clean/trunk-jpl/src/py/model/display/fielddisplay.rest (revision 12042)
5@@ -1,154 +0,0 @@
6-def fielddisplay(md,name,comment):
7-#FIELDDISPLAY - display model field
8-#
9-# Usage:
10-# fielddisplay(md,offset,name,comment)
11-
12- #get field
13- field=getattr(md,name)
14-
15- #disp corresponding line as a function of field type (offset set as 9 spaces)
16- #parsedisplay(' ',name,field,comment);
17-
18- return
19-
20-function parsedisplay(offset,name,field,comment); %{{{
21-
22- %string
23- if ischar(field),
24-
25- if length(field)>30;
26- displayunit(offset,name,'not displayed',comment),
27- else
28- displayunit(offset,name,['''' field ''''],comment),
29- end
30-
31- %numeric
32- elseif isnumeric(field)
33-
34- %get size
35- fieldsize=size(field);
36-
37- %double
38- if max(fieldsize)==1,
39- displayunit(offset,name,num2str(field),comment),
40- %matrix
41- else
42- displayunit(offset,name,['(' num2str(fieldsize(1)) 'x' num2str(fieldsize(2)) ')'],comment),
43- end
44-
45- %logical
46- elseif islogical(field)
47-
48- %get size
49- fieldsize=size(field);
50-
51- %single value
52- if max(fieldsize)==1,
53- if (field)
54- displayunit(offset,name,'true',comment),
55- else
56- displayunit(offset,name,'false',comment),
57- end
58- %matrix
59- else
60- displayunit(offset,name,['(' num2str(fieldsize(1)) 'x' num2str(fieldsize(2)) ')'],comment),
61- end
62-
63- %structure
64- elseif isstruct(field),
65- if ~isempty(fields(field))
66- displayunit(offset,name,'(structure)',comment),
67- struct_display(field,[offset ' ']),
68- else
69- displayunit(offset,name,'N/A',comment),
70- end
71-
72- %cell
73- elseif iscell(field),
74- cell_display(offset,name,field,comment),
75-
76- else
77- displayunit(offset,name,'not displayed',comment),
78-
79- end
80-end%}}}
81-
82-function struct_display(structure,offset) % {{{
83-
84- structure_fields=fields(structure);
85-
86- for i=1:length(structure_fields),
87-
88- %get current field
89- field=structure.(structure_fields{i});
90-
91- %recursive call if necessary
92- if isstruct(field),
93- displayunit(offset,structure_fields{i},'(structure)',''),
94- struct_display(field,[offset ' ']);
95-
96- %display value
97- else
98- parsedisplay(offset,structure_fields{i},field,'');
99- end
100- end
101-end% }}}
102-function cell_display(offset,name,field,comment) % {{{
103-
104- %initialization
105- string='{';
106-
107- %go through the cell and fill string
108- if length(field)<5;
109- for i=1:length(field),
110- if ischar(field{i}),
111- string=[string '''' field{i} ''','];
112- elseif (isnumeric(field{i}) & length(field{i})==1)
113- string=[string num2str(field{i}) ',' ];
114- else
115- string='{';
116- break
117- end
118- end
119- end
120- if strcmp(string,'{'),
121- string=['(' num2str(size(field,1)) 'x' num2str(size(field,2)) ')'];
122- else
123- string=[string(1:end-1) '}'];
124- end
125-
126- %call displayunit
127- displayunit(offset,name,string,comment);
128-end% }}}
129-function displayunit(offset,name,characterization,comment),% {{{
130-
131- %take care of name
132- if length(name)>23,
133- name=[name(1:20) '...'];
134- end
135-
136- %take care of characterization
137- if (strcmp(characterization,['''' '''']) | strcmp(characterization,'NaN')),
138- characterization='N/A';
139- end
140- if length(characterization)>15,
141- characterization=[characterization(1:12) '...'];
142- end
143-
144- %print
145- if isempty(comment)
146- disp(sprintf('%s%-23s: %-15s',offset,name,characterization));
147- else
148- if ischar(comment),
149- disp(sprintf('%s%-23s: %-15s -- %s',offset,name,characterization,comment));
150- elseif iscell(comment),
151- disp(sprintf('%s%-23s: %-15s -- %s',offset,name,characterization,comment{1}));
152- for i=2:length(comment),
153- disp(sprintf('%s%-23s %-15s %s',offset,'','',comment{i}));
154- end
155- else
156- error('fielddisplay error message: format for comment not supportet yet');
157- end
158- end
159-end% }}}
Note: See TracBrowser for help on using the repository browser.