Commit 02f183a2 authored by ssomnath's avatar ssomnath
Browse files

Added the new is_valid_file function to BE ODF Translator

parent 9088c864
......@@ -23,6 +23,7 @@ from import write_ind_val_dsets, write_main_dataset, write_r
from import USIDataset
from pyUSID.processing.comp_utils import get_available_memory
class BEodfTranslator(Translator):
Translates either the Band Excitation (BE) scan or Band Excitation
......@@ -37,6 +38,36 @@ class BEodfTranslator(Translator):
self.signal_type = None
self.expt_type = None
def is_valid_file(file_path):
Checks whether the provided file can be read by this translator
file_path : str
Path to raw data file
bool : Whether or not this translator can read this file
file_path = path.abspath(file_path)
# Check if the data is in the new or old format:
data_dir, _ = path.split(file_path)
_, base_name = path.split(data_dir)
if base_name == 'newdataformat':
# Though this translator could also read the files but the NDF Translator is more robust...
return False
_, path_dict = BEodfTranslator._parse_file_path(file_path)
if any([x in path_dict.keys() for x in ['parm_txt', 'old_mat_parms',
'read_real', 'write_real']]):
return True
return False
def translate(self, file_path, show_plots=True, save_plots=True, do_histogram=False, verbose=False):
Translates .dat data file(s) to a single .h5 file
......@@ -538,7 +569,8 @@ class BEodfTranslator(Translator):
print('---- Finished reading files -----')
def _parse_file_path(self, data_filepath):
def _parse_file_path(data_filepath):
Returns the basename and a dictionary containing the absolute file paths for the
real and imaginary data files, text and mat parameter files in a dictionary
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment