mirror of https://gitlab.com/pamhyr/pamhyr2
AdisTS & AdisTT: deleted data no more exported in solver files
parent
6d58c09104
commit
456559ffe2
|
|
@ -505,12 +505,13 @@ class AdisTSwc(AdisTS):
|
|||
study, pollutant._data, f, qlog
|
||||
)
|
||||
|
||||
POL_ICs = next(filter(
|
||||
lambda ic: ic.pollutant == pollutant.id,
|
||||
POL_ICs = next((
|
||||
ic for ic in
|
||||
study.river.ic_adists.Initial_Conditions_List
|
||||
))
|
||||
if ic.pollutant == pollutant.id
|
||||
), None)
|
||||
|
||||
if POL_ICs.concentration is not None:
|
||||
if POL_ICs is not None and POL_ICs.concentration is not None:
|
||||
f.write(f"file_ini = {name}.INI\n")
|
||||
self._export_ICs_AdisTS(
|
||||
study, repertory, POL_ICs, qlog, name
|
||||
|
|
@ -550,15 +551,18 @@ class AdisTSwc(AdisTS):
|
|||
os.path.join(repertory, f"{POL_name}.ALD"), "w+"
|
||||
) as f:
|
||||
for LC in POL_LC:
|
||||
reach = next(filter(
|
||||
lambda edge: edge.id == LC.edge, study.river.enable_edges()
|
||||
)) # .name
|
||||
reach = next((
|
||||
edge for edge in study.river.enable_edges()
|
||||
if edge.id == LC.edge
|
||||
), None)
|
||||
if reach is None:
|
||||
continue
|
||||
reach_name = self.get_reach_name(reach)
|
||||
f.write(f"${reach_name} {LC.begin_rk} {LC.end_rk}\n")
|
||||
f.write(f"*temps |débit massique (kg/s)\n")
|
||||
f.write(f"*---------++++++++++\n")
|
||||
|
||||
for LC_data in LC._data:
|
||||
for LC_data in LC.data:
|
||||
tmp = timestamp_to_old_pamhyr_date_adists(int(LC_data[0]))
|
||||
f.write(" ".join((f"{tmp}",
|
||||
f"{LC_data[1]}\n")))
|
||||
|
|
@ -575,9 +579,10 @@ class AdisTSwc(AdisTS):
|
|||
repertory, f"{POL_name}.CDT"), "w+"
|
||||
) as f:
|
||||
for BC in POL_BC:
|
||||
node = next(filter(
|
||||
lambda x: x.id == BC.node, study.river._nodes
|
||||
))
|
||||
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")
|
||||
|
||||
if BC.type == "Concentration":
|
||||
|
|
@ -589,7 +594,7 @@ class AdisTSwc(AdisTS):
|
|||
f.write(f"*JJ:HH:MM | (kg/s)\n")
|
||||
f.write(f"*---------++++++++++\n")
|
||||
|
||||
for BC_data in BC._data:
|
||||
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")))
|
||||
|
|
@ -623,6 +628,9 @@ class AdisTSwc(AdisTS):
|
|||
|
||||
edges = study.river.enable_edges()
|
||||
for ic_spec in pol_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:
|
||||
|
|
@ -646,7 +654,9 @@ class AdisTSwc(AdisTS):
|
|||
list_characteristics = ["type", "diametre", "rho", "porosity",
|
||||
"cdc_riv", "cdc_cas", "apd", "ac", "bc"]
|
||||
|
||||
if len(list_characteristics) <= (len(pol_data[0])):
|
||||
pol_data = [data for data in pol_data if not data.is_deleted()]
|
||||
|
||||
if pol_data and len(list_characteristics) <= len(pol_data[0]):
|
||||
for i in range(len(list_characteristics)):
|
||||
f.write(f"{list_characteristics[i]} = {pol_data[0][i]}\n")
|
||||
|
||||
|
|
@ -675,6 +685,9 @@ class AdisTSwc(AdisTS):
|
|||
def _export_d90_spec(self, study, d90_spec_data, f, qlog, name="0"):
|
||||
|
||||
for d90_spec in d90_spec_data:
|
||||
if d90_spec.is_deleted():
|
||||
continue
|
||||
|
||||
if (d90_spec.name is None
|
||||
or d90_spec.reach is None
|
||||
or d90_spec.start_rk is None
|
||||
|
|
@ -734,6 +747,9 @@ class AdisTSwc(AdisTS):
|
|||
def _export_dif_spec(self, study, dif_spec_data, f, qlog, name="0"):
|
||||
|
||||
for dif_spec in dif_spec_data:
|
||||
if dif_spec.is_deleted():
|
||||
continue
|
||||
|
||||
if (dif_spec.reach is None
|
||||
or dif_spec.start_rk is None
|
||||
or dif_spec.end_rk is None
|
||||
|
|
|
|||
|
|
@ -497,16 +497,17 @@ class AdisTTwc(AdisTT):
|
|||
repertory, f"{TEM_name}.CDT"), "w+"
|
||||
) as f:
|
||||
for BC in TEM_BC:
|
||||
node = next(filter(
|
||||
lambda x: x.id == BC.node, study.river._nodes
|
||||
))
|
||||
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:
|
||||
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")))
|
||||
|
|
@ -538,6 +539,9 @@ class AdisTTwc(AdisTT):
|
|||
|
||||
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:
|
||||
|
|
@ -978,7 +982,7 @@ class AdisTTwc(AdisTT):
|
|||
filename = "TEM.CDT"
|
||||
with adistt_file_open(os.path.join(repertory, filename), "w+") as f:
|
||||
for boundary_condition in boundary_conditions:
|
||||
node = next((node for node in study.river._nodes
|
||||
node = next((node for node in study.river.nodes()
|
||||
if node.id == boundary_condition.node), None)
|
||||
if node is None:
|
||||
continue
|
||||
|
|
@ -1035,7 +1039,8 @@ class AdisTTwc(AdisTT):
|
|||
weather_files = {}
|
||||
for weather_parameter in study.river.weather_parameters.lst:
|
||||
config = self._weather_files.get(weather_parameter.type)
|
||||
if config is None or weather_parameter.reach is None:
|
||||
if (config is None or weather_parameter.reach is None
|
||||
or weather_parameter.reach.is_deleted()):
|
||||
continue
|
||||
_, extension = config
|
||||
exported = self._export_weather_file(
|
||||
|
|
@ -1049,7 +1054,7 @@ class AdisTTwc(AdisTT):
|
|||
defaults = study.river.weather_parameters
|
||||
for type_, (parameter, _) in self._weather_files.items():
|
||||
default = defaults.default_for_type(type_)
|
||||
if default is not None:
|
||||
if default is not None and not default.is_deleted():
|
||||
f.write(f"{parameter} = {default.value}\n")
|
||||
|
||||
f.write(f"file_ini = {initial_file}\n")
|
||||
|
|
|
|||
Loading…
Reference in New Issue