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
cc6a0c96
Commit
cc6a0c96
authored
Jun 23, 2020
by
ssomnath
Browse files
Refactored dunder functions to be more open
Helps especially when reusing static functions
parent
162a7f2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
pycroscopy/io/translators/be_odf.py
View file @
cc6a0c96
...
...
@@ -260,7 +260,7 @@ class BEodfTranslator(Translator):
elif
'old_mat_parms'
in
path_dict
.
keys
():
if
verbose
:
print
(
'
\t
reading BE arrays from old mat text file'
)
bin_inds
,
bin_freqs
,
bin_FFT
,
ex_wfm
,
dc_amp_vec
=
self
.
_
_
read_old_mat_be_vecs
(
path_dict
[
'old_mat_parms'
],
verbose
=
verbose
)
bin_inds
,
bin_freqs
,
bin_FFT
,
ex_wfm
,
dc_amp_vec
=
self
.
_read_old_mat_be_vecs
(
path_dict
[
'old_mat_parms'
],
verbose
=
verbose
)
else
:
if
verbose
:
print
(
'
\t
Generating dummy BE arrays'
)
...
...
@@ -285,7 +285,7 @@ class BEodfTranslator(Translator):
if
isBEPS
:
if
verbose
:
print
(
'
\t
Building UDVS table for BEPS'
)
UDVS_labs
,
UDVS_units
,
UDVS_mat
=
self
.
_
_
build_udvs_table
(
parm_dict
,
verbose
=
verbose
)
UDVS_labs
,
UDVS_units
,
UDVS_mat
=
self
.
_build_udvs_table
(
parm_dict
,
verbose
=
verbose
)
if
verbose
:
print
(
'
\t
Trimming UDVS table to remove unused plot group columns'
)
...
...
@@ -577,25 +577,25 @@ class BEodfTranslator(Translator):
# Do this for all BE-Line (always small enough to read in one shot)
if
verbose
:
print
(
'
\t\t
Reading all raw data for BE-Line in one shot'
)
self
.
_
_
quick_read_data
(
path_dict
[
'read_real'
],
path_dict
[
'read_imag'
],
parm_dict
[
'num_udvs_steps'
])
self
.
_quick_read_data
(
path_dict
[
'read_real'
],
path_dict
[
'read_imag'
],
parm_dict
[
'num_udvs_steps'
])
elif
real_size
<
self
.
max_ram
and
parm_dict
[
'VS_measure_in_field_loops'
]
==
'out-of-field'
:
# Do this for out-of-field BEPS ONLY that is also small (256 MB)
if
verbose
:
print
(
'
\t\t
Reading all raw BEPS (out-of-field) data in one shot'
)
self
.
_
_
quick_read_data
(
path_dict
[
'read_real'
],
path_dict
[
'read_imag'
],
parm_dict
[
'num_udvs_steps'
])
self
.
_quick_read_data
(
path_dict
[
'read_real'
],
path_dict
[
'read_imag'
],
parm_dict
[
'num_udvs_steps'
])
elif
real_size
<
self
.
max_ram
and
parm_dict
[
'VS_measure_in_field_loops'
]
==
'in-field'
:
# Do this for in-field only
if
verbose
:
print
(
'
\t\t
Reading all raw BEPS (in-field only) data in one shot'
)
self
.
_
_
quick_read_data
(
path_dict
[
'write_real'
],
path_dict
[
'write_imag'
],
parm_dict
[
'num_udvs_steps'
])
self
.
_quick_read_data
(
path_dict
[
'write_real'
],
path_dict
[
'write_imag'
],
parm_dict
[
'num_udvs_steps'
])
else
:
# Large BEPS datasets OR those with in-and-out of field
if
verbose
:
print
(
'
\t\t
Reading all raw data for in and out of filed OR very large file'
)
self
.
_
_
read_beps_data
(
path_dict
,
UDVS_mat
.
shape
[
0
],
parm_dict
[
'VS_measure_in_field_loops'
],
add_pix
)
self
.
_read_beps_data
(
path_dict
,
UDVS_mat
.
shape
[
0
],
parm_dict
[
'VS_measure_in_field_loops'
],
add_pix
)
self
.
h5_raw
.
file
.
flush
()
def
_
_read_beps_data
(
self
,
path_dict
,
udvs_steps
,
mode
,
add_pixel
=
False
):
def
_read_beps_data
(
self
,
path_dict
,
udvs_steps
,
mode
,
add_pixel
=
False
):
"""
Reads the imaginary and real data files pixelwise and writes to the H5 file
...
...
@@ -643,8 +643,8 @@ class BEodfTranslator(Translator):
step_size
=
int
(
step_size
)
rand_spectra
=
self
.
_
_
get_random_spectra
(
parsers
,
self
.
h5_raw
.
shape
[
0
],
udvs_steps
,
step_size
,
num_spectra
=
self
.
num_rand_spectra
)
rand_spectra
=
self
.
_get_random_spectra
(
parsers
,
self
.
h5_raw
.
shape
[
0
],
udvs_steps
,
step_size
,
num_spectra
=
self
.
num_rand_spectra
)
take_conjugate
=
requires_conjugate
(
rand_spectra
,
cores
=
self
.
_cores
)
self
.
mean_resp
=
np
.
zeros
(
shape
=
(
self
.
h5_raw
.
shape
[
1
]),
dtype
=
np
.
complex64
)
...
...
@@ -698,7 +698,7 @@ class BEodfTranslator(Translator):
print
(
'---- Finished reading files -----'
)
def
_
_quick_read_data
(
self
,
real_path
,
imag_path
,
udvs_steps
):
def
_quick_read_data
(
self
,
real_path
,
imag_path
,
udvs_steps
):
"""
Returns information about the excitation BE waveform present in the .mat file
...
...
@@ -716,8 +716,8 @@ class BEodfTranslator(Translator):
parser
=
BEodfParser
(
real_path
,
imag_path
,
self
.
h5_raw
.
shape
[
0
],
self
.
h5_raw
.
shape
[
1
]
*
4
)
step_size
=
self
.
h5_raw
.
shape
[
1
]
/
udvs_steps
rand_spectra
=
self
.
_
_
get_random_spectra
([
parser
],
self
.
h5_raw
.
shape
[
0
],
udvs_steps
,
step_size
,
num_spectra
=
self
.
num_rand_spectra
)
rand_spectra
=
self
.
_get_random_spectra
([
parser
],
self
.
h5_raw
.
shape
[
0
],
udvs_steps
,
step_size
,
num_spectra
=
self
.
num_rand_spectra
)
take_conjugate
=
requires_conjugate
(
rand_spectra
,
cores
=
self
.
_cores
)
raw_vec
=
parser
.
read_all_data
()
if
take_conjugate
:
...
...
@@ -902,7 +902,7 @@ class BEodfTranslator(Translator):
@
staticmethod
def
_
_read_old_mat_be_vecs
(
file_path
,
verbose
=
False
):
def
_read_old_mat_be_vecs
(
file_path
,
verbose
=
False
):
"""
Returns information about the excitation BE waveform present in the
more parms.mat file
...
...
@@ -1242,7 +1242,7 @@ class BEodfTranslator(Translator):
return
BE_bin_ind
,
BE_bin_w
,
BE_bin_FFT
,
ex_wfm
def
_
_build_udvs_table
(
self
,
parm_dict
,
verbose
=
False
):
def
_build_udvs_table
(
self
,
parm_dict
,
verbose
=
False
):
"""
Generates the UDVS table using the parameters
...
...
@@ -1426,7 +1426,7 @@ class BEodfTranslator(Translator):
return
UD_VS_table_label
,
UD_VS_table_unit
,
udvs_table
@
staticmethod
def
_
_get_random_spectra
(
parsers
,
num_pixels
,
num_udvs_steps
,
num_bins
,
num_spectra
=
100
,
verbose
=
False
):
def
_get_random_spectra
(
parsers
,
num_pixels
,
num_udvs_steps
,
num_bins
,
num_spectra
=
100
,
verbose
=
False
):
"""
Parameters
----------
...
...
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