r""" Add QA calibration data to the object. Calibration data is represented as a dictionary which satisfies ``_xrf_quant_fluor_schema`` schema. Calibration data may be loaded from JSON file (with file name ``file_path``), but it may already exist in memory as a dictio
(self, file_path, *, calibration_data)
| 1232 | self.add_entry(file_path, calibration_data=calib_data) |
| 1233 | |
| 1234 | def add_entry(self, file_path, *, calibration_data): |
| 1235 | r""" |
| 1236 | Add QA calibration data to the object. Calibration data is represented as a dictionary |
| 1237 | which satisfies ``_xrf_quant_fluor_schema`` schema. Calibration data may be loaded |
| 1238 | from JSON file (with file name ``file_path``), but it may already exist in memory |
| 1239 | as a dictionary (for example it may be generated or stored by some other module of |
| 1240 | the program). ``file_path`` does not have to represent valid file path, but some |
| 1241 | unique meaningful string, which may be used to identify calibration entries. |
| 1242 | This function DOES NOT LOAD calibration data from file! Use the function |
| 1243 | ``load_entry()`` to load data from file. |
| 1244 | |
| 1245 | Parameters |
| 1246 | ---------- |
| 1247 | |
| 1248 | file_path: str |
| 1249 | |
| 1250 | String (perferably meaningful and human readable) used to identify the data entry. |
| 1251 | The value of this parameter is used to distinguish between calibration data |
| 1252 | entries (identify duplicates, search for calibration entries etc.). If data is |
| 1253 | loaded from file, then this parameter is naturally set to full path to the file |
| 1254 | that holds calibration data entry. |
| 1255 | |
| 1256 | calibration_data: dict |
| 1257 | |
| 1258 | Calibration data entry: dictionary that satisfies schema ``_xrf_quant_fluor_schema``. |
| 1259 | |
| 1260 | """ |
| 1261 | |
| 1262 | # Do not load duplicates (distinguished by file name). Different file names may contain |
| 1263 | # the same data, but this is totally up to the user. Loading duplicates should not |
| 1264 | # disrupt the processing, since the user may choose the source of calibration data |
| 1265 | # for each emission line. |
| 1266 | if not any(file_path == _["file_path"] for _ in self.calibration_settings): |
| 1267 | self.calibration_data.append(calibration_data) |
| 1268 | |
| 1269 | settings = {} |
| 1270 | settings["file_path"] = file_path |
| 1271 | settings["element_lines"] = {} |
| 1272 | for ln in calibration_data["element_lines"]: |
| 1273 | settings["element_lines"][ln] = {} |
| 1274 | # Do not select the emission line |
| 1275 | settings["element_lines"][ln]["selected"] = False |
| 1276 | |
| 1277 | self.calibration_settings.append(settings) |
| 1278 | # This will also select the emission line if it occurs the first time |
| 1279 | self.update_emission_line_list() |
| 1280 | else: |
| 1281 | logger.info(f"Calibration data file '{file_path}' is already loaded") |
| 1282 | |
| 1283 | def remove_entry(self, file_path): |
| 1284 | r""" |
no test coverage detected