Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
4
Merge Requests
4
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Institute of Technical Acoustics (ITA)
toolbox
Commits
d8272a76
Commit
d8272a76
authored
Nov 24, 2016
by
Jonas Stienen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing metadata problems for daff v17 to v15 converter
parent
1ebebe6d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
19 deletions
+40
-19
applications/VirtualAcoustics/openDAFF/OpenDAFFv1.5/daffv15_metadata_addKey.m
...Acoustics/openDAFF/OpenDAFFv1.5/daffv15_metadata_addKey.m
+30
-18
applications/VirtualAcoustics/openDAFF/OpenDAFFv1.5/daffv15_write_metadata.m
...lAcoustics/openDAFF/OpenDAFFv1.5/daffv15_write_metadata.m
+10
-1
No files found.
applications/VirtualAcoustics/openDAFF/OpenDAFFv1.5/daffv15_metadata_addKey.m
View file @
d8272a76
function
[
metadata
]
=
daffv15_metadata_addKey
(
metadata
,
keyname
,
datatype
,
value
)
function
[
metadata
]
=
daffv15_metadata_addKey
(
metadata_in
,
keyname
,
datatype
,
value
)
%DAFF_METADATA_ADDKEY Adds another key to a DAFF metadata struct
%DAFF_METADATA_ADDKEY Adds another key to a DAFF metadata struct
% TODO:
% TODO:
% ITAToolbox schauen
% ITAToolbox schauen
...
@@ -9,42 +9,54 @@ function [ metadata ] = daffv15_metadata_addKey(metadata, keyname, datatype, val
...
@@ -9,42 +9,54 @@ function [ metadata ] = daffv15_metadata_addKey(metadata, keyname, datatype, val
% You can find the license for this m-file in the application folder.
% You can find the license for this m-file in the application folder.
% </ITA-Toolbox>
% </ITA-Toolbox>
% if (~isempty(metadata))
if
(
~
isempty
(
metadata_in
))
% if (~isstruct(metadata)), error(['[' mfilename '] Wrong datatype for metadata']); end;
if
(
~
isstruct
(
metadata_in
))
% else
error
(
'Input metadata is not empty and not a struct'
)
metadata
=
struct
(
'name'
,
{},
'datatype'
,
{},
'value'
,
{});
end
;
% end
metadata
=
metadata_in
;
else
if
(
~
ischar
(
keyname
)),
error
([
'['
mfilename
'] Key name must be a string'
]);
end
;
metadata
=
struct
();
end
keyname
(
ismember
(
keyname
,
' '
))
=
'_'
;
keyname
(
ismember
(
keyname
,
',.:;!'
))
=
[];
if
(
~
ischar
(
keyname
))
error
(
'Key %s name must be a string'
,
keyname
)
end
;
% Keynames are case-insensitive (convert to upper case)
% Keynames are case-insensitive (convert to upper case)
keyname
=
upper
(
keyname
);
keyname
=
upper
(
keyname
);
% Test wheather a key of the given name already exists
% Test wheather a key of the given name already exists
if
any
(
strcmp
({
metadata
(:)
.
name
},
keyname
)
)
if
isfield
(
metadata
,
keyname
)
error
([
'
['
mfilename
']
Key
''
'
keyname
'
''
already exists'
]);
error
([
'Key
''
'
keyname
'
''
already exists'
]);
end
end
if
(
~
ischar
(
datatype
)),
error
([
'['
mfilename
'] Datatype must be a string'
]);
end
;
if
(
~
ischar
(
datatype
))
error
([
'Datatype must be a string'
])
end
switch
(
upper
(
datatype
))
switch
(
upper
(
datatype
))
case
'BOOL'
case
'BOOL'
if
(
~
islogical
(
value
)),
error
([
'['
mfilename
'] Value must be logical for boolean keys'
]);
end
;
if
(
~
islogical
(
value
))
metadata
(
end
+
1
)
=
struct
(
'name'
,
keyname
,
'datatype'
,
0
,
'value'
,
value
);
error
([
'['
mfilename
'] Value must be logical for boolean keys'
])
end
;
metadata
.
(
keyname
)
=
boolean
(
value
);
case
'INT'
case
'INT'
if
(
~
isfinite
(
value
)),
error
([
'['
mfilename
'] Value must be finite'
]);
end
;
if
(
~
isfinite
(
value
)),
error
([
'['
mfilename
'] Value must be finite'
]);
end
;
if
(
~
isreal
(
value
)),
error
([
'['
mfilename
'] Value must be real'
]);
end
;
if
(
~
isreal
(
value
)),
error
([
'['
mfilename
'] Value must be real'
]);
end
;
if
(
value
~=
ceil
(
value
)),
error
([
'['
mfilename
'] Value must be an integer number for integer keys'
]);
end
;
if
(
value
~=
ceil
(
value
)),
error
([
'['
mfilename
'] Value must be an integer number for integer keys'
]);
end
;
metadata
(
end
+
1
)
=
struct
(
'name'
,
keyname
,
'datatype'
,
1
,
'value'
,
int32
(
value
));
metadata
.
(
keyname
)
=
int32
(
value
);
case
'FLOAT'
case
'FLOAT'
if
(
~
isfinite
(
value
)),
error
([
'['
mfilename
'] Value must be finite'
]);
end
;
if
(
~
isfinite
(
value
)),
error
([
'['
mfilename
'] Value must be finite'
]);
end
;
if
(
~
isreal
(
value
)),
error
([
'['
mfilename
'] Value must be real'
]);
end
;
if
(
~
isreal
(
value
)),
error
([
'['
mfilename
'] Value must be real'
]);
end
;
metadata
(
end
+
1
)
=
struct
(
'name'
,
keyname
,
'datatype'
,
2
,
'value'
,
double
(
value
));
metadata
.
(
keyname
)
=
double
(
value
);
case
'STRING'
case
'STRING'
if
(
~
ischar
(
value
)),
error
([
'['
mfilename
'] Value must be a string for string keys'
]);
end
;
if
(
~
ischar
(
value
)),
error
([
'['
mfilename
'] Value must be a string for string keys'
]);
end
;
metadata
(
end
+
1
)
=
struct
(
'name'
,
keyname
,
'datatype'
,
3
,
'value'
,
value
);
metadata
.
(
keyname
)
=
char
(
value
);
end
end
end
end
applications/VirtualAcoustics/openDAFF/OpenDAFFv1.5/daffv15_write_metadata.m
View file @
d8272a76
...
@@ -35,33 +35,42 @@ function [ ] = daffv15_write_metadata( fid, metadata )
...
@@ -35,33 +35,42 @@ function [ ] = daffv15_write_metadata( fid, metadata )
% Logical scalar (DAFF_BOOL)
% Logical scalar (DAFF_BOOL)
if
islogical
(
value
)
&&
isscalar
(
value
)
if
islogical
(
value
)
&&
isscalar
(
value
)
type
=
'BOOL'
;
type
=
'BOOL'
;
datatype
=
0
;
end
end
% Integer scalar (DAFF_INT)
% Integer scalar (DAFF_INT)
if
isinteger
(
value
)
&&
isfinite
(
value
)
&&
isreal
(
value
)
&&
isscalar
(
value
)
if
isinteger
(
value
)
&&
isfinite
(
value
)
&&
isreal
(
value
)
&&
isscalar
(
value
)
type
=
'INT'
;
type
=
'INT'
;
datatype
=
1
;
end
end
% Floating point scalar (DAFF_FLOAT)
% Floating point scalar (DAFF_FLOAT)
if
isfloat
(
value
)
&&
isfinite
(
value
)
&&
isreal
(
value
)
&&
isscalar
(
value
)
if
isfloat
(
value
)
&&
isfinite
(
value
)
&&
isreal
(
value
)
&&
isscalar
(
value
)
type
=
'FLOAT'
;
type
=
'FLOAT'
;
datatype
=
2
;
end
end
% String (DAFF_STRING)
% String (DAFF_STRING)
if
ischar
(
value
)
if
ischar
(
value
)
type
=
'STRING'
;
type
=
'STRING'
;
datatype
=
3
;
end
end
if
isempty
(
type
)
if
isempty
(
type
)
error
(
'Unsupported datatype %s for key
''
%s
''
in metadata'
,
class
(
value
),
name
);
error
(
'Unsupported datatype %s for key
''
%s
''
in metadata'
,
class
(
value
),
name
);
end
end
metadata_new_format
=
daffv15_metadata_addKey
(
metadata_new_format
,
name
,
type
,
value
);
%metadata_new_format = daffv15_metadata_addKey( metadata_new_format, name, type, value );
metadata_new_format
(
i
)
.
name
=
name
;
metadata_new_format
(
i
)
.
datatype
=
datatype
;
metadata_new_format
(
i
)
.
value
=
value
;
end
end
metadata
=
metadata_new_format
;
metadata
=
metadata_new_format
;
end
end
nkeys
=
length
(
metadata
);
% Number of keys
% Number of keys
fwrite
(
fid
,
nkeys
,
'int32'
);
fwrite
(
fid
,
nkeys
,
'int32'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment