Skip to content

Commit

Permalink
update in-code documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrgarcia committed Nov 20, 2022
1 parent be8b432 commit fba45b4
Showing 1 changed file with 39 additions and 7 deletions.
46 changes: 39 additions & 7 deletions powerxrd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,13 @@ def __init__(self,x,y):
self.lambdaKi = 0.139

def local_max(self,xrange=[12,13]):
'''Local maxima finder'''
'''Local maxima finder
Parameters
----------
xrange_Ka : [](float)
range of x to find local max
'''
x1,x2=xrange
xsearch_index=[]
for n in self.x:
Expand All @@ -110,13 +116,20 @@ def local_max(self,xrange=[12,13]):
max_x = self.x[i]

return max_x, max_y



def emission_lines(self, show = True, twothet_range_Ka=[10,20]):
def emission_lines(self, show = True, xrange_Ka=[10,20]):
'''Emission lines arising from different types of radiation i.e. K_beta radiation
wavelength of K_beta == 0.139 nm'''
twothet_Ka_deg, int_Ka = Chart(self.x, self.y).local_max(xrange=twothet_range_Ka)
wavelength of K_beta == 0.139 nm
Parameters
----------
show: bool
show plot of XRD chart
xrange_Ka : [](float)
range of x-axis (2-theta) for K_alpha radiation
'''
twothet_Ka_deg, int_Ka = Chart(self.x, self.y).local_max(xrange=xrange_Ka)
twothet_Ka=twothet_Ka_deg*np.pi/180

twothet_Ki = 2*np.arcsin((self.lambdaKi/self.lambdaKa)*np.sin(twothet_Ka/2))
Expand Down Expand Up @@ -144,8 +157,18 @@ def gaussfit(self):
print('y-shift {}\namplitude {}\nmean {}\nsigma {}'.format(*popt))
print('covariance matrix \n{}'.format(pcov))
return popt


def SchPeak(self,show=True,xrange=[12,13]):
'''Scherrer width calculation for peak within a specified range
Parameters
----------
xrange : [](float)
range of x-axis (2-theta) where peak to be calculated is found
show: bool
show plot of XRD chart
'''

print('\nSchPeak: Scherrer width calc. for peak in range of [{},{}]'.format(*xrange))

Expand Down Expand Up @@ -194,7 +217,7 @@ def SchPeak(self,show=True,xrange=[12,13]):
return max_twotheta, Sch, left,right

def allpeaks_recur(self,show = True, left=0, right=1, tol=0.2,schpeaks=[]):

'''recursion component function for main allpeaks function below'''
maxx, maxy = Chart(self.x, self.y).local_max(xrange=[left,right])

Sch_x, Sch, l,r = Chart(self.x, self.y).SchPeak(show=show,xrange=[maxx-0.5,maxx+0.5])
Expand All @@ -209,7 +232,16 @@ def allpeaks_recur(self,show = True, left=0, right=1, tol=0.2,schpeaks=[]):


def allpeaks(self, tol=0.2, show = True):
'''Driver code for allpeaks recursion. This is what must be called'''
'''Driver code for allpeaks recursion : Automated Scherrer width calculation of all peaks
Parameters
----------
tol : float
tolerance for recursion - tol relates to the minimum peak height to be
calculated as a percent of maximum peak in chart i.e. peak_max > tol*max(self.y)
show: bool
show plot of XRD chart
'''

#init xrange [left, right]
left = min(self.x)
Expand Down

0 comments on commit fba45b4

Please sign in to comment.