Skip to content

Commit

Permalink
Python 3 support
Browse files Browse the repository at this point in the history
This version longer works with Python 2 as it has reached its end of life. Please upgrade to Python 3 to continue using this program
  • Loading branch information
yz3062 committed Jan 20, 2020
1 parent a8a78f1 commit a511e14
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 25 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,27 @@ python ThxsPy.py
```
You'll be prompted to confirm the version of Th spikes you're using

![alt text](/README_screenshots/spike_prompt_ThxsPy.png)
![alt text](./README_screenshots/spike_prompt_ThxsPy.png)

Hit "Enter", and you'll be asked whether you want to inspect the data in figures

![alt text](/README_screenshots/inspect_figures_prompt.png)
![alt text](./README_screenshots/inspect_figures_prompt.png)

Hit "Enter". Figures of all the ICPMS counts will be saved in the same folder as the input files. You can check the figures to see if there's anything abnormal, e.g. a spike in counts or trailing in counts midway. Notice that the all isotopes are plotted on the same y-axis, meaning you'll mostly see the variations in major isotopes like 238U and 232Th. You'll then select data files as well as a sample info file. Notice that the file selector window sometimes doesn't pop up and is open in the background.

![alt text](/README_screenshots/data_selection_ThxsPy.JPG)
![alt text](./README_screenshots/data_selection_ThxsPy.JPG)

Where you should double click "data" folder and select all the files in that folder

![alt text](/README_screenshots/data_select_all_ThxsPy.JPG)
![alt text](./README_screenshots/data_select_all_ThxsPy.JPG)

Notice that alongside the data files, there's also a "sample_info.xlsx" file that looks like this

![alt text](/README_screenshots/sample_info_screenshot.JPG)
![alt text](./README_screenshots/sample_info_screenshot.JPG)

And Voila! Calculation is done and you're asked to save the output file with a file name of your choice. You can either write the ".xlsx" or not. The program will add one for you if you don't.

![alt text](/README_screenshots/save_output_ThxyPy.JPG)
![alt text](./README_screenshots/save_output_ThxyPy.JPG)


## License
Expand Down
28 changes: 9 additions & 19 deletions ThxsPy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,26 @@
'''
# If directly import mpl, crashes. Source: https://stackoverflow.com/questions/32019556/matplotlib-crashing-tkinter-application/34109240#34109240
import matplotlib
matplotlib.use("TkAgg")
# matplotlib.use("TkAgg")
from matplotlib import pyplot as plt
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 subprocess

spike_answer = str(raw_input("Are you using 2006-2 UTh spike? If not, click no and search \'unspike\' in script and change its values. [y] or n:") or 'y')
spike_answer = str(input("Are you using 2006-2 UTh spike? If not, click no and search \'unspike\' 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.cdll.user32.MessageBoxA(0, "Are you using 2006-2 UTh spike? If not, click no and search \'unspike\' in script and change its values", "2006-2 spike?", 4)
# if spike_answer == 7:
# sys.exit()
#elif platform.system() == 'Darwin':
# window = Tk()
# window.wm_withdraw()
# tkMessageBox.showinfo(title="2006-2 spike?", message="Are you using 2006-2 UTh spike? If not, exit and search \'unspike\' in script and change its values")

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' file") # show an "Open" dialog box and return the path to the selected file
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' file") # show an "Open" dialog box and return the path to the selected file

def return_five_point_avg(file_name):
# read txt as csv, using tab as separator
Expand Down Expand Up @@ -348,7 +338,7 @@ def reject_outliers(data, m = 2.):
export_df = pd.concat([sample_name_df,export_data_df],axis=1)

#%% save to csv
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 a511e14

Please sign in to comment.