diff --git a/src/Solver/AdisTS.py b/src/Solver/AdisTS.py index e03a69761a0a41e07a27733c0086d6ba5e9c8274..337736dc6339acd91b07d8939d0bf14d38af58e4 100644 --- a/src/Solver/AdisTS.py +++ b/src/Solver/AdisTS.py @@ -619,6 +619,7 @@ class AdisTSwc(AdisTS): @timer def read_bin(self, study, repertory, results, qlog=None, name="0"): + repertory_results = os.path.join(repertory, "resultats") files_bin_names = [el.split("/")[-1] @@ -626,13 +627,11 @@ class AdisTSwc(AdisTS): files_bin_names.insert(0, files_bin_names.pop( files_bin_names.index("total_sediment.bin")) ) - print("files names resultats: ", files_bin_names) ifilename = os.path.join(repertory_results, files_bin_names[0]) logger.info(f"read_bin: Start reading '{ifilename}' ...") - print("reading ", ifilename) with open(ifilename, 'rb') as f: # header # first line @@ -651,7 +650,6 @@ class AdisTSwc(AdisTS): data = np.fromfile(f, dtype=np.int32, count=2 * ibmax) is1 = np.zeros(ibmax, dtype=np.int32) is2 = np.zeros(ibmax, dtype=np.int32) - print("nombre de biefs : ", ibmax) logger.debug(f"read_bin: nb_reach = {ibmax}") logger.debug(f"read_bin: nb_profile = {ismax}") @@ -813,15 +811,6 @@ class AdisTSwc(AdisTS): [timestamps_keys[0]].keys()) type_pol_index = len(phys_data_names) - # ##print("pol keys: ", pollutants_keys) - # ##print("t keys: ", timestamps_keys) - # ##print("phys var: ", phys_data_names) - # ##print("phys data names mass zero:", - # list(data_tmp[pollutants_keys[1]][timestamps_keys[0]].keys())) - # print("set timestamps keys: ", set(timestamps_keys)) - # print("isma") - # ##print("iprofiles: ", iprofiles) - for r, reach in enumerate(reachs): for i in range(is1[r]-1, is2[r]): p_i = ip_to_ri(reach, i) @@ -861,15 +850,29 @@ class AdisTSwc(AdisTS): self._export_POLs, ] + def rm_previous_results(self, study, repertory, qlog): + + if "resultats" not in os.listdir(repertory): + return + + repertory_results = os.path.join(repertory, "resultats") + + files_bin_names = [el.split("/")[-1] + for el in glob.glob(repertory_results+"/*.bin")] + for el in glob.glob(repertory_results+"/*.bin"): + os.remove(el) + @timer def export(self, study, repertory, mage_rep, qlog=None, name="0"): - print("cmd solver adistswc : ", self._cmd_solver) + logger.debug(f"cmd solver adistswc : {self._cmd_solver}") self._study = study name = study.name.replace(" ", "_") # Generate files files = [] + self.rm_previous_results(study, repertory, qlog) + try: for func in self.export_func_dict(): files = files + func(study, repertory, qlog, name=name) diff --git a/src/View/BoundaryConditionsAdisTS/Table.py b/src/View/BoundaryConditionsAdisTS/Table.py index 9f657b463511ecbd0b3b3c5659a459427be2ff12..8b1554970dba01f67ec6db90bb8ef6fc4dd425f5 100644 --- a/src/View/BoundaryConditionsAdisTS/Table.py +++ b/src/View/BoundaryConditionsAdisTS/Table.py @@ -146,8 +146,7 @@ class TableModel(PamhyrTableModel): n = data[row].node if n is None: return self._trad["not_associated"] - tmp = next(filter(lambda x: x.id == n, self._data._nodes), - None) + tmp = next(filter(lambda x: x.id == n, self._data._nodes), None) if tmp is not None: return tmp.name else: @@ -156,7 +155,14 @@ class TableModel(PamhyrTableModel): n = data[row].pollutant if n is None or n == "not_associated" or n == "": return self._trad["not_associated"] - return self._data._Pollutants.Pollutants_List[n].name + tmp = next(filter(lambda x: x.id == n, + self._data._Pollutants.Pollutants_List + ), + None) + if tmp is not None: + return tmp.name + else: + return self._trad["not_associated"] return QVariant() diff --git a/src/View/InitialConditionsAdisTS/Table.py b/src/View/InitialConditionsAdisTS/Table.py index e84498124424e4ad8951d0b8a8c8d185d9ade37e..3ea581988c4c1347a6cbd159b8ddfe9b5ba3408c 100644 --- a/src/View/InitialConditionsAdisTS/Table.py +++ b/src/View/InitialConditionsAdisTS/Table.py @@ -63,7 +63,7 @@ class ComboBoxDelegate(QItemDelegate): reach_id = self._ic_spec_lst[index.row()].reach reach = next(filter(lambda edge: edge.id == reach_id, - self._data.edges())) + self._data.edges()), None) if reach_id is not None: val = list( diff --git a/src/View/Pollutants/UndoCommand.py b/src/View/Pollutants/UndoCommand.py index 999676a5fd4aa4b8bab3d7f64b08b0d3d1c787ed..085a48b55845baa94e52fe236edb9f8b4921f3aa 100644 --- a/src/View/Pollutants/UndoCommand.py +++ b/src/View/Pollutants/UndoCommand.py @@ -101,7 +101,9 @@ class DelCommand(QUndoCommand): for row in rows: self._pollutants.append((row, self._pollutants_lst.get(row))) - self._inc_pollutants.append((row, self._inc_pollutants_lst)) + self._inc_pollutants.append( + (row, self._inc_pollutants_lst.get(row)) + ) self._pollutants.sort() self._inc_pollutants.sort() diff --git a/src/View/Pollutants/Window.py b/src/View/Pollutants/Window.py index 37cb36c30154b8bad3b1acb0ae800d8635b3429f..8304ec23b86a712079af2e4df3cf89cf1435e004 100644 --- a/src/View/Pollutants/Window.py +++ b/src/View/Pollutants/Window.py @@ -105,7 +105,6 @@ class PollutantsWindow(PamhyrWindow): def setup_connections(self): self.find(QAction, "action_add").triggered.connect(self.add) - self.find(QAction, "action_delete").setEnabled(False) self.find(QAction, "action_delete").triggered.connect(self.delete) self.find(QAction, "action_edit").triggered.connect(self.edit) self.find(QAction, "action_initial_conditions" @@ -205,8 +204,9 @@ class PollutantsWindow(PamhyrWindow): for row in rows: pollutant_id = self._pollutants_lst.get(row).id + iclist = self._study.river.ic_adists.Initial_Conditions_List ics_adists = next(filter(lambda x: x.pollutant == pollutant_id, - self._study.river.ic_adists.lst)) + iclist)) if self.sub_window_exists( InitialConditionsAdisTSWindow,