repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
cgarciae/phi
phi/dsl.py
Expression.Seq
def Seq(self, *sequence, **kwargs): """ `Seq` is used to express function composition. The expression Seq(f, g) be equivalent to lambda x: g(f(x)) As you see, its a little different from the mathematical definition. Excecution order flow from left to right, this makes reading and reasoning about cod...
python
def Seq(self, *sequence, **kwargs): """ `Seq` is used to express function composition. The expression Seq(f, g) be equivalent to lambda x: g(f(x)) As you see, its a little different from the mathematical definition. Excecution order flow from left to right, this makes reading and reasoning about cod...
[ "def", "Seq", "(", "self", ",", "*", "sequence", ",", "*", "*", "kwargs", ")", ":", "fs", "=", "[", "_parse", "(", "elem", ")", ".", "_f", "for", "elem", "in", "sequence", "]", "def", "g", "(", "x", ",", "state", ")", ":", "return", "functools"...
`Seq` is used to express function composition. The expression Seq(f, g) be equivalent to lambda x: g(f(x)) As you see, its a little different from the mathematical definition. Excecution order flow from left to right, this makes reading and reasoning about code way more easy. This bahaviour is based upon th...
[ "Seq", "is", "used", "to", "express", "function", "composition", ".", "The", "expression" ]
train
https://github.com/cgarciae/phi/blob/87fd7100a76f823232f4fd8360498b4b80675265/phi/dsl.py#L801-L869
cgarciae/phi
phi/dsl.py
Expression.With
def With(self, context_manager, *body, **kwargs): """ **With** def With(context_manager, *body): **Arguments** * **context_manager**: a [context manager](https://docs.python.org/2/reference/datamodel.html#context-managers) object or valid expression from the DSL that returns a context manager. * ***body*...
python
def With(self, context_manager, *body, **kwargs): """ **With** def With(context_manager, *body): **Arguments** * **context_manager**: a [context manager](https://docs.python.org/2/reference/datamodel.html#context-managers) object or valid expression from the DSL that returns a context manager. * ***body*...
[ "def", "With", "(", "self", ",", "context_manager", ",", "*", "body", ",", "*", "*", "kwargs", ")", ":", "context_f", "=", "_parse", "(", "context_manager", ")", ".", "_f", "body_f", "=", "E", ".", "Seq", "(", "*", "body", ")", ".", "_f", "def", ...
**With** def With(context_manager, *body): **Arguments** * **context_manager**: a [context manager](https://docs.python.org/2/reference/datamodel.html#context-managers) object or valid expression from the DSL that returns a context manager. * ***body**: any valid expression of the DSL to be evaluated inside the ...
[ "**", "With", "**" ]
train
https://github.com/cgarciae/phi/blob/87fd7100a76f823232f4fd8360498b4b80675265/phi/dsl.py#L930-L973
cgarciae/phi
phi/dsl.py
Expression.ReadList
def ReadList(self, *branches, **kwargs): """ Same as `phi.dsl.Expression.List` but any string argument `x` is translated to `Read(x)`. """ branches = map(lambda x: E.Read(x) if isinstance(x, str) else x, branches) return self.List(*branches, **kwargs)
python
def ReadList(self, *branches, **kwargs): """ Same as `phi.dsl.Expression.List` but any string argument `x` is translated to `Read(x)`. """ branches = map(lambda x: E.Read(x) if isinstance(x, str) else x, branches) return self.List(*branches, **kwargs)
[ "def", "ReadList", "(", "self", ",", "*", "branches", ",", "*", "*", "kwargs", ")", ":", "branches", "=", "map", "(", "lambda", "x", ":", "E", ".", "Read", "(", "x", ")", "if", "isinstance", "(", "x", ",", "str", ")", "else", "x", ",", "branche...
Same as `phi.dsl.Expression.List` but any string argument `x` is translated to `Read(x)`.
[ "Same", "as", "phi", ".", "dsl", ".", "Expression", ".", "List", "but", "any", "string", "argument", "x", "is", "translated", "to", "Read", "(", "x", ")", "." ]
train
https://github.com/cgarciae/phi/blob/87fd7100a76f823232f4fd8360498b4b80675265/phi/dsl.py#L1021-L1027
cgarciae/phi
phi/dsl.py
Expression.Write
def Write(self, *state_args, **state_dict): """See `phi.dsl.Expression.Read`""" if len(state_dict) + len(state_args) < 1: raise Exception("Please include at-least 1 state variable, got {0} and {1}".format(state_args, state_dict)) if len(state_dict) > 1: raise Exception("...
python
def Write(self, *state_args, **state_dict): """See `phi.dsl.Expression.Read`""" if len(state_dict) + len(state_args) < 1: raise Exception("Please include at-least 1 state variable, got {0} and {1}".format(state_args, state_dict)) if len(state_dict) > 1: raise Exception("...
[ "def", "Write", "(", "self", ",", "*", "state_args", ",", "*", "*", "state_dict", ")", ":", "if", "len", "(", "state_dict", ")", "+", "len", "(", "state_args", ")", "<", "1", ":", "raise", "Exception", "(", "\"Please include at-least 1 state variable, got {0...
See `phi.dsl.Expression.Read`
[ "See", "phi", ".", "dsl", ".", "Expression", ".", "Read" ]
train
https://github.com/cgarciae/phi/blob/87fd7100a76f823232f4fd8360498b4b80675265/phi/dsl.py#L1030-L1061
cgarciae/phi
phi/dsl.py
Expression.Val
def Val(self, val, **kwargs): """ The expression Val(a) is equivalent to the constant function lambda x: a All expression in this module interprete values that are not functions as constant functions using `Val`, for example Seq(1, P + 1) is equivalent to Seq(Val(1), P + 1) The previous ...
python
def Val(self, val, **kwargs): """ The expression Val(a) is equivalent to the constant function lambda x: a All expression in this module interprete values that are not functions as constant functions using `Val`, for example Seq(1, P + 1) is equivalent to Seq(Val(1), P + 1) The previous ...
[ "def", "Val", "(", "self", ",", "val", ",", "*", "*", "kwargs", ")", ":", "f", "=", "utils", ".", "lift", "(", "lambda", "z", ":", "val", ")", "return", "self", ".", "__then__", "(", "f", ",", "*", "*", "kwargs", ")" ]
The expression Val(a) is equivalent to the constant function lambda x: a All expression in this module interprete values that are not functions as constant functions using `Val`, for example Seq(1, P + 1) is equivalent to Seq(Val(1), P + 1) The previous expression as a whole is a constant functi...
[ "The", "expression" ]
train
https://github.com/cgarciae/phi/blob/87fd7100a76f823232f4fd8360498b4b80675265/phi/dsl.py#L1181-L1203
cgarciae/phi
phi/dsl.py
Expression.If
def If(self, condition, *then, **kwargs): """ **If** If(Predicate, *Then) Having conditionals expressions a necesity in every language, Phi includes the `If` expression for such a purpose. **Arguments** * **Predicate** : a predicate expression uses to determine if the `Then` or `Else` branches should be...
python
def If(self, condition, *then, **kwargs): """ **If** If(Predicate, *Then) Having conditionals expressions a necesity in every language, Phi includes the `If` expression for such a purpose. **Arguments** * **Predicate** : a predicate expression uses to determine if the `Then` or `Else` branches should be...
[ "def", "If", "(", "self", ",", "condition", ",", "*", "then", ",", "*", "*", "kwargs", ")", ":", "cond_f", "=", "_parse", "(", "condition", ")", ".", "_f", "then_f", "=", "E", ".", "Seq", "(", "*", "then", ")", ".", "_f", "else_f", "=", "utils"...
**If** If(Predicate, *Then) Having conditionals expressions a necesity in every language, Phi includes the `If` expression for such a purpose. **Arguments** * **Predicate** : a predicate expression uses to determine if the `Then` or `Else` branches should be used. * ***Then** : an expression to be excecuted if ...
[ "**", "If", "**" ]
train
https://github.com/cgarciae/phi/blob/87fd7100a76f823232f4fd8360498b4b80675265/phi/dsl.py#L1206-L1253
cgarciae/phi
phi/dsl.py
Expression.Else
def Else(self, *Else, **kwargs): """See `phi.dsl.Expression.If`""" root = self._root ast = self._ast next_else = E.Seq(*Else)._f ast = _add_else(ast, next_else) g = _compile_if(ast) return root.__then__(g, **kwargs)
python
def Else(self, *Else, **kwargs): """See `phi.dsl.Expression.If`""" root = self._root ast = self._ast next_else = E.Seq(*Else)._f ast = _add_else(ast, next_else) g = _compile_if(ast) return root.__then__(g, **kwargs)
[ "def", "Else", "(", "self", ",", "*", "Else", ",", "*", "*", "kwargs", ")", ":", "root", "=", "self", ".", "_root", "ast", "=", "self", ".", "_ast", "next_else", "=", "E", ".", "Seq", "(", "*", "Else", ")", ".", "_f", "ast", "=", "_add_else", ...
See `phi.dsl.Expression.If`
[ "See", "phi", ".", "dsl", ".", "Expression", ".", "If" ]
train
https://github.com/cgarciae/phi/blob/87fd7100a76f823232f4fd8360498b4b80675265/phi/dsl.py#L1255-L1265
alvinlindstam/grapheme
grapheme/api.py
length
def length(string, until=None): """ Returns the number of graphemes in the string. Note that this functions needs to traverse the full string to calculate the length, unlike `len(string)` and it's time consumption is linear to the length of the string (up to the `until` value). Only counts up ...
python
def length(string, until=None): """ Returns the number of graphemes in the string. Note that this functions needs to traverse the full string to calculate the length, unlike `len(string)` and it's time consumption is linear to the length of the string (up to the `until` value). Only counts up ...
[ "def", "length", "(", "string", ",", "until", "=", "None", ")", ":", "if", "until", "is", "None", ":", "return", "sum", "(", "1", "for", "_", "in", "GraphemeIterator", "(", "string", ")", ")", "iterator", "=", "graphemes", "(", "string", ")", "count"...
Returns the number of graphemes in the string. Note that this functions needs to traverse the full string to calculate the length, unlike `len(string)` and it's time consumption is linear to the length of the string (up to the `until` value). Only counts up to the `until` argument, if given. This is u...
[ "Returns", "the", "number", "of", "graphemes", "in", "the", "string", "." ]
train
https://github.com/alvinlindstam/grapheme/blob/45cd9b8326ddf96d2618406724a7ebf273cbde03/grapheme/api.py#L21-L55
alvinlindstam/grapheme
grapheme/api.py
slice
def slice(string, start=None, end=None): """ Returns a substring of the given string, counting graphemes instead of codepoints. Negative indices is currently not supported. >>> string = "tamil நி (ni)" >>> string[:7] 'tamil ந' >>> grapheme.slice(string, end=7) 'tamil நி' >>> string...
python
def slice(string, start=None, end=None): """ Returns a substring of the given string, counting graphemes instead of codepoints. Negative indices is currently not supported. >>> string = "tamil நி (ni)" >>> string[:7] 'tamil ந' >>> grapheme.slice(string, end=7) 'tamil நி' >>> string...
[ "def", "slice", "(", "string", ",", "start", "=", "None", ",", "end", "=", "None", ")", ":", "if", "start", "is", "None", ":", "start", "=", "0", "if", "end", "is", "not", "None", "and", "start", ">=", "end", ":", "return", "\"\"", "if", "start",...
Returns a substring of the given string, counting graphemes instead of codepoints. Negative indices is currently not supported. >>> string = "tamil நி (ni)" >>> string[:7] 'tamil ந' >>> grapheme.slice(string, end=7) 'tamil நி' >>> string[7:] 'ி (ni)' >>> grapheme.slice(string, 7) ...
[ "Returns", "a", "substring", "of", "the", "given", "string", "counting", "graphemes", "instead", "of", "codepoints", "." ]
train
https://github.com/alvinlindstam/grapheme/blob/45cd9b8326ddf96d2618406724a7ebf273cbde03/grapheme/api.py#L66-L103
alvinlindstam/grapheme
grapheme/api.py
contains
def contains(string, substring): """ Returns true if the sequence of graphemes in substring is also present in string. This differs from the normal python `in` operator, since the python operator will return true if the sequence of codepoints are withing the other string without considering graphem...
python
def contains(string, substring): """ Returns true if the sequence of graphemes in substring is also present in string. This differs from the normal python `in` operator, since the python operator will return true if the sequence of codepoints are withing the other string without considering graphem...
[ "def", "contains", "(", "string", ",", "substring", ")", ":", "if", "substring", "not", "in", "string", ":", "return", "False", "substr_graphemes", "=", "list", "(", "graphemes", "(", "substring", ")", ")", "if", "len", "(", "substr_graphemes", ")", "==", ...
Returns true if the sequence of graphemes in substring is also present in string. This differs from the normal python `in` operator, since the python operator will return true if the sequence of codepoints are withing the other string without considering grapheme boundaries. Performance notes: Very fa...
[ "Returns", "true", "if", "the", "sequence", "of", "graphemes", "in", "substring", "is", "also", "present", "in", "string", "." ]
train
https://github.com/alvinlindstam/grapheme/blob/45cd9b8326ddf96d2618406724a7ebf273cbde03/grapheme/api.py#L105-L147
alvinlindstam/grapheme
grapheme/api.py
startswith
def startswith(string, prefix): """ Like str.startswith, but also checks that the string starts with the given prefixes sequence of graphemes. str.startswith may return true for a prefix that is not visually represented as a prefix if a grapheme cluster is continued after the prefix ends. >>> grap...
python
def startswith(string, prefix): """ Like str.startswith, but also checks that the string starts with the given prefixes sequence of graphemes. str.startswith may return true for a prefix that is not visually represented as a prefix if a grapheme cluster is continued after the prefix ends. >>> grap...
[ "def", "startswith", "(", "string", ",", "prefix", ")", ":", "return", "string", ".", "startswith", "(", "prefix", ")", "and", "safe_split_index", "(", "string", ",", "len", "(", "prefix", ")", ")", "==", "len", "(", "prefix", ")" ]
Like str.startswith, but also checks that the string starts with the given prefixes sequence of graphemes. str.startswith may return true for a prefix that is not visually represented as a prefix if a grapheme cluster is continued after the prefix ends. >>> grapheme.startswith("✊🏾", "✊") False >>...
[ "Like", "str", ".", "startswith", "but", "also", "checks", "that", "the", "string", "starts", "with", "the", "given", "prefixes", "sequence", "of", "graphemes", "." ]
train
https://github.com/alvinlindstam/grapheme/blob/45cd9b8326ddf96d2618406724a7ebf273cbde03/grapheme/api.py#L150-L162
alvinlindstam/grapheme
grapheme/api.py
endswith
def endswith(string, suffix): """ Like str.endswith, but also checks that the string ends with the given prefixes sequence of graphemes. str.endswith may return true for a suffix that is not visually represented as a suffix if a grapheme cluster is initiated before the suffix starts. >>> grapheme....
python
def endswith(string, suffix): """ Like str.endswith, but also checks that the string ends with the given prefixes sequence of graphemes. str.endswith may return true for a suffix that is not visually represented as a suffix if a grapheme cluster is initiated before the suffix starts. >>> grapheme....
[ "def", "endswith", "(", "string", ",", "suffix", ")", ":", "expected_index", "=", "len", "(", "string", ")", "-", "len", "(", "suffix", ")", "return", "string", ".", "endswith", "(", "suffix", ")", "and", "safe_split_index", "(", "string", ",", "expected...
Like str.endswith, but also checks that the string ends with the given prefixes sequence of graphemes. str.endswith may return true for a suffix that is not visually represented as a suffix if a grapheme cluster is initiated before the suffix starts. >>> grapheme.endswith("🏳️‍🌈", "🌈") False >>>...
[ "Like", "str", ".", "endswith", "but", "also", "checks", "that", "the", "string", "ends", "with", "the", "given", "prefixes", "sequence", "of", "graphemes", "." ]
train
https://github.com/alvinlindstam/grapheme/blob/45cd9b8326ddf96d2618406724a7ebf273cbde03/grapheme/api.py#L165-L178
alvinlindstam/grapheme
grapheme/api.py
safe_split_index
def safe_split_index(string, max_len): """ Returns the highest index up to `max_len` at which the given string can be sliced, without breaking a grapheme. This is useful for when you want to split or take a substring from a string, and don't really care about the exact grapheme length, but don't want t...
python
def safe_split_index(string, max_len): """ Returns the highest index up to `max_len` at which the given string can be sliced, without breaking a grapheme. This is useful for when you want to split or take a substring from a string, and don't really care about the exact grapheme length, but don't want t...
[ "def", "safe_split_index", "(", "string", ",", "max_len", ")", ":", "last_index", "=", "get_last_certain_break_index", "(", "string", ",", "max_len", ")", "for", "l", "in", "grapheme_lengths", "(", "string", "[", "last_index", ":", "]", ")", ":", "if", "last...
Returns the highest index up to `max_len` at which the given string can be sliced, without breaking a grapheme. This is useful for when you want to split or take a substring from a string, and don't really care about the exact grapheme length, but don't want to risk breaking existing graphemes. This funct...
[ "Returns", "the", "highest", "index", "up", "to", "max_len", "at", "which", "the", "given", "string", "can", "be", "sliced", "without", "breaking", "a", "grapheme", "." ]
train
https://github.com/alvinlindstam/grapheme/blob/45cd9b8326ddf96d2618406724a7ebf273cbde03/grapheme/api.py#L181-L209
awacha/sastool
sastool/io/header.py
readB1logfile
def readB1logfile(filename): """Read B1 logfile (*.log) Inputs: filename: the file name Output: A dictionary. """ dic = dict() # try to open. If this fails, an exception is raised with open(filename, 'rt', encoding='utf-8') as f: for l in f: l = l.strip() ...
python
def readB1logfile(filename): """Read B1 logfile (*.log) Inputs: filename: the file name Output: A dictionary. """ dic = dict() # try to open. If this fails, an exception is raised with open(filename, 'rt', encoding='utf-8') as f: for l in f: l = l.strip() ...
[ "def", "readB1logfile", "(", "filename", ")", ":", "dic", "=", "dict", "(", ")", "# try to open. If this fails, an exception is raised", "with", "open", "(", "filename", ",", "'rt'", ",", "encoding", "=", "'utf-8'", ")", "as", "f", ":", "for", "l", "in", "f"...
Read B1 logfile (*.log) Inputs: filename: the file name Output: A dictionary.
[ "Read", "B1", "logfile", "(", "*", ".", "log", ")" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/header.py#L142-L203
awacha/sastool
sastool/io/header.py
writeB1logfile
def writeB1logfile(filename, data): """Write a header structure into a B1 logfile. Inputs: filename: name of the file. data: header dictionary Notes: exceptions pass through to the caller. """ allkeys = list(data.keys()) f = open(filename, 'wt', encoding='utf-8') fo...
python
def writeB1logfile(filename, data): """Write a header structure into a B1 logfile. Inputs: filename: name of the file. data: header dictionary Notes: exceptions pass through to the caller. """ allkeys = list(data.keys()) f = open(filename, 'wt', encoding='utf-8') fo...
[ "def", "writeB1logfile", "(", "filename", ",", "data", ")", ":", "allkeys", "=", "list", "(", "data", ".", "keys", "(", ")", ")", "f", "=", "open", "(", "filename", ",", "'wt'", ",", "encoding", "=", "'utf-8'", ")", "for", "ld", "in", "_logfile_data"...
Write a header structure into a B1 logfile. Inputs: filename: name of the file. data: header dictionary Notes: exceptions pass through to the caller.
[ "Write", "a", "header", "structure", "into", "a", "B1", "logfile", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/header.py#L206-L275
awacha/sastool
sastool/io/header.py
readB1header
def readB1header(filename): """Read beamline B1 (HASYLAB, Hamburg) header data Input ----- filename: string the file name. If ends with ``.gz``, it is fed through a ``gunzip`` filter Output ------ A header dictionary. Examples -------- read header data from 'OR...
python
def readB1header(filename): """Read beamline B1 (HASYLAB, Hamburg) header data Input ----- filename: string the file name. If ends with ``.gz``, it is fed through a ``gunzip`` filter Output ------ A header dictionary. Examples -------- read header data from 'OR...
[ "def", "readB1header", "(", "filename", ")", ":", "# Planck's constant times speed of light: incorrect", "# constant in the old program on hasjusi1, which was", "# taken over by the measurement program, to keep", "# compatibility with that.", "hed", "=", "{", "}", "if", "libconfig", ...
Read beamline B1 (HASYLAB, Hamburg) header data Input ----- filename: string the file name. If ends with ``.gz``, it is fed through a ``gunzip`` filter Output ------ A header dictionary. Examples -------- read header data from 'ORG000123.DAT':: header=read...
[ "Read", "beamline", "B1", "(", "HASYLAB", "Hamburg", ")", "header", "data" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/header.py#L278-L369
awacha/sastool
sastool/io/header.py
_readedf_extractline
def _readedf_extractline(left, right): """Helper function to interpret lines in an EDF file header. """ functions = [int, float, lambda l:float(l.split(None, 1)[0]), lambda l:int(l.split(None, 1)[0]), dateutil.parser.parse, lambda x:str(x)] for f in functions: t...
python
def _readedf_extractline(left, right): """Helper function to interpret lines in an EDF file header. """ functions = [int, float, lambda l:float(l.split(None, 1)[0]), lambda l:int(l.split(None, 1)[0]), dateutil.parser.parse, lambda x:str(x)] for f in functions: t...
[ "def", "_readedf_extractline", "(", "left", ",", "right", ")", ":", "functions", "=", "[", "int", ",", "float", ",", "lambda", "l", ":", "float", "(", "l", ".", "split", "(", "None", ",", "1", ")", "[", "0", "]", ")", ",", "lambda", "l", ":", "...
Helper function to interpret lines in an EDF file header.
[ "Helper", "function", "to", "interpret", "lines", "in", "an", "EDF", "file", "header", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/header.py#L372-L384
awacha/sastool
sastool/io/header.py
readehf
def readehf(filename): """Read EDF header (ESRF data format, as of beamline ID01 and ID02) Input ----- filename: string the file name to load Output ------ the EDF header structure in a dictionary """ f = open(filename, 'r') edf = {} if not f.readline().strip().star...
python
def readehf(filename): """Read EDF header (ESRF data format, as of beamline ID01 and ID02) Input ----- filename: string the file name to load Output ------ the EDF header structure in a dictionary """ f = open(filename, 'r') edf = {} if not f.readline().strip().star...
[ "def", "readehf", "(", "filename", ")", ":", "f", "=", "open", "(", "filename", ",", "'r'", ")", "edf", "=", "{", "}", "if", "not", "f", ".", "readline", "(", ")", ".", "strip", "(", ")", ".", "startswith", "(", "'{'", ")", ":", "raise", "Value...
Read EDF header (ESRF data format, as of beamline ID01 and ID02) Input ----- filename: string the file name to load Output ------ the EDF header structure in a dictionary
[ "Read", "EDF", "header", "(", "ESRF", "data", "format", "as", "of", "beamline", "ID01", "and", "ID02", ")" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/header.py#L387-L428
awacha/sastool
sastool/io/header.py
readbhfv1
def readbhfv1(filename, load_data=False, bdfext='.bdf', bhfext='.bhf'): """Read header data from bdf/bhf file (Bessy Data Format v1) Input: filename: the name of the file load_data: if the matrices are to be loaded Output: bdf: the BDF header structure Adapted the bdf_read.m m...
python
def readbhfv1(filename, load_data=False, bdfext='.bdf', bhfext='.bhf'): """Read header data from bdf/bhf file (Bessy Data Format v1) Input: filename: the name of the file load_data: if the matrices are to be loaded Output: bdf: the BDF header structure Adapted the bdf_read.m m...
[ "def", "readbhfv1", "(", "filename", ",", "load_data", "=", "False", ",", "bdfext", "=", "'.bdf'", ",", "bhfext", "=", "'.bhf'", ")", ":", "# strip the bhf or bdf extension if there.", "if", "filename", ".", "endswith", "(", "bdfext", ")", ":", "basename", "="...
Read header data from bdf/bhf file (Bessy Data Format v1) Input: filename: the name of the file load_data: if the matrices are to be loaded Output: bdf: the BDF header structure Adapted the bdf_read.m macro from Sylvio Haas.
[ "Read", "header", "data", "from", "bdf", "/", "bhf", "file", "(", "Bessy", "Data", "Format", "v1", ")" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/header.py#L545-L678
awacha/sastool
sastool/io/header.py
readmarheader
def readmarheader(filename): """Read a header from a MarResearch .image file.""" with open(filename, 'rb') as f: intheader = np.fromstring(f.read(10 * 4), np.int32) floatheader = np.fromstring(f.read(15 * 4), '<f4') strheader = f.read(24) f.read(4) otherstrings = [f.read(...
python
def readmarheader(filename): """Read a header from a MarResearch .image file.""" with open(filename, 'rb') as f: intheader = np.fromstring(f.read(10 * 4), np.int32) floatheader = np.fromstring(f.read(15 * 4), '<f4') strheader = f.read(24) f.read(4) otherstrings = [f.read(...
[ "def", "readmarheader", "(", "filename", ")", ":", "with", "open", "(", "filename", ",", "'rb'", ")", "as", "f", ":", "intheader", "=", "np", ".", "fromstring", "(", "f", ".", "read", "(", "10", "*", "4", ")", ",", "np", ".", "int32", ")", "float...
Read a header from a MarResearch .image file.
[ "Read", "a", "header", "from", "a", "MarResearch", ".", "image", "file", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/header.py#L745-L760
awacha/sastool
sastool/io/header.py
readBerSANS
def readBerSANS(filename): """Read a header from a SANS file (produced usually by BerSANS)""" hed = {'Comment': ''} translate = {'Lambda': 'Wavelength', 'Title': 'Owner', 'SampleName': 'Title', 'BeamcenterX': 'BeamPosY', 'BeamcenterY': 'Bea...
python
def readBerSANS(filename): """Read a header from a SANS file (produced usually by BerSANS)""" hed = {'Comment': ''} translate = {'Lambda': 'Wavelength', 'Title': 'Owner', 'SampleName': 'Title', 'BeamcenterX': 'BeamPosY', 'BeamcenterY': 'Bea...
[ "def", "readBerSANS", "(", "filename", ")", ":", "hed", "=", "{", "'Comment'", ":", "''", "}", "translate", "=", "{", "'Lambda'", ":", "'Wavelength'", ",", "'Title'", ":", "'Owner'", ",", "'SampleName'", ":", "'Title'", ",", "'BeamcenterX'", ":", "'BeamPos...
Read a header from a SANS file (produced usually by BerSANS)
[ "Read", "a", "header", "from", "a", "SANS", "file", "(", "produced", "usually", "by", "BerSANS", ")" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/header.py#L763-L817
awacha/sastool
sastool/fitting/fitfunctions/basic.py
Sine
def Sine(x, a, omega, phi, y0): """Sine function Inputs: ------- ``x``: independent variable ``a``: amplitude ``omega``: circular frequency ``phi``: phase ``y0``: offset Formula: -------- ``a*sin(x*omega + phi)+y0`` """ return a * np.sin(x * ...
python
def Sine(x, a, omega, phi, y0): """Sine function Inputs: ------- ``x``: independent variable ``a``: amplitude ``omega``: circular frequency ``phi``: phase ``y0``: offset Formula: -------- ``a*sin(x*omega + phi)+y0`` """ return a * np.sin(x * ...
[ "def", "Sine", "(", "x", ",", "a", ",", "omega", ",", "phi", ",", "y0", ")", ":", "return", "a", "*", "np", ".", "sin", "(", "x", "*", "omega", "+", "phi", ")", "+", "y0" ]
Sine function Inputs: ------- ``x``: independent variable ``a``: amplitude ``omega``: circular frequency ``phi``: phase ``y0``: offset Formula: -------- ``a*sin(x*omega + phi)+y0``
[ "Sine", "function" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/basic.py#L23-L38
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/basic.py#L41-L56
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/basic.py#L59-L73
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/basic.py#L76-L91
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/basic.py#L110-L124
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/basic.py#L127-L142
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/basic.py#L145-L160
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/fitfunctions/basic.py#L163-L178
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/integrate.py#L10-L48
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/integrate.py#L51-L79
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/searchpath.py#L107-L135
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/basicfit.py#L18-L38
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/basicfit.py#L41-L97
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/basicfit.py#L99-L178
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/basicfit.py#L181-L265
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/onedim.py#L18-L82
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/onedim.py#L85-L162
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/onedim.py#L165-L275
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/credo_cpth5/header.py#L50-L55
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/credo_cpth5/header.py#L191-L199
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/centering.py#L11-L58
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/centering.py#L61-L110
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/centering.py#L113-L157
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/centering.py#L160-L201
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/centering.py#L204-L262
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/centering.py#L265-L315
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", ")", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/centering.py#L318-L355
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", ")", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/centering.py#L358-L400
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/credo_cct/header.py#L106-L113
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/credo_cct/header.py#L124-L131
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/credo_cct/header.py#L197-L202
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/curve.py#L15-L29
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", "()" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/curve.py#L63-L87
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", ")", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/curve.py#L238-L254
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/curve.py#L279-L306
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/fitter.py#L209-L226
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/credo_cct/loader.py#L57-L61
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/credo_cct/loader.py#L63-L65
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/twodim.py#L87-L212
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", ")" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/twodim.py#L215-L231
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", "))" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/twodim.py#L253-L303
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/twodim.py#L306-L333
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/twodim.py#L336-L360
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", ")" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/twodim.py#L363-L390
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/twodim.py#L393-L416
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/twodim.py#L423-L435
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/twodim.py#L438-L478
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/twodim.py#L481-L512
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", "." ]
train
https://github.com/ClearcodeHQ/querystringsafe_base64/blob/5353c4a8e275435d9d38356a0db64e5c43198ccd/src/querystringsafe_base64/__init__.py#L27-L43
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", "." ]
train
https://github.com/ClearcodeHQ/querystringsafe_base64/blob/5353c4a8e275435d9d38356a0db64e5c43198ccd/src/querystringsafe_base64/__init__.py#L63-L79
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", ...
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/utils.py#L27-L37
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", "()", ...
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/utils.py#L40-L58
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/utils.py#L61-L107
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", ">", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/utils.py#L115-L119
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", ...
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/statistics.py#L105-L167
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/standalone.py#L11-L65
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...
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/fitting/standalone.py#L67-L97
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/pathutils.py#L17-L63
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/corrections.py#L10-L23
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/corrections.py#L26-L39
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/corrections.py#L42-L61
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/corrections.py#L63-L83
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/corrections.py#L108-L123
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/corrections.py#L125-L138
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/utils2d/corrections.py#L140-L168
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/loader.py#L69-L86
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/loader.py#L96-L101
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/exposure.py#L47-L49
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/exposure.py#L51-L58
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/exposure.py#L60-L69
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/exposure.py#L72-L80
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/exposure.py#L87-L107
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", ")" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/exposure.py#L109-L201
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/exposure.py#L257-L320
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/exposure.py#L331-L333
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/exposure.py#L335-L337
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", "." ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/classes2/exposure.py#L339-L341
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/credo_saxsctrl/header.py#L114-L126
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" ]
train
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/io/credo_saxsctrl/header.py#L136-L141