mirror of https://gitlab.com/pamhyr/pamhyr2
work on import data in results
parent
016f3fc73c
commit
57a80d00aa
|
|
@ -337,7 +337,8 @@ class ResultsWindow(PamhyrWindow):
|
||||||
"action_add": self._add_custom_plot,
|
"action_add": self._add_custom_plot,
|
||||||
"action_export": self._export,
|
"action_export": self._export,
|
||||||
# "action_export": self.export_current,
|
# "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").setEnabled(False)
|
||||||
self.find(QAction, "action_Geo_tiff").setVisible(False)
|
self.find(QAction, "action_Geo_tiff").setVisible(False)
|
||||||
|
|
@ -703,7 +704,7 @@ class ResultsWindow(PamhyrWindow):
|
||||||
select_file="AnyFile",
|
select_file="AnyFile",
|
||||||
callback=lambda f: self.export_to(f[0], x, y, envelop, solver_id),
|
callback=lambda f: self.export_to(f[0], x, y, envelop, solver_id),
|
||||||
default_suffix=".csv",
|
default_suffix=".csv",
|
||||||
file_filter=["CSV (*.csv)"],
|
file_filter=[self._dict["file_csv"]],
|
||||||
)
|
)
|
||||||
|
|
||||||
def export_to(self, filename, x, y, envelop, solver_id):
|
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_xlim(xlim)
|
||||||
# self.canvas.axes.set_ylim(ylim)
|
# self.canvas.axes.set_ylim(ylim)
|
||||||
return
|
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()
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,8 @@ class ResultsTranslate(MainTranslate):
|
||||||
self._dict["file_all"] = _translate("Results", "All files (*)")
|
self._dict["file_all"] = _translate("Results", "All files (*)")
|
||||||
self._dict["file_geotiff"] = _translate(
|
self._dict["file_geotiff"] = _translate(
|
||||||
"Results", "GeoTIFF file (*.tiff *.tif)")
|
"Results", "GeoTIFF file (*.tiff *.tif)")
|
||||||
|
self._dict["file_csv"] = _translate(
|
||||||
|
"Results", "CSV file (*.csv)")
|
||||||
self._dict["ImageCoordinates"] = _translate(
|
self._dict["ImageCoordinates"] = _translate(
|
||||||
"Results", "Image coordinates"
|
"Results", "Image coordinates"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -239,6 +239,7 @@
|
||||||
<addaction name="action_export"/>
|
<addaction name="action_export"/>
|
||||||
<addaction name="action_reload"/>
|
<addaction name="action_reload"/>
|
||||||
<addaction name="action_Geo_tiff"/>
|
<addaction name="action_Geo_tiff"/>
|
||||||
|
<addaction name="action_import_data"/>
|
||||||
</widget>
|
</widget>
|
||||||
<action name="action_add">
|
<action name="action_add">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
|
|
@ -288,6 +289,18 @@
|
||||||
<string>Import background image</string>
|
<string>Import background image</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="action_import_data">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>ressources/import.png</normaloff>ressources/import.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Import data</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Import data from SCV file</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue