Commit d73f3b41 authored by Yan's avatar Yan
Browse files

Modified DRL export behaviour

parent b5900f09
......@@ -10,6 +10,7 @@ import numpy as np
import prasopes.datatools as dt
import prasopes.graphtools as gt
import prasopes.filetools as ft
import os.path
matplotlib.use("Qt5Agg")
......@@ -366,22 +367,37 @@ def export_drlspectrum(parent, fn, ptable, dtable, ds):
return
names, times, intensities = get_daughterset(ptable, dtable, ds)
pnames, ptimes, pintensities = get_parentset(ptable, dtable, ds)
exp_f_name = ft.get_save_filename(
fname = ft.get_save_filename(
"Export DRL data", "comma-separated values (*.csv)", "csv", parent)
names.append(" ")
for name in pnames:
names.append(name)
if exp_f_name is not '':
expf = open(exp_f_name, 'w')
exp_f_name = ["{}-raw.csv".format(fname[:-4]),
"{}-corrected.csv".format(fname[:-4])]
for name in exp_f_name:
if os.path.isfile(name):
quest = QtWidgets.QMessageBox.warning(
parent, "Export DRL data",
"File {} already exists in the filesystem.\n"
"Do you want to overwrite it?"
.format(os.path.basename(name)),
QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No)
if quest == QtWidgets.QMessageBox.No:
return
if fname is not '':
expf = open(exp_f_name[0], 'w')
expf.write("times, {}\n".format((",".join(pnames))))
for i in range(len(times)):
dataset = list()
dataset.append(times[i])
for intensity in pintensities:
dataset.append(intensity[i])
expf.write("{}\n".format((",".join(map(str, dataset)))))
expf.close()
expf = open(exp_f_name[1], 'w')
expf.write("times, {}\n".format((",".join(names))))
for i in range(len(times)):
dataset = list()
dataset.append(times[i])
for intensity in intensities:
dataset.append(intensity[i])
dataset.append(" ")
for intensity in pintensities:
dataset.append(intensity[i])
expf.write("{}\n".format((",".join(map(str, dataset)))))
expf.close()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment