repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
awacha/sastool | sastool/fitting/fitfunctions/basic.py | Cosine | def Cosine(x, a, omega, phi, y0):
"""Cosine function
Inputs:
-------
``x``: independent variable
``a``: amplitude
``omega``: circular frequency
``phi``: phase
``y0``: offset
Formula:
--------
``a*cos(x*omega + phi)+y0``
"""
return a * np.cos(... | python | def Cosine(x, a, omega, phi, y0):
"""Cosine function
Inputs:
-------
``x``: independent variable
``a``: amplitude
``omega``: circular frequency
``phi``: phase
``y0``: offset
Formula:
--------
``a*cos(x*omega + phi)+y0``
"""
return a * np.cos(... | [
"def",
"Cosine",
"(",
"x",
",",
"a",
",",
"omega",
",",
"phi",
",",
"y0",
")",
":",
"return",
"a",
"*",
"np",
".",
"cos",
"(",
"x",
"*",
"omega",
"+",
"phi",
")",
"+",
"y0"
] | Cosine function
Inputs:
-------
``x``: independent variable
``a``: amplitude
``omega``: circular frequency
``phi``: phase
``y0``: offset
Formula:
--------
``a*cos(x*omega + phi)+y0`` | [
"Cosine",
"function"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/basic.py#L41-L56 | train |
awacha/sastool | sastool/fitting/fitfunctions/basic.py | Square | def Square(x, a, b, c):
"""Second order polynomial
Inputs:
-------
``x``: independent variable
``a``: coefficient of the second-order term
``b``: coefficient of the first-order term
``c``: additive constant
Formula:
--------
``a*x^2 + b*x + c``
"""
r... | python | def Square(x, a, b, c):
"""Second order polynomial
Inputs:
-------
``x``: independent variable
``a``: coefficient of the second-order term
``b``: coefficient of the first-order term
``c``: additive constant
Formula:
--------
``a*x^2 + b*x + c``
"""
r... | [
"def",
"Square",
"(",
"x",
",",
"a",
",",
"b",
",",
"c",
")",
":",
"return",
"a",
"*",
"x",
"**",
"2",
"+",
"b",
"*",
"x",
"+",
"c"
] | Second order polynomial
Inputs:
-------
``x``: independent variable
``a``: coefficient of the second-order term
``b``: coefficient of the first-order term
``c``: additive constant
Formula:
--------
``a*x^2 + b*x + c`` | [
"Second",
"order",
"polynomial"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/basic.py#L59-L73 | train |
awacha/sastool | sastool/fitting/fitfunctions/basic.py | Cube | def Cube(x, a, b, c, d):
"""Third order polynomial
Inputs:
-------
``x``: independent variable
``a``: coefficient of the third-order term
``b``: coefficient of the second-order term
``c``: coefficient of the first-order term
``d``: additive constant
Formula:
... | python | def Cube(x, a, b, c, d):
"""Third order polynomial
Inputs:
-------
``x``: independent variable
``a``: coefficient of the third-order term
``b``: coefficient of the second-order term
``c``: coefficient of the first-order term
``d``: additive constant
Formula:
... | [
"def",
"Cube",
"(",
"x",
",",
"a",
",",
"b",
",",
"c",
",",
"d",
")",
":",
"return",
"a",
"*",
"x",
"**",
"3",
"+",
"b",
"*",
"x",
"**",
"2",
"+",
"c",
"*",
"x",
"+",
"d"
] | Third order polynomial
Inputs:
-------
``x``: independent variable
``a``: coefficient of the third-order term
``b``: coefficient of the second-order term
``c``: coefficient of the first-order term
``d``: additive constant
Formula:
--------
``a*x^3 + b*x^... | [
"Third",
"order",
"polynomial"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/basic.py#L76-L91 | train |
awacha/sastool | sastool/fitting/fitfunctions/basic.py | Exponential | def Exponential(x, a, tau, y0):
"""Exponential function
Inputs:
-------
``x``: independent variable
``a``: scaling factor
``tau``: time constant
``y0``: additive constant
Formula:
--------
``a*exp(x/tau)+y0``
"""
return np.exp(x / tau) * a + y0 | python | def Exponential(x, a, tau, y0):
"""Exponential function
Inputs:
-------
``x``: independent variable
``a``: scaling factor
``tau``: time constant
``y0``: additive constant
Formula:
--------
``a*exp(x/tau)+y0``
"""
return np.exp(x / tau) * a + y0 | [
"def",
"Exponential",
"(",
"x",
",",
"a",
",",
"tau",
",",
"y0",
")",
":",
"return",
"np",
".",
"exp",
"(",
"x",
"/",
"tau",
")",
"*",
"a",
"+",
"y0"
] | Exponential function
Inputs:
-------
``x``: independent variable
``a``: scaling factor
``tau``: time constant
``y0``: additive constant
Formula:
--------
``a*exp(x/tau)+y0`` | [
"Exponential",
"function"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/basic.py#L110-L124 | train |
awacha/sastool | sastool/fitting/fitfunctions/basic.py | Lorentzian | def Lorentzian(x, a, x0, sigma, y0):
"""Lorentzian peak
Inputs:
-------
``x``: independent variable
``a``: scaling factor (extremal value)
``x0``: center
``sigma``: half width at half maximum
``y0``: additive constant
Formula:
--------
``a/(1+((x-x0)... | python | def Lorentzian(x, a, x0, sigma, y0):
"""Lorentzian peak
Inputs:
-------
``x``: independent variable
``a``: scaling factor (extremal value)
``x0``: center
``sigma``: half width at half maximum
``y0``: additive constant
Formula:
--------
``a/(1+((x-x0)... | [
"def",
"Lorentzian",
"(",
"x",
",",
"a",
",",
"x0",
",",
"sigma",
",",
"y0",
")",
":",
"return",
"a",
"/",
"(",
"1",
"+",
"(",
"(",
"x",
"-",
"x0",
")",
"/",
"sigma",
")",
"**",
"2",
")",
"+",
"y0"
] | Lorentzian peak
Inputs:
-------
``x``: independent variable
``a``: scaling factor (extremal value)
``x0``: center
``sigma``: half width at half maximum
``y0``: additive constant
Formula:
--------
``a/(1+((x-x0)/sigma)^2)+y0`` | [
"Lorentzian",
"peak"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/basic.py#L127-L142 | train |
awacha/sastool | sastool/fitting/fitfunctions/basic.py | Gaussian | def Gaussian(x, a, x0, sigma, y0):
"""Gaussian peak
Inputs:
-------
``x``: independent variable
``a``: scaling factor (extremal value)
``x0``: center
``sigma``: half width at half maximum
``y0``: additive constant
Formula:
--------
``a*exp(-(x-x0)^2)... | python | def Gaussian(x, a, x0, sigma, y0):
"""Gaussian peak
Inputs:
-------
``x``: independent variable
``a``: scaling factor (extremal value)
``x0``: center
``sigma``: half width at half maximum
``y0``: additive constant
Formula:
--------
``a*exp(-(x-x0)^2)... | [
"def",
"Gaussian",
"(",
"x",
",",
"a",
",",
"x0",
",",
"sigma",
",",
"y0",
")",
":",
"return",
"a",
"*",
"np",
".",
"exp",
"(",
"-",
"(",
"x",
"-",
"x0",
")",
"**",
"2",
"/",
"(",
"2",
"*",
"sigma",
"**",
"2",
")",
")",
"+",
"y0"
] | Gaussian peak
Inputs:
-------
``x``: independent variable
``a``: scaling factor (extremal value)
``x0``: center
``sigma``: half width at half maximum
``y0``: additive constant
Formula:
--------
``a*exp(-(x-x0)^2)/(2*sigma^2)+y0`` | [
"Gaussian",
"peak"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/basic.py#L145-L160 | train |
awacha/sastool | sastool/fitting/fitfunctions/basic.py | LogNormal | def LogNormal(x, a, mu, sigma):
"""PDF of a log-normal distribution
Inputs:
-------
``x``: independent variable
``a``: amplitude
``mu``: center parameter
``sigma``: width parameter
Formula:
--------
``a/ (2*pi*sigma^2*x^2)^0.5 * exp(-(log(x)-mu)^2/(2*sigma^2... | python | def LogNormal(x, a, mu, sigma):
"""PDF of a log-normal distribution
Inputs:
-------
``x``: independent variable
``a``: amplitude
``mu``: center parameter
``sigma``: width parameter
Formula:
--------
``a/ (2*pi*sigma^2*x^2)^0.5 * exp(-(log(x)-mu)^2/(2*sigma^2... | [
"def",
"LogNormal",
"(",
"x",
",",
"a",
",",
"mu",
",",
"sigma",
")",
":",
"return",
"a",
"/",
"np",
".",
"sqrt",
"(",
"2",
"*",
"np",
".",
"pi",
"*",
"sigma",
"**",
"2",
"*",
"x",
"**",
"2",
")",
"*",
"np",
".",
"exp",
"(",
"-",
"(",
"... | PDF of a log-normal distribution
Inputs:
-------
``x``: independent variable
``a``: amplitude
``mu``: center parameter
``sigma``: width parameter
Formula:
--------
``a/ (2*pi*sigma^2*x^2)^0.5 * exp(-(log(x)-mu)^2/(2*sigma^2)) | [
"PDF",
"of",
"a",
"log",
"-",
"normal",
"distribution"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/basic.py#L163-L178 | train |
awacha/sastool | sastool/utils2d/integrate.py | radintpix | def radintpix(data, dataerr, bcx, bcy, mask=None, pix=None, returnavgpix=False,
phi0=0, dphi=0, returnmask=False, symmetric_sector=False,
doslice=False, errorpropagation=2, autoqrange_linear=True):
"""Radial integration (averaging) on the detector plane
Inputs:
data: scatter... | python | def radintpix(data, dataerr, bcx, bcy, mask=None, pix=None, returnavgpix=False,
phi0=0, dphi=0, returnmask=False, symmetric_sector=False,
doslice=False, errorpropagation=2, autoqrange_linear=True):
"""Radial integration (averaging) on the detector plane
Inputs:
data: scatter... | [
"def",
"radintpix",
"(",
"data",
",",
"dataerr",
",",
"bcx",
",",
"bcy",
",",
"mask",
"=",
"None",
",",
"pix",
"=",
"None",
",",
"returnavgpix",
"=",
"False",
",",
"phi0",
"=",
"0",
",",
"dphi",
"=",
"0",
",",
"returnmask",
"=",
"False",
",",
"sy... | Radial integration (averaging) on the detector plane
Inputs:
data: scattering pattern matrix (np.ndarray, dtype: np.double)
dataerr: error matrix (np.ndarray, dtype: np.double; or None)
bcx, bcy: beam position, counting from 1
mask: mask matrix (np.ndarray, dtype: np.uint8)
... | [
"Radial",
"integration",
"(",
"averaging",
")",
"on",
"the",
"detector",
"plane"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/integrate.py#L10-L48 | train |
awacha/sastool | sastool/utils2d/integrate.py | azimintpix | def azimintpix(data, dataerr, bcx, bcy, mask=None, Ntheta=100, pixmin=0,
pixmax=np.inf, returnmask=False, errorpropagation=2):
"""Azimuthal integration (averaging) on the detector plane
Inputs:
data: scattering pattern matrix (np.ndarray, dtype: np.double)
dataerr: error matrix (... | python | def azimintpix(data, dataerr, bcx, bcy, mask=None, Ntheta=100, pixmin=0,
pixmax=np.inf, returnmask=False, errorpropagation=2):
"""Azimuthal integration (averaging) on the detector plane
Inputs:
data: scattering pattern matrix (np.ndarray, dtype: np.double)
dataerr: error matrix (... | [
"def",
"azimintpix",
"(",
"data",
",",
"dataerr",
",",
"bcx",
",",
"bcy",
",",
"mask",
"=",
"None",
",",
"Ntheta",
"=",
"100",
",",
"pixmin",
"=",
"0",
",",
"pixmax",
"=",
"np",
".",
"inf",
",",
"returnmask",
"=",
"False",
",",
"errorpropagation",
... | Azimuthal integration (averaging) on the detector plane
Inputs:
data: scattering pattern matrix (np.ndarray, dtype: np.double)
dataerr: error matrix (np.ndarray, dtype: np.double; or None)
bcx, bcy: beam position, counting from 1
mask: mask matrix (np.ndarray, dtype: np.uint8)
... | [
"Azimuthal",
"integration",
"(",
"averaging",
")",
"on",
"the",
"detector",
"plane"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/integrate.py#L51-L79 | train |
awacha/sastool | sastool/misc/searchpath.py | find_subdirs | def find_subdirs(startdir='.', recursion_depth=None):
"""Find all subdirectory of a directory.
Inputs:
startdir: directory to start with. Defaults to the current folder.
recursion_depth: number of levels to traverse. None is infinite.
Output: a list of absolute names of subfolders.
Ex... | python | def find_subdirs(startdir='.', recursion_depth=None):
"""Find all subdirectory of a directory.
Inputs:
startdir: directory to start with. Defaults to the current folder.
recursion_depth: number of levels to traverse. None is infinite.
Output: a list of absolute names of subfolders.
Ex... | [
"def",
"find_subdirs",
"(",
"startdir",
"=",
"'.'",
",",
"recursion_depth",
"=",
"None",
")",
":",
"startdir",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"startdir",
")",
"direct_subdirs",
"=",
"[",
"os",
".",
"path",
".",
"join",
"(",
"startdir",
... | Find all subdirectory of a directory.
Inputs:
startdir: directory to start with. Defaults to the current folder.
recursion_depth: number of levels to traverse. None is infinite.
Output: a list of absolute names of subfolders.
Examples:
>>> find_subdirs('dir',0) # returns just ['d... | [
"Find",
"all",
"subdirectory",
"of",
"a",
"directory",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/searchpath.py#L107-L135 | train |
awacha/sastool | sastool/misc/basicfit.py | findpeak | def findpeak(x, y, dy=None, position=None, hwhm=None, baseline=None, amplitude=None, curve='Lorentz'):
"""Find a (positive) peak in the dataset.
This function is deprecated, please consider using findpeak_single() instead.
Inputs:
x, y, dy: abscissa, ordinate and the error of the ordinate (can... | python | def findpeak(x, y, dy=None, position=None, hwhm=None, baseline=None, amplitude=None, curve='Lorentz'):
"""Find a (positive) peak in the dataset.
This function is deprecated, please consider using findpeak_single() instead.
Inputs:
x, y, dy: abscissa, ordinate and the error of the ordinate (can... | [
"def",
"findpeak",
"(",
"x",
",",
"y",
",",
"dy",
"=",
"None",
",",
"position",
"=",
"None",
",",
"hwhm",
"=",
"None",
",",
"baseline",
"=",
"None",
",",
"amplitude",
"=",
"None",
",",
"curve",
"=",
"'Lorentz'",
")",
":",
"warnings",
".",
"warn",
... | Find a (positive) peak in the dataset.
This function is deprecated, please consider using findpeak_single() instead.
Inputs:
x, y, dy: abscissa, ordinate and the error of the ordinate (can be None)
position, hwhm, baseline, amplitude: first guesses for the named parameters
curve: '... | [
"Find",
"a",
"(",
"positive",
")",
"peak",
"in",
"the",
"dataset",
".",
"This",
"function",
"is",
"deprecated",
"please",
"consider",
"using",
"findpeak_single",
"()",
"instead",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/basicfit.py#L18-L38 | train |
awacha/sastool | sastool/misc/basicfit.py | findpeak_single | def findpeak_single(x, y, dy=None, position=None, hwhm=None, baseline=None, amplitude=None, curve='Lorentz',
return_stat=False, signs=(-1, 1), return_x=None):
"""Find a (positive or negative) peak in the dataset.
Inputs:
x, y, dy: abscissa, ordinate and the error of the ordinate (ca... | python | def findpeak_single(x, y, dy=None, position=None, hwhm=None, baseline=None, amplitude=None, curve='Lorentz',
return_stat=False, signs=(-1, 1), return_x=None):
"""Find a (positive or negative) peak in the dataset.
Inputs:
x, y, dy: abscissa, ordinate and the error of the ordinate (ca... | [
"def",
"findpeak_single",
"(",
"x",
",",
"y",
",",
"dy",
"=",
"None",
",",
"position",
"=",
"None",
",",
"hwhm",
"=",
"None",
",",
"baseline",
"=",
"None",
",",
"amplitude",
"=",
"None",
",",
"curve",
"=",
"'Lorentz'",
",",
"return_stat",
"=",
"False... | Find a (positive or negative) peak in the dataset.
Inputs:
x, y, dy: abscissa, ordinate and the error of the ordinate (can be None)
position, hwhm, baseline, amplitude: first guesses for the named parameters
curve: 'Gauss' or 'Lorentz' (default)
return_stat: return fitting statistic... | [
"Find",
"a",
"(",
"positive",
"or",
"negative",
")",
"peak",
"in",
"the",
"dataset",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/basicfit.py#L41-L97 | train |
awacha/sastool | sastool/misc/basicfit.py | findpeak_multi | def findpeak_multi(x, y, dy, N, Ntolerance, Nfit=None, curve='Lorentz', return_xfit=False, return_stat=False):
"""Find multiple peaks in the dataset given by vectors x and y.
Points are searched for in the dataset where the N points before and
after have strictly lower values than them. To get rid of false... | python | def findpeak_multi(x, y, dy, N, Ntolerance, Nfit=None, curve='Lorentz', return_xfit=False, return_stat=False):
"""Find multiple peaks in the dataset given by vectors x and y.
Points are searched for in the dataset where the N points before and
after have strictly lower values than them. To get rid of false... | [
"def",
"findpeak_multi",
"(",
"x",
",",
"y",
",",
"dy",
",",
"N",
",",
"Ntolerance",
",",
"Nfit",
"=",
"None",
",",
"curve",
"=",
"'Lorentz'",
",",
"return_xfit",
"=",
"False",
",",
"return_stat",
"=",
"False",
")",
":",
"if",
"Nfit",
"is",
"None",
... | Find multiple peaks in the dataset given by vectors x and y.
Points are searched for in the dataset where the N points before and
after have strictly lower values than them. To get rid of false
negatives caused by fluctuations, Ntolerance is introduced. It is the
number of outlier points to be tolerate... | [
"Find",
"multiple",
"peaks",
"in",
"the",
"dataset",
"given",
"by",
"vectors",
"x",
"and",
"y",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/basicfit.py#L99-L178 | train |
awacha/sastool | sastool/misc/basicfit.py | findpeak_asymmetric | def findpeak_asymmetric(x, y, dy=None, curve='Lorentz', return_x=None, init_parameters=None):
"""Find an asymmetric Lorentzian peak.
Inputs:
x: numpy array of the abscissa
y: numpy array of the ordinate
dy: numpy array of the errors in y (or None if not present)
curve: string (c... | python | def findpeak_asymmetric(x, y, dy=None, curve='Lorentz', return_x=None, init_parameters=None):
"""Find an asymmetric Lorentzian peak.
Inputs:
x: numpy array of the abscissa
y: numpy array of the ordinate
dy: numpy array of the errors in y (or None if not present)
curve: string (c... | [
"def",
"findpeak_asymmetric",
"(",
"x",
",",
"y",
",",
"dy",
"=",
"None",
",",
"curve",
"=",
"'Lorentz'",
",",
"return_x",
"=",
"None",
",",
"init_parameters",
"=",
"None",
")",
":",
"idx",
"=",
"np",
".",
"logical_and",
"(",
"np",
".",
"isfinite",
"... | Find an asymmetric Lorentzian peak.
Inputs:
x: numpy array of the abscissa
y: numpy array of the ordinate
dy: numpy array of the errors in y (or None if not present)
curve: string (case insensitive): if starts with "Lorentz",
a Lorentzian curve will be fitted. If starts ... | [
"Find",
"an",
"asymmetric",
"Lorentzian",
"peak",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/basicfit.py#L181-L265 | train |
awacha/sastool | sastool/io/onedim.py | readspecscan | def readspecscan(f, number=None):
"""Read the next spec scan in the file, which starts at the current position."""
scan = None
scannumber = None
while True:
l = f.readline()
if l.startswith('#S'):
scannumber = int(l[2:].split()[0])
if not ((number is None) or (num... | python | def readspecscan(f, number=None):
"""Read the next spec scan in the file, which starts at the current position."""
scan = None
scannumber = None
while True:
l = f.readline()
if l.startswith('#S'):
scannumber = int(l[2:].split()[0])
if not ((number is None) or (num... | [
"def",
"readspecscan",
"(",
"f",
",",
"number",
"=",
"None",
")",
":",
"scan",
"=",
"None",
"scannumber",
"=",
"None",
"while",
"True",
":",
"l",
"=",
"f",
".",
"readline",
"(",
")",
"if",
"l",
".",
"startswith",
"(",
"'#S'",
")",
":",
"scannumber"... | Read the next spec scan in the file, which starts at the current position. | [
"Read",
"the",
"next",
"spec",
"scan",
"in",
"the",
"file",
"which",
"starts",
"at",
"the",
"current",
"position",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/onedim.py#L18-L82 | train |
awacha/sastool | sastool/io/onedim.py | readspec | def readspec(filename, read_scan=None):
"""Open a SPEC file and read its content
Inputs:
filename: string
the file to open
read_scan: None, 'all' or integer
the index of scan to be read from the file. If None, no scan should be read. If
'all', all scans sho... | python | def readspec(filename, read_scan=None):
"""Open a SPEC file and read its content
Inputs:
filename: string
the file to open
read_scan: None, 'all' or integer
the index of scan to be read from the file. If None, no scan should be read. If
'all', all scans sho... | [
"def",
"readspec",
"(",
"filename",
",",
"read_scan",
"=",
"None",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'rt'",
")",
"as",
"f",
":",
"sf",
"=",
"{",
"'motors'",
":",
"[",
"]",
",",
"'maxscannumber'",
":",
"0",
"}",
"sf",
"[",
"'originalf... | Open a SPEC file and read its content
Inputs:
filename: string
the file to open
read_scan: None, 'all' or integer
the index of scan to be read from the file. If None, no scan should be read. If
'all', all scans should be read. If a number, just the scan with th... | [
"Open",
"a",
"SPEC",
"file",
"and",
"read",
"its",
"content"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/onedim.py#L85-L162 | train |
awacha/sastool | sastool/io/onedim.py | readabt | def readabt(filename, dirs='.'):
"""Read abt_*.fio type files from beamline B1, HASYLAB.
Input:
filename: the name of the file.
dirs: directories to search for files in
Output:
A dictionary. The fields are self-explanatory.
"""
# resolve filename
filename = misc.findfil... | python | def readabt(filename, dirs='.'):
"""Read abt_*.fio type files from beamline B1, HASYLAB.
Input:
filename: the name of the file.
dirs: directories to search for files in
Output:
A dictionary. The fields are self-explanatory.
"""
# resolve filename
filename = misc.findfil... | [
"def",
"readabt",
"(",
"filename",
",",
"dirs",
"=",
"'.'",
")",
":",
"# resolve filename",
"filename",
"=",
"misc",
".",
"findfileindirs",
"(",
"filename",
",",
"dirs",
")",
"f",
"=",
"open",
"(",
"filename",
",",
"'rt'",
")",
"abt",
"=",
"{",
"'offse... | Read abt_*.fio type files from beamline B1, HASYLAB.
Input:
filename: the name of the file.
dirs: directories to search for files in
Output:
A dictionary. The fields are self-explanatory. | [
"Read",
"abt_",
"*",
".",
"fio",
"type",
"files",
"from",
"beamline",
"B1",
"HASYLAB",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/onedim.py#L165-L275 | train |
awacha/sastool | sastool/io/credo_cpth5/header.py | Header.energy | def energy(self) -> ErrorValue:
"""X-ray energy"""
return (ErrorValue(*(scipy.constants.physical_constants['speed of light in vacuum'][0::2])) *
ErrorValue(*(scipy.constants.physical_constants['Planck constant in eV s'][0::2])) /
scipy.constants.nano /
sel... | python | def energy(self) -> ErrorValue:
"""X-ray energy"""
return (ErrorValue(*(scipy.constants.physical_constants['speed of light in vacuum'][0::2])) *
ErrorValue(*(scipy.constants.physical_constants['Planck constant in eV s'][0::2])) /
scipy.constants.nano /
sel... | [
"def",
"energy",
"(",
"self",
")",
"->",
"ErrorValue",
":",
"return",
"(",
"ErrorValue",
"(",
"*",
"(",
"scipy",
".",
"constants",
".",
"physical_constants",
"[",
"'speed of light in vacuum'",
"]",
"[",
"0",
":",
":",
"2",
"]",
")",
")",
"*",
"ErrorValue... | X-ray energy | [
"X",
"-",
"ray",
"energy"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/credo_cpth5/header.py#L50-L55 | train |
awacha/sastool | sastool/io/credo_cpth5/header.py | Header.maskname | def maskname(self) -> Optional[str]:
"""Name of the mask matrix file."""
try:
maskid = self._data['maskname']
if not maskid.endswith('.mat'):
maskid = maskid + '.mat'
return maskid
except KeyError:
return None | python | def maskname(self) -> Optional[str]:
"""Name of the mask matrix file."""
try:
maskid = self._data['maskname']
if not maskid.endswith('.mat'):
maskid = maskid + '.mat'
return maskid
except KeyError:
return None | [
"def",
"maskname",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"try",
":",
"maskid",
"=",
"self",
".",
"_data",
"[",
"'maskname'",
"]",
"if",
"not",
"maskid",
".",
"endswith",
"(",
"'.mat'",
")",
":",
"maskid",
"=",
"maskid",
"+",
"'.... | Name of the mask matrix file. | [
"Name",
"of",
"the",
"mask",
"matrix",
"file",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/credo_cpth5/header.py#L191-L199 | train |
awacha/sastool | sastool/utils2d/centering.py | findbeam_gravity | def findbeam_gravity(data, mask):
"""Find beam center with the "gravity" method
Inputs:
data: scattering image
mask: mask matrix
Output:
a vector of length 2 with the x (row) and y (column) coordinates
of the origin, starting from 1
"""
# for each row and column fi... | python | def findbeam_gravity(data, mask):
"""Find beam center with the "gravity" method
Inputs:
data: scattering image
mask: mask matrix
Output:
a vector of length 2 with the x (row) and y (column) coordinates
of the origin, starting from 1
"""
# for each row and column fi... | [
"def",
"findbeam_gravity",
"(",
"data",
",",
"mask",
")",
":",
"# for each row and column find the center of gravity",
"data1",
"=",
"data",
".",
"copy",
"(",
")",
"# take a copy, because elements will be tampered with",
"data1",
"[",
"mask",
"==",
"0",
"]",
"=",
"0",... | Find beam center with the "gravity" method
Inputs:
data: scattering image
mask: mask matrix
Output:
a vector of length 2 with the x (row) and y (column) coordinates
of the origin, starting from 1 | [
"Find",
"beam",
"center",
"with",
"the",
"gravity",
"method"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/centering.py#L11-L58 | train |
awacha/sastool | sastool/utils2d/centering.py | findbeam_slices | def findbeam_slices(data, orig_initial, mask=None, maxiter=0, epsfcn=0.001,
dmin=0, dmax=np.inf, sector_width=np.pi / 9.0, extent=10, callback=None):
"""Find beam center with the "slices" method
Inputs:
data: scattering matrix
orig_initial: estimated value for x (row) and y ... | python | def findbeam_slices(data, orig_initial, mask=None, maxiter=0, epsfcn=0.001,
dmin=0, dmax=np.inf, sector_width=np.pi / 9.0, extent=10, callback=None):
"""Find beam center with the "slices" method
Inputs:
data: scattering matrix
orig_initial: estimated value for x (row) and y ... | [
"def",
"findbeam_slices",
"(",
"data",
",",
"orig_initial",
",",
"mask",
"=",
"None",
",",
"maxiter",
"=",
"0",
",",
"epsfcn",
"=",
"0.001",
",",
"dmin",
"=",
"0",
",",
"dmax",
"=",
"np",
".",
"inf",
",",
"sector_width",
"=",
"np",
".",
"pi",
"/",
... | Find beam center with the "slices" method
Inputs:
data: scattering matrix
orig_initial: estimated value for x (row) and y (column)
coordinates of the beam center, starting from 1.
mask: mask matrix. If None, nothing will be masked. Otherwise it
should be of the same ... | [
"Find",
"beam",
"center",
"with",
"the",
"slices",
"method"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/centering.py#L61-L110 | train |
awacha/sastool | sastool/utils2d/centering.py | findbeam_azimuthal | def findbeam_azimuthal(data, orig_initial, mask=None, maxiter=100, Ntheta=50,
dmin=0, dmax=np.inf, extent=10, callback=None):
"""Find beam center using azimuthal integration
Inputs:
data: scattering matrix
orig_initial: estimated value for x (row) and y (column)
... | python | def findbeam_azimuthal(data, orig_initial, mask=None, maxiter=100, Ntheta=50,
dmin=0, dmax=np.inf, extent=10, callback=None):
"""Find beam center using azimuthal integration
Inputs:
data: scattering matrix
orig_initial: estimated value for x (row) and y (column)
... | [
"def",
"findbeam_azimuthal",
"(",
"data",
",",
"orig_initial",
",",
"mask",
"=",
"None",
",",
"maxiter",
"=",
"100",
",",
"Ntheta",
"=",
"50",
",",
"dmin",
"=",
"0",
",",
"dmax",
"=",
"np",
".",
"inf",
",",
"extent",
"=",
"10",
",",
"callback",
"="... | Find beam center using azimuthal integration
Inputs:
data: scattering matrix
orig_initial: estimated value for x (row) and y (column)
coordinates of the beam center, starting from 1.
mask: mask matrix. If None, nothing will be masked. Otherwise it
should be of the sa... | [
"Find",
"beam",
"center",
"using",
"azimuthal",
"integration"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/centering.py#L113-L157 | train |
awacha/sastool | sastool/utils2d/centering.py | findbeam_azimuthal_fold | def findbeam_azimuthal_fold(data, orig_initial, mask=None, maxiter=100,
Ntheta=50, dmin=0, dmax=np.inf, extent=10, callback=None):
"""Find beam center using azimuthal integration and folding
Inputs:
data: scattering matrix
orig_initial: estimated value for x (row) an... | python | def findbeam_azimuthal_fold(data, orig_initial, mask=None, maxiter=100,
Ntheta=50, dmin=0, dmax=np.inf, extent=10, callback=None):
"""Find beam center using azimuthal integration and folding
Inputs:
data: scattering matrix
orig_initial: estimated value for x (row) an... | [
"def",
"findbeam_azimuthal_fold",
"(",
"data",
",",
"orig_initial",
",",
"mask",
"=",
"None",
",",
"maxiter",
"=",
"100",
",",
"Ntheta",
"=",
"50",
",",
"dmin",
"=",
"0",
",",
"dmax",
"=",
"np",
".",
"inf",
",",
"extent",
"=",
"10",
",",
"callback",
... | Find beam center using azimuthal integration and folding
Inputs:
data: scattering matrix
orig_initial: estimated value for x (row) and y (column)
coordinates of the beam center, starting from 1.
mask: mask matrix. If None, nothing will be masked. Otherwise it
should ... | [
"Find",
"beam",
"center",
"using",
"azimuthal",
"integration",
"and",
"folding"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/centering.py#L160-L201 | train |
awacha/sastool | sastool/utils2d/centering.py | findbeam_semitransparent | def findbeam_semitransparent(data, pri, threshold=0.05):
"""Find beam with 2D weighting of semitransparent beamstop area
Inputs:
data: scattering matrix
pri: list of four: [xmin,xmax,ymin,ymax] for the borders of the beam
area under the semitransparent beamstop. X corresponds to the... | python | def findbeam_semitransparent(data, pri, threshold=0.05):
"""Find beam with 2D weighting of semitransparent beamstop area
Inputs:
data: scattering matrix
pri: list of four: [xmin,xmax,ymin,ymax] for the borders of the beam
area under the semitransparent beamstop. X corresponds to the... | [
"def",
"findbeam_semitransparent",
"(",
"data",
",",
"pri",
",",
"threshold",
"=",
"0.05",
")",
":",
"rowmin",
"=",
"np",
".",
"floor",
"(",
"min",
"(",
"pri",
"[",
"2",
":",
"]",
")",
")",
"rowmax",
"=",
"np",
".",
"ceil",
"(",
"max",
"(",
"pri"... | Find beam with 2D weighting of semitransparent beamstop area
Inputs:
data: scattering matrix
pri: list of four: [xmin,xmax,ymin,ymax] for the borders of the beam
area under the semitransparent beamstop. X corresponds to the column
index (ie. A[Y,X] is the element of A from t... | [
"Find",
"beam",
"with",
"2D",
"weighting",
"of",
"semitransparent",
"beamstop",
"area"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/centering.py#L204-L262 | train |
awacha/sastool | sastool/utils2d/centering.py | findbeam_radialpeak | def findbeam_radialpeak(data, orig_initial, mask, rmin, rmax, maxiter=100,
drive_by='amplitude', extent=10, callback=None):
"""Find the beam by minimizing the width of a peak in the radial average.
Inputs:
data: scattering matrix
orig_initial: first guess for the origin
... | python | def findbeam_radialpeak(data, orig_initial, mask, rmin, rmax, maxiter=100,
drive_by='amplitude', extent=10, callback=None):
"""Find the beam by minimizing the width of a peak in the radial average.
Inputs:
data: scattering matrix
orig_initial: first guess for the origin
... | [
"def",
"findbeam_radialpeak",
"(",
"data",
",",
"orig_initial",
",",
"mask",
",",
"rmin",
",",
"rmax",
",",
"maxiter",
"=",
"100",
",",
"drive_by",
"=",
"'amplitude'",
",",
"extent",
"=",
"10",
",",
"callback",
"=",
"None",
")",
":",
"orig_initial",
"=",... | Find the beam by minimizing the width of a peak in the radial average.
Inputs:
data: scattering matrix
orig_initial: first guess for the origin
mask: mask matrix. Nonzero is non-masked.
rmin,rmax: distance from the origin (in pixels) of the peak range.
drive_by: 'hwhm' to mi... | [
"Find",
"the",
"beam",
"by",
"minimizing",
"the",
"width",
"of",
"a",
"peak",
"in",
"the",
"radial",
"average",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/centering.py#L265-L315 | train |
awacha/sastool | sastool/utils2d/centering.py | findbeam_Guinier | def findbeam_Guinier(data, orig_initial, mask, rmin, rmax, maxiter=100,
extent=10, callback=None):
"""Find the beam by minimizing the width of a Gaussian centered at the
origin (i.e. maximizing the radius of gyration in a Guinier scattering).
Inputs:
data: scattering matrix
... | python | def findbeam_Guinier(data, orig_initial, mask, rmin, rmax, maxiter=100,
extent=10, callback=None):
"""Find the beam by minimizing the width of a Gaussian centered at the
origin (i.e. maximizing the radius of gyration in a Guinier scattering).
Inputs:
data: scattering matrix
... | [
"def",
"findbeam_Guinier",
"(",
"data",
",",
"orig_initial",
",",
"mask",
",",
"rmin",
",",
"rmax",
",",
"maxiter",
"=",
"100",
",",
"extent",
"=",
"10",
",",
"callback",
"=",
"None",
")",
":",
"orig_initial",
"=",
"np",
".",
"array",
"(",
"orig_initia... | Find the beam by minimizing the width of a Gaussian centered at the
origin (i.e. maximizing the radius of gyration in a Guinier scattering).
Inputs:
data: scattering matrix
orig_initial: first guess for the origin
mask: mask matrix. Nonzero is non-masked.
rmin,rmax: distance fro... | [
"Find",
"the",
"beam",
"by",
"minimizing",
"the",
"width",
"of",
"a",
"Gaussian",
"centered",
"at",
"the",
"origin",
"(",
"i",
".",
"e",
".",
"maximizing",
"the",
"radius",
"of",
"gyration",
"in",
"a",
"Guinier",
"scattering",
")",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/centering.py#L318-L355 | train |
awacha/sastool | sastool/utils2d/centering.py | findbeam_powerlaw | def findbeam_powerlaw(data, orig_initial, mask, rmin, rmax, maxiter=100,
drive_by='R2', extent=10, callback=None):
"""Find the beam by minimizing the width of a Gaussian centered at the
origin (i.e. maximizing the radius of gyration in a Guinier scattering).
Inputs:
data: scat... | python | def findbeam_powerlaw(data, orig_initial, mask, rmin, rmax, maxiter=100,
drive_by='R2', extent=10, callback=None):
"""Find the beam by minimizing the width of a Gaussian centered at the
origin (i.e. maximizing the radius of gyration in a Guinier scattering).
Inputs:
data: scat... | [
"def",
"findbeam_powerlaw",
"(",
"data",
",",
"orig_initial",
",",
"mask",
",",
"rmin",
",",
"rmax",
",",
"maxiter",
"=",
"100",
",",
"drive_by",
"=",
"'R2'",
",",
"extent",
"=",
"10",
",",
"callback",
"=",
"None",
")",
":",
"orig_initial",
"=",
"np",
... | Find the beam by minimizing the width of a Gaussian centered at the
origin (i.e. maximizing the radius of gyration in a Guinier scattering).
Inputs:
data: scattering matrix
orig_initial: first guess for the origin
mask: mask matrix. Nonzero is non-masked.
rmin,rmax: distance fro... | [
"Find",
"the",
"beam",
"by",
"minimizing",
"the",
"width",
"of",
"a",
"Gaussian",
"centered",
"at",
"the",
"origin",
"(",
"i",
".",
"e",
".",
"maximizing",
"the",
"radius",
"of",
"gyration",
"in",
"a",
"Guinier",
"scattering",
")",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/centering.py#L358-L400 | train |
awacha/sastool | sastool/io/credo_cct/header.py | Header.beamcenterx | def beamcenterx(self) -> ErrorValue:
"""X (column) coordinate of the beam center, pixel units, 0-based."""
try:
return ErrorValue(self._data['geometry']['beamposy'],
self._data['geometry']['beamposy.err'])
except KeyError:
return ErrorValue(s... | python | def beamcenterx(self) -> ErrorValue:
"""X (column) coordinate of the beam center, pixel units, 0-based."""
try:
return ErrorValue(self._data['geometry']['beamposy'],
self._data['geometry']['beamposy.err'])
except KeyError:
return ErrorValue(s... | [
"def",
"beamcenterx",
"(",
"self",
")",
"->",
"ErrorValue",
":",
"try",
":",
"return",
"ErrorValue",
"(",
"self",
".",
"_data",
"[",
"'geometry'",
"]",
"[",
"'beamposy'",
"]",
",",
"self",
".",
"_data",
"[",
"'geometry'",
"]",
"[",
"'beamposy.err'",
"]",... | X (column) coordinate of the beam center, pixel units, 0-based. | [
"X",
"(",
"column",
")",
"coordinate",
"of",
"the",
"beam",
"center",
"pixel",
"units",
"0",
"-",
"based",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/credo_cct/header.py#L106-L113 | train |
awacha/sastool | sastool/io/credo_cct/header.py | Header.beamcentery | def beamcentery(self) -> ErrorValue:
"""Y (row) coordinate of the beam center, pixel units, 0-based."""
try:
return ErrorValue(self._data['geometry']['beamposx'],
self._data['geometry']['beamposx.err'])
except KeyError:
return ErrorValue(self... | python | def beamcentery(self) -> ErrorValue:
"""Y (row) coordinate of the beam center, pixel units, 0-based."""
try:
return ErrorValue(self._data['geometry']['beamposx'],
self._data['geometry']['beamposx.err'])
except KeyError:
return ErrorValue(self... | [
"def",
"beamcentery",
"(",
"self",
")",
"->",
"ErrorValue",
":",
"try",
":",
"return",
"ErrorValue",
"(",
"self",
".",
"_data",
"[",
"'geometry'",
"]",
"[",
"'beamposx'",
"]",
",",
"self",
".",
"_data",
"[",
"'geometry'",
"]",
"[",
"'beamposx.err'",
"]",... | Y (row) coordinate of the beam center, pixel units, 0-based. | [
"Y",
"(",
"row",
")",
"coordinate",
"of",
"the",
"beam",
"center",
"pixel",
"units",
"0",
"-",
"based",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/credo_cct/header.py#L124-L131 | train |
awacha/sastool | sastool/io/credo_cct/header.py | Header.maskname | def maskname(self) -> Optional[str]:
"""Name of the mask matrix file."""
mask = self._data['geometry']['mask']
if os.path.abspath(mask):
mask = os.path.split(mask)[-1]
return mask | python | def maskname(self) -> Optional[str]:
"""Name of the mask matrix file."""
mask = self._data['geometry']['mask']
if os.path.abspath(mask):
mask = os.path.split(mask)[-1]
return mask | [
"def",
"maskname",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"mask",
"=",
"self",
".",
"_data",
"[",
"'geometry'",
"]",
"[",
"'mask'",
"]",
"if",
"os",
".",
"path",
".",
"abspath",
"(",
"mask",
")",
":",
"mask",
"=",
"os",
".",
... | Name of the mask matrix file. | [
"Name",
"of",
"the",
"mask",
"matrix",
"file",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/credo_cct/header.py#L197-L202 | train |
awacha/sastool | sastool/classes2/curve.py | errtrapz | def errtrapz(x, yerr):
"""Error of the trapezoid formula
Inputs:
x: the abscissa
yerr: the error of the dependent variable
Outputs:
the error of the integral
"""
x = np.array(x)
assert isinstance(x, np.ndarray)
yerr = np.array(yerr)
return 0.5 * np.sqrt((x[1] - x... | python | def errtrapz(x, yerr):
"""Error of the trapezoid formula
Inputs:
x: the abscissa
yerr: the error of the dependent variable
Outputs:
the error of the integral
"""
x = np.array(x)
assert isinstance(x, np.ndarray)
yerr = np.array(yerr)
return 0.5 * np.sqrt((x[1] - x... | [
"def",
"errtrapz",
"(",
"x",
",",
"yerr",
")",
":",
"x",
"=",
"np",
".",
"array",
"(",
"x",
")",
"assert",
"isinstance",
"(",
"x",
",",
"np",
".",
"ndarray",
")",
"yerr",
"=",
"np",
".",
"array",
"(",
"yerr",
")",
"return",
"0.5",
"*",
"np",
... | Error of the trapezoid formula
Inputs:
x: the abscissa
yerr: the error of the dependent variable
Outputs:
the error of the integral | [
"Error",
"of",
"the",
"trapezoid",
"formula",
"Inputs",
":",
"x",
":",
"the",
"abscissa",
"yerr",
":",
"the",
"error",
"of",
"the",
"dependent",
"variable"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/curve.py#L15-L29 | train |
awacha/sastool | sastool/classes2/curve.py | Curve.fit | def fit(self, fitfunction, parinit, unfittableparameters=(), *args, **kwargs):
"""Perform a nonlinear least-squares fit, using sastool.misc.fitter.Fitter()
Other arguments and keyword arguments will be passed through to the
__init__ method of Fitter. For example, these are:
- lbounds
... | python | def fit(self, fitfunction, parinit, unfittableparameters=(), *args, **kwargs):
"""Perform a nonlinear least-squares fit, using sastool.misc.fitter.Fitter()
Other arguments and keyword arguments will be passed through to the
__init__ method of Fitter. For example, these are:
- lbounds
... | [
"def",
"fit",
"(",
"self",
",",
"fitfunction",
",",
"parinit",
",",
"unfittableparameters",
"=",
"(",
")",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'otherparameters'",
"]",
"=",
"unfittableparameters",
"fitter",
"=",
"Fitter",
... | Perform a nonlinear least-squares fit, using sastool.misc.fitter.Fitter()
Other arguments and keyword arguments will be passed through to the
__init__ method of Fitter. For example, these are:
- lbounds
- ubounds
- ytransform
- loss
- method
Returns: the... | [
"Perform",
"a",
"nonlinear",
"least",
"-",
"squares",
"fit",
"using",
"sastool",
".",
"misc",
".",
"fitter",
".",
"Fitter",
"()"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/curve.py#L63-L87 | train |
awacha/sastool | sastool/classes2/curve.py | Curve.momentum | def momentum(self, exponent=1, errorrequested=True):
"""Calculate momenta (integral of y times x^exponent)
The integration is done by the trapezoid formula (np.trapz).
Inputs:
exponent: the exponent of q in the integration.
errorrequested: True if error should be returne... | python | def momentum(self, exponent=1, errorrequested=True):
"""Calculate momenta (integral of y times x^exponent)
The integration is done by the trapezoid formula (np.trapz).
Inputs:
exponent: the exponent of q in the integration.
errorrequested: True if error should be returne... | [
"def",
"momentum",
"(",
"self",
",",
"exponent",
"=",
"1",
",",
"errorrequested",
"=",
"True",
")",
":",
"y",
"=",
"self",
".",
"Intensity",
"*",
"self",
".",
"q",
"**",
"exponent",
"m",
"=",
"np",
".",
"trapz",
"(",
"y",
",",
"self",
".",
"q",
... | Calculate momenta (integral of y times x^exponent)
The integration is done by the trapezoid formula (np.trapz).
Inputs:
exponent: the exponent of q in the integration.
errorrequested: True if error should be returned (true Gaussian
error-propagation of the trapez... | [
"Calculate",
"momenta",
"(",
"integral",
"of",
"y",
"times",
"x^exponent",
")",
"The",
"integration",
"is",
"done",
"by",
"the",
"trapezoid",
"formula",
"(",
"np",
".",
"trapz",
")",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/curve.py#L238-L254 | train |
awacha/sastool | sastool/classes2/curve.py | Curve.scalefactor | def scalefactor(self, other, qmin=None, qmax=None, Npoints=None):
"""Calculate a scaling factor, by which this curve is to be multiplied to best fit the other one.
Inputs:
other: the other curve (an instance of GeneralCurve or of a subclass of it)
qmin: lower cut-off (None to de... | python | def scalefactor(self, other, qmin=None, qmax=None, Npoints=None):
"""Calculate a scaling factor, by which this curve is to be multiplied to best fit the other one.
Inputs:
other: the other curve (an instance of GeneralCurve or of a subclass of it)
qmin: lower cut-off (None to de... | [
"def",
"scalefactor",
"(",
"self",
",",
"other",
",",
"qmin",
"=",
"None",
",",
"qmax",
"=",
"None",
",",
"Npoints",
"=",
"None",
")",
":",
"if",
"qmin",
"is",
"None",
":",
"qmin",
"=",
"max",
"(",
"self",
".",
"q",
".",
"min",
"(",
")",
",",
... | Calculate a scaling factor, by which this curve is to be multiplied to best fit the other one.
Inputs:
other: the other curve (an instance of GeneralCurve or of a subclass of it)
qmin: lower cut-off (None to determine the common range automatically)
qmax: upper cut-off (None... | [
"Calculate",
"a",
"scaling",
"factor",
"by",
"which",
"this",
"curve",
"is",
"to",
"be",
"multiplied",
"to",
"best",
"fit",
"the",
"other",
"one",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/curve.py#L279-L306 | train |
awacha/sastool | sastool/misc/fitter.py | Fitter._substitute_fixed_parameters_covar | def _substitute_fixed_parameters_covar(self, covar):
"""Insert fixed parameters in a covariance matrix"""
covar_resolved = np.empty((len(self._fixed_parameters), len(self._fixed_parameters)))
indices_of_fixed_parameters = [i for i in range(len(self.parameters())) if
... | python | def _substitute_fixed_parameters_covar(self, covar):
"""Insert fixed parameters in a covariance matrix"""
covar_resolved = np.empty((len(self._fixed_parameters), len(self._fixed_parameters)))
indices_of_fixed_parameters = [i for i in range(len(self.parameters())) if
... | [
"def",
"_substitute_fixed_parameters_covar",
"(",
"self",
",",
"covar",
")",
":",
"covar_resolved",
"=",
"np",
".",
"empty",
"(",
"(",
"len",
"(",
"self",
".",
"_fixed_parameters",
")",
",",
"len",
"(",
"self",
".",
"_fixed_parameters",
")",
")",
")",
"ind... | Insert fixed parameters in a covariance matrix | [
"Insert",
"fixed",
"parameters",
"in",
"a",
"covariance",
"matrix"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/fitter.py#L209-L226 | train |
awacha/sastool | sastool/io/credo_cct/loader.py | Loader.loadmask | def loadmask(self, filename: str) -> np.ndarray:
"""Load a mask file."""
mask = scipy.io.loadmat(self.find_file(filename, what='mask'))
maskkey = [k for k in mask.keys() if not (k.startswith('_') or k.endswith('_'))][0]
return mask[maskkey].astype(np.bool) | python | def loadmask(self, filename: str) -> np.ndarray:
"""Load a mask file."""
mask = scipy.io.loadmat(self.find_file(filename, what='mask'))
maskkey = [k for k in mask.keys() if not (k.startswith('_') or k.endswith('_'))][0]
return mask[maskkey].astype(np.bool) | [
"def",
"loadmask",
"(",
"self",
",",
"filename",
":",
"str",
")",
"->",
"np",
".",
"ndarray",
":",
"mask",
"=",
"scipy",
".",
"io",
".",
"loadmat",
"(",
"self",
".",
"find_file",
"(",
"filename",
",",
"what",
"=",
"'mask'",
")",
")",
"maskkey",
"="... | Load a mask file. | [
"Load",
"a",
"mask",
"file",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/credo_cct/loader.py#L57-L61 | train |
awacha/sastool | sastool/io/credo_cct/loader.py | Loader.loadcurve | def loadcurve(self, fsn: int) -> classes2.Curve:
"""Load a radial scattering curve"""
return classes2.Curve.new_from_file(self.find_file(self._exposureclass + '_%05d.txt' % fsn)) | python | def loadcurve(self, fsn: int) -> classes2.Curve:
"""Load a radial scattering curve"""
return classes2.Curve.new_from_file(self.find_file(self._exposureclass + '_%05d.txt' % fsn)) | [
"def",
"loadcurve",
"(",
"self",
",",
"fsn",
":",
"int",
")",
"->",
"classes2",
".",
"Curve",
":",
"return",
"classes2",
".",
"Curve",
".",
"new_from_file",
"(",
"self",
".",
"find_file",
"(",
"self",
".",
"_exposureclass",
"+",
"'_%05d.txt'",
"%",
"fsn"... | Load a radial scattering curve | [
"Load",
"a",
"radial",
"scattering",
"curve"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/credo_cct/loader.py#L63-L65 | train |
awacha/sastool | sastool/io/twodim.py | readcbf | def readcbf(name, load_header=False, load_data=True, for_nexus=False):
"""Read a cbf (crystallographic binary format) file from a Dectris PILATUS
detector.
Inputs
------
name: string
the file name
load_header: bool
if the header data is to be loaded.
load_data: bool
... | python | def readcbf(name, load_header=False, load_data=True, for_nexus=False):
"""Read a cbf (crystallographic binary format) file from a Dectris PILATUS
detector.
Inputs
------
name: string
the file name
load_header: bool
if the header data is to be loaded.
load_data: bool
... | [
"def",
"readcbf",
"(",
"name",
",",
"load_header",
"=",
"False",
",",
"load_data",
"=",
"True",
",",
"for_nexus",
"=",
"False",
")",
":",
"with",
"open",
"(",
"name",
",",
"'rb'",
")",
"as",
"f",
":",
"cbfbin",
"=",
"f",
".",
"read",
"(",
")",
"d... | Read a cbf (crystallographic binary format) file from a Dectris PILATUS
detector.
Inputs
------
name: string
the file name
load_header: bool
if the header data is to be loaded.
load_data: bool
if the binary data is to be loaded.
for_nexus: bool
if the array s... | [
"Read",
"a",
"cbf",
"(",
"crystallographic",
"binary",
"format",
")",
"file",
"from",
"a",
"Dectris",
"PILATUS",
"detector",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/twodim.py#L87-L212 | train |
awacha/sastool | sastool/io/twodim.py | readbdfv1 | def readbdfv1(filename, bdfext='.bdf', bhfext='.bhf'):
"""Read bdf file (Bessy Data Format v1)
Input
-----
filename: string
the name of the file
Output
------
the BDF structure in a dict
Notes
-----
This is an adaptation of the bdf_read.m macro of Sylvio Haas.
"""
... | python | def readbdfv1(filename, bdfext='.bdf', bhfext='.bhf'):
"""Read bdf file (Bessy Data Format v1)
Input
-----
filename: string
the name of the file
Output
------
the BDF structure in a dict
Notes
-----
This is an adaptation of the bdf_read.m macro of Sylvio Haas.
"""
... | [
"def",
"readbdfv1",
"(",
"filename",
",",
"bdfext",
"=",
"'.bdf'",
",",
"bhfext",
"=",
"'.bhf'",
")",
":",
"return",
"header",
".",
"readbhfv1",
"(",
"filename",
",",
"True",
",",
"bdfext",
",",
"bhfext",
")"
] | Read bdf file (Bessy Data Format v1)
Input
-----
filename: string
the name of the file
Output
------
the BDF structure in a dict
Notes
-----
This is an adaptation of the bdf_read.m macro of Sylvio Haas. | [
"Read",
"bdf",
"file",
"(",
"Bessy",
"Data",
"Format",
"v1",
")"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/twodim.py#L215-L231 | train |
awacha/sastool | sastool/io/twodim.py | readint2dnorm | def readint2dnorm(filename):
"""Read corrected intensity and error matrices (Matlab mat or numpy npz
format for Beamline B1 (HASYLAB/DORISIII))
Input
-----
filename: string
the name of the file
Outputs
-------
two ``np.ndarray``-s, the Intensity and the Error matrices
File... | python | def readint2dnorm(filename):
"""Read corrected intensity and error matrices (Matlab mat or numpy npz
format for Beamline B1 (HASYLAB/DORISIII))
Input
-----
filename: string
the name of the file
Outputs
-------
two ``np.ndarray``-s, the Intensity and the Error matrices
File... | [
"def",
"readint2dnorm",
"(",
"filename",
")",
":",
"# the core of read2dintfile",
"if",
"filename",
".",
"upper",
"(",
")",
".",
"endswith",
"(",
"'.MAT'",
")",
":",
"# Matlab",
"m",
"=",
"scipy",
".",
"io",
".",
"loadmat",
"(",
"filename",
")",
"elif",
... | Read corrected intensity and error matrices (Matlab mat or numpy npz
format for Beamline B1 (HASYLAB/DORISIII))
Input
-----
filename: string
the name of the file
Outputs
-------
two ``np.ndarray``-s, the Intensity and the Error matrices
File formats supported:
------------... | [
"Read",
"corrected",
"intensity",
"and",
"error",
"matrices",
"(",
"Matlab",
"mat",
"or",
"numpy",
"npz",
"format",
"for",
"Beamline",
"B1",
"(",
"HASYLAB",
"/",
"DORISIII",
"))"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/twodim.py#L253-L303 | train |
awacha/sastool | sastool/io/twodim.py | writeint2dnorm | def writeint2dnorm(filename, Intensity, Error=None):
"""Save the intensity and error matrices to a file
Inputs
------
filename: string
the name of the file
Intensity: np.ndarray
the intensity matrix
Error: np.ndarray, optional
the error matrix (can be ``None``, if no err... | python | def writeint2dnorm(filename, Intensity, Error=None):
"""Save the intensity and error matrices to a file
Inputs
------
filename: string
the name of the file
Intensity: np.ndarray
the intensity matrix
Error: np.ndarray, optional
the error matrix (can be ``None``, if no err... | [
"def",
"writeint2dnorm",
"(",
"filename",
",",
"Intensity",
",",
"Error",
"=",
"None",
")",
":",
"whattosave",
"=",
"{",
"'Intensity'",
":",
"Intensity",
"}",
"if",
"Error",
"is",
"not",
"None",
":",
"whattosave",
"[",
"'Error'",
"]",
"=",
"Error",
"if",... | Save the intensity and error matrices to a file
Inputs
------
filename: string
the name of the file
Intensity: np.ndarray
the intensity matrix
Error: np.ndarray, optional
the error matrix (can be ``None``, if no error matrix is to be saved)
Output
------
None | [
"Save",
"the",
"intensity",
"and",
"error",
"matrices",
"to",
"a",
"file"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/twodim.py#L306-L333 | train |
awacha/sastool | sastool/io/twodim.py | readmask | def readmask(filename, fieldname=None):
"""Try to load a maskfile from a matlab(R) matrix file
Inputs
------
filename: string
the input file name
fieldname: string, optional
field in the mat file. None to autodetect.
Outputs
-------
the mask in a numpy array of type np.... | python | def readmask(filename, fieldname=None):
"""Try to load a maskfile from a matlab(R) matrix file
Inputs
------
filename: string
the input file name
fieldname: string, optional
field in the mat file. None to autodetect.
Outputs
-------
the mask in a numpy array of type np.... | [
"def",
"readmask",
"(",
"filename",
",",
"fieldname",
"=",
"None",
")",
":",
"f",
"=",
"scipy",
".",
"io",
".",
"loadmat",
"(",
"filename",
")",
"if",
"fieldname",
"is",
"not",
"None",
":",
"return",
"f",
"[",
"fieldname",
"]",
".",
"astype",
"(",
... | Try to load a maskfile from a matlab(R) matrix file
Inputs
------
filename: string
the input file name
fieldname: string, optional
field in the mat file. None to autodetect.
Outputs
-------
the mask in a numpy array of type np.uint8 | [
"Try",
"to",
"load",
"a",
"maskfile",
"from",
"a",
"matlab",
"(",
"R",
")",
"matrix",
"file"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/twodim.py#L336-L360 | train |
awacha/sastool | sastool/io/twodim.py | readedf | def readedf(filename):
"""Read an ESRF data file (measured at beamlines ID01 or ID02)
Inputs
------
filename: string
the input file name
Output
------
the imported EDF structure in a dict. The scattering pattern is under key
'data'.
Notes
-----
Only datatype ``Floa... | python | def readedf(filename):
"""Read an ESRF data file (measured at beamlines ID01 or ID02)
Inputs
------
filename: string
the input file name
Output
------
the imported EDF structure in a dict. The scattering pattern is under key
'data'.
Notes
-----
Only datatype ``Floa... | [
"def",
"readedf",
"(",
"filename",
")",
":",
"edf",
"=",
"header",
".",
"readehf",
"(",
"filename",
")",
"f",
"=",
"open",
"(",
"filename",
",",
"'rb'",
")",
"f",
".",
"read",
"(",
"edf",
"[",
"'EDF_HeaderSize'",
"]",
")",
"# skip header.",
"if",
"ed... | Read an ESRF data file (measured at beamlines ID01 or ID02)
Inputs
------
filename: string
the input file name
Output
------
the imported EDF structure in a dict. The scattering pattern is under key
'data'.
Notes
-----
Only datatype ``FloatValue`` is supported right no... | [
"Read",
"an",
"ESRF",
"data",
"file",
"(",
"measured",
"at",
"beamlines",
"ID01",
"or",
"ID02",
")"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/twodim.py#L363-L390 | train |
awacha/sastool | sastool/io/twodim.py | readbdfv2 | def readbdfv2(filename, bdfext='.bdf', bhfext='.bhf'):
"""Read a version 2 Bessy Data File
Inputs
------
filename: string
the name of the input file. One can give the complete header or datafile
name or just the base name without the extensions.
bdfext: string, optional
the ... | python | def readbdfv2(filename, bdfext='.bdf', bhfext='.bhf'):
"""Read a version 2 Bessy Data File
Inputs
------
filename: string
the name of the input file. One can give the complete header or datafile
name or just the base name without the extensions.
bdfext: string, optional
the ... | [
"def",
"readbdfv2",
"(",
"filename",
",",
"bdfext",
"=",
"'.bdf'",
",",
"bhfext",
"=",
"'.bhf'",
")",
":",
"datas",
"=",
"header",
".",
"readbhfv2",
"(",
"filename",
",",
"True",
",",
"bdfext",
",",
"bhfext",
")",
"return",
"datas"
] | Read a version 2 Bessy Data File
Inputs
------
filename: string
the name of the input file. One can give the complete header or datafile
name or just the base name without the extensions.
bdfext: string, optional
the extension of the data file
bhfext: string, optional
... | [
"Read",
"a",
"version",
"2",
"Bessy",
"Data",
"File"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/twodim.py#L393-L416 | train |
awacha/sastool | sastool/io/twodim.py | readmar | def readmar(filename):
"""Read a two-dimensional scattering pattern from a MarResearch .image file.
"""
hed = header.readmarheader(filename)
with open(filename, 'rb') as f:
h = f.read(hed['recordlength'])
data = np.fromstring(
f.read(2 * hed['Xsize'] * hed['Ysize']), '<u2').a... | python | def readmar(filename):
"""Read a two-dimensional scattering pattern from a MarResearch .image file.
"""
hed = header.readmarheader(filename)
with open(filename, 'rb') as f:
h = f.read(hed['recordlength'])
data = np.fromstring(
f.read(2 * hed['Xsize'] * hed['Ysize']), '<u2').a... | [
"def",
"readmar",
"(",
"filename",
")",
":",
"hed",
"=",
"header",
".",
"readmarheader",
"(",
"filename",
")",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"f",
":",
"h",
"=",
"f",
".",
"read",
"(",
"hed",
"[",
"'recordlength'",
"]",
")... | Read a two-dimensional scattering pattern from a MarResearch .image file. | [
"Read",
"a",
"two",
"-",
"dimensional",
"scattering",
"pattern",
"from",
"a",
"MarResearch",
".",
"image",
"file",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/twodim.py#L423-L435 | train |
awacha/sastool | sastool/io/twodim.py | writebdfv2 | def writebdfv2(filename, bdf, bdfext='.bdf', bhfext='.bhf'):
"""Write a version 2 Bessy Data File
Inputs
------
filename: string
the name of the output file. One can give the complete header or
datafile name or just the base name without the extensions.
bdf: dict
the BDF str... | python | def writebdfv2(filename, bdf, bdfext='.bdf', bhfext='.bhf'):
"""Write a version 2 Bessy Data File
Inputs
------
filename: string
the name of the output file. One can give the complete header or
datafile name or just the base name without the extensions.
bdf: dict
the BDF str... | [
"def",
"writebdfv2",
"(",
"filename",
",",
"bdf",
",",
"bdfext",
"=",
"'.bdf'",
",",
"bhfext",
"=",
"'.bhf'",
")",
":",
"if",
"filename",
".",
"endswith",
"(",
"bdfext",
")",
":",
"basename",
"=",
"filename",
"[",
":",
"-",
"len",
"(",
"bdfext",
")",... | Write a version 2 Bessy Data File
Inputs
------
filename: string
the name of the output file. One can give the complete header or
datafile name or just the base name without the extensions.
bdf: dict
the BDF structure (in the same format as loaded by ``readbdfv2()``
bdfext: ... | [
"Write",
"a",
"version",
"2",
"Bessy",
"Data",
"File"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/twodim.py#L438-L478 | train |
awacha/sastool | sastool/io/twodim.py | rebinmask | def rebinmask(mask, binx, biny, enlarge=False):
"""Re-bin (shrink or enlarge) a mask matrix.
Inputs
------
mask: np.ndarray
mask matrix.
binx: integer
binning along the 0th axis
biny: integer
binning along the 1st axis
enlarge: bool, optional
direction of bin... | python | def rebinmask(mask, binx, biny, enlarge=False):
"""Re-bin (shrink or enlarge) a mask matrix.
Inputs
------
mask: np.ndarray
mask matrix.
binx: integer
binning along the 0th axis
biny: integer
binning along the 1st axis
enlarge: bool, optional
direction of bin... | [
"def",
"rebinmask",
"(",
"mask",
",",
"binx",
",",
"biny",
",",
"enlarge",
"=",
"False",
")",
":",
"if",
"not",
"enlarge",
"and",
"(",
"(",
"mask",
".",
"shape",
"[",
"0",
"]",
"%",
"binx",
")",
"or",
"(",
"mask",
".",
"shape",
"[",
"1",
"]",
... | Re-bin (shrink or enlarge) a mask matrix.
Inputs
------
mask: np.ndarray
mask matrix.
binx: integer
binning along the 0th axis
biny: integer
binning along the 1st axis
enlarge: bool, optional
direction of binning. If True, the matrix will be enlarged, otherwise
... | [
"Re",
"-",
"bin",
"(",
"shrink",
"or",
"enlarge",
")",
"a",
"mask",
"matrix",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/twodim.py#L481-L512 | train |
ClearcodeHQ/querystringsafe_base64 | src/querystringsafe_base64/__init__.py | fill_padding | def fill_padding(padded_string):
# type: (bytes) -> bytes
"""
Fill up missing padding in a string.
This function makes sure that the string has length which is multiplication of 4,
and if not, fills the missing places with dots.
:param str padded_string: string to be decoded that might miss pa... | python | def fill_padding(padded_string):
# type: (bytes) -> bytes
"""
Fill up missing padding in a string.
This function makes sure that the string has length which is multiplication of 4,
and if not, fills the missing places with dots.
:param str padded_string: string to be decoded that might miss pa... | [
"def",
"fill_padding",
"(",
"padded_string",
")",
":",
"# type: (bytes) -> bytes",
"length",
"=",
"len",
"(",
"padded_string",
")",
"reminder",
"=",
"len",
"(",
"padded_string",
")",
"%",
"4",
"if",
"reminder",
":",
"return",
"padded_string",
".",
"ljust",
"("... | Fill up missing padding in a string.
This function makes sure that the string has length which is multiplication of 4,
and if not, fills the missing places with dots.
:param str padded_string: string to be decoded that might miss padding dots.
:return: properly padded string
:rtype: str | [
"Fill",
"up",
"missing",
"padding",
"in",
"a",
"string",
"."
] | 5353c4a8e275435d9d38356a0db64e5c43198ccd | https://github.com/ClearcodeHQ/querystringsafe_base64/blob/5353c4a8e275435d9d38356a0db64e5c43198ccd/src/querystringsafe_base64/__init__.py#L27-L43 | train |
ClearcodeHQ/querystringsafe_base64 | src/querystringsafe_base64/__init__.py | decode | def decode(encoded):
# type: (bytes) -> bytes
"""
Decode the result of querystringsafe_base64_encode or a regular base64.
.. note ::
As a regular base64 string does not contain dots, replacing dots with
equal signs does basically noting to it. Also,
base64.urlsafe_b64decode allo... | python | def decode(encoded):
# type: (bytes) -> bytes
"""
Decode the result of querystringsafe_base64_encode or a regular base64.
.. note ::
As a regular base64 string does not contain dots, replacing dots with
equal signs does basically noting to it. Also,
base64.urlsafe_b64decode allo... | [
"def",
"decode",
"(",
"encoded",
")",
":",
"# type: (bytes) -> bytes",
"padded_string",
"=",
"fill_padding",
"(",
"encoded",
")",
"return",
"urlsafe_b64decode",
"(",
"padded_string",
".",
"replace",
"(",
"b'.'",
",",
"b'='",
")",
")"
] | Decode the result of querystringsafe_base64_encode or a regular base64.
.. note ::
As a regular base64 string does not contain dots, replacing dots with
equal signs does basically noting to it. Also,
base64.urlsafe_b64decode allows to decode both safe and unsafe base64.
Therefore th... | [
"Decode",
"the",
"result",
"of",
"querystringsafe_base64_encode",
"or",
"a",
"regular",
"base64",
"."
] | 5353c4a8e275435d9d38356a0db64e5c43198ccd | https://github.com/ClearcodeHQ/querystringsafe_base64/blob/5353c4a8e275435d9d38356a0db64e5c43198ccd/src/querystringsafe_base64/__init__.py#L63-L79 | train |
awacha/sastool | sastool/misc/utils.py | normalize_listargument | def normalize_listargument(arg):
"""Check if arg is an iterable (list, tuple, set, dict, np.ndarray, except
string!). If not, make a list of it. Numpy arrays are flattened and
converted to lists."""
if isinstance(arg, np.ndarray):
return arg.flatten()
if isinstance(arg, str):
... | python | def normalize_listargument(arg):
"""Check if arg is an iterable (list, tuple, set, dict, np.ndarray, except
string!). If not, make a list of it. Numpy arrays are flattened and
converted to lists."""
if isinstance(arg, np.ndarray):
return arg.flatten()
if isinstance(arg, str):
... | [
"def",
"normalize_listargument",
"(",
"arg",
")",
":",
"if",
"isinstance",
"(",
"arg",
",",
"np",
".",
"ndarray",
")",
":",
"return",
"arg",
".",
"flatten",
"(",
")",
"if",
"isinstance",
"(",
"arg",
",",
"str",
")",
":",
"return",
"[",
"arg",
"]",
... | Check if arg is an iterable (list, tuple, set, dict, np.ndarray, except
string!). If not, make a list of it. Numpy arrays are flattened and
converted to lists. | [
"Check",
"if",
"arg",
"is",
"an",
"iterable",
"(",
"list",
"tuple",
"set",
"dict",
"np",
".",
"ndarray",
"except",
"string!",
")",
".",
"If",
"not",
"make",
"a",
"list",
"of",
"it",
".",
"Numpy",
"arrays",
"are",
"flattened",
"and",
"converted",
"to",
... | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/utils.py#L27-L37 | train |
awacha/sastool | sastool/misc/utils.py | parse_number | def parse_number(val, use_dateutilparser=False):
"""Try to auto-detect the numeric type of the value. First a conversion to
int is tried. If this fails float is tried, and if that fails too, unicode()
is executed. If this also fails, a ValueError is raised.
"""
if use_dateutilparser:
funcs =... | python | def parse_number(val, use_dateutilparser=False):
"""Try to auto-detect the numeric type of the value. First a conversion to
int is tried. If this fails float is tried, and if that fails too, unicode()
is executed. If this also fails, a ValueError is raised.
"""
if use_dateutilparser:
funcs =... | [
"def",
"parse_number",
"(",
"val",
",",
"use_dateutilparser",
"=",
"False",
")",
":",
"if",
"use_dateutilparser",
":",
"funcs",
"=",
"[",
"int",
",",
"float",
",",
"parse_list_from_string",
",",
"dateutil",
".",
"parser",
".",
"parse",
",",
"str",
"]",
"el... | Try to auto-detect the numeric type of the value. First a conversion to
int is tried. If this fails float is tried, and if that fails too, unicode()
is executed. If this also fails, a ValueError is raised. | [
"Try",
"to",
"auto",
"-",
"detect",
"the",
"numeric",
"type",
"of",
"the",
"value",
".",
"First",
"a",
"conversion",
"to",
"int",
"is",
"tried",
".",
"If",
"this",
"fails",
"float",
"is",
"tried",
"and",
"if",
"that",
"fails",
"too",
"unicode",
"()",
... | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/utils.py#L40-L58 | train |
awacha/sastool | sastool/misc/utils.py | flatten_hierarchical_dict | def flatten_hierarchical_dict(original_dict, separator='.', max_recursion_depth=None):
"""Flatten a dict.
Inputs
------
original_dict: dict
the dictionary to flatten
separator: string, optional
the separator item in the keys of the flattened dictionary
max_recursion_depth: posit... | python | def flatten_hierarchical_dict(original_dict, separator='.', max_recursion_depth=None):
"""Flatten a dict.
Inputs
------
original_dict: dict
the dictionary to flatten
separator: string, optional
the separator item in the keys of the flattened dictionary
max_recursion_depth: posit... | [
"def",
"flatten_hierarchical_dict",
"(",
"original_dict",
",",
"separator",
"=",
"'.'",
",",
"max_recursion_depth",
"=",
"None",
")",
":",
"if",
"max_recursion_depth",
"is",
"not",
"None",
"and",
"max_recursion_depth",
"<=",
"0",
":",
"# we reached the maximum recursi... | Flatten a dict.
Inputs
------
original_dict: dict
the dictionary to flatten
separator: string, optional
the separator item in the keys of the flattened dictionary
max_recursion_depth: positive integer, optional
the number of recursions to be done. None is infinte.
Outpu... | [
"Flatten",
"a",
"dict",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/utils.py#L61-L107 | train |
awacha/sastool | sastool/misc/utils.py | random_str | def random_str(Nchars=6, randstrbase='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'):
"""Return a random string of <Nchars> characters. Characters are sampled
uniformly from <randstrbase>.
"""
return ''.join([randstrbase[random.randint(0, len(randstrbase) - 1)] for i in range(Nchars)]) | python | def random_str(Nchars=6, randstrbase='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'):
"""Return a random string of <Nchars> characters. Characters are sampled
uniformly from <randstrbase>.
"""
return ''.join([randstrbase[random.randint(0, len(randstrbase) - 1)] for i in range(Nchars)]) | [
"def",
"random_str",
"(",
"Nchars",
"=",
"6",
",",
"randstrbase",
"=",
"'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'",
")",
":",
"return",
"''",
".",
"join",
"(",
"[",
"randstrbase",
"[",
"random",
".",
"randint",
"(",
"0",
",",
"len",
"(",
... | Return a random string of <Nchars> characters. Characters are sampled
uniformly from <randstrbase>. | [
"Return",
"a",
"random",
"string",
"of",
"<Nchars",
">",
"characters",
".",
"Characters",
"are",
"sampled",
"uniformly",
"from",
"<randstrbase",
">",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/utils.py#L115-L119 | train |
awacha/sastool | sastool/io/statistics.py | listB1 | def listB1(fsns, xlsname, dirs, whattolist = None, headerformat = 'org_%05d.header'):
""" getsamplenames revisited, XLS output.
Inputs:
fsns: FSN sequence
xlsname: XLS file name to output listing
dirs: either a single directory (string) or a list of directories, a la readheader()
... | python | def listB1(fsns, xlsname, dirs, whattolist = None, headerformat = 'org_%05d.header'):
""" getsamplenames revisited, XLS output.
Inputs:
fsns: FSN sequence
xlsname: XLS file name to output listing
dirs: either a single directory (string) or a list of directories, a la readheader()
... | [
"def",
"listB1",
"(",
"fsns",
",",
"xlsname",
",",
"dirs",
",",
"whattolist",
"=",
"None",
",",
"headerformat",
"=",
"'org_%05d.header'",
")",
":",
"if",
"whattolist",
"is",
"None",
":",
"whattolist",
"=",
"[",
"(",
"'FSN'",
",",
"'FSN'",
")",
",",
"("... | getsamplenames revisited, XLS output.
Inputs:
fsns: FSN sequence
xlsname: XLS file name to output listing
dirs: either a single directory (string) or a list of directories, a la readheader()
whattolist: format specifier for listing. Should be a list of tuples. Each tuple
... | [
"getsamplenames",
"revisited",
"XLS",
"output",
".",
"Inputs",
":",
"fsns",
":",
"FSN",
"sequence",
"xlsname",
":",
"XLS",
"file",
"name",
"to",
"output",
"listing",
"dirs",
":",
"either",
"a",
"single",
"directory",
"(",
"string",
")",
"or",
"a",
"list",
... | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/statistics.py#L105-L167 | train |
awacha/sastool | sastool/fitting/standalone.py | fit_shullroess | def fit_shullroess(q, Intensity, Error, R0=None, r=None):
"""Do a Shull-Roess fitting on the scattering data.
Inputs:
q: np.ndarray[ndim=1]
vector of the q values (4*pi*sin(theta)/lambda)
Intensity: np.ndarray[ndim=1]
Intensity vector
Error: np.ndarray[ndim=1]
... | python | def fit_shullroess(q, Intensity, Error, R0=None, r=None):
"""Do a Shull-Roess fitting on the scattering data.
Inputs:
q: np.ndarray[ndim=1]
vector of the q values (4*pi*sin(theta)/lambda)
Intensity: np.ndarray[ndim=1]
Intensity vector
Error: np.ndarray[ndim=1]
... | [
"def",
"fit_shullroess",
"(",
"q",
",",
"Intensity",
",",
"Error",
",",
"R0",
"=",
"None",
",",
"r",
"=",
"None",
")",
":",
"q",
"=",
"np",
".",
"array",
"(",
"q",
")",
"Intensity",
"=",
"np",
".",
"array",
"(",
"Intensity",
")",
"Error",
"=",
... | Do a Shull-Roess fitting on the scattering data.
Inputs:
q: np.ndarray[ndim=1]
vector of the q values (4*pi*sin(theta)/lambda)
Intensity: np.ndarray[ndim=1]
Intensity vector
Error: np.ndarray[ndim=1]
Error of the intensity (absolute uncertainty, 1sigma)
... | [
"Do",
"a",
"Shull",
"-",
"Roess",
"fitting",
"on",
"the",
"scattering",
"data",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/standalone.py#L11-L65 | train |
awacha/sastool | sastool/fitting/standalone.py | maxwellian | def maxwellian(r, r0, n):
"""Maxwellian-like distribution of spherical particles
Inputs:
-------
r: np.ndarray or scalar
radii
r0: positive scalar or ErrorValue
mean radius
n: positive scalar or ErrorValue
"n" parameter
Output:
--... | python | def maxwellian(r, r0, n):
"""Maxwellian-like distribution of spherical particles
Inputs:
-------
r: np.ndarray or scalar
radii
r0: positive scalar or ErrorValue
mean radius
n: positive scalar or ErrorValue
"n" parameter
Output:
--... | [
"def",
"maxwellian",
"(",
"r",
",",
"r0",
",",
"n",
")",
":",
"r0",
"=",
"ErrorValue",
"(",
"r0",
")",
"n",
"=",
"ErrorValue",
"(",
"n",
")",
"expterm",
"=",
"np",
".",
"exp",
"(",
"-",
"r",
"**",
"2",
"/",
"r0",
".",
"val",
"**",
"2",
")",... | Maxwellian-like distribution of spherical particles
Inputs:
-------
r: np.ndarray or scalar
radii
r0: positive scalar or ErrorValue
mean radius
n: positive scalar or ErrorValue
"n" parameter
Output:
-------
the distribution fu... | [
"Maxwellian",
"-",
"like",
"distribution",
"of",
"spherical",
"particles",
"Inputs",
":",
"-------",
"r",
":",
"np",
".",
"ndarray",
"or",
"scalar",
"radii",
"r0",
":",
"positive",
"scalar",
"or",
"ErrorValue",
"mean",
"radius",
"n",
":",
"positive",
"scalar... | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/standalone.py#L67-L97 | train |
awacha/sastool | sastool/misc/pathutils.py | findfileindirs | def findfileindirs(filename, dirs=None, use_pythonpath=True, use_searchpath=True, notfound_is_fatal=True, notfound_val=None):
"""Find file in multiple directories.
Inputs:
filename: the file name to be searched for.
dirs: list of folders or None
use_pythonpath: use the Python module sea... | python | def findfileindirs(filename, dirs=None, use_pythonpath=True, use_searchpath=True, notfound_is_fatal=True, notfound_val=None):
"""Find file in multiple directories.
Inputs:
filename: the file name to be searched for.
dirs: list of folders or None
use_pythonpath: use the Python module sea... | [
"def",
"findfileindirs",
"(",
"filename",
",",
"dirs",
"=",
"None",
",",
"use_pythonpath",
"=",
"True",
",",
"use_searchpath",
"=",
"True",
",",
"notfound_is_fatal",
"=",
"True",
",",
"notfound_val",
"=",
"None",
")",
":",
"if",
"os",
".",
"path",
".",
"... | Find file in multiple directories.
Inputs:
filename: the file name to be searched for.
dirs: list of folders or None
use_pythonpath: use the Python module search path
use_searchpath: use the sastool search path.
notfound_is_fatal: if an exception is to be raised if the file ... | [
"Find",
"file",
"in",
"multiple",
"directories",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/pathutils.py#L17-L63 | train |
awacha/sastool | sastool/utils2d/corrections.py | twotheta | def twotheta(matrix, bcx, bcy, pixsizeperdist):
"""Calculate the two-theta matrix for a scattering matrix
Inputs:
matrix: only the shape of it is needed
bcx, bcy: beam position (counting from 0; x is row, y is column index)
pixsizeperdist: the pixel size divided by the sample-to-detecto... | python | def twotheta(matrix, bcx, bcy, pixsizeperdist):
"""Calculate the two-theta matrix for a scattering matrix
Inputs:
matrix: only the shape of it is needed
bcx, bcy: beam position (counting from 0; x is row, y is column index)
pixsizeperdist: the pixel size divided by the sample-to-detecto... | [
"def",
"twotheta",
"(",
"matrix",
",",
"bcx",
",",
"bcy",
",",
"pixsizeperdist",
")",
":",
"col",
",",
"row",
"=",
"np",
".",
"meshgrid",
"(",
"list",
"(",
"range",
"(",
"matrix",
".",
"shape",
"[",
"1",
"]",
")",
")",
",",
"list",
"(",
"range",
... | Calculate the two-theta matrix for a scattering matrix
Inputs:
matrix: only the shape of it is needed
bcx, bcy: beam position (counting from 0; x is row, y is column index)
pixsizeperdist: the pixel size divided by the sample-to-detector
distance
Outputs:
the two th... | [
"Calculate",
"the",
"two",
"-",
"theta",
"matrix",
"for",
"a",
"scattering",
"matrix"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/corrections.py#L10-L23 | train |
awacha/sastool | sastool/utils2d/corrections.py | solidangle | def solidangle(twotheta, sampletodetectordistance, pixelsize=None):
"""Solid-angle correction for two-dimensional SAS images
Inputs:
twotheta: matrix of two-theta values
sampletodetectordistance: sample-to-detector distance
pixelsize: the pixel size in mm
The output matrix is of th... | python | def solidangle(twotheta, sampletodetectordistance, pixelsize=None):
"""Solid-angle correction for two-dimensional SAS images
Inputs:
twotheta: matrix of two-theta values
sampletodetectordistance: sample-to-detector distance
pixelsize: the pixel size in mm
The output matrix is of th... | [
"def",
"solidangle",
"(",
"twotheta",
",",
"sampletodetectordistance",
",",
"pixelsize",
"=",
"None",
")",
":",
"if",
"pixelsize",
"is",
"None",
":",
"pixelsize",
"=",
"1",
"return",
"sampletodetectordistance",
"**",
"2",
"/",
"np",
".",
"cos",
"(",
"twothet... | Solid-angle correction for two-dimensional SAS images
Inputs:
twotheta: matrix of two-theta values
sampletodetectordistance: sample-to-detector distance
pixelsize: the pixel size in mm
The output matrix is of the same shape as twotheta. The scattering intensity
matrix should be... | [
"Solid",
"-",
"angle",
"correction",
"for",
"two",
"-",
"dimensional",
"SAS",
"images"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/corrections.py#L26-L39 | train |
awacha/sastool | sastool/utils2d/corrections.py | solidangle_errorprop | def solidangle_errorprop(twotheta, dtwotheta, sampletodetectordistance, dsampletodetectordistance, pixelsize=None):
"""Solid-angle correction for two-dimensional SAS images with error propagation
Inputs:
twotheta: matrix of two-theta values
dtwotheta: matrix of absolute error of two-theta value... | python | def solidangle_errorprop(twotheta, dtwotheta, sampletodetectordistance, dsampletodetectordistance, pixelsize=None):
"""Solid-angle correction for two-dimensional SAS images with error propagation
Inputs:
twotheta: matrix of two-theta values
dtwotheta: matrix of absolute error of two-theta value... | [
"def",
"solidangle_errorprop",
"(",
"twotheta",
",",
"dtwotheta",
",",
"sampletodetectordistance",
",",
"dsampletodetectordistance",
",",
"pixelsize",
"=",
"None",
")",
":",
"SAC",
"=",
"solidangle",
"(",
"twotheta",
",",
"sampletodetectordistance",
",",
"pixelsize",
... | Solid-angle correction for two-dimensional SAS images with error propagation
Inputs:
twotheta: matrix of two-theta values
dtwotheta: matrix of absolute error of two-theta values
sampletodetectordistance: sample-to-detector distance
dsampletodetectordistance: absolute error of sample... | [
"Solid",
"-",
"angle",
"correction",
"for",
"two",
"-",
"dimensional",
"SAS",
"images",
"with",
"error",
"propagation"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/corrections.py#L42-L61 | train |
awacha/sastool | sastool/utils2d/corrections.py | angledependentabsorption | def angledependentabsorption(twotheta, transmission):
"""Correction for angle-dependent absorption of the sample
Inputs:
twotheta: matrix of two-theta values
transmission: the transmission of the sample (I_after/I_before, or
exp(-mu*d))
The output matrix is of the same shape as... | python | def angledependentabsorption(twotheta, transmission):
"""Correction for angle-dependent absorption of the sample
Inputs:
twotheta: matrix of two-theta values
transmission: the transmission of the sample (I_after/I_before, or
exp(-mu*d))
The output matrix is of the same shape as... | [
"def",
"angledependentabsorption",
"(",
"twotheta",
",",
"transmission",
")",
":",
"cor",
"=",
"np",
".",
"ones",
"(",
"twotheta",
".",
"shape",
")",
"if",
"transmission",
"==",
"1",
":",
"return",
"cor",
"mud",
"=",
"-",
"np",
".",
"log",
"(",
"transm... | Correction for angle-dependent absorption of the sample
Inputs:
twotheta: matrix of two-theta values
transmission: the transmission of the sample (I_after/I_before, or
exp(-mu*d))
The output matrix is of the same shape as twotheta. The scattering intensity
matrix should be ... | [
"Correction",
"for",
"angle",
"-",
"dependent",
"absorption",
"of",
"the",
"sample"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/corrections.py#L63-L83 | train |
awacha/sastool | sastool/utils2d/corrections.py | angledependentabsorption_errorprop | def angledependentabsorption_errorprop(twotheta, dtwotheta, transmission, dtransmission):
"""Correction for angle-dependent absorption of the sample with error propagation
Inputs:
twotheta: matrix of two-theta values
dtwotheta: matrix of absolute error of two-theta values
transmission: ... | python | def angledependentabsorption_errorprop(twotheta, dtwotheta, transmission, dtransmission):
"""Correction for angle-dependent absorption of the sample with error propagation
Inputs:
twotheta: matrix of two-theta values
dtwotheta: matrix of absolute error of two-theta values
transmission: ... | [
"def",
"angledependentabsorption_errorprop",
"(",
"twotheta",
",",
"dtwotheta",
",",
"transmission",
",",
"dtransmission",
")",
":",
"# error propagation formula calculated using sympy",
"return",
"(",
"angledependentabsorption",
"(",
"twotheta",
",",
"transmission",
")",
"... | Correction for angle-dependent absorption of the sample with error propagation
Inputs:
twotheta: matrix of two-theta values
dtwotheta: matrix of absolute error of two-theta values
transmission: the transmission of the sample (I_after/I_before, or
exp(-mu*d))
dtransmissio... | [
"Correction",
"for",
"angle",
"-",
"dependent",
"absorption",
"of",
"the",
"sample",
"with",
"error",
"propagation"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/corrections.py#L108-L123 | train |
awacha/sastool | sastool/utils2d/corrections.py | angledependentairtransmission | def angledependentairtransmission(twotheta, mu_air, sampletodetectordistance):
"""Correction for the angle dependent absorption of air in the scattered
beam path.
Inputs:
twotheta: matrix of two-theta values
mu_air: the linear absorption coefficient of air
sampletodetect... | python | def angledependentairtransmission(twotheta, mu_air, sampletodetectordistance):
"""Correction for the angle dependent absorption of air in the scattered
beam path.
Inputs:
twotheta: matrix of two-theta values
mu_air: the linear absorption coefficient of air
sampletodetect... | [
"def",
"angledependentairtransmission",
"(",
"twotheta",
",",
"mu_air",
",",
"sampletodetectordistance",
")",
":",
"return",
"np",
".",
"exp",
"(",
"mu_air",
"*",
"sampletodetectordistance",
"/",
"np",
".",
"cos",
"(",
"twotheta",
")",
")"
] | Correction for the angle dependent absorption of air in the scattered
beam path.
Inputs:
twotheta: matrix of two-theta values
mu_air: the linear absorption coefficient of air
sampletodetectordistance: sample-to-detector distance
1/mu_air and sampletodetectordistance sho... | [
"Correction",
"for",
"the",
"angle",
"dependent",
"absorption",
"of",
"air",
"in",
"the",
"scattered",
"beam",
"path",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/corrections.py#L125-L138 | train |
awacha/sastool | sastool/utils2d/corrections.py | angledependentairtransmission_errorprop | def angledependentairtransmission_errorprop(twotheta, dtwotheta, mu_air,
dmu_air, sampletodetectordistance,
dsampletodetectordistance):
"""Correction for the angle dependent absorption of air in the scattered
beam path, with... | python | def angledependentairtransmission_errorprop(twotheta, dtwotheta, mu_air,
dmu_air, sampletodetectordistance,
dsampletodetectordistance):
"""Correction for the angle dependent absorption of air in the scattered
beam path, with... | [
"def",
"angledependentairtransmission_errorprop",
"(",
"twotheta",
",",
"dtwotheta",
",",
"mu_air",
",",
"dmu_air",
",",
"sampletodetectordistance",
",",
"dsampletodetectordistance",
")",
":",
"return",
"(",
"np",
".",
"exp",
"(",
"mu_air",
"*",
"sampletodetectordista... | Correction for the angle dependent absorption of air in the scattered
beam path, with error propagation
Inputs:
twotheta: matrix of two-theta values
dtwotheta: absolute error matrix of two-theta
mu_air: the linear absorption coefficient of air
dmu_air: error of t... | [
"Correction",
"for",
"the",
"angle",
"dependent",
"absorption",
"of",
"air",
"in",
"the",
"scattered",
"beam",
"path",
"with",
"error",
"propagation"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/corrections.py#L140-L168 | train |
awacha/sastool | sastool/classes2/loader.py | Loader.find_file | def find_file(self, filename: str, strip_path: bool = True, what='exposure') -> str:
"""Find file in the path"""
if what == 'exposure':
path = self._path
elif what == 'header':
path = self._headerpath
elif what == 'mask':
path = self._maskpath
... | python | def find_file(self, filename: str, strip_path: bool = True, what='exposure') -> str:
"""Find file in the path"""
if what == 'exposure':
path = self._path
elif what == 'header':
path = self._headerpath
elif what == 'mask':
path = self._maskpath
... | [
"def",
"find_file",
"(",
"self",
",",
"filename",
":",
"str",
",",
"strip_path",
":",
"bool",
"=",
"True",
",",
"what",
"=",
"'exposure'",
")",
"->",
"str",
":",
"if",
"what",
"==",
"'exposure'",
":",
"path",
"=",
"self",
".",
"_path",
"elif",
"what"... | Find file in the path | [
"Find",
"file",
"in",
"the",
"path"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/loader.py#L69-L86 | train |
awacha/sastool | sastool/classes2/loader.py | Loader.get_subpath | def get_subpath(self, subpath: str):
"""Search a file or directory relative to the base path"""
for d in self._path:
if os.path.exists(os.path.join(d, subpath)):
return os.path.join(d, subpath)
raise FileNotFoundError | python | def get_subpath(self, subpath: str):
"""Search a file or directory relative to the base path"""
for d in self._path:
if os.path.exists(os.path.join(d, subpath)):
return os.path.join(d, subpath)
raise FileNotFoundError | [
"def",
"get_subpath",
"(",
"self",
",",
"subpath",
":",
"str",
")",
":",
"for",
"d",
"in",
"self",
".",
"_path",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",
".",
"join",
"(",
"d",
",",
"subpath",
")",
")",
":",
"return"... | Search a file or directory relative to the base path | [
"Search",
"a",
"file",
"or",
"directory",
"relative",
"to",
"the",
"base",
"path"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/loader.py#L96-L101 | train |
awacha/sastool | sastool/classes2/exposure.py | Exposure.new_from_file | def new_from_file(self, filename: str, header_data: Optional[Header] = None,
mask_data: Optional[np.ndarray] = None):
"""Load an exposure from a file.""" | python | def new_from_file(self, filename: str, header_data: Optional[Header] = None,
mask_data: Optional[np.ndarray] = None):
"""Load an exposure from a file.""" | [
"def",
"new_from_file",
"(",
"self",
",",
"filename",
":",
"str",
",",
"header_data",
":",
"Optional",
"[",
"Header",
"]",
"=",
"None",
",",
"mask_data",
":",
"Optional",
"[",
"np",
".",
"ndarray",
"]",
"=",
"None",
")",
":"
] | Load an exposure from a file. | [
"Load",
"an",
"exposure",
"from",
"a",
"file",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/exposure.py#L47-L49 | train |
awacha/sastool | sastool/classes2/exposure.py | Exposure.sum | def sum(self, only_valid=True) -> ErrorValue:
"""Calculate the sum of pixels, not counting the masked ones if only_valid is True."""
if not only_valid:
mask = 1
else:
mask = self.mask
return ErrorValue((self.intensity * mask).sum(),
((sel... | python | def sum(self, only_valid=True) -> ErrorValue:
"""Calculate the sum of pixels, not counting the masked ones if only_valid is True."""
if not only_valid:
mask = 1
else:
mask = self.mask
return ErrorValue((self.intensity * mask).sum(),
((sel... | [
"def",
"sum",
"(",
"self",
",",
"only_valid",
"=",
"True",
")",
"->",
"ErrorValue",
":",
"if",
"not",
"only_valid",
":",
"mask",
"=",
"1",
"else",
":",
"mask",
"=",
"self",
".",
"mask",
"return",
"ErrorValue",
"(",
"(",
"self",
".",
"intensity",
"*",... | Calculate the sum of pixels, not counting the masked ones if only_valid is True. | [
"Calculate",
"the",
"sum",
"of",
"pixels",
"not",
"counting",
"the",
"masked",
"ones",
"if",
"only_valid",
"is",
"True",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/exposure.py#L51-L58 | train |
awacha/sastool | sastool/classes2/exposure.py | Exposure.mean | def mean(self, only_valid=True) -> ErrorValue:
"""Calculate the mean of the pixels, not counting the masked ones if only_valid is True."""
if not only_valid:
intensity = self.intensity
error = self.error
else:
intensity = self.intensity[self.mask]
... | python | def mean(self, only_valid=True) -> ErrorValue:
"""Calculate the mean of the pixels, not counting the masked ones if only_valid is True."""
if not only_valid:
intensity = self.intensity
error = self.error
else:
intensity = self.intensity[self.mask]
... | [
"def",
"mean",
"(",
"self",
",",
"only_valid",
"=",
"True",
")",
"->",
"ErrorValue",
":",
"if",
"not",
"only_valid",
":",
"intensity",
"=",
"self",
".",
"intensity",
"error",
"=",
"self",
".",
"error",
"else",
":",
"intensity",
"=",
"self",
".",
"inten... | Calculate the mean of the pixels, not counting the masked ones if only_valid is True. | [
"Calculate",
"the",
"mean",
"of",
"the",
"pixels",
"not",
"counting",
"the",
"masked",
"ones",
"if",
"only_valid",
"is",
"True",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/exposure.py#L60-L69 | train |
awacha/sastool | sastool/classes2/exposure.py | Exposure.twotheta | def twotheta(self) -> ErrorValue:
"""Calculate the two-theta array"""
row, column = np.ogrid[0:self.shape[0], 0:self.shape[1]]
rho = (((self.header.beamcentery - row) * self.header.pixelsizey) ** 2 +
((self.header.beamcenterx - column) * self.header.pixelsizex) ** 2) ** 0.5
... | python | def twotheta(self) -> ErrorValue:
"""Calculate the two-theta array"""
row, column = np.ogrid[0:self.shape[0], 0:self.shape[1]]
rho = (((self.header.beamcentery - row) * self.header.pixelsizey) ** 2 +
((self.header.beamcenterx - column) * self.header.pixelsizex) ** 2) ** 0.5
... | [
"def",
"twotheta",
"(",
"self",
")",
"->",
"ErrorValue",
":",
"row",
",",
"column",
"=",
"np",
".",
"ogrid",
"[",
"0",
":",
"self",
".",
"shape",
"[",
"0",
"]",
",",
"0",
":",
"self",
".",
"shape",
"[",
"1",
"]",
"]",
"rho",
"=",
"(",
"(",
... | Calculate the two-theta array | [
"Calculate",
"the",
"two",
"-",
"theta",
"array"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/exposure.py#L72-L80 | train |
awacha/sastool | sastool/classes2/exposure.py | Exposure.pixel_to_q | def pixel_to_q(self, row: float, column: float):
"""Return the q coordinates of a given pixel.
Inputs:
row: float
the row (vertical) coordinate of the pixel
column: float
the column (horizontal) coordinate of the pixel
Coordinates are 0-b... | python | def pixel_to_q(self, row: float, column: float):
"""Return the q coordinates of a given pixel.
Inputs:
row: float
the row (vertical) coordinate of the pixel
column: float
the column (horizontal) coordinate of the pixel
Coordinates are 0-b... | [
"def",
"pixel_to_q",
"(",
"self",
",",
"row",
":",
"float",
",",
"column",
":",
"float",
")",
":",
"qrow",
"=",
"4",
"*",
"np",
".",
"pi",
"*",
"np",
".",
"sin",
"(",
"0.5",
"*",
"np",
".",
"arctan",
"(",
"(",
"row",
"-",
"float",
"(",
"self"... | Return the q coordinates of a given pixel.
Inputs:
row: float
the row (vertical) coordinate of the pixel
column: float
the column (horizontal) coordinate of the pixel
Coordinates are 0-based and calculated from the top left corner. | [
"Return",
"the",
"q",
"coordinates",
"of",
"a",
"given",
"pixel",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/exposure.py#L87-L107 | train |
awacha/sastool | sastool/classes2/exposure.py | Exposure.imshow | def imshow(self, *args, show_crosshair=True, show_mask=True,
show_qscale=True, axes=None, invalid_color='black',
mask_opacity=0.8, show_colorbar=True, **kwargs):
"""Plot the matrix (imshow)
Keyword arguments [and their default values]:
show_crosshair [True]: if a ... | python | def imshow(self, *args, show_crosshair=True, show_mask=True,
show_qscale=True, axes=None, invalid_color='black',
mask_opacity=0.8, show_colorbar=True, **kwargs):
"""Plot the matrix (imshow)
Keyword arguments [and their default values]:
show_crosshair [True]: if a ... | [
"def",
"imshow",
"(",
"self",
",",
"*",
"args",
",",
"show_crosshair",
"=",
"True",
",",
"show_mask",
"=",
"True",
",",
"show_qscale",
"=",
"True",
",",
"axes",
"=",
"None",
",",
"invalid_color",
"=",
"'black'",
",",
"mask_opacity",
"=",
"0.8",
",",
"s... | Plot the matrix (imshow)
Keyword arguments [and their default values]:
show_crosshair [True]: if a cross-hair marking the beam position is
to be plotted.
show_mask [True]: if the mask is to be plotted.
show_qscale [True]: if the horizontal and vertical axes are to be
... | [
"Plot",
"the",
"matrix",
"(",
"imshow",
")"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/exposure.py#L109-L201 | train |
awacha/sastool | sastool/classes2/exposure.py | Exposure.radial_average | def radial_average(self, qrange=None, pixel=False, returnmask=False,
errorpropagation=3, abscissa_errorpropagation=3,
raw_result=False) -> Curve:
"""Do a radial averaging
Inputs:
qrange: the q-range. If None, auto-determine. If 'linear', auto-de... | python | def radial_average(self, qrange=None, pixel=False, returnmask=False,
errorpropagation=3, abscissa_errorpropagation=3,
raw_result=False) -> Curve:
"""Do a radial averaging
Inputs:
qrange: the q-range. If None, auto-determine. If 'linear', auto-de... | [
"def",
"radial_average",
"(",
"self",
",",
"qrange",
"=",
"None",
",",
"pixel",
"=",
"False",
",",
"returnmask",
"=",
"False",
",",
"errorpropagation",
"=",
"3",
",",
"abscissa_errorpropagation",
"=",
"3",
",",
"raw_result",
"=",
"False",
")",
"->",
"Curve... | Do a radial averaging
Inputs:
qrange: the q-range. If None, auto-determine. If 'linear', auto-determine
with linear spacing (same as None). If 'log', auto-determine
with log10 spacing.
pixel: do a pixel-integration (instead of q)
returnmask: i... | [
"Do",
"a",
"radial",
"averaging"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/exposure.py#L257-L320 | train |
awacha/sastool | sastool/classes2/exposure.py | Exposure.mask_negative | def mask_negative(self):
"""Extend the mask with the image elements where the intensity is negative."""
self.mask = np.logical_and(self.mask, ~(self.intensity < 0)) | python | def mask_negative(self):
"""Extend the mask with the image elements where the intensity is negative."""
self.mask = np.logical_and(self.mask, ~(self.intensity < 0)) | [
"def",
"mask_negative",
"(",
"self",
")",
":",
"self",
".",
"mask",
"=",
"np",
".",
"logical_and",
"(",
"self",
".",
"mask",
",",
"~",
"(",
"self",
".",
"intensity",
"<",
"0",
")",
")"
] | Extend the mask with the image elements where the intensity is negative. | [
"Extend",
"the",
"mask",
"with",
"the",
"image",
"elements",
"where",
"the",
"intensity",
"is",
"negative",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/exposure.py#L331-L333 | train |
awacha/sastool | sastool/classes2/exposure.py | Exposure.mask_nan | def mask_nan(self):
"""Extend the mask with the image elements where the intensity is NaN."""
self.mask = np.logical_and(self.mask, ~(np.isnan(self.intensity))) | python | def mask_nan(self):
"""Extend the mask with the image elements where the intensity is NaN."""
self.mask = np.logical_and(self.mask, ~(np.isnan(self.intensity))) | [
"def",
"mask_nan",
"(",
"self",
")",
":",
"self",
".",
"mask",
"=",
"np",
".",
"logical_and",
"(",
"self",
".",
"mask",
",",
"~",
"(",
"np",
".",
"isnan",
"(",
"self",
".",
"intensity",
")",
")",
")"
] | Extend the mask with the image elements where the intensity is NaN. | [
"Extend",
"the",
"mask",
"with",
"the",
"image",
"elements",
"where",
"the",
"intensity",
"is",
"NaN",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/exposure.py#L335-L337 | train |
awacha/sastool | sastool/classes2/exposure.py | Exposure.mask_nonfinite | def mask_nonfinite(self):
"""Extend the mask with the image elements where the intensity is NaN."""
self.mask = np.logical_and(self.mask, (np.isfinite(self.intensity))) | python | def mask_nonfinite(self):
"""Extend the mask with the image elements where the intensity is NaN."""
self.mask = np.logical_and(self.mask, (np.isfinite(self.intensity))) | [
"def",
"mask_nonfinite",
"(",
"self",
")",
":",
"self",
".",
"mask",
"=",
"np",
".",
"logical_and",
"(",
"self",
".",
"mask",
",",
"(",
"np",
".",
"isfinite",
"(",
"self",
".",
"intensity",
")",
")",
")"
] | Extend the mask with the image elements where the intensity is NaN. | [
"Extend",
"the",
"mask",
"with",
"the",
"image",
"elements",
"where",
"the",
"intensity",
"is",
"NaN",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/exposure.py#L339-L341 | train |
awacha/sastool | sastool/io/credo_saxsctrl/header.py | Header.distance | def distance(self) -> ErrorValue:
"""Sample-to-detector distance"""
if 'DistCalibrated' in self._data:
dist = self._data['DistCalibrated']
else:
dist = self._data["Dist"]
if 'DistCalibratedError' in self._data:
disterr = self._data['DistCalibratedError... | python | def distance(self) -> ErrorValue:
"""Sample-to-detector distance"""
if 'DistCalibrated' in self._data:
dist = self._data['DistCalibrated']
else:
dist = self._data["Dist"]
if 'DistCalibratedError' in self._data:
disterr = self._data['DistCalibratedError... | [
"def",
"distance",
"(",
"self",
")",
"->",
"ErrorValue",
":",
"if",
"'DistCalibrated'",
"in",
"self",
".",
"_data",
":",
"dist",
"=",
"self",
".",
"_data",
"[",
"'DistCalibrated'",
"]",
"else",
":",
"dist",
"=",
"self",
".",
"_data",
"[",
"\"Dist\"",
"... | Sample-to-detector distance | [
"Sample",
"-",
"to",
"-",
"detector",
"distance"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/credo_saxsctrl/header.py#L114-L126 | train |
awacha/sastool | sastool/io/credo_saxsctrl/header.py | Header.temperature | def temperature(self) -> Optional[ErrorValue]:
"""Sample temperature"""
try:
return ErrorValue(self._data['Temperature'], self._data.setdefault('TemperatureError', 0.0))
except KeyError:
return None | python | def temperature(self) -> Optional[ErrorValue]:
"""Sample temperature"""
try:
return ErrorValue(self._data['Temperature'], self._data.setdefault('TemperatureError', 0.0))
except KeyError:
return None | [
"def",
"temperature",
"(",
"self",
")",
"->",
"Optional",
"[",
"ErrorValue",
"]",
":",
"try",
":",
"return",
"ErrorValue",
"(",
"self",
".",
"_data",
"[",
"'Temperature'",
"]",
",",
"self",
".",
"_data",
".",
"setdefault",
"(",
"'TemperatureError'",
",",
... | Sample temperature | [
"Sample",
"temperature"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/credo_saxsctrl/header.py#L136-L141 | train |
awacha/sastool | sastool/io/credo_saxsctrl/header.py | Header.date | def date(self) -> datetime.datetime:
"""Date of the experiment (start of exposure)"""
return self._data['Date'] - datetime.timedelta(0, float(self.exposuretime), 0) | python | def date(self) -> datetime.datetime:
"""Date of the experiment (start of exposure)"""
return self._data['Date'] - datetime.timedelta(0, float(self.exposuretime), 0) | [
"def",
"date",
"(",
"self",
")",
"->",
"datetime",
".",
"datetime",
":",
"return",
"self",
".",
"_data",
"[",
"'Date'",
"]",
"-",
"datetime",
".",
"timedelta",
"(",
"0",
",",
"float",
"(",
"self",
".",
"exposuretime",
")",
",",
"0",
")"
] | Date of the experiment (start of exposure) | [
"Date",
"of",
"the",
"experiment",
"(",
"start",
"of",
"exposure",
")"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/credo_saxsctrl/header.py#L211-L213 | train |
awacha/sastool | sastool/io/credo_saxsctrl/header.py | Header.flux | def flux(self) -> ErrorValue:
"""X-ray flux in photons/sec."""
try:
return ErrorValue(self._data['Flux'], self._data.setdefault('FluxError',0.0))
except KeyError:
return 1 / self.pixelsizex / self.pixelsizey / ErrorValue(self._data['NormFactor'],
... | python | def flux(self) -> ErrorValue:
"""X-ray flux in photons/sec."""
try:
return ErrorValue(self._data['Flux'], self._data.setdefault('FluxError',0.0))
except KeyError:
return 1 / self.pixelsizex / self.pixelsizey / ErrorValue(self._data['NormFactor'],
... | [
"def",
"flux",
"(",
"self",
")",
"->",
"ErrorValue",
":",
"try",
":",
"return",
"ErrorValue",
"(",
"self",
".",
"_data",
"[",
"'Flux'",
"]",
",",
"self",
".",
"_data",
".",
"setdefault",
"(",
"'FluxError'",
",",
"0.0",
")",
")",
"except",
"KeyError",
... | X-ray flux in photons/sec. | [
"X",
"-",
"ray",
"flux",
"in",
"photons",
"/",
"sec",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/credo_saxsctrl/header.py#L276-L282 | train |
awacha/sastool | sastool/misc/easylsq.py | nonlinear_leastsquares | def nonlinear_leastsquares(x: np.ndarray, y: np.ndarray, dy: np.ndarray, func: Callable, params_init: np.ndarray,
verbose: bool = False, **kwargs):
"""Perform a non-linear least squares fit, return the results as
ErrorValue() instances.
Inputs:
x: one-dimensional numpy ar... | python | def nonlinear_leastsquares(x: np.ndarray, y: np.ndarray, dy: np.ndarray, func: Callable, params_init: np.ndarray,
verbose: bool = False, **kwargs):
"""Perform a non-linear least squares fit, return the results as
ErrorValue() instances.
Inputs:
x: one-dimensional numpy ar... | [
"def",
"nonlinear_leastsquares",
"(",
"x",
":",
"np",
".",
"ndarray",
",",
"y",
":",
"np",
".",
"ndarray",
",",
"dy",
":",
"np",
".",
"ndarray",
",",
"func",
":",
"Callable",
",",
"params_init",
":",
"np",
".",
"ndarray",
",",
"verbose",
":",
"bool",... | Perform a non-linear least squares fit, return the results as
ErrorValue() instances.
Inputs:
x: one-dimensional numpy array of the independent variable
y: one-dimensional numpy array of the dependent variable
dy: absolute error (square root of the variance) of the dependent
... | [
"Perform",
"a",
"non",
"-",
"linear",
"least",
"squares",
"fit",
"return",
"the",
"results",
"as",
"ErrorValue",
"()",
"instances",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/easylsq.py#L64-L114 | train |
awacha/sastool | sastool/misc/easylsq.py | nonlinear_odr | def nonlinear_odr(x, y, dx, dy, func, params_init, **kwargs):
"""Perform a non-linear orthogonal distance regression, return the results as
ErrorValue() instances.
Inputs:
x: one-dimensional numpy array of the independent variable
y: one-dimensional numpy array of the dependent variable
... | python | def nonlinear_odr(x, y, dx, dy, func, params_init, **kwargs):
"""Perform a non-linear orthogonal distance regression, return the results as
ErrorValue() instances.
Inputs:
x: one-dimensional numpy array of the independent variable
y: one-dimensional numpy array of the dependent variable
... | [
"def",
"nonlinear_odr",
"(",
"x",
",",
"y",
",",
"dx",
",",
"dy",
",",
"func",
",",
"params_init",
",",
"*",
"*",
"kwargs",
")",
":",
"odrmodel",
"=",
"odr",
".",
"Model",
"(",
"lambda",
"pars",
",",
"x",
":",
"func",
"(",
"x",
",",
"*",
"pars"... | Perform a non-linear orthogonal distance regression, return the results as
ErrorValue() instances.
Inputs:
x: one-dimensional numpy array of the independent variable
y: one-dimensional numpy array of the dependent variable
dx: absolute error (square root of the variance) of the independ... | [
"Perform",
"a",
"non",
"-",
"linear",
"orthogonal",
"distance",
"regression",
"return",
"the",
"results",
"as",
"ErrorValue",
"()",
"instances",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/easylsq.py#L116-L179 | train |
awacha/sastool | sastool/misc/easylsq.py | simultaneous_nonlinear_leastsquares | def simultaneous_nonlinear_leastsquares(xs, ys, dys, func, params_inits, verbose=False, **kwargs):
"""Do a simultaneous nonlinear least-squares fit and return the fitted
parameters as instances of ErrorValue.
Input:
------
`xs`: tuple of abscissa vectors (1d numpy ndarrays)
`ys`: tuple of ordin... | python | def simultaneous_nonlinear_leastsquares(xs, ys, dys, func, params_inits, verbose=False, **kwargs):
"""Do a simultaneous nonlinear least-squares fit and return the fitted
parameters as instances of ErrorValue.
Input:
------
`xs`: tuple of abscissa vectors (1d numpy ndarrays)
`ys`: tuple of ordin... | [
"def",
"simultaneous_nonlinear_leastsquares",
"(",
"xs",
",",
"ys",
",",
"dys",
",",
"func",
",",
"params_inits",
",",
"verbose",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"p",
",",
"dp",
",",
"statdict",
"=",
"simultaneous_nlsq_fit",
"(",
"xs",
"... | Do a simultaneous nonlinear least-squares fit and return the fitted
parameters as instances of ErrorValue.
Input:
------
`xs`: tuple of abscissa vectors (1d numpy ndarrays)
`ys`: tuple of ordinate vectors (1d numpy ndarrays)
`dys`: tuple of the errors of ordinate vectors (1d numpy ndarrays or N... | [
"Do",
"a",
"simultaneous",
"nonlinear",
"least",
"-",
"squares",
"fit",
"and",
"return",
"the",
"fitted",
"parameters",
"as",
"instances",
"of",
"ErrorValue",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/easylsq.py#L182-L215 | train |
awacha/sastool | sastool/misc/easylsq.py | nlsq_fit | def nlsq_fit(x, y, dy, func, params_init, verbose=False, **kwargs):
"""Perform a non-linear least squares fit
Inputs:
x: one-dimensional numpy array of the independent variable
y: one-dimensional numpy array of the dependent variable
dy: absolute error (square root of the variance) of t... | python | def nlsq_fit(x, y, dy, func, params_init, verbose=False, **kwargs):
"""Perform a non-linear least squares fit
Inputs:
x: one-dimensional numpy array of the independent variable
y: one-dimensional numpy array of the dependent variable
dy: absolute error (square root of the variance) of t... | [
"def",
"nlsq_fit",
"(",
"x",
",",
"y",
",",
"dy",
",",
"func",
",",
"params_init",
",",
"verbose",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"verbose",
":",
"t0",
"=",
"time",
".",
"monotonic",
"(",
")",
"print",
"(",
"\"nlsq_fit start... | Perform a non-linear least squares fit
Inputs:
x: one-dimensional numpy array of the independent variable
y: one-dimensional numpy array of the dependent variable
dy: absolute error (square root of the variance) of the dependent
variable. Either a one-dimensional numpy array or ... | [
"Perform",
"a",
"non",
"-",
"linear",
"least",
"squares",
"fit"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/easylsq.py#L217-L319 | train |
awacha/sastool | sastool/misc/easylsq.py | simultaneous_nlsq_fit | def simultaneous_nlsq_fit(xs, ys, dys, func, params_inits, verbose=False,
**kwargs):
"""Do a simultaneous nonlinear least-squares fit
Input:
------
`xs`: tuple of abscissa vectors (1d numpy ndarrays)
`ys`: tuple of ordinate vectors (1d numpy ndarrays)
`dys`: tuple o... | python | def simultaneous_nlsq_fit(xs, ys, dys, func, params_inits, verbose=False,
**kwargs):
"""Do a simultaneous nonlinear least-squares fit
Input:
------
`xs`: tuple of abscissa vectors (1d numpy ndarrays)
`ys`: tuple of ordinate vectors (1d numpy ndarrays)
`dys`: tuple o... | [
"def",
"simultaneous_nlsq_fit",
"(",
"xs",
",",
"ys",
",",
"dys",
",",
"func",
",",
"params_inits",
",",
"verbose",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"xs",
",",
"collections",
".",
"Sequence",
")",
"or",
... | Do a simultaneous nonlinear least-squares fit
Input:
------
`xs`: tuple of abscissa vectors (1d numpy ndarrays)
`ys`: tuple of ordinate vectors (1d numpy ndarrays)
`dys`: tuple of the errors of ordinate vectors (1d numpy ndarrays or Nones)
`func`: fitting function (the same for all the datasets... | [
"Do",
"a",
"simultaneous",
"nonlinear",
"least",
"-",
"squares",
"fit"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/easylsq.py#L329-L449 | train |
awacha/sastool | sastool/misc/errorvalue.py | ErrorValue.tostring | def tostring(self: 'ErrorValue', extra_digits: int = 0, plusminus: str = ' +/- ', fmt: str = None) -> str:
"""Make a string representation of the value and its uncertainty.
Inputs:
-------
``extra_digits``: integer
how many extra digits should be shown (plus or minus... | python | def tostring(self: 'ErrorValue', extra_digits: int = 0, plusminus: str = ' +/- ', fmt: str = None) -> str:
"""Make a string representation of the value and its uncertainty.
Inputs:
-------
``extra_digits``: integer
how many extra digits should be shown (plus or minus... | [
"def",
"tostring",
"(",
"self",
":",
"'ErrorValue'",
",",
"extra_digits",
":",
"int",
"=",
"0",
",",
"plusminus",
":",
"str",
"=",
"' +/- '",
",",
"fmt",
":",
"str",
"=",
"None",
")",
"->",
"str",
":",
"if",
"isinstance",
"(",
"fmt",
",",
"str",
")... | Make a string representation of the value and its uncertainty.
Inputs:
-------
``extra_digits``: integer
how many extra digits should be shown (plus or minus, zero means
that the number of digits should be defined by the magnitude of
the uncer... | [
"Make",
"a",
"string",
"representation",
"of",
"the",
"value",
"and",
"its",
"uncertainty",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/errorvalue.py#L157-L190 | train |
awacha/sastool | sastool/misc/errorvalue.py | ErrorValue.random | def random(self: 'ErrorValue') -> np.ndarray:
"""Sample a random number (array) of the distribution defined by
mean=`self.val` and variance=`self.err`^2.
"""
if isinstance(self.val, np.ndarray):
# IGNORE:E1103
return np.random.randn(self.val.shape) * self.err + se... | python | def random(self: 'ErrorValue') -> np.ndarray:
"""Sample a random number (array) of the distribution defined by
mean=`self.val` and variance=`self.err`^2.
"""
if isinstance(self.val, np.ndarray):
# IGNORE:E1103
return np.random.randn(self.val.shape) * self.err + se... | [
"def",
"random",
"(",
"self",
":",
"'ErrorValue'",
")",
"->",
"np",
".",
"ndarray",
":",
"if",
"isinstance",
"(",
"self",
".",
"val",
",",
"np",
".",
"ndarray",
")",
":",
"# IGNORE:E1103",
"return",
"np",
".",
"random",
".",
"randn",
"(",
"self",
"."... | Sample a random number (array) of the distribution defined by
mean=`self.val` and variance=`self.err`^2. | [
"Sample",
"a",
"random",
"number",
"(",
"array",
")",
"of",
"the",
"distribution",
"defined",
"by",
"mean",
"=",
"self",
".",
"val",
"and",
"variance",
"=",
"self",
".",
"err",
"^2",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/errorvalue.py#L240-L248 | train |
awacha/sastool | sastool/misc/errorvalue.py | ErrorValue.evalfunc | def evalfunc(cls, func, *args, **kwargs):
"""Evaluate a function with error propagation.
Inputs:
-------
``func``: callable
this is the function to be evaluated. Should return either a
number or a np.ndarray.
``*args``: other positional ar... | python | def evalfunc(cls, func, *args, **kwargs):
"""Evaluate a function with error propagation.
Inputs:
-------
``func``: callable
this is the function to be evaluated. Should return either a
number or a np.ndarray.
``*args``: other positional ar... | [
"def",
"evalfunc",
"(",
"cls",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"do_random",
"(",
"x",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"cls",
")",
":",
"return",
"x",
".",
"random",
"(",
")",
"else",
":",
... | Evaluate a function with error propagation.
Inputs:
-------
``func``: callable
this is the function to be evaluated. Should return either a
number or a np.ndarray.
``*args``: other positional arguments of func. Arguments which are
... | [
"Evaluate",
"a",
"function",
"with",
"error",
"propagation",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/errorvalue.py#L251-L311 | train |
awacha/sastool | sastool/fitting/fitfunctions/sasbasic.py | Fsphere | def Fsphere(q, R):
"""Scattering form-factor amplitude of a sphere normalized to F(q=0)=V
Inputs:
-------
``q``: independent variable
``R``: sphere radius
Formula:
--------
``4*pi/q^3 * (sin(qR) - qR*cos(qR))``
"""
return 4 * np.pi / q ** 3 * (np.sin(q * R) - q * R ... | python | def Fsphere(q, R):
"""Scattering form-factor amplitude of a sphere normalized to F(q=0)=V
Inputs:
-------
``q``: independent variable
``R``: sphere radius
Formula:
--------
``4*pi/q^3 * (sin(qR) - qR*cos(qR))``
"""
return 4 * np.pi / q ** 3 * (np.sin(q * R) - q * R ... | [
"def",
"Fsphere",
"(",
"q",
",",
"R",
")",
":",
"return",
"4",
"*",
"np",
".",
"pi",
"/",
"q",
"**",
"3",
"*",
"(",
"np",
".",
"sin",
"(",
"q",
"*",
"R",
")",
"-",
"q",
"*",
"R",
"*",
"np",
".",
"cos",
"(",
"q",
"*",
"R",
")",
")"
] | Scattering form-factor amplitude of a sphere normalized to F(q=0)=V
Inputs:
-------
``q``: independent variable
``R``: sphere radius
Formula:
--------
``4*pi/q^3 * (sin(qR) - qR*cos(qR))`` | [
"Scattering",
"form",
"-",
"factor",
"amplitude",
"of",
"a",
"sphere",
"normalized",
"to",
"F",
"(",
"q",
"=",
"0",
")",
"=",
"V"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/sasbasic.py#L10-L22 | train |
awacha/sastool | sastool/fitting/fitfunctions/sasbasic.py | GeneralGuinier | def GeneralGuinier(q, G, Rg, s):
"""Generalized Guinier scattering
Inputs:
-------
``q``: independent variable
``G``: factor
``Rg``: radius of gyration
``s``: dimensionality parameter (can be 1, 2, 3)
Formula:
--------
``G/q**(3-s)*exp(-(q^2*Rg^2)/s)``
"... | python | def GeneralGuinier(q, G, Rg, s):
"""Generalized Guinier scattering
Inputs:
-------
``q``: independent variable
``G``: factor
``Rg``: radius of gyration
``s``: dimensionality parameter (can be 1, 2, 3)
Formula:
--------
``G/q**(3-s)*exp(-(q^2*Rg^2)/s)``
"... | [
"def",
"GeneralGuinier",
"(",
"q",
",",
"G",
",",
"Rg",
",",
"s",
")",
":",
"return",
"G",
"/",
"q",
"**",
"(",
"3",
"-",
"s",
")",
"*",
"np",
".",
"exp",
"(",
"-",
"(",
"q",
"*",
"Rg",
")",
"**",
"2",
"/",
"s",
")"
] | Generalized Guinier scattering
Inputs:
-------
``q``: independent variable
``G``: factor
``Rg``: radius of gyration
``s``: dimensionality parameter (can be 1, 2, 3)
Formula:
--------
``G/q**(3-s)*exp(-(q^2*Rg^2)/s)`` | [
"Generalized",
"Guinier",
"scattering"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/sasbasic.py#L39-L53 | train |
awacha/sastool | sastool/fitting/fitfunctions/sasbasic.py | GuinierPorod | def GuinierPorod(q, G, Rg, alpha):
"""Empirical Guinier-Porod scattering
Inputs:
-------
``q``: independent variable
``G``: factor of the Guinier-branch
``Rg``: radius of gyration
``alpha``: power-law exponent
Formula:
--------
``G * exp(-q^2*Rg^2/3)`` if ``... | python | def GuinierPorod(q, G, Rg, alpha):
"""Empirical Guinier-Porod scattering
Inputs:
-------
``q``: independent variable
``G``: factor of the Guinier-branch
``Rg``: radius of gyration
``alpha``: power-law exponent
Formula:
--------
``G * exp(-q^2*Rg^2/3)`` if ``... | [
"def",
"GuinierPorod",
"(",
"q",
",",
"G",
",",
"Rg",
",",
"alpha",
")",
":",
"return",
"GuinierPorodMulti",
"(",
"q",
",",
"G",
",",
"Rg",
",",
"alpha",
")"
] | Empirical Guinier-Porod scattering
Inputs:
-------
``q``: independent variable
``G``: factor of the Guinier-branch
``Rg``: radius of gyration
``alpha``: power-law exponent
Formula:
--------
``G * exp(-q^2*Rg^2/3)`` if ``q<q_sep`` and ``a*q^alpha`` otherwise.
... | [
"Empirical",
"Guinier",
"-",
"Porod",
"scattering"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/sasbasic.py#L86-L107 | train |
awacha/sastool | sastool/fitting/fitfunctions/sasbasic.py | PorodGuinier | def PorodGuinier(q, a, alpha, Rg):
"""Empirical Porod-Guinier scattering
Inputs:
-------
``q``: independent variable
``a``: factor of the power-law branch
``alpha``: power-law exponent
``Rg``: radius of gyration
Formula:
--------
``G * exp(-q^2*Rg^2/3)`` if ... | python | def PorodGuinier(q, a, alpha, Rg):
"""Empirical Porod-Guinier scattering
Inputs:
-------
``q``: independent variable
``a``: factor of the power-law branch
``alpha``: power-law exponent
``Rg``: radius of gyration
Formula:
--------
``G * exp(-q^2*Rg^2/3)`` if ... | [
"def",
"PorodGuinier",
"(",
"q",
",",
"a",
",",
"alpha",
",",
"Rg",
")",
":",
"return",
"PorodGuinierMulti",
"(",
"q",
",",
"a",
",",
"alpha",
",",
"Rg",
")"
] | Empirical Porod-Guinier scattering
Inputs:
-------
``q``: independent variable
``a``: factor of the power-law branch
``alpha``: power-law exponent
``Rg``: radius of gyration
Formula:
--------
``G * exp(-q^2*Rg^2/3)`` if ``q>q_sep`` and ``a*q^alpha`` otherwise.
... | [
"Empirical",
"Porod",
"-",
"Guinier",
"scattering"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/sasbasic.py#L109-L130 | train |
awacha/sastool | sastool/fitting/fitfunctions/sasbasic.py | PorodGuinierPorod | def PorodGuinierPorod(q, a, alpha, Rg, beta):
"""Empirical Porod-Guinier-Porod scattering
Inputs:
-------
``q``: independent variable
``a``: factor of the first power-law branch
``alpha``: exponent of the first power-law branch
``Rg``: radius of gyration
``beta``: ex... | python | def PorodGuinierPorod(q, a, alpha, Rg, beta):
"""Empirical Porod-Guinier-Porod scattering
Inputs:
-------
``q``: independent variable
``a``: factor of the first power-law branch
``alpha``: exponent of the first power-law branch
``Rg``: radius of gyration
``beta``: ex... | [
"def",
"PorodGuinierPorod",
"(",
"q",
",",
"a",
",",
"alpha",
",",
"Rg",
",",
"beta",
")",
":",
"return",
"PorodGuinierMulti",
"(",
"q",
",",
"a",
",",
"alpha",
",",
"Rg",
",",
"beta",
")"
] | Empirical Porod-Guinier-Porod scattering
Inputs:
-------
``q``: independent variable
``a``: factor of the first power-law branch
``alpha``: exponent of the first power-law branch
``Rg``: radius of gyration
``beta``: exponent of the second power-law branch
Formula:
... | [
"Empirical",
"Porod",
"-",
"Guinier",
"-",
"Porod",
"scattering"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/sasbasic.py#L132-L155 | train |
awacha/sastool | sastool/fitting/fitfunctions/sasbasic.py | GuinierPorodGuinier | def GuinierPorodGuinier(q, G, Rg1, alpha, Rg2):
"""Empirical Guinier-Porod-Guinier scattering
Inputs:
-------
``q``: independent variable
``G``: factor for the first Guinier-branch
``Rg1``: the first radius of gyration
``alpha``: the power-law exponent
``Rg2``: the s... | python | def GuinierPorodGuinier(q, G, Rg1, alpha, Rg2):
"""Empirical Guinier-Porod-Guinier scattering
Inputs:
-------
``q``: independent variable
``G``: factor for the first Guinier-branch
``Rg1``: the first radius of gyration
``alpha``: the power-law exponent
``Rg2``: the s... | [
"def",
"GuinierPorodGuinier",
"(",
"q",
",",
"G",
",",
"Rg1",
",",
"alpha",
",",
"Rg2",
")",
":",
"return",
"GuinierPorodMulti",
"(",
"q",
",",
"G",
",",
"Rg1",
",",
"alpha",
",",
"Rg2",
")"
] | Empirical Guinier-Porod-Guinier scattering
Inputs:
-------
``q``: independent variable
``G``: factor for the first Guinier-branch
``Rg1``: the first radius of gyration
``alpha``: the power-law exponent
``Rg2``: the second radius of gyration
Formula:
--------
... | [
"Empirical",
"Guinier",
"-",
"Porod",
"-",
"Guinier",
"scattering"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/sasbasic.py#L157-L182 | train |
awacha/sastool | sastool/fitting/fitfunctions/sasbasic.py | DampedPowerlaw | def DampedPowerlaw(q, a, alpha, sigma):
"""Damped power-law
Inputs:
-------
``q``: independent variable
``a``: factor
``alpha``: exponent
``sigma``: hwhm of the damping Gaussian
Formula:
--------
``a*q^alpha*exp(-q^2/(2*sigma^2))``
"""
return a * q *... | python | def DampedPowerlaw(q, a, alpha, sigma):
"""Damped power-law
Inputs:
-------
``q``: independent variable
``a``: factor
``alpha``: exponent
``sigma``: hwhm of the damping Gaussian
Formula:
--------
``a*q^alpha*exp(-q^2/(2*sigma^2))``
"""
return a * q *... | [
"def",
"DampedPowerlaw",
"(",
"q",
",",
"a",
",",
"alpha",
",",
"sigma",
")",
":",
"return",
"a",
"*",
"q",
"**",
"alpha",
"*",
"np",
".",
"exp",
"(",
"-",
"q",
"**",
"2",
"/",
"(",
"2",
"*",
"sigma",
"**",
"2",
")",
")"
] | Damped power-law
Inputs:
-------
``q``: independent variable
``a``: factor
``alpha``: exponent
``sigma``: hwhm of the damping Gaussian
Formula:
--------
``a*q^alpha*exp(-q^2/(2*sigma^2))`` | [
"Damped",
"power",
"-",
"law"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/sasbasic.py#L185-L199 | train |
awacha/sastool | sastool/fitting/fitfunctions/sasbasic.py | LogNormSpheres | def LogNormSpheres(q, A, mu, sigma, N=1000):
"""Scattering of a population of non-correlated spheres (radii from a log-normal distribution)
Inputs:
-------
``q``: independent variable
``A``: scaling factor
``mu``: expectation of ``ln(R)``
``sigma``: hwhm of ``ln(R)``
No... | python | def LogNormSpheres(q, A, mu, sigma, N=1000):
"""Scattering of a population of non-correlated spheres (radii from a log-normal distribution)
Inputs:
-------
``q``: independent variable
``A``: scaling factor
``mu``: expectation of ``ln(R)``
``sigma``: hwhm of ``ln(R)``
No... | [
"def",
"LogNormSpheres",
"(",
"q",
",",
"A",
",",
"mu",
",",
"sigma",
",",
"N",
"=",
"1000",
")",
":",
"Rmin",
"=",
"0",
"Rmax",
"=",
"np",
".",
"exp",
"(",
"mu",
"+",
"3",
"*",
"sigma",
")",
"R",
"=",
"np",
".",
"linspace",
"(",
"Rmin",
",... | Scattering of a population of non-correlated spheres (radii from a log-normal distribution)
Inputs:
-------
``q``: independent variable
``A``: scaling factor
``mu``: expectation of ``ln(R)``
``sigma``: hwhm of ``ln(R)``
Non-fittable inputs:
--------------------
... | [
"Scattering",
"of",
"a",
"population",
"of",
"non",
"-",
"correlated",
"spheres",
"(",
"radii",
"from",
"a",
"log",
"-",
"normal",
"distribution",
")"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/sasbasic.py#L201-L230 | train |
awacha/sastool | sastool/fitting/fitfunctions/sasbasic.py | GaussSpheres | def GaussSpheres(q, A, R0, sigma, N=1000, weighting='intensity'):
"""Scattering of a population of non-correlated spheres (radii from a gaussian distribution)
Inputs:
-------
``q``: independent variable
``A``: scaling factor
``R0``: expectation of ``R``
``sigma``: hwhm of ``... | python | def GaussSpheres(q, A, R0, sigma, N=1000, weighting='intensity'):
"""Scattering of a population of non-correlated spheres (radii from a gaussian distribution)
Inputs:
-------
``q``: independent variable
``A``: scaling factor
``R0``: expectation of ``R``
``sigma``: hwhm of ``... | [
"def",
"GaussSpheres",
"(",
"q",
",",
"A",
",",
"R0",
",",
"sigma",
",",
"N",
"=",
"1000",
",",
"weighting",
"=",
"'intensity'",
")",
":",
"Rmin",
"=",
"max",
"(",
"0",
",",
"R0",
"-",
"3",
"*",
"sigma",
")",
"Rmax",
"=",
"R0",
"+",
"3",
"*",... | Scattering of a population of non-correlated spheres (radii from a gaussian distribution)
Inputs:
-------
``q``: independent variable
``A``: scaling factor
``R0``: expectation of ``R``
``sigma``: hwhm of ``R``
``weighting``: 'intensity' (default), 'volume' or 'number'
... | [
"Scattering",
"of",
"a",
"population",
"of",
"non",
"-",
"correlated",
"spheres",
"(",
"radii",
"from",
"a",
"gaussian",
"distribution",
")"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/sasbasic.py#L232-L270 | train |
awacha/sastool | sastool/fitting/fitfunctions/sasbasic.py | PowerlawGuinierPorodConst | def PowerlawGuinierPorodConst(q, A, alpha, G, Rg, beta, C):
"""Sum of a Power-law, a Guinier-Porod curve and a constant.
Inputs:
-------
``q``: independent variable (momentum transfer)
``A``: scaling factor of the power-law
``alpha``: power-law exponent
``G``: scaling factor... | python | def PowerlawGuinierPorodConst(q, A, alpha, G, Rg, beta, C):
"""Sum of a Power-law, a Guinier-Porod curve and a constant.
Inputs:
-------
``q``: independent variable (momentum transfer)
``A``: scaling factor of the power-law
``alpha``: power-law exponent
``G``: scaling factor... | [
"def",
"PowerlawGuinierPorodConst",
"(",
"q",
",",
"A",
",",
"alpha",
",",
"G",
",",
"Rg",
",",
"beta",
",",
"C",
")",
":",
"return",
"PowerlawPlusConstant",
"(",
"q",
",",
"A",
",",
"alpha",
",",
"C",
")",
"+",
"GuinierPorod",
"(",
"q",
",",
"G",
... | Sum of a Power-law, a Guinier-Porod curve and a constant.
Inputs:
-------
``q``: independent variable (momentum transfer)
``A``: scaling factor of the power-law
``alpha``: power-law exponent
``G``: scaling factor of the Guinier-Porod curve
``Rg``: Radius of gyration
... | [
"Sum",
"of",
"a",
"Power",
"-",
"law",
"a",
"Guinier",
"-",
"Porod",
"curve",
"and",
"a",
"constant",
"."
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/sasbasic.py#L273-L290 | train |
awacha/sastool | sastool/fitting/fitfunctions/sasbasic.py | GuinierPorodMulti | def GuinierPorodMulti(q, G, *Rgsalphas):
"""Empirical multi-part Guinier-Porod scattering
Inputs:
-------
``q``: independent variable
``G``: factor for the first Guinier-branch
other arguments: [Rg1, alpha1, Rg2, alpha2, Rg3 ...] the radii of
gyration and power-law exponents... | python | def GuinierPorodMulti(q, G, *Rgsalphas):
"""Empirical multi-part Guinier-Porod scattering
Inputs:
-------
``q``: independent variable
``G``: factor for the first Guinier-branch
other arguments: [Rg1, alpha1, Rg2, alpha2, Rg3 ...] the radii of
gyration and power-law exponents... | [
"def",
"GuinierPorodMulti",
"(",
"q",
",",
"G",
",",
"*",
"Rgsalphas",
")",
":",
"scalefactor",
"=",
"G",
"funcs",
"=",
"[",
"lambda",
"q",
":",
"Guinier",
"(",
"q",
",",
"G",
",",
"Rgsalphas",
"[",
"0",
"]",
")",
"]",
"indices",
"=",
"np",
".",
... | Empirical multi-part Guinier-Porod scattering
Inputs:
-------
``q``: independent variable
``G``: factor for the first Guinier-branch
other arguments: [Rg1, alpha1, Rg2, alpha2, Rg3 ...] the radii of
gyration and power-law exponents of the consecutive parts
Formula:
----... | [
"Empirical",
"multi",
"-",
"part",
"Guinier",
"-",
"Porod",
"scattering"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/sasbasic.py#L320-L364 | train |
awacha/sastool | sastool/fitting/fitfunctions/sasbasic.py | PorodGuinierMulti | def PorodGuinierMulti(q, A, *alphasRgs):
"""Empirical multi-part Porod-Guinier scattering
Inputs:
-------
``q``: independent variable
``A``: factor for the first Power-law-branch
other arguments: [alpha1, Rg1, alpha2, Rg2, alpha3 ...] the radii of
gyration and power-law expo... | python | def PorodGuinierMulti(q, A, *alphasRgs):
"""Empirical multi-part Porod-Guinier scattering
Inputs:
-------
``q``: independent variable
``A``: factor for the first Power-law-branch
other arguments: [alpha1, Rg1, alpha2, Rg2, alpha3 ...] the radii of
gyration and power-law expo... | [
"def",
"PorodGuinierMulti",
"(",
"q",
",",
"A",
",",
"*",
"alphasRgs",
")",
":",
"scalefactor",
"=",
"A",
"funcs",
"=",
"[",
"lambda",
"q",
":",
"Powerlaw",
"(",
"q",
",",
"A",
",",
"alphasRgs",
"[",
"0",
"]",
")",
"]",
"indices",
"=",
"np",
".",... | Empirical multi-part Porod-Guinier scattering
Inputs:
-------
``q``: independent variable
``A``: factor for the first Power-law-branch
other arguments: [alpha1, Rg1, alpha2, Rg2, alpha3 ...] the radii of
gyration and power-law exponents of the consecutive parts
Formula:
... | [
"Empirical",
"multi",
"-",
"part",
"Porod",
"-",
"Guinier",
"scattering"
] | deaddfa3002f3f6818697e36139633b7e30427a3 | https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/sasbasic.py#L366-L410 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.