Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pygwinc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lee McCuller
pygwinc
Commits
7370169b
Commit
7370169b
authored
6 years ago
by
Jameson Graef Rollins
Browse files
Options
Downloads
Patches
Plain Diff
convenience load_struct() function to load a Struct from yaml or mat file
parent
0f2aa828
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gwinc/__init__.py
+1
-0
1 addition, 0 deletions
gwinc/__init__.py
gwinc/struct.py
+28
-0
28 additions, 0 deletions
gwinc/struct.py
with
29 additions
and
0 deletions
gwinc/__init__.py
+
1
−
0
View file @
7370169b
from
.struct
import
load_struct
from
.ifo
import
load_ifo
from
.precomp
import
precompIFO
from
.gwinc
import
noise_calc
...
...
This diff is collapsed.
Click to expand it.
gwinc/struct.py
+
28
−
0
View file @
7370169b
...
...
@@ -324,3 +324,31 @@ class Struct(object):
return
cls
.
from_matstruct
(
s
)
else
:
raise
IOError
(
"
Unknown file type: {}
"
.
format
(
ext
))
def
load_struct
(
path
):
"""
Load struct from YAML or MATLAB file.
Files may be either .yaml, .mat or .m. For .m files, the file is
expected to include either an object or function that corresponds
to the basename of the file. The MATLAB engine will be invoked to
execute the .m code and extract the resultant IFO data.
"""
root
,
ext
=
os
.
path
.
splitext
(
path
)
if
ext
==
'
.m
'
:
from
..gwinc_matlab
import
Matlab
matlab
=
Matlab
()
matlab
.
addpath
(
os
.
path
.
dirname
(
path
))
func_name
=
os
.
path
.
basename
(
root
)
matlab
.
eval
(
"
ifo = {};
"
.
format
(
func_name
),
nargout
=
0
)
ifo
=
matlab
.
extract
(
'
ifo
'
)
return
Struct
.
from_matstruct
(
ifo
)
else
:
return
Struct
.
from_file
(
path
)
# accepted extension types for struct files
STRUCT_EXT
=
[
'
.yaml
'
,
'
.yml
'
,
'
.mat
'
,
'
.m
'
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment