Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
- the parameter addPerimeter is now renamed as correct_diameters
- minor issue in the extract_area function
  • Loading branch information
marcoalopez committed Jan 31, 2017
1 parent cacb6ce commit c4062b6
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions GrainSizeTools_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def extract_areas(file_path='auto', col_name='Area'):
root.attributes("-topmost", True)
file_path = filedialog.askopenfilename(initialdir=os.getcwd(),
title="Select file",
filetypes=[('Text files', '*.txt'), ('Text file', '*.csv')])
filetypes=[('Text files', '*.txt'), ('Text files', '*.csv')])
except ImportError: # code for Python 2.7.x versions
import Tkinter as tk
import tkFileDialog
Expand All @@ -85,7 +85,7 @@ def extract_areas(file_path='auto', col_name='Area'):
root.attributes("-topmost", True)
file_path = tkFileDialog.askopenfilename(initialdir=os.getcwd(),
title="Select file",
filetypes=[('Text files', '*.txt'), ('Text file', '*.csv')])
filetypes=[('Text files', '*.txt'), ('Text files', '*.csv')])
form = file_path[-3:]

if form == 'txt':
Expand All @@ -112,7 +112,7 @@ def extract_areas(file_path='auto', col_name='Area'):
return data_set


def calc_diameters(areas, addPerimeter=0):
def calc_diameters(areas, correct_diameter=0):
""" Calculate the diameters from the sectional areas via the equivalent circular
diameter.
Expand All @@ -121,18 +121,18 @@ def calc_diameters(areas, addPerimeter=0):
areas:
A numpy array with the sectional areas of the grains
addPerimeter:
Correct the diameters estimated from the areas by adding the perimeter of
the grain. If addPerimeter is not declared, it is considered 0. A float or
integer.
correct_diameter:
Correct the diameters estimated from the areas of the grains by adding the
the width of the grain boundaries. If correct_diameter is not declared, it
is considered 0. A float or integer.
"""

# calculate diameters via equivalent circular diameter
diameters = 2 * sqrt(areas / pi)

# diameter correction adding edges (if applicable)
if addPerimeter != 0:
diameters += addPerimeter
if correct_diameter != 0:
diameters += correct_diameter

return diameters

Expand Down

0 comments on commit c4062b6

Please sign in to comment.