Skip to content

Commit

Permalink
Python 3 support
Browse files Browse the repository at this point in the history
This program no longer works with Python 2 as it has reach its end of life. Please upgrade to Python 3 to continue using this program.
  • Loading branch information
yz3062 committed Jan 20, 2020
1 parent 1bb3190 commit 5528e57
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions PaxsPy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,23 @@
import numpy as np
import numpy.ma as ma
from scipy import stats # for linear regression
from Tkinter import Tk
from tkFileDialog import askopenfilenames, asksaveasfilename
import tkinter as tk
from tkinter import filedialog
import sys
import pandas as pd
import matplotlib
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt

spike_answer = str(raw_input("Are you using 2006-2 UTh spike and 2019-2a Pa spike? If not, click no and search \'MixedPa' in script and change its values. [y] or n:") or 'y')
spike_answer = str(input("Are you using 2006-2 UTh spike and 2019-2a Pa spike? If not, click no and search \'MixedPa' in script and change its values. [y] or n:") or 'y')
if spike_answer == 'n':
sys.exit()
figure_answer = str(raw_input("Do you want to inspect ICPMS raw output in figures?[y] or n:") or 'y')
figure_answer = str(input("Do you want to inspect ICPMS raw output in figures?[y] or n:") or 'y')

## check OS
#if platform.system() == 'Windows':
# spike_answer = ctypes.windll.user32.MessageBoxA(0, "Are you using 2006-2 UTh spike and 2017-1a Pa spike? If not, click no and search \'MixedPa' in script and change its values", "Spike?", 4)
# if spike_answer == 7:
# sys.exit()
#elif platform.system() == 'Darwin':
# window = Tk()
# window.wm_withdraw()
# tkMessageBox.showinfo(title="Spike?", message="Are you using 2006-2 UTh spike and 2017-1a Pa spike? If not, click no and search \'MixedPa' in script and change its values")
root = tk.Tk()
root.withdraw() # we don't want a full GUI, so keep the root window from appearing
file_names = filedialog.askopenfilenames(title="Select all the ICPMS output files and a \'sample_info' excel file") # show an "Open" dialog box and return the path to the selected file

Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
file_names = askopenfilenames(title="Select all the ICPMS output files and a \'sample_info' excel file") # show an "Open" dialog box and return the path to the selected file

def return_five_point_avg(file_name):
def return_five_point_avg(file_name):
# read txt as csv, using tab as separator
txt_handle = pd.read_csv(file_name,sep='\t',header=None)
Expand Down Expand Up @@ -292,13 +282,13 @@ def reject_outliers(data, m = 2.):
elif sample_info_type == 'xlsx':
sample_name_df = pd.DataFrame({'Sample name':sample_info[0]})
if nochem_mixPa_flag:
avg_233Pa_231Pa_df = pd.DataFrame({'avg_233Pa_231Pa for Marty':[decay_days,avg_233Pa_231Pa,nochem_mixPa_233231_avg]},index=[0,1,2])
avg_233Pa_231Pa_df = pd.DataFrame({'avg_233Pa_231Pa':[decay_days,avg_233Pa_231Pa,nochem_mixPa_233231_avg]},index=[0,1,2])
else:
avg_233Pa_231Pa_df = pd.DataFrame({'avg_233Pa_231Pa for Marty':[decay_days,avg_233Pa_231Pa]},index=[0,1])
avg_233Pa_231Pa_df = pd.DataFrame({'avg_233Pa_231Pa':[decay_days,avg_233Pa_231Pa]},index=[0,1])
export_df = pd.concat([sample_name_df,export_data_df,avg_233Pa_231Pa_df],axis=1)

#%% save to excel
output_file_name = asksaveasfilename(title='Save the output file as')
output_file_name = filedialog.asksaveasfilename(title='Save the output file as')
if 'xlsx' not in output_file_name:
output_file_name = output_file_name + '.xlsx'
export_df.to_excel(output_file_name)

0 comments on commit 5528e57

Please sign in to comment.