Browse Source

added --quite flag to cli to bypass sanity checks

xmlparsing
Holger Frey 3 years ago
parent
commit
430ed5c8ca
  1. 11
      sensospot_data/__init__.py
  2. 8
      sensospot_data/parser.py

11
sensospot_data/__init__.py

@ -38,9 +38,16 @@ from .dynamic_range import blend, create_xdr, normalize_values # noqa: F401 @@ -38,9 +38,16 @@ from .dynamic_range import blend, create_xdr, normalize_values # noqa: F401
default="raw_data.h5",
help="Output file name",
)
def run(source, outfile):
@click.option(
"-q",
"--quiet",
is_flag=True,
default=False,
help="Ignore Sanity Check",
)
def run(source, outfile, quiet=False):
source_path = Path(source)
# read the raw data of a folder
raw_data = parse_folder(source_path)
raw_data = parse_folder(source_path, quiet=quiet)
hdf5_path = source_path / outfile
raw_data.to_hdf(hdf5_path, key="raw_data", format="table")

8
sensospot_data/parser.py

@ -124,16 +124,20 @@ def _sanity_check(data_frame): @@ -124,16 +124,20 @@ def _sanity_check(data_frame):
spot_positions = len(data_frame[RAW_DATA_POS_ID].unique())
expected_rows = field_rows * field_cols * exposures * spot_positions
if expected_rows != len(data_frame):
raise ValueError("Measurements are missing")
raise ValueError(
f"Measurements are missing: {expected_rows} != {len(data_frame)}"
)
# set the right data type for measurement columns
for raw_column in RAW_DATA_NORMALIZATION_MAP:
data_frame[raw_column] = pandas.to_numeric(data_frame[raw_column])
return data_frame
def parse_folder(folder):
def parse_folder(folder, quiet=False):
""" parses all csv files in a folder to one large dataframe """
file_list = list_csv_files(Path(folder))
data_frame = parse_multiple_files(file_list)
data_frame = add_optional_measurement_parameters(data_frame, folder)
if quiet:
return data_frame
return _sanity_check(data_frame)

Loading…
Cancel
Save