MCPcopy Create free account
hub / github.com/NSLS2/PyXRF / _save_data

Function _save_data

pyxrf/model/fileio.py:1359–1379  ·  view source on GitHub ↗
(
        data, *, output_dir, file_name, name_prefix_detector, name_append, file_format, scaler_name_list
    )

Source from the content-addressed store, hash-verified

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:

Callers 1

output_data_to_tiffFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected