diff --git a/src/Solver/AdisTT.py b/src/Solver/AdisTT.py index bcb644a8..4d16753e 100644 --- a/src/Solver/AdisTT.py +++ b/src/Solver/AdisTT.py @@ -444,119 +444,6 @@ class AdisTTwc(AdisTT): return lst - def _export_TEMs(self, study, repertory, qlog=None, name="0"): - - files = [] - - if qlog is not None: - qlog.put("Export TEMs files") - - name = "TEM" - with adistt_file_open( - os.path.join(repertory, f"{name}.POL"), "w+" - ) as f: - - TEM_ICs = ( - study.river._InitialConditionsTemperature - .Initial_Conditions_List - ) - - TEM_IC = TEM_ICs[0] if TEM_ICs else None - print(f"TEM_IC: {TEM_IC}") - - if TEM_IC and TEM_IC._temperature is not None: - print(f"TEM_IC._temperature: {TEM_IC._temperature}") - f.write(f"file_ini = {name}.INI\n") - self._export_ICs_AdisTT( - study, repertory, TEM_IC, qlog, name - ) - else: - logger.info( - "No TEM initial conditions defined, skipping export" - ) - - TEM_BCs = ( - study.river._BoundaryConditionsTemperature - .BCs_Temperature_List - ) - - if TEM_BCs: - f.write(f"file_cl = {name}.CDT\n") - self._export_BCs_AdisTT( - study, repertory, TEM_BCs, qlog, name - ) - - return files - - def _export_BCs_AdisTT(self, study, repertory, TEM_BC, qlog, TEM_name): - - if qlog is not None: - qlog.put("Export TEM BCs files") - - with adistt_file_open(os.path.join( - repertory, f"{TEM_name}.CDT"), "w+" - ) as f: - for BC in TEM_BC: - node = next((node for node in study.river.nodes() - if node.id == BC.node), None) - if node is None: - continue - f.write(f"${self.get_node_name(node)}\n") - - f.write(f"*temps |temperature\n") - f.write(f"*JJ:HH:MM | (°C)\n") - f.write(f"*---------++++++++++\n") - - for BC_data in BC.data: - tmp = timestamp_to_old_pamhyr_date_adists(int(BC_data[0])) - f.write(" ".join((f"{tmp}", - f"{BC_data[1]}\n"))) - f.write(f"*\n") - - return True - - def _export_ICs_AdisTT(self, study, repertory, - TEM_IC_default, qlog, TEM_name): - - if qlog is not None: - qlog.put("Export TEM ICs files") - - with adistt_file_open(os.path.join( - repertory, f"{TEM_name}.INI" - ), "w+") as f: - f.write(f"*État initial pour le polluant {TEM_name}\n") - f.write(" ".join(("DEFAULT =", - f"{TEM_IC_default.temperature}", - "0.0 0.0 0.0\n"))) # fake 0 to match adists - - if len(TEM_IC_default._data) != 0: - self._export_ICs_AdisTT_Spec( - study, TEM_IC_default._data, f, qlog - ) - - def _export_ICs_AdisTT_Spec(self, study, tem_ics_spec_data, - f, qlog, name="0"): - - edges = study.river.enable_edges() - for ic_spec in tem_ics_spec_data: - if ic_spec.is_deleted(): - continue - - id_reach = ic_spec.reach - reach = next((x for x in edges if x.id == id_reach), None) - if reach is None: - continue - - f.write(" ".join((f"{ic_spec.name}", - "=", - f"{study.river.get_edge_id(reach)+1}", - f"{ic_spec.start_rk}", - f"{ic_spec.end_rk}", - f"{ic_spec.temperature}", - f"0.0 0.0 0.0 0.0\n"))) # fake 0 to match adists - - return True - # def _export_D90(self, study, repertory, qlog=None, name="0"): # files = [] @@ -1022,6 +909,10 @@ class AdisTTwc(AdisTT): if qlog is not None: qlog.put("Export TEM files") + legacy_pol = os.path.join(repertory, "TEM.POL") + if os.path.exists(legacy_pol): + os.remove(legacy_pol) + # Weather files are appended range by range below. Remove files from # a previous export first so rerunning an unchanged study is stable. for _, extension in self._weather_files.values(): @@ -1071,8 +962,7 @@ class AdisTTwc(AdisTT): def export_func_dict(self): return [ self._export_NUM, - self._export_TEM, - self._export_TEMs + self._export_TEM ] def rm_previous_results(self, study, repertory, qlog): diff --git a/src/tools.py b/src/tools.py index d98d40ae..35f806fd 100644 --- a/src/tools.py +++ b/src/tools.py @@ -321,7 +321,7 @@ def timestamp_to_old_pamhyr_date_adists(time: int): minutes = (dt.seconds % 3600) // 60 seconds = dt.seconds % 60 - s = f"{dt.days:>3}:{hours:>2}:{minutes:>2}"#:{seconds:>2}" + s = f"{dt.days:>3}:{hours:>2}:{minutes:>2}" s = s.replace(" ", "0") return s