-
Notifications
You must be signed in to change notification settings - Fork 0
/
parseProp.m
149 lines (122 loc) · 4.15 KB
/
parseProp.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
function prop = parseProp( dbentry )
% PROP = parseProp( DBENTRY ) parses data from DBENTRY into struct PROP.
%
% parseProp( DBENTRY ) parses propeller data from files in the UIUC
% propeller database. DBENTRY is a meta-data structure as parsed by
% PROPDATABASE.
%
% PROP is a struct with the following fields.
%
% Numeric data. Empty for not applicable or not specified.
% RPM % Vector of RPM values for wind-on data.
% CT % Cell array of vectors of CT for wind-on data.
% CP % Cell array of vectors of CP for wind-on data.
% J % Cell array of vectors of J for wind-on data.
% RPM_static % Vector of RPM values for wind-on data.
% CT_static % Vector of CT values for wind-on data.
% CP_static % Vector of CP values for wind-on data.
% r_R % Vector of r/R values for blade geometry.
% c_R % Vector of c/R values for blade geometry.
% beta % Vector of beta values for blade geometry.
% r_R_thickness % Vector of r/R values for thickness vector.
% t_c % Vector of t/c values for blade geometry.
% Image data. Empty for not applicable or not specified.
% front % Image data for front view of prop.
% side % Image data for side view of prop.
%
% See also PROPDATABASE, PLOTPROP.
% Rob McDonald
% 17 February 2021 v. 1.0 -- Original version.
%
% Initialize all fields to empty.
prop.RPM = [];
prop.CT = [];
prop.CP = [];
prop.J = [];
prop.RPM_static = [];
prop.CT_static = [];
prop.CP_static = [];
prop.r_R = [];
prop.c_R = [];
prop.beta = [];
prop.r_R_thickness = [];
prop.t_c = [];
prop.front = [];
prop.side = [];
if( ~isempty( dbentry.rpmv ) )
nrpm = length( dbentry.rpmv );
prop.RPM = dbentry.rpmv;
prop.CT = cell( nrpm, 1 );
prop.CP = cell( nrpm, 1 );
prop.J = cell( nrpm, 1 );
for irpm = 1:length( dbentry.rpmv )
imdat = imdata( char( strcat('./', dbentry.vname, '/data/', dbentry.perf{irpm}, '.txt') ) );
prop.CT{irpm} = imdat.CT;
prop.CP{irpm} = imdat.CP;
prop.J{irpm} = imdat.J;
end
end
if( ~isempty( dbentry.static ) )
imdat = imdata( char( strcat('./', dbentry.vname, '/data/', dbentry.static, '.txt') ) );
prop.RPM_static = imdat.RPM;
prop.CT_static = imdat.CT;
prop.CP_static = imdat.CP;
end
if( ~isempty( dbentry.geom ) )
imdat = imdata( char( strcat('./', dbentry.vname, '/data/', dbentry.geom, '.txt') ) );
prop.r_R = imdat.r_R;
prop.c_R = imdat.c_R;
prop.beta = imdat.beta;
end
if( ~isempty( dbentry.thick ) )
imdat = imdata( char( strcat('./', dbentry.vname, '/data/', dbentry.thick, '.txt') ) );
prop.r_R_thickness = imdat.r_R;
prop.t_c = imdat.t_c;
end
if( ~isempty( dbentry.front ) )
if( contains( dbentry.front, '.png' ) )
itype = 'PNG';
else
itype = 'JPEG';
end
img = imread( char( strcat('./', dbentry.vname, '/prop_photos/', dbentry.front) ), itype );
prop.front = img;
end
if( ~isempty( dbentry.side ) )
if( contains( dbentry.side, '.png' ) )
itype = 'PNG';
else
itype = 'JPEG';
end
img = imread( char( strcat('./', dbentry.vname, '/prop_photos/', dbentry.side) ), itype );
prop.side = img;
end
end
function str = imdata( fname )
% str = imdata( FILENAME ) loads data from FILENAME into struct str.
%
% imdata( FILENAME ) is a simple wrapper around importdata( FILENAME )
% that places columns of data into named fields of a struct instead
% of leaving them in a matrix.
%
% See also IMPORTDATA.
% Rob McDonald
% 17 February 2021 v. 1.0 -- Original version.
%
% Check if file exists
if ( exist( fname, 'file' ) )
% Use importdata to detect format and read data in
imdat = importdata( fname );
% Convert matrix data in imdat to named fields in str
for icol = 1:length( imdat.colheaders )
fname = imdat.colheaders{icol};
fname = matlab.lang.makeValidName( fname );
str.(fname) = imdat.data( :, icol );
end
else
warning( ['File ' fname ' not found'] );
str = [];
end
end