Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Vasudevan, Rama K
pycroscopy
Commits
6b5f5598
Commit
6b5f5598
authored
Jan 17, 2019
by
Raj Giridharagopal
Browse files
added custom group name ability to pifm and igor
parent
a3879709
Changes
2
Hide whitespace changes
Inline
Side-by-side
pycroscopy/io/translators/igor_ibw.py
View file @
6b5f5598
...
...
@@ -22,7 +22,8 @@ class IgorIBWTranslator(Translator):
Translates Igor Binary Wave (.ibw) files containing images or force curves to .h5
"""
def
translate
(
self
,
file_path
,
verbose
=
False
,
append_path
=
''
,
parm_encoding
=
'utf-8'
):
def
translate
(
self
,
file_path
,
verbose
=
False
,
append_path
=
''
,
grp_name
=
''
,
parm_encoding
=
'utf-8'
):
"""
Translates the provided file to .h5
...
...
@@ -34,6 +35,8 @@ class IgorIBWTranslator(Translator):
Whether or not to show print statements for debugging
append_path : string (Optional)
h5_file to add these data to
grp_name : string (Optional)
Change from default "Measurement" name to something specific
parm_encoding : str, optional
Codec to be used to decode the bytestrings into Python strings if needed.
Default 'utf-8'
...
...
@@ -55,6 +58,8 @@ class IgorIBWTranslator(Translator):
h5_file
=
h5py
.
File
(
h5_path
,
'w'
)
else
:
h5_path
=
append_path
if
not
path
.
exists
(
append_path
):
raise
Exception
(
'Improper file'
)
h5_file
=
h5py
.
File
(
h5_path
,
'r+'
)
...
...
@@ -118,7 +123,10 @@ class IgorIBWTranslator(Translator):
spec_desc
=
Dimension
(
'Z'
,
'm'
,
spec_data
)
# Create measurement group
meas_grp
=
create_indexed_group
(
h5_file
,
'Measurement'
)
if
not
grp_name
:
meas_grp
=
create_indexed_group
(
h5_file
,
'Measurement'
)
else
:
meas_grp
=
create_indexed_group
(
h5_file
,
grp_name
)
# Write file and measurement level parameters
global_parms
=
generate_dummy_main_parms
()
...
...
pycroscopy/io/translators/pifm.py
View file @
6b5f5598
...
...
@@ -12,7 +12,7 @@ class PiFMTranslator(Translator):
structure.
"""
def
translate
(
self
,
path
,
append_path
=
''
):
def
translate
(
self
,
path
,
append_path
=
''
,
grp_name
=
''
):
"""
Parameters
----------
...
...
@@ -38,7 +38,7 @@ class PiFMTranslator(Translator):
self
.
read_imgs
()
self
.
read_spectra
()
self
.
make_pos_vals_inds_dims
()
self
.
create_hdf5_file
(
append_path
)
self
.
create_hdf5_file
(
append_path
,
grp_name
)
self
.
write_spectrograms
()
self
.
write_images
()
self
.
write_spectra
()
...
...
@@ -184,7 +184,7 @@ class PiFMTranslator(Translator):
usid
.
write_utils
.
Dimension
(
'Y'
,
self
.
params_dictionary
[
'YPhysUnit'
].
replace
(
'
\xb5
'
,
'u'
),
self
.
y_len
)]
self
.
pos_ind
,
self
.
pos_val
,
self
.
pos_dims
=
pos_ind
,
pos_val
,
pos_dims
def
create_hdf5_file
(
self
,
append_path
=
''
):
def
create_hdf5_file
(
self
,
append_path
=
''
,
grp_name
=
''
):
if
not
append_path
:
h5_path
=
os
.
path
.
join
(
self
.
directory
,
self
.
basename
.
replace
(
'.txt'
,
'.h5'
))
if
os
.
path
.
exists
(
h5_path
):
...
...
@@ -196,7 +196,11 @@ class PiFMTranslator(Translator):
else
:
self
.
h5_f
=
h5py
.
File
(
append_path
,
mode
=
'r+'
)
self
.
h5_meas_grp
=
usid
.
hdf_utils
.
create_indexed_group
(
self
.
h5_f
,
'Measurement_'
)
if
not
grp_name
:
self
.
h5_meas_grp
=
usid
.
hdf_utils
.
create_indexed_group
(
self
.
h5_f
,
'Measurement_'
)
else
:
self
.
h5_meas_grp
=
usid
.
hdf_utils
.
create_indexed_group
(
self
.
h5_f
,
grp_name
)
usid
.
hdf_utils
.
write_simple_attrs
(
self
.
h5_meas_grp
,
self
.
params_dictionary
)
return
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment