(
data, *, output_dir, file_name, name_prefix_detector, name_append, file_format, scaler_name_list
)
| 1357 | os.makedirs(output_dir, exist_ok=True) |
| 1358 | |
| 1359 | def _save_data( |
| 1360 | data, *, output_dir, file_name, name_prefix_detector, name_append, file_format, scaler_name_list |
| 1361 | ): |
| 1362 | # The 'file_format' is specified as file extension |
| 1363 | file_extension = file_format.lower() |
| 1364 | |
| 1365 | # If data is scalar or position, then don't attach the prefix |
| 1366 | fname = ( |
| 1367 | f"{name_prefix_detector}_{file_name}" |
| 1368 | if (file_name not in scaler_name_list) and ("pos" not in file_name) |
| 1369 | else file_name |
| 1370 | ) |
| 1371 | |
| 1372 | fname = f"{fname}{name_append}.{file_extension}" |
| 1373 | fname = os.path.join(output_dir, fname) |
| 1374 | if file_format.lower() == "tiff": |
| 1375 | sio.imsave(fname, data.astype(np.float32)) |
| 1376 | elif file_format.lower() == "txt": |
| 1377 | np.savetxt(fname, data.astype(np.float32)) |
| 1378 | else: |
| 1379 | raise ValueError(f"Function is called with invalid file format '{file_format}'.") |
| 1380 | |
| 1381 | if quant_norm: |
| 1382 | if param_quant_analysis: |
no outgoing calls
no test coverage detected