mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
work on import data in results
This commit is contained in:
1 parent
016f3fc73c
commit
57a80d00aa
3 files changed
+49
-2
No files matched your search
@@ -337,7 +337,8 @@ class ResultsWindow(PamhyrWindow):
|
||||
"action_add": self._add_custom_plot,
|
||||
"action_export": self._export,
|
||||
# "action_export": self.export_current,
|
||||
"action_Geo_tiff": self.import_geotiff
|
||||
"action_Geo_tiff": self.import_geotiff,
|
||||
"action_import_data": self.import_data
|
||||
}
|
||||
self.find(QAction, "action_Geo_tiff").setEnabled(False)
|
||||
self.find(QAction, "action_Geo_tiff").setVisible(False)
|
||||
@@ -703,7 +704,7 @@ class ResultsWindow(PamhyrWindow):
|
||||
select_file="AnyFile",
|
||||
callback=lambda f: self.export_to(f[0], x, y, envelop, solver_id),
|
||||
default_suffix=".csv",
|
||||
file_filter=["CSV (*.csv)"],
|
||||
file_filter=[self._dict["file_csv"]],
|
||||
)
|
||||
|
||||
def export_to(self, filename, x, y, envelop, solver_id):
|
||||
@@ -1214,3 +1215,34 @@ class ResultsWindow(PamhyrWindow):
|
||||
# self.canvas.axes.set_xlim(xlim)
|
||||
# self.canvas.axes.set_ylim(ylim)
|
||||
return
|
||||
|
||||
def import_data(self):
|
||||
|
||||
file_types = [
|
||||
self._trad["file_csv"],
|
||||
self._trad["file_all"],
|
||||
]
|
||||
|
||||
self.file_dialog(
|
||||
select_file="Existing_file",
|
||||
callback=lambda f: self.read_csv_file(f[0]),
|
||||
default_suffix=".csv",
|
||||
file_filter=file_types,
|
||||
)
|
||||
|
||||
def read_csv_file(self, filename):
|
||||
with open(filename, 'r', newline='') as f:
|
||||
lines=f.readlines()
|
||||
x = []
|
||||
y = []
|
||||
for line in lines:
|
||||
if line[0] != "*" and line[0] != "#" and line[0] != "$":
|
||||
row = line.split(" ")
|
||||
print(row)
|
||||
if len(row) > 1:
|
||||
x.append(float(row[0]))
|
||||
y.append(float(row[1]))
|
||||
print(x)
|
||||
print(y)
|
||||
self.canvas_2.axes.scatter(x, y, marker="+")
|
||||
self.plot_rkc.idle()
|
||||
Reference in new issue
Block a user