repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
aaugustin/django-sesame
sesame/backends.py
UrlAuthBackendMixin.parse_token
def parse_token(self, token): """ Obtain a user from a signed token. """ try: data = self.unsign(token) except signing.SignatureExpired: logger.debug("Expired token: %s", token) return except signing.BadSignature: logger.de...
python
def parse_token(self, token): """ Obtain a user from a signed token. """ try: data = self.unsign(token) except signing.SignatureExpired: logger.debug("Expired token: %s", token) return except signing.BadSignature: logger.de...
[ "def", "parse_token", "(", "self", ",", "token", ")", ":", "try", ":", "data", "=", "self", ".", "unsign", "(", "token", ")", "except", "signing", ".", "SignatureExpired", ":", "logger", ".", "debug", "(", "\"Expired token: %s\"", ",", "token", ")", "ret...
Obtain a user from a signed token.
[ "Obtain", "a", "user", "from", "a", "signed", "token", "." ]
4bf902c637b0674b8fc78bc95937271948c99282
https://github.com/aaugustin/django-sesame/blob/4bf902c637b0674b8fc78bc95937271948c99282/sesame/backends.py#L114-L147
train
aaugustin/django-sesame
sesame/backends.py
ModelBackend.authenticate
def authenticate(self, request, url_auth_token=None): """ Check the token and return the corresponding user. """ try: return self.parse_token(url_auth_token) except TypeError: backend = "%s.%s" % (self.__module__, self.__class__.__name__) logg...
python
def authenticate(self, request, url_auth_token=None): """ Check the token and return the corresponding user. """ try: return self.parse_token(url_auth_token) except TypeError: backend = "%s.%s" % (self.__module__, self.__class__.__name__) logg...
[ "def", "authenticate", "(", "self", ",", "request", ",", "url_auth_token", "=", "None", ")", ":", "try", ":", "return", "self", ".", "parse_token", "(", "url_auth_token", ")", "except", "TypeError", ":", "backend", "=", "\"%s.%s\"", "%", "(", "self", ".", ...
Check the token and return the corresponding user.
[ "Check", "the", "token", "and", "return", "the", "corresponding", "user", "." ]
4bf902c637b0674b8fc78bc95937271948c99282
https://github.com/aaugustin/django-sesame/blob/4bf902c637b0674b8fc78bc95937271948c99282/sesame/backends.py#L155-L166
train
nlppln/nlppln
nlppln/commands/frog_to_saf.py
_add_pos1
def _add_pos1(token): """ Adds a 'pos1' element to a frog token. """ result = token.copy() result['pos1'] = _POSMAP[token['pos'].split("(")[0]] return result
python
def _add_pos1(token): """ Adds a 'pos1' element to a frog token. """ result = token.copy() result['pos1'] = _POSMAP[token['pos'].split("(")[0]] return result
[ "def", "_add_pos1", "(", "token", ")", ":", "result", "=", "token", ".", "copy", "(", ")", "result", "[", "'pos1'", "]", "=", "_POSMAP", "[", "token", "[", "'pos'", "]", ".", "split", "(", "\"(\"", ")", "[", "0", "]", "]", "return", "result" ]
Adds a 'pos1' element to a frog token.
[ "Adds", "a", "pos1", "element", "to", "a", "frog", "token", "." ]
1155191921289a65ba2becd2bf8dfabb48eaf1f1
https://github.com/nlppln/nlppln/blob/1155191921289a65ba2becd2bf8dfabb48eaf1f1/nlppln/commands/frog_to_saf.py#L53-L59
train
nlppln/nlppln
nlppln/commands/frog_to_saf.py
frog_to_saf
def frog_to_saf(tokens): """ Convert frog tokens into a new SAF document """ tokens = [_add_pos1(token) for token in tokens] module = {'module': "frog", "started": datetime.datetime.now().isoformat()} return {"header": {'format': "SAF", 'format-version': "0.0...
python
def frog_to_saf(tokens): """ Convert frog tokens into a new SAF document """ tokens = [_add_pos1(token) for token in tokens] module = {'module': "frog", "started": datetime.datetime.now().isoformat()} return {"header": {'format': "SAF", 'format-version': "0.0...
[ "def", "frog_to_saf", "(", "tokens", ")", ":", "tokens", "=", "[", "_add_pos1", "(", "token", ")", "for", "token", "in", "tokens", "]", "module", "=", "{", "'module'", ":", "\"frog\"", ",", "\"started\"", ":", "datetime", ".", "datetime", ".", "now", "...
Convert frog tokens into a new SAF document
[ "Convert", "frog", "tokens", "into", "a", "new", "SAF", "document" ]
1155191921289a65ba2becd2bf8dfabb48eaf1f1
https://github.com/nlppln/nlppln/blob/1155191921289a65ba2becd2bf8dfabb48eaf1f1/nlppln/commands/frog_to_saf.py#L62-L72
train
nlppln/nlppln
nlppln/copycwl.py
copy_cwl_files
def copy_cwl_files(from_dir=CWL_PATH, to_dir=None): """Copy cwl files to a directory where the cwl-runner can find them. Args: from_dir (str): Path to directory where to copy files from (default: the cwl directory of nlppln). to_dir (str): Path to directory where the files should be...
python
def copy_cwl_files(from_dir=CWL_PATH, to_dir=None): """Copy cwl files to a directory where the cwl-runner can find them. Args: from_dir (str): Path to directory where to copy files from (default: the cwl directory of nlppln). to_dir (str): Path to directory where the files should be...
[ "def", "copy_cwl_files", "(", "from_dir", "=", "CWL_PATH", ",", "to_dir", "=", "None", ")", ":", "cwl_files", "=", "glob", ".", "glob", "(", "'{}{}*.cwl'", ".", "format", "(", "from_dir", ",", "os", ".", "sep", ")", ")", "if", "len", "(", "cwl_files", ...
Copy cwl files to a directory where the cwl-runner can find them. Args: from_dir (str): Path to directory where to copy files from (default: the cwl directory of nlppln). to_dir (str): Path to directory where the files should be copied to (e.g., the CWL working directory).
[ "Copy", "cwl", "files", "to", "a", "directory", "where", "the", "cwl", "-", "runner", "can", "find", "them", "." ]
1155191921289a65ba2becd2bf8dfabb48eaf1f1
https://github.com/nlppln/nlppln/blob/1155191921289a65ba2becd2bf8dfabb48eaf1f1/nlppln/copycwl.py#L10-L27
train
nlppln/nlppln
nlppln/copycwl.py
main
def main(to_dir, from_dir): """Copy CWL files.""" num = copy_cwl_files(from_dir=from_dir, to_dir=to_dir) if num > 0: click.echo('Copied {} CWL files to "{}".'.format(num, to_dir)) else: msg = 'No CWL files found in "{}". Copied 0 files'.format(from_dir) click.echo(msg)
python
def main(to_dir, from_dir): """Copy CWL files.""" num = copy_cwl_files(from_dir=from_dir, to_dir=to_dir) if num > 0: click.echo('Copied {} CWL files to "{}".'.format(num, to_dir)) else: msg = 'No CWL files found in "{}". Copied 0 files'.format(from_dir) click.echo(msg)
[ "def", "main", "(", "to_dir", ",", "from_dir", ")", ":", "num", "=", "copy_cwl_files", "(", "from_dir", "=", "from_dir", ",", "to_dir", "=", "to_dir", ")", "if", "num", ">", "0", ":", "click", ".", "echo", "(", "'Copied {} CWL files to \"{}\".'", ".", "f...
Copy CWL files.
[ "Copy", "CWL", "files", "." ]
1155191921289a65ba2becd2bf8dfabb48eaf1f1
https://github.com/nlppln/nlppln/blob/1155191921289a65ba2becd2bf8dfabb48eaf1f1/nlppln/copycwl.py#L35-L42
train
sileht/python-jsonpath-rw-ext
jsonpath_rw_ext/_iterable.py
SortedThis.find
def find(self, datum): """Return sorted value of This if list or dict.""" if isinstance(datum.value, dict) and self.expressions: return datum if isinstance(datum.value, dict) or isinstance(datum.value, list): key = (functools.cmp_to_key(self._compare) ...
python
def find(self, datum): """Return sorted value of This if list or dict.""" if isinstance(datum.value, dict) and self.expressions: return datum if isinstance(datum.value, dict) or isinstance(datum.value, list): key = (functools.cmp_to_key(self._compare) ...
[ "def", "find", "(", "self", ",", "datum", ")", ":", "if", "isinstance", "(", "datum", ".", "value", ",", "dict", ")", "and", "self", ".", "expressions", ":", "return", "datum", "if", "isinstance", "(", "datum", ".", "value", ",", "dict", ")", "or", ...
Return sorted value of This if list or dict.
[ "Return", "sorted", "value", "of", "This", "if", "list", "or", "dict", "." ]
30dd6f209ae16d448e1e071aac90cc9d3f10cff5
https://github.com/sileht/python-jsonpath-rw-ext/blob/30dd6f209ae16d448e1e071aac90cc9d3f10cff5/jsonpath_rw_ext/_iterable.py#L46-L56
train
nlppln/nlppln
nlppln/wfgenerator.py
WorkflowGenerator.save
def save(self, fname, mode=None, validate=True, wd=False, inline=False, relative=True, pack=False, encoding='utf-8'): """Save workflow to file For nlppln, the default is to save workflows with relative paths. """ super(WorkflowGenerator, self).save(fname, ...
python
def save(self, fname, mode=None, validate=True, wd=False, inline=False, relative=True, pack=False, encoding='utf-8'): """Save workflow to file For nlppln, the default is to save workflows with relative paths. """ super(WorkflowGenerator, self).save(fname, ...
[ "def", "save", "(", "self", ",", "fname", ",", "mode", "=", "None", ",", "validate", "=", "True", ",", "wd", "=", "False", ",", "inline", "=", "False", ",", "relative", "=", "True", ",", "pack", "=", "False", ",", "encoding", "=", "'utf-8'", ")", ...
Save workflow to file For nlppln, the default is to save workflows with relative paths.
[ "Save", "workflow", "to", "file" ]
1155191921289a65ba2becd2bf8dfabb48eaf1f1
https://github.com/nlppln/nlppln/blob/1155191921289a65ba2becd2bf8dfabb48eaf1f1/nlppln/wfgenerator.py#L15-L28
train
sileht/python-jsonpath-rw-ext
jsonpath_rw_ext/parser.py
match
def match(pattern, data, **parse_kwargs): """Returns all matched values of pattern in data""" return [m.value for m in parse(pattern, **parse_kwargs).find(data)]
python
def match(pattern, data, **parse_kwargs): """Returns all matched values of pattern in data""" return [m.value for m in parse(pattern, **parse_kwargs).find(data)]
[ "def", "match", "(", "pattern", ",", "data", ",", "**", "parse_kwargs", ")", ":", "return", "[", "m", ".", "value", "for", "m", "in", "parse", "(", "pattern", ",", "**", "parse_kwargs", ")", ".", "find", "(", "data", ")", "]" ]
Returns all matched values of pattern in data
[ "Returns", "all", "matched", "values", "of", "pattern", "in", "data" ]
30dd6f209ae16d448e1e071aac90cc9d3f10cff5
https://github.com/sileht/python-jsonpath-rw-ext/blob/30dd6f209ae16d448e1e071aac90cc9d3f10cff5/jsonpath_rw_ext/parser.py#L182-L184
train
sileht/python-jsonpath-rw-ext
jsonpath_rw_ext/parser.py
match1
def match1(pattern, data, **parse_kwargs): """Returns first matched value of pattern in data or None if no matches""" matches = match(pattern, data, **parse_kwargs) return matches[0] if matches else None
python
def match1(pattern, data, **parse_kwargs): """Returns first matched value of pattern in data or None if no matches""" matches = match(pattern, data, **parse_kwargs) return matches[0] if matches else None
[ "def", "match1", "(", "pattern", ",", "data", ",", "**", "parse_kwargs", ")", ":", "matches", "=", "match", "(", "pattern", ",", "data", ",", "**", "parse_kwargs", ")", "return", "matches", "[", "0", "]", "if", "matches", "else", "None" ]
Returns first matched value of pattern in data or None if no matches
[ "Returns", "first", "matched", "value", "of", "pattern", "in", "data", "or", "None", "if", "no", "matches" ]
30dd6f209ae16d448e1e071aac90cc9d3f10cff5
https://github.com/sileht/python-jsonpath-rw-ext/blob/30dd6f209ae16d448e1e071aac90cc9d3f10cff5/jsonpath_rw_ext/parser.py#L187-L190
train
nlppln/nlppln
nlppln/commands/create_chunked_list.py
create_chunked_list
def create_chunked_list(in_dir, size, out_dir, out_name): """Create a division of the input files in chunks. The result is stored to a JSON file. """ create_dirs(out_dir) in_files = get_files(in_dir) chunks = chunk(in_files, size) division = {} for i, files in enumerate(chunks): ...
python
def create_chunked_list(in_dir, size, out_dir, out_name): """Create a division of the input files in chunks. The result is stored to a JSON file. """ create_dirs(out_dir) in_files = get_files(in_dir) chunks = chunk(in_files, size) division = {} for i, files in enumerate(chunks): ...
[ "def", "create_chunked_list", "(", "in_dir", ",", "size", ",", "out_dir", ",", "out_name", ")", ":", "create_dirs", "(", "out_dir", ")", "in_files", "=", "get_files", "(", "in_dir", ")", "chunks", "=", "chunk", "(", "in_files", ",", "size", ")", "division"...
Create a division of the input files in chunks. The result is stored to a JSON file.
[ "Create", "a", "division", "of", "the", "input", "files", "in", "chunks", "." ]
1155191921289a65ba2becd2bf8dfabb48eaf1f1
https://github.com/nlppln/nlppln/blob/1155191921289a65ba2becd2bf8dfabb48eaf1f1/nlppln/commands/create_chunked_list.py#L22-L39
train
nlppln/nlppln
nlppln/utils.py
remove_ext
def remove_ext(fname): """Removes the extension from a filename """ bn = os.path.basename(fname) return os.path.splitext(bn)[0]
python
def remove_ext(fname): """Removes the extension from a filename """ bn = os.path.basename(fname) return os.path.splitext(bn)[0]
[ "def", "remove_ext", "(", "fname", ")", ":", "bn", "=", "os", ".", "path", ".", "basename", "(", "fname", ")", "return", "os", ".", "path", ".", "splitext", "(", "bn", ")", "[", "0", "]" ]
Removes the extension from a filename
[ "Removes", "the", "extension", "from", "a", "filename" ]
1155191921289a65ba2becd2bf8dfabb48eaf1f1
https://github.com/nlppln/nlppln/blob/1155191921289a65ba2becd2bf8dfabb48eaf1f1/nlppln/utils.py#L14-L18
train
nlppln/nlppln
nlppln/utils.py
out_file_name
def out_file_name(out_dir, fname, ext=None): """Return path of output file, given a directory, file name and extension. If fname is a path, it is converted to its basename. Args: out_dir (str): path to the directory where output should be written. fname (str): path to the input file. ...
python
def out_file_name(out_dir, fname, ext=None): """Return path of output file, given a directory, file name and extension. If fname is a path, it is converted to its basename. Args: out_dir (str): path to the directory where output should be written. fname (str): path to the input file. ...
[ "def", "out_file_name", "(", "out_dir", ",", "fname", ",", "ext", "=", "None", ")", ":", "if", "ext", "is", "None", ":", "return", "os", ".", "path", ".", "join", "(", "out_dir", ",", "os", ".", "path", ".", "basename", "(", "fname", ")", ")", "f...
Return path of output file, given a directory, file name and extension. If fname is a path, it is converted to its basename. Args: out_dir (str): path to the directory where output should be written. fname (str): path to the input file. ext (str): file extension of the output file (def...
[ "Return", "path", "of", "output", "file", "given", "a", "directory", "file", "name", "and", "extension", "." ]
1155191921289a65ba2becd2bf8dfabb48eaf1f1
https://github.com/nlppln/nlppln/blob/1155191921289a65ba2becd2bf8dfabb48eaf1f1/nlppln/utils.py#L34-L52
train
nlppln/nlppln
nlppln/utils.py
get_files
def get_files(directory, recursive=False): """Return a list of all files in the directory.""" files_out = [] if recursive: for root, dirs, files in os.walk(os.path.abspath(directory)): files = [os.path.join(root, f) for f in files] files_out.append(files) files_out = ...
python
def get_files(directory, recursive=False): """Return a list of all files in the directory.""" files_out = [] if recursive: for root, dirs, files in os.walk(os.path.abspath(directory)): files = [os.path.join(root, f) for f in files] files_out.append(files) files_out = ...
[ "def", "get_files", "(", "directory", ",", "recursive", "=", "False", ")", ":", "files_out", "=", "[", "]", "if", "recursive", ":", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "os", ".", "path", ".", "abspath", "(", "dir...
Return a list of all files in the directory.
[ "Return", "a", "list", "of", "all", "files", "in", "the", "directory", "." ]
1155191921289a65ba2becd2bf8dfabb48eaf1f1
https://github.com/nlppln/nlppln/blob/1155191921289a65ba2becd2bf8dfabb48eaf1f1/nlppln/utils.py#L59-L72
train
gplepage/lsqfit
src/lsqfit/__init__.py
_reformat
def _reformat(p, buf): """ Apply format of ``p`` to data in 1-d array ``buf``. """ if numpy.ndim(buf) != 1: raise ValueError("Buffer ``buf`` must be 1-d.") if hasattr(p, 'keys'): ans = _gvar.BufferDict(p) if ans.size != len(buf): raise ValueError( # ...
python
def _reformat(p, buf): """ Apply format of ``p`` to data in 1-d array ``buf``. """ if numpy.ndim(buf) != 1: raise ValueError("Buffer ``buf`` must be 1-d.") if hasattr(p, 'keys'): ans = _gvar.BufferDict(p) if ans.size != len(buf): raise ValueError( # ...
[ "def", "_reformat", "(", "p", ",", "buf", ")", ":", "if", "numpy", ".", "ndim", "(", "buf", ")", "!=", "1", ":", "raise", "ValueError", "(", "\"Buffer ``buf`` must be 1-d.\"", ")", "if", "hasattr", "(", "p", ",", "'keys'", ")", ":", "ans", "=", "_gva...
Apply format of ``p`` to data in 1-d array ``buf``.
[ "Apply", "format", "of", "p", "to", "data", "in", "1", "-", "d", "array", "buf", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/__init__.py#L1543-L1558
train
gplepage/lsqfit
src/lsqfit/__init__.py
_unpack_gvars
def _unpack_gvars(g): """ Unpack collection of GVars to BufferDict or numpy array. """ if g is not None: g = _gvar.gvar(g) if not hasattr(g, 'flat'): # must be a scalar (ie, not an array and not a dictionary) g = numpy.asarray(g) return g
python
def _unpack_gvars(g): """ Unpack collection of GVars to BufferDict or numpy array. """ if g is not None: g = _gvar.gvar(g) if not hasattr(g, 'flat'): # must be a scalar (ie, not an array and not a dictionary) g = numpy.asarray(g) return g
[ "def", "_unpack_gvars", "(", "g", ")", ":", "if", "g", "is", "not", "None", ":", "g", "=", "_gvar", ".", "gvar", "(", "g", ")", "if", "not", "hasattr", "(", "g", ",", "'flat'", ")", ":", "g", "=", "numpy", ".", "asarray", "(", "g", ")", "retu...
Unpack collection of GVars to BufferDict or numpy array.
[ "Unpack", "collection", "of", "GVars", "to", "BufferDict", "or", "numpy", "array", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/__init__.py#L1658-L1665
train
gplepage/lsqfit
src/lsqfit/__init__.py
_unpack_p0
def _unpack_p0(p0, p0file, prior): """ Create proper p0. Try to read from a file. If that doesn't work, try using p0, and then, finally, the prior. If the p0 is from the file, it is checked against the prior to make sure that all elements have the right shape; if not the p0 elements are adjusted (u...
python
def _unpack_p0(p0, p0file, prior): """ Create proper p0. Try to read from a file. If that doesn't work, try using p0, and then, finally, the prior. If the p0 is from the file, it is checked against the prior to make sure that all elements have the right shape; if not the p0 elements are adjusted (u...
[ "def", "_unpack_p0", "(", "p0", ",", "p0file", ",", "prior", ")", ":", "if", "p0file", "is", "not", "None", ":", "try", ":", "with", "open", "(", "p0file", ",", "\"rb\"", ")", "as", "f", ":", "p0", "=", "pickle", ".", "load", "(", "f", ")", "ex...
Create proper p0. Try to read from a file. If that doesn't work, try using p0, and then, finally, the prior. If the p0 is from the file, it is checked against the prior to make sure that all elements have the right shape; if not the p0 elements are adjusted (using info from the prior) to be the cor...
[ "Create", "proper", "p0", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/__init__.py#L1667-L1754
train
gplepage/lsqfit
src/lsqfit/__init__.py
_unpack_fcn
def _unpack_fcn(fcn, p0, y, x): """ reconfigure fitting fcn so inputs, outputs = flat arrays; hide x """ if y.shape is not None: if p0.shape is not None: def nfcn(p, x=x, fcn=fcn, pshape=p0.shape): po = p.reshape(pshape) ans = fcn(po) if x is False else fcn(x,...
python
def _unpack_fcn(fcn, p0, y, x): """ reconfigure fitting fcn so inputs, outputs = flat arrays; hide x """ if y.shape is not None: if p0.shape is not None: def nfcn(p, x=x, fcn=fcn, pshape=p0.shape): po = p.reshape(pshape) ans = fcn(po) if x is False else fcn(x,...
[ "def", "_unpack_fcn", "(", "fcn", ",", "p0", ",", "y", ",", "x", ")", ":", "if", "y", ".", "shape", "is", "not", "None", ":", "if", "p0", ".", "shape", "is", "not", "None", ":", "def", "nfcn", "(", "p", ",", "x", "=", "x", ",", "fcn", "=", ...
reconfigure fitting fcn so inputs, outputs = flat arrays; hide x
[ "reconfigure", "fitting", "fcn", "so", "inputs", "outputs", "=", "flat", "arrays", ";", "hide", "x" ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/__init__.py#L1757-L1794
train
gplepage/lsqfit
src/lsqfit/__init__.py
nonlinear_fit.check_roundoff
def check_roundoff(self, rtol=0.25, atol=1e-6): """ Check for roundoff errors in fit.p. Compares standard deviations from fit.p and fit.palt to see if they agree to within relative tolerance ``rtol`` and absolute tolerance ``atol``. Generates a warning if they do not (in which c...
python
def check_roundoff(self, rtol=0.25, atol=1e-6): """ Check for roundoff errors in fit.p. Compares standard deviations from fit.p and fit.palt to see if they agree to within relative tolerance ``rtol`` and absolute tolerance ``atol``. Generates a warning if they do not (in which c...
[ "def", "check_roundoff", "(", "self", ",", "rtol", "=", "0.25", ",", "atol", "=", "1e-6", ")", ":", "psdev", "=", "_gvar", ".", "sdev", "(", "self", ".", "p", ".", "flat", ")", "paltsdev", "=", "_gvar", ".", "sdev", "(", "self", ".", "palt", ".",...
Check for roundoff errors in fit.p. Compares standard deviations from fit.p and fit.palt to see if they agree to within relative tolerance ``rtol`` and absolute tolerance ``atol``. Generates a warning if they do not (in which case an SVD cut might be advisable).
[ "Check", "for", "roundoff", "errors", "in", "fit", ".", "p", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/__init__.py#L831-L842
train
gplepage/lsqfit
src/lsqfit/__init__.py
nonlinear_fit.plot_residuals
def plot_residuals(self, plot=None): """ Plot normalized fit residuals. The sum of the squares of the residuals equals ``self.chi2``. Individual residuals should be distributed about one, in a Gaussian distribution. Args: plot: :mod:`matplotlib` plotter. If ``None``...
python
def plot_residuals(self, plot=None): """ Plot normalized fit residuals. The sum of the squares of the residuals equals ``self.chi2``. Individual residuals should be distributed about one, in a Gaussian distribution. Args: plot: :mod:`matplotlib` plotter. If ``None``...
[ "def", "plot_residuals", "(", "self", ",", "plot", "=", "None", ")", ":", "if", "plot", "is", "None", ":", "import", "matplotlib", ".", "pyplot", "as", "plot", "x", "=", "numpy", ".", "arange", "(", "1", ",", "len", "(", "self", ".", "residuals", "...
Plot normalized fit residuals. The sum of the squares of the residuals equals ``self.chi2``. Individual residuals should be distributed about one, in a Gaussian distribution. Args: plot: :mod:`matplotlib` plotter. If ``None``, uses ``matplotlib.pyplot`. ...
[ "Plot", "normalized", "fit", "residuals", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/__init__.py#L875-L901
train
gplepage/lsqfit
src/lsqfit/__init__.py
nonlinear_fit.load_parameters
def load_parameters(filename): """ Load parameters stored in file ``filename``. ``p = nonlinear_fit.load_p(filename)`` is used to recover the values of fit parameters dumped using ``fit.dump_p(filename)`` (or ``fit.dump_pmean(filename)``) where ``fit`` is of type :class:`lsqfit....
python
def load_parameters(filename): """ Load parameters stored in file ``filename``. ``p = nonlinear_fit.load_p(filename)`` is used to recover the values of fit parameters dumped using ``fit.dump_p(filename)`` (or ``fit.dump_pmean(filename)``) where ``fit`` is of type :class:`lsqfit....
[ "def", "load_parameters", "(", "filename", ")", ":", "warnings", ".", "warn", "(", "\"nonlinear_fit.load_parameters deprecated; use pickle.load or gvar.load instead\"", ",", "DeprecationWarning", ",", ")", "with", "open", "(", "filename", ",", "\"rb\"", ")", "as", "f", ...
Load parameters stored in file ``filename``. ``p = nonlinear_fit.load_p(filename)`` is used to recover the values of fit parameters dumped using ``fit.dump_p(filename)`` (or ``fit.dump_pmean(filename)``) where ``fit`` is of type :class:`lsqfit.nonlinear_fit`. The layout of the returned ...
[ "Load", "parameters", "stored", "in", "file", "filename", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/__init__.py#L1228-L1243
train
gplepage/lsqfit
src/lsqfit/__init__.py
nonlinear_fit.simulated_fit_iter
def simulated_fit_iter( self, n=None, pexact=None, add_priornoise=False, bootstrap=None, **kargs ): """ Iterator that returns simulation copies of a fit. Fit reliability is tested using simulated data which replaces the mean values in ``self.y`` with random numbers drawn...
python
def simulated_fit_iter( self, n=None, pexact=None, add_priornoise=False, bootstrap=None, **kargs ): """ Iterator that returns simulation copies of a fit. Fit reliability is tested using simulated data which replaces the mean values in ``self.y`` with random numbers drawn...
[ "def", "simulated_fit_iter", "(", "self", ",", "n", "=", "None", ",", "pexact", "=", "None", ",", "add_priornoise", "=", "False", ",", "bootstrap", "=", "None", ",", "**", "kargs", ")", ":", "pexact", "=", "self", ".", "pmean", "if", "pexact", "is", ...
Iterator that returns simulation copies of a fit. Fit reliability is tested using simulated data which replaces the mean values in ``self.y`` with random numbers drawn from a distribution whose mean equals ``self.fcn(pexact)`` and whose covariance matrix is the same as ``self.y``'s. Sim...
[ "Iterator", "that", "returns", "simulation", "copies", "of", "a", "fit", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/__init__.py#L1282-L1360
train
gplepage/lsqfit
src/lsqfit/__init__.py
nonlinear_fit.simulated_data_iter
def simulated_data_iter( self, n=None, pexact=None, add_priornoise=False, bootstrap=None ): """ Iterator that returns simulated data based upon a fit's data. Simulated data is generated from a fit's data ``fit.y`` by replacing the mean values in that data with random numbers ...
python
def simulated_data_iter( self, n=None, pexact=None, add_priornoise=False, bootstrap=None ): """ Iterator that returns simulated data based upon a fit's data. Simulated data is generated from a fit's data ``fit.y`` by replacing the mean values in that data with random numbers ...
[ "def", "simulated_data_iter", "(", "self", ",", "n", "=", "None", ",", "pexact", "=", "None", ",", "add_priornoise", "=", "False", ",", "bootstrap", "=", "None", ")", ":", "pexact", "=", "self", ".", "pmean", "if", "pexact", "is", "None", "else", "pexa...
Iterator that returns simulated data based upon a fit's data. Simulated data is generated from a fit's data ``fit.y`` by replacing the mean values in that data with random numbers drawn from a distribution whose mean is ``self.fcn(pexact)`` and whose covariance matrix is the same as tha...
[ "Iterator", "that", "returns", "simulated", "data", "based", "upon", "a", "fit", "s", "data", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/__init__.py#L1362-L1434
train
gplepage/lsqfit
src/lsqfit/_extras.py
chained_nonlinear_fit.formatall
def formatall(self, *args, **kargs): " Add-on method for fits returned by chained_nonlinear_fit. " ans = '' for x in self.chained_fits: ans += 10 * '=' + ' ' + str(x) + '\n' ans += self.chained_fits[x].format(*args, **kargs) ans += '\n' return ans[:-1]
python
def formatall(self, *args, **kargs): " Add-on method for fits returned by chained_nonlinear_fit. " ans = '' for x in self.chained_fits: ans += 10 * '=' + ' ' + str(x) + '\n' ans += self.chained_fits[x].format(*args, **kargs) ans += '\n' return ans[:-1]
[ "def", "formatall", "(", "self", ",", "*", "args", ",", "**", "kargs", ")", ":", "\" Add-on method for fits returned by chained_nonlinear_fit. \"", "ans", "=", "''", "for", "x", "in", "self", ".", "chained_fits", ":", "ans", "+=", "10", "*", "'='", "+", "' '...
Add-on method for fits returned by chained_nonlinear_fit.
[ "Add", "-", "on", "method", "for", "fits", "returned", "by", "chained_nonlinear_fit", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/_extras.py#L758-L765
train
gplepage/lsqfit
src/lsqfit/_extras.py
MultiFitter.set
def set(self, **kargs): """ Reset default keyword parameters. Assigns new default values from dictionary ``kargs`` to the fitter's keyword parameters. Keywords for the underlying :mod:`lsqfit` fitters can also be included (or grouped together in dictionary ``fitterargs``). ...
python
def set(self, **kargs): """ Reset default keyword parameters. Assigns new default values from dictionary ``kargs`` to the fitter's keyword parameters. Keywords for the underlying :mod:`lsqfit` fitters can also be included (or grouped together in dictionary ``fitterargs``). ...
[ "def", "set", "(", "self", ",", "**", "kargs", ")", ":", "kwords", "=", "set", "(", "[", "'mopt'", ",", "'fast'", ",", "'ratio'", ",", "'wavg_kargs'", ",", "'wavg_all'", ",", "'fitterargs'", ",", "'fitname'", ",", "]", ")", "kargs", "=", "dict", "(",...
Reset default keyword parameters. Assigns new default values from dictionary ``kargs`` to the fitter's keyword parameters. Keywords for the underlying :mod:`lsqfit` fitters can also be included (or grouped together in dictionary ``fitterargs``). Returns tuple ``(kargs, oldkarg...
[ "Reset", "default", "keyword", "parameters", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/_extras.py#L837-L878
train
gplepage/lsqfit
src/lsqfit/_extras.py
MultiFitter.buildfitfcn
def buildfitfcn(self): """ Create fit function to fit models in list ``models``. """ def _fitfcn(p, flatmodels=self.flatmodels): ans = gvar.BufferDict() for m in flatmodels: ans[m.datatag] = ( m.fitfcn(p) if m.ncg <= 1 else ...
python
def buildfitfcn(self): """ Create fit function to fit models in list ``models``. """ def _fitfcn(p, flatmodels=self.flatmodels): ans = gvar.BufferDict() for m in flatmodels: ans[m.datatag] = ( m.fitfcn(p) if m.ncg <= 1 else ...
[ "def", "buildfitfcn", "(", "self", ")", ":", "def", "_fitfcn", "(", "p", ",", "flatmodels", "=", "self", ".", "flatmodels", ")", ":", "ans", "=", "gvar", ".", "BufferDict", "(", ")", "for", "m", "in", "flatmodels", ":", "ans", "[", "m", ".", "datat...
Create fit function to fit models in list ``models``.
[ "Create", "fit", "function", "to", "fit", "models", "in", "list", "models", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/_extras.py#L880-L890
train
gplepage/lsqfit
src/lsqfit/_extras.py
MultiFitter.builddata
def builddata(self, mopt=None, data=None, pdata=None, prior=None): """ Rebuild pdata to account for marginalization. """ if pdata is None: if data is None: raise ValueError('no data or pdata') pdata = gvar.BufferDict() for m in self.flatmodels: ...
python
def builddata(self, mopt=None, data=None, pdata=None, prior=None): """ Rebuild pdata to account for marginalization. """ if pdata is None: if data is None: raise ValueError('no data or pdata') pdata = gvar.BufferDict() for m in self.flatmodels: ...
[ "def", "builddata", "(", "self", ",", "mopt", "=", "None", ",", "data", "=", "None", ",", "pdata", "=", "None", ",", "prior", "=", "None", ")", ":", "if", "pdata", "is", "None", ":", "if", "data", "is", "None", ":", "raise", "ValueError", "(", "'...
Rebuild pdata to account for marginalization.
[ "Rebuild", "pdata", "to", "account", "for", "marginalization", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/_extras.py#L892-L927
train
gplepage/lsqfit
src/lsqfit/_extras.py
MultiFitter.buildprior
def buildprior(self, prior, mopt=None): """ Create prior to fit models in list ``models``. """ nprior = gvar.BufferDict() for m in self.flatmodels: nprior.update(m.buildprior( prior, mopt=mopt, )) if not self.fast: for k in prior: ...
python
def buildprior(self, prior, mopt=None): """ Create prior to fit models in list ``models``. """ nprior = gvar.BufferDict() for m in self.flatmodels: nprior.update(m.buildprior( prior, mopt=mopt, )) if not self.fast: for k in prior: ...
[ "def", "buildprior", "(", "self", ",", "prior", ",", "mopt", "=", "None", ")", ":", "nprior", "=", "gvar", ".", "BufferDict", "(", ")", "for", "m", "in", "self", ".", "flatmodels", ":", "nprior", ".", "update", "(", "m", ".", "buildprior", "(", "pr...
Create prior to fit models in list ``models``.
[ "Create", "prior", "to", "fit", "models", "in", "list", "models", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/_extras.py#L929-L940
train
gplepage/lsqfit
src/lsqfit/_extras.py
MultiFitter._flatten_models
def _flatten_models(tasklist): " Create 1d-array containing all disctinct models from ``tasklist``. " ans = gvar.BufferDict() for task, mlist in tasklist: if task != 'fit': continue for m in mlist: id_m = id(m) if id_m not i...
python
def _flatten_models(tasklist): " Create 1d-array containing all disctinct models from ``tasklist``. " ans = gvar.BufferDict() for task, mlist in tasklist: if task != 'fit': continue for m in mlist: id_m = id(m) if id_m not i...
[ "def", "_flatten_models", "(", "tasklist", ")", ":", "\" Create 1d-array containing all disctinct models from ``tasklist``. \"", "ans", "=", "gvar", ".", "BufferDict", "(", ")", "for", "task", ",", "mlist", "in", "tasklist", ":", "if", "task", "!=", "'fit'", ":", ...
Create 1d-array containing all disctinct models from ``tasklist``.
[ "Create", "1d", "-", "array", "containing", "all", "disctinct", "models", "from", "tasklist", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/_extras.py#L943-L953
train
gplepage/lsqfit
src/lsqfit/_extras.py
MultiFitter.flatten_models
def flatten_models(models): " Create 1d-array containing all disctinct models from ``models``. " if isinstance(models, MultiFitterModel): ans = [models] else: tasklist = MultiFitter._compile_models(models) ans = MultiFitter._flatten_models(tasklist) re...
python
def flatten_models(models): " Create 1d-array containing all disctinct models from ``models``. " if isinstance(models, MultiFitterModel): ans = [models] else: tasklist = MultiFitter._compile_models(models) ans = MultiFitter._flatten_models(tasklist) re...
[ "def", "flatten_models", "(", "models", ")", ":", "\" Create 1d-array containing all disctinct models from ``models``. \"", "if", "isinstance", "(", "models", ",", "MultiFitterModel", ")", ":", "ans", "=", "[", "models", "]", "else", ":", "tasklist", "=", "MultiFitter...
Create 1d-array containing all disctinct models from ``models``.
[ "Create", "1d", "-", "array", "containing", "all", "disctinct", "models", "from", "models", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/_extras.py#L956-L963
train
gplepage/lsqfit
src/lsqfit/_extras.py
MultiFitter.lsqfit
def lsqfit(self, data=None, pdata=None, prior=None, p0=None, **kargs): """ Compute least-squares fit of models to data. :meth:`MultiFitter.lsqfit` fits all of the models together, in a single fit. It returns the |nonlinear_fit| object from the fit. To see plots of the fit data divided ...
python
def lsqfit(self, data=None, pdata=None, prior=None, p0=None, **kargs): """ Compute least-squares fit of models to data. :meth:`MultiFitter.lsqfit` fits all of the models together, in a single fit. It returns the |nonlinear_fit| object from the fit. To see plots of the fit data divided ...
[ "def", "lsqfit", "(", "self", ",", "data", "=", "None", ",", "pdata", "=", "None", ",", "prior", "=", "None", ",", "p0", "=", "None", ",", "**", "kargs", ")", ":", "if", "prior", "is", "None", ":", "raise", "ValueError", "(", "'no prior'", ")", "...
Compute least-squares fit of models to data. :meth:`MultiFitter.lsqfit` fits all of the models together, in a single fit. It returns the |nonlinear_fit| object from the fit. To see plots of the fit data divided by the fit function with the best-fit parameters use fit.show_...
[ "Compute", "least", "-", "squares", "fit", "of", "models", "to", "data", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/_extras.py#L965-L1071
train
gplepage/lsqfit
src/lsqfit/_extras.py
MultiFitter._compile_models
def _compile_models(models): """ Convert ``models`` into a list of tasks. Each task is tuple ``(name, data)`` where ``name`` indicates the task task and ``data`` is the relevant data for that task. Supported tasks and data: - ``'fit'`` and list of models - ``'...
python
def _compile_models(models): """ Convert ``models`` into a list of tasks. Each task is tuple ``(name, data)`` where ``name`` indicates the task task and ``data`` is the relevant data for that task. Supported tasks and data: - ``'fit'`` and list of models - ``'...
[ "def", "_compile_models", "(", "models", ")", ":", "tasklist", "=", "[", "]", "for", "m", "in", "models", ":", "if", "isinstance", "(", "m", ",", "MultiFitterModel", ")", ":", "tasklist", "+=", "[", "(", "'fit'", ",", "[", "m", "]", ")", "]", "task...
Convert ``models`` into a list of tasks. Each task is tuple ``(name, data)`` where ``name`` indicates the task task and ``data`` is the relevant data for that task. Supported tasks and data: - ``'fit'`` and list of models - ``'update-kargs'`` and ``None`` ...
[ "Convert", "models", "into", "a", "list", "of", "tasks", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/_extras.py#L1250-L1290
train
gplepage/lsqfit
src/lsqfit/_extras.py
MultiFitter.coarse_grain
def coarse_grain(G, ncg): """ Coarse-grain last index of array ``G``. Bin the last index of array ``G`` in bins of width ``ncg``, and replace each bin by its average. Return the binned results. Args: G: Array to be coarse-grained. ncg: Bin width for coarse-grain...
python
def coarse_grain(G, ncg): """ Coarse-grain last index of array ``G``. Bin the last index of array ``G`` in bins of width ``ncg``, and replace each bin by its average. Return the binned results. Args: G: Array to be coarse-grained. ncg: Bin width for coarse-grain...
[ "def", "coarse_grain", "(", "G", ",", "ncg", ")", ":", "if", "ncg", "<=", "1", ":", "return", "G", "G", "=", "numpy", ".", "asarray", "(", "G", ")", "nbin", ",", "remainder", "=", "divmod", "(", "G", ".", "shape", "[", "-", "1", "]", ",", "nc...
Coarse-grain last index of array ``G``. Bin the last index of array ``G`` in bins of width ``ncg``, and replace each bin by its average. Return the binned results. Args: G: Array to be coarse-grained. ncg: Bin width for coarse-graining.
[ "Coarse", "-", "grain", "last", "index", "of", "array", "G", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/_extras.py#L1355-L1374
train
gplepage/lsqfit
src/lsqfit/_extras.py
MultiFitter.process_data
def process_data(data, models): """ Convert ``data`` to processed data using ``models``. Data from dictionary ``data`` is processed by each model in list ``models``, and the results collected into a new dictionary ``pdata`` for use in :meth:`MultiFitter.lsqfit` and :meth:`MultiF...
python
def process_data(data, models): """ Convert ``data`` to processed data using ``models``. Data from dictionary ``data`` is processed by each model in list ``models``, and the results collected into a new dictionary ``pdata`` for use in :meth:`MultiFitter.lsqfit` and :meth:`MultiF...
[ "def", "process_data", "(", "data", ",", "models", ")", ":", "pdata", "=", "gvar", ".", "BufferDict", "(", ")", "for", "m", "in", "MultiFitter", ".", "flatten_models", "(", "models", ")", ":", "pdata", "[", "m", ".", "datatag", "]", "=", "(", "m", ...
Convert ``data`` to processed data using ``models``. Data from dictionary ``data`` is processed by each model in list ``models``, and the results collected into a new dictionary ``pdata`` for use in :meth:`MultiFitter.lsqfit` and :meth:`MultiFitter.chained_lsqft`.
[ "Convert", "data", "to", "processed", "data", "using", "models", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/_extras.py#L1377-L1391
train
gplepage/lsqfit
src/lsqfit/_extras.py
MultiFitter.process_dataset
def process_dataset(dataset, models, **kargs): """ Convert ``dataset`` to processed data using ``models``. :class:`gvar.dataset.Dataset` (or similar dictionary) object ``dataset`` is processed by each model in list ``models``, and the results collected into a new dictionary ``pdata`` fo...
python
def process_dataset(dataset, models, **kargs): """ Convert ``dataset`` to processed data using ``models``. :class:`gvar.dataset.Dataset` (or similar dictionary) object ``dataset`` is processed by each model in list ``models``, and the results collected into a new dictionary ``pdata`` fo...
[ "def", "process_dataset", "(", "dataset", ",", "models", ",", "**", "kargs", ")", ":", "dset", "=", "collections", ".", "OrderedDict", "(", ")", "for", "m", "in", "MultiFitter", ".", "flatten_models", "(", "models", ")", ":", "dset", "[", "m", ".", "da...
Convert ``dataset`` to processed data using ``models``. :class:`gvar.dataset.Dataset` (or similar dictionary) object ``dataset`` is processed by each model in list ``models``, and the results collected into a new dictionary ``pdata`` for use in :meth:`MultiFitter.lsqfit` and :meth:`Mult...
[ "Convert", "dataset", "to", "processed", "data", "using", "models", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/src/lsqfit/_extras.py#L1394-L1412
train
gplepage/lsqfit
examples/multifitter.py
Linear.buildprior
def buildprior(self, prior, mopt=None, extend=False): " Extract the model's parameters from prior. " newprior = {} # allow for log-normal, etc priors intercept, slope = gv.get_dictkeys( prior, [self.intercept, self.slope] ) newprior[intercept] = prior[inte...
python
def buildprior(self, prior, mopt=None, extend=False): " Extract the model's parameters from prior. " newprior = {} # allow for log-normal, etc priors intercept, slope = gv.get_dictkeys( prior, [self.intercept, self.slope] ) newprior[intercept] = prior[inte...
[ "def", "buildprior", "(", "self", ",", "prior", ",", "mopt", "=", "None", ",", "extend", "=", "False", ")", ":", "\" Extract the model's parameters from prior. \"", "newprior", "=", "{", "}", "intercept", ",", "slope", "=", "gv", ".", "get_dictkeys", "(", "p...
Extract the model's parameters from prior.
[ "Extract", "the", "model", "s", "parameters", "from", "prior", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/examples/multifitter.py#L98-L109
train
gplepage/lsqfit
examples/pendulum.py
show_plot
def show_plot(t_array, th_array): """ Display theta vs t plot. """ th_mean = gv.mean(th_array) th_sdev = gv.sdev(th_array) thp = th_mean + th_sdev thm = th_mean - th_sdev plt.fill_between(t_array, thp, thm, color='0.8') plt.plot(t_array, th_mean, linewidth=0.5) plt.xlabel('$t$') plt....
python
def show_plot(t_array, th_array): """ Display theta vs t plot. """ th_mean = gv.mean(th_array) th_sdev = gv.sdev(th_array) thp = th_mean + th_sdev thm = th_mean - th_sdev plt.fill_between(t_array, thp, thm, color='0.8') plt.plot(t_array, th_mean, linewidth=0.5) plt.xlabel('$t$') plt....
[ "def", "show_plot", "(", "t_array", ",", "th_array", ")", ":", "th_mean", "=", "gv", ".", "mean", "(", "th_array", ")", "th_sdev", "=", "gv", ".", "sdev", "(", "th_array", ")", "thp", "=", "th_mean", "+", "th_sdev", "thm", "=", "th_mean", "-", "th_sd...
Display theta vs t plot.
[ "Display", "theta", "vs", "t", "plot", "." ]
6a57fd687632c175fccb47d8e8e943cda5e9ce9d
https://github.com/gplepage/lsqfit/blob/6a57fd687632c175fccb47d8e8e943cda5e9ce9d/examples/pendulum.py#L127-L138
train
obsrvbl/flowlogs-reader
flowlogs_reader/aggregation.py
aggregated_records
def aggregated_records(all_records, key_fields=KEY_FIELDS): """ Yield dicts that correspond to aggregates of the flow records given by the sequence of FlowRecords in `all_records`. Skips incomplete records. This will consume the `all_records` iterator, and requires enough memory to be able to read i...
python
def aggregated_records(all_records, key_fields=KEY_FIELDS): """ Yield dicts that correspond to aggregates of the flow records given by the sequence of FlowRecords in `all_records`. Skips incomplete records. This will consume the `all_records` iterator, and requires enough memory to be able to read i...
[ "def", "aggregated_records", "(", "all_records", ",", "key_fields", "=", "KEY_FIELDS", ")", ":", "flow_table", "=", "defaultdict", "(", "_FlowStats", ")", "for", "flow_record", "in", "all_records", ":", "key", "=", "tuple", "(", "getattr", "(", "flow_record", ...
Yield dicts that correspond to aggregates of the flow records given by the sequence of FlowRecords in `all_records`. Skips incomplete records. This will consume the `all_records` iterator, and requires enough memory to be able to read it entirely. `key_fields` optionally contains the fields over which t...
[ "Yield", "dicts", "that", "correspond", "to", "aggregates", "of", "the", "flow", "records", "given", "by", "the", "sequence", "of", "FlowRecords", "in", "all_records", ".", "Skips", "incomplete", "records", ".", "This", "will", "consume", "the", "all_records", ...
248d8cb3cc586859b6744d30cebce0f359d9900c
https://github.com/obsrvbl/flowlogs-reader/blob/248d8cb3cc586859b6744d30cebce0f359d9900c/flowlogs_reader/aggregation.py#L48-L67
train
obsrvbl/flowlogs-reader
flowlogs_reader/__main__.py
action_print
def action_print(reader, *args): """Simply print the Flow Log records to output.""" arg_count = len(args) if arg_count == 0: stop_after = 0 elif arg_count == 1: stop_after = int(args[0]) else: raise RuntimeError("0 or 1 arguments expected for action 'print'") for i, reco...
python
def action_print(reader, *args): """Simply print the Flow Log records to output.""" arg_count = len(args) if arg_count == 0: stop_after = 0 elif arg_count == 1: stop_after = int(args[0]) else: raise RuntimeError("0 or 1 arguments expected for action 'print'") for i, reco...
[ "def", "action_print", "(", "reader", ",", "*", "args", ")", ":", "arg_count", "=", "len", "(", "args", ")", "if", "arg_count", "==", "0", ":", "stop_after", "=", "0", "elif", "arg_count", "==", "1", ":", "stop_after", "=", "int", "(", "args", "[", ...
Simply print the Flow Log records to output.
[ "Simply", "print", "the", "Flow", "Log", "records", "to", "output", "." ]
248d8cb3cc586859b6744d30cebce0f359d9900c
https://github.com/obsrvbl/flowlogs-reader/blob/248d8cb3cc586859b6744d30cebce0f359d9900c/flowlogs_reader/__main__.py#L31-L44
train
obsrvbl/flowlogs-reader
flowlogs_reader/__main__.py
action_ipset
def action_ipset(reader, *args): """Show the set of IPs seen in Flow Log records.""" ip_set = set() for record in reader: if record.log_status in (SKIPDATA, NODATA): continue ip_set.add(record.srcaddr) ip_set.add(record.dstaddr) for ip in ip_set: print(ip)
python
def action_ipset(reader, *args): """Show the set of IPs seen in Flow Log records.""" ip_set = set() for record in reader: if record.log_status in (SKIPDATA, NODATA): continue ip_set.add(record.srcaddr) ip_set.add(record.dstaddr) for ip in ip_set: print(ip)
[ "def", "action_ipset", "(", "reader", ",", "*", "args", ")", ":", "ip_set", "=", "set", "(", ")", "for", "record", "in", "reader", ":", "if", "record", ".", "log_status", "in", "(", "SKIPDATA", ",", "NODATA", ")", ":", "continue", "ip_set", ".", "add...
Show the set of IPs seen in Flow Log records.
[ "Show", "the", "set", "of", "IPs", "seen", "in", "Flow", "Log", "records", "." ]
248d8cb3cc586859b6744d30cebce0f359d9900c
https://github.com/obsrvbl/flowlogs-reader/blob/248d8cb3cc586859b6744d30cebce0f359d9900c/flowlogs_reader/__main__.py#L50-L60
train
obsrvbl/flowlogs-reader
flowlogs_reader/__main__.py
action_findip
def action_findip(reader, *args): """Find Flow Log records involving a specific IP or IPs.""" target_ips = set(args) for record in reader: if (record.srcaddr in target_ips) or (record.dstaddr in target_ips): print(record.to_message())
python
def action_findip(reader, *args): """Find Flow Log records involving a specific IP or IPs.""" target_ips = set(args) for record in reader: if (record.srcaddr in target_ips) or (record.dstaddr in target_ips): print(record.to_message())
[ "def", "action_findip", "(", "reader", ",", "*", "args", ")", ":", "target_ips", "=", "set", "(", "args", ")", "for", "record", "in", "reader", ":", "if", "(", "record", ".", "srcaddr", "in", "target_ips", ")", "or", "(", "record", ".", "dstaddr", "i...
Find Flow Log records involving a specific IP or IPs.
[ "Find", "Flow", "Log", "records", "involving", "a", "specific", "IP", "or", "IPs", "." ]
248d8cb3cc586859b6744d30cebce0f359d9900c
https://github.com/obsrvbl/flowlogs-reader/blob/248d8cb3cc586859b6744d30cebce0f359d9900c/flowlogs_reader/__main__.py#L66-L71
train
obsrvbl/flowlogs-reader
flowlogs_reader/__main__.py
action_aggregate
def action_aggregate(reader, *args): """Aggregate flow records by 5-tuple and print a tab-separated stream""" all_aggregated = aggregated_records(reader) first_row = next(all_aggregated) keys = sorted(first_row.keys()) print(*keys, sep='\t') # Join the first row with the rest of the rows and pr...
python
def action_aggregate(reader, *args): """Aggregate flow records by 5-tuple and print a tab-separated stream""" all_aggregated = aggregated_records(reader) first_row = next(all_aggregated) keys = sorted(first_row.keys()) print(*keys, sep='\t') # Join the first row with the rest of the rows and pr...
[ "def", "action_aggregate", "(", "reader", ",", "*", "args", ")", ":", "all_aggregated", "=", "aggregated_records", "(", "reader", ")", "first_row", "=", "next", "(", "all_aggregated", ")", "keys", "=", "sorted", "(", "first_row", ".", "keys", "(", ")", ")"...
Aggregate flow records by 5-tuple and print a tab-separated stream
[ "Aggregate", "flow", "records", "by", "5", "-", "tuple", "and", "print", "a", "tab", "-", "separated", "stream" ]
248d8cb3cc586859b6744d30cebce0f359d9900c
https://github.com/obsrvbl/flowlogs-reader/blob/248d8cb3cc586859b6744d30cebce0f359d9900c/flowlogs_reader/__main__.py#L77-L87
train
erdc/RAPIDpy
RAPIDpy/gis/weight.py
get_poly_area_geo
def get_poly_area_geo(poly): """ Calculates the area in meters squared of the individual polygon """ minx, miny, maxx, maxy = poly.bounds # reproject polygon to get area reprojected_for_area = Proj("+proj=aea +lat_1={0} +lat_1={1} " "+lat_0={2} +lon_0={3}" ...
python
def get_poly_area_geo(poly): """ Calculates the area in meters squared of the individual polygon """ minx, miny, maxx, maxy = poly.bounds # reproject polygon to get area reprojected_for_area = Proj("+proj=aea +lat_1={0} +lat_1={1} " "+lat_0={2} +lon_0={3}" ...
[ "def", "get_poly_area_geo", "(", "poly", ")", ":", "minx", ",", "miny", ",", "maxx", ",", "maxy", "=", "poly", ".", "bounds", "reprojected_for_area", "=", "Proj", "(", "\"+proj=aea +lat_1={0} +lat_1={1} \"", "\"+lat_0={2} +lon_0={3}\"", ".", "format", "(", "miny",...
Calculates the area in meters squared of the individual polygon
[ "Calculates", "the", "area", "in", "meters", "squared", "of", "the", "individual", "polygon" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/weight.py#L30-L47
train
erdc/RAPIDpy
RAPIDpy/gis/weight.py
CreateWeightTableECMWF
def CreateWeightTableECMWF(in_ecmwf_nc, in_catchment_shapefile, river_id, in_connectivity_file, out_weight_table, area_id=None, file_geodatabase=None): ""...
python
def CreateWeightTableECMWF(in_ecmwf_nc, in_catchment_shapefile, river_id, in_connectivity_file, out_weight_table, area_id=None, file_geodatabase=None): ""...
[ "def", "CreateWeightTableECMWF", "(", "in_ecmwf_nc", ",", "in_catchment_shapefile", ",", "river_id", ",", "in_connectivity_file", ",", "out_weight_table", ",", "area_id", "=", "None", ",", "file_geodatabase", "=", "None", ")", ":", "data_ecmwf_nc", "=", "Dataset", "...
Create Weight Table for ECMWF Grids .. note:: The grids are in the RAPIDpy package under the gis/lsm_grids folder. Parameters ---------- in_ecmwf_nc: str Path to the ECMWF NetCDF grid. in_catchment_shapefile: str Path to the Catchment shapefile. river_id: str ...
[ "Create", "Weight", "Table", "for", "ECMWF", "Grids" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/weight.py#L277-L346
train
erdc/RAPIDpy
RAPIDpy/gis/weight.py
CreateWeightTableLDAS
def CreateWeightTableLDAS(in_ldas_nc, in_nc_lon_var, in_nc_lat_var, in_catchment_shapefile, river_id, in_connectivity_file, out_weight_table, ...
python
def CreateWeightTableLDAS(in_ldas_nc, in_nc_lon_var, in_nc_lat_var, in_catchment_shapefile, river_id, in_connectivity_file, out_weight_table, ...
[ "def", "CreateWeightTableLDAS", "(", "in_ldas_nc", ",", "in_nc_lon_var", ",", "in_nc_lat_var", ",", "in_catchment_shapefile", ",", "river_id", ",", "in_connectivity_file", ",", "out_weight_table", ",", "area_id", "=", "None", ",", "file_geodatabase", "=", "None", ")",...
Create Weight Table for NLDAS, GLDAS grids as well as for 2D Joules, or LIS Grids Parameters ---------- in_ldas_nc: str Path to the land surface model NetCDF grid. in_nc_lon_var: str The variable name in the NetCDF file for the longitude. in_nc_lat_var: str The variable ...
[ "Create", "Weight", "Table", "for", "NLDAS", "GLDAS", "grids", "as", "well", "as", "for", "2D", "Joules", "or", "LIS", "Grids" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/weight.py#L349-L419
train
erdc/RAPIDpy
RAPIDpy/postprocess/generate_seasonal_averages.py
generate_single_seasonal_average
def generate_single_seasonal_average(args): """ This function calculates the seasonal average for a single day of the year for all river segments """ qout_file = args[0] seasonal_average_file = args[1] day_of_year = args[2] mp_lock = args[3] min_day = day_of_year - 3 max_day = d...
python
def generate_single_seasonal_average(args): """ This function calculates the seasonal average for a single day of the year for all river segments """ qout_file = args[0] seasonal_average_file = args[1] day_of_year = args[2] mp_lock = args[3] min_day = day_of_year - 3 max_day = d...
[ "def", "generate_single_seasonal_average", "(", "args", ")", ":", "qout_file", "=", "args", "[", "0", "]", "seasonal_average_file", "=", "args", "[", "1", "]", "day_of_year", "=", "args", "[", "2", "]", "mp_lock", "=", "args", "[", "3", "]", "min_day", "...
This function calculates the seasonal average for a single day of the year for all river segments
[ "This", "function", "calculates", "the", "seasonal", "average", "for", "a", "single", "day", "of", "the", "year", "for", "all", "river", "segments" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/postprocess/generate_seasonal_averages.py#L20-L67
train
erdc/RAPIDpy
RAPIDpy/postprocess/generate_seasonal_averages.py
generate_seasonal_averages
def generate_seasonal_averages(qout_file, seasonal_average_file, num_cpus=multiprocessing.cpu_count()): """ This function loops through a CF compliant rapid streamflow file to produce a netCDF file with a seasonal average for 365 days a year """ with RAPIDDataset(q...
python
def generate_seasonal_averages(qout_file, seasonal_average_file, num_cpus=multiprocessing.cpu_count()): """ This function loops through a CF compliant rapid streamflow file to produce a netCDF file with a seasonal average for 365 days a year """ with RAPIDDataset(q...
[ "def", "generate_seasonal_averages", "(", "qout_file", ",", "seasonal_average_file", ",", "num_cpus", "=", "multiprocessing", ".", "cpu_count", "(", ")", ")", ":", "with", "RAPIDDataset", "(", "qout_file", ")", "as", "qout_nc_file", ":", "print", "(", "\"Generatin...
This function loops through a CF compliant rapid streamflow file to produce a netCDF file with a seasonal average for 365 days a year
[ "This", "function", "loops", "through", "a", "CF", "compliant", "rapid", "streamflow", "file", "to", "produce", "a", "netCDF", "file", "with", "a", "seasonal", "average", "for", "365", "days", "a", "year" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/postprocess/generate_seasonal_averages.py#L70-L143
train
erdc/RAPIDpy
RAPIDpy/gis/__init__.py
open_shapefile
def open_shapefile(shapefile_path, file_geodatabase=None): """Opens a shapefile using either a shapefile path or a file geodatabase """ if file_geodatabase: gdb_driver = ogr.GetDriverByName("OpenFileGDB") ogr_shapefile = gdb_driver.Open(file_geodatabase) ogr_shapefile_lyr = o...
python
def open_shapefile(shapefile_path, file_geodatabase=None): """Opens a shapefile using either a shapefile path or a file geodatabase """ if file_geodatabase: gdb_driver = ogr.GetDriverByName("OpenFileGDB") ogr_shapefile = gdb_driver.Open(file_geodatabase) ogr_shapefile_lyr = o...
[ "def", "open_shapefile", "(", "shapefile_path", ",", "file_geodatabase", "=", "None", ")", ":", "if", "file_geodatabase", ":", "gdb_driver", "=", "ogr", ".", "GetDriverByName", "(", "\"OpenFileGDB\"", ")", "ogr_shapefile", "=", "gdb_driver", ".", "Open", "(", "f...
Opens a shapefile using either a shapefile path or a file geodatabase
[ "Opens", "a", "shapefile", "using", "either", "a", "shapefile", "path", "or", "a", "file", "geodatabase" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/__init__.py#L12-L23
train
erdc/RAPIDpy
RAPIDpy/rapid.py
RAPID._get_cygwin_path
def _get_cygwin_path(self, windows_path): """ Convert windows path to cygpath """ conv_cmd = [os.path.join(self._cygwin_bin_location, "cygpath.exe"), "-u", windows_path] process = Popen(conv_cmd, stdout=PIPE, stderr=PIPE, shell=False) ...
python
def _get_cygwin_path(self, windows_path): """ Convert windows path to cygpath """ conv_cmd = [os.path.join(self._cygwin_bin_location, "cygpath.exe"), "-u", windows_path] process = Popen(conv_cmd, stdout=PIPE, stderr=PIPE, shell=False) ...
[ "def", "_get_cygwin_path", "(", "self", ",", "windows_path", ")", ":", "conv_cmd", "=", "[", "os", ".", "path", ".", "join", "(", "self", ".", "_cygwin_bin_location", ",", "\"cygpath.exe\"", ")", ",", "\"-u\"", ",", "windows_path", "]", "process", "=", "Po...
Convert windows path to cygpath
[ "Convert", "windows", "path", "to", "cygpath" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/rapid.py#L255-L268
train
erdc/RAPIDpy
RAPIDpy/rapid.py
RAPID._create_symlink_cygwin
def _create_symlink_cygwin(self, initial_path, final_path): """ Use cygqin to generate symbolic link """ symlink_cmd = [os.path.join(self._cygwin_bin_location, "ln.exe"), "-s", self._get_cygwin_path(initial_path), self._get_cygwin_path(final_...
python
def _create_symlink_cygwin(self, initial_path, final_path): """ Use cygqin to generate symbolic link """ symlink_cmd = [os.path.join(self._cygwin_bin_location, "ln.exe"), "-s", self._get_cygwin_path(initial_path), self._get_cygwin_path(final_...
[ "def", "_create_symlink_cygwin", "(", "self", ",", "initial_path", ",", "final_path", ")", ":", "symlink_cmd", "=", "[", "os", ".", "path", ".", "join", "(", "self", ".", "_cygwin_bin_location", ",", "\"ln.exe\"", ")", ",", "\"-s\"", ",", "self", ".", "_ge...
Use cygqin to generate symbolic link
[ "Use", "cygqin", "to", "generate", "symbolic", "link" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/rapid.py#L270-L284
train
erdc/RAPIDpy
RAPIDpy/rapid.py
RAPID._dos2unix_cygwin
def _dos2unix_cygwin(self, file_path): """ Use cygwin to convert file to unix format """ dos2unix_cmd = \ [os.path.join(self._cygwin_bin_location, "dos2unix.exe"), self._get_cygwin_path(file_path)] process = Popen(dos2unix_cmd, std...
python
def _dos2unix_cygwin(self, file_path): """ Use cygwin to convert file to unix format """ dos2unix_cmd = \ [os.path.join(self._cygwin_bin_location, "dos2unix.exe"), self._get_cygwin_path(file_path)] process = Popen(dos2unix_cmd, std...
[ "def", "_dos2unix_cygwin", "(", "self", ",", "file_path", ")", ":", "dos2unix_cmd", "=", "[", "os", ".", "path", ".", "join", "(", "self", ".", "_cygwin_bin_location", ",", "\"dos2unix.exe\"", ")", ",", "self", ".", "_get_cygwin_path", "(", "file_path", ")",...
Use cygwin to convert file to unix format
[ "Use", "cygwin", "to", "convert", "file", "to", "unix", "format" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/rapid.py#L286-L295
train
erdc/RAPIDpy
RAPIDpy/rapid.py
RAPID.update_reach_number_data
def update_reach_number_data(self): """ Update the reach number data for the namelist based on input files. .. warning:: You need to make sure you set *rapid_connect_file* and *riv_bas_id_file* before running this function. Example: .. code:: python ...
python
def update_reach_number_data(self): """ Update the reach number data for the namelist based on input files. .. warning:: You need to make sure you set *rapid_connect_file* and *riv_bas_id_file* before running this function. Example: .. code:: python ...
[ "def", "update_reach_number_data", "(", "self", ")", ":", "if", "not", "self", ".", "rapid_connect_file", ":", "log", "(", "\"Missing rapid_connect_file. \"", "\"Please set before running this function ...\"", ",", "\"ERROR\"", ")", "if", "not", "self", ".", "riv_bas_id...
Update the reach number data for the namelist based on input files. .. warning:: You need to make sure you set *rapid_connect_file* and *riv_bas_id_file* before running this function. Example: .. code:: python from RAPIDpy import RAPID rapid_man...
[ "Update", "the", "reach", "number", "data", "for", "the", "namelist", "based", "on", "input", "files", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/rapid.py#L342-L427
train
erdc/RAPIDpy
RAPIDpy/rapid.py
RAPID.generate_namelist_file
def generate_namelist_file(self, rapid_namelist_file): """ Generate rapid_namelist file. Parameters ---------- rapid_namelist_file: str Path of namelist file to generate from parameters added to the RAPID manager. """ log("Generating RAPID...
python
def generate_namelist_file(self, rapid_namelist_file): """ Generate rapid_namelist file. Parameters ---------- rapid_namelist_file: str Path of namelist file to generate from parameters added to the RAPID manager. """ log("Generating RAPID...
[ "def", "generate_namelist_file", "(", "self", ",", "rapid_namelist_file", ")", ":", "log", "(", "\"Generating RAPID namelist file ...\"", ",", "\"INFO\"", ")", "try", ":", "os", ".", "remove", "(", "rapid_namelist_file", ")", "except", "OSError", ":", "pass", "wit...
Generate rapid_namelist file. Parameters ---------- rapid_namelist_file: str Path of namelist file to generate from parameters added to the RAPID manager.
[ "Generate", "rapid_namelist", "file", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/rapid.py#L469-L501
train
erdc/RAPIDpy
RAPIDpy/rapid.py
RAPID.update_namelist_file
def update_namelist_file(self, rapid_namelist_file, new_namelist_file=None): """ Update existing namelist file with new parameters Parameters ---------- rapid_namelist_file: str Path of namelist file to use in the simulation. It will be ...
python
def update_namelist_file(self, rapid_namelist_file, new_namelist_file=None): """ Update existing namelist file with new parameters Parameters ---------- rapid_namelist_file: str Path of namelist file to use in the simulation. It will be ...
[ "def", "update_namelist_file", "(", "self", ",", "rapid_namelist_file", ",", "new_namelist_file", "=", "None", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "rapid_namelist_file", ")", "and", "rapid_namelist_file", ":", "log", "(", "\"Adding missing input...
Update existing namelist file with new parameters Parameters ---------- rapid_namelist_file: str Path of namelist file to use in the simulation. It will be updated with any parameters added to the RAPID manager. new_namelist_file: str, optional Path t...
[ "Update", "existing", "namelist", "file", "with", "new", "parameters" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/rapid.py#L503-L553
train
erdc/RAPIDpy
RAPIDpy/rapid.py
RAPID.generate_qinit_from_past_qout
def generate_qinit_from_past_qout(self, qinit_file, time_index=-1, out_datetime=None): """ Generate qinit from a RAPID qout file Parameters ---------- qinit_file: str Path to output qinit_file. time_index: int, optional ...
python
def generate_qinit_from_past_qout(self, qinit_file, time_index=-1, out_datetime=None): """ Generate qinit from a RAPID qout file Parameters ---------- qinit_file: str Path to output qinit_file. time_index: int, optional ...
[ "def", "generate_qinit_from_past_qout", "(", "self", ",", "qinit_file", ",", "time_index", "=", "-", "1", ",", "out_datetime", "=", "None", ")", ":", "if", "not", "self", ".", "Qout_file", "or", "not", "os", ".", "path", ".", "exists", "(", "self", ".", ...
Generate qinit from a RAPID qout file Parameters ---------- qinit_file: str Path to output qinit_file. time_index: int, optional Index of simulation to generate initial flow file. Default is the last index. out_datetime: :obj:`datetime.datetim...
[ "Generate", "qinit", "from", "a", "RAPID", "qout", "file" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/rapid.py#L802-L880
train
erdc/RAPIDpy
RAPIDpy/rapid.py
RAPID.generate_seasonal_intitialization
def generate_seasonal_intitialization( self, qinit_file, datetime_start_initialization=datetime.datetime.utcnow() ): """This creates a seasonal qinit file from a RAPID qout file. This requires a simulation Qout file with a longer time period of record and to be CF com...
python
def generate_seasonal_intitialization( self, qinit_file, datetime_start_initialization=datetime.datetime.utcnow() ): """This creates a seasonal qinit file from a RAPID qout file. This requires a simulation Qout file with a longer time period of record and to be CF com...
[ "def", "generate_seasonal_intitialization", "(", "self", ",", "qinit_file", ",", "datetime_start_initialization", "=", "datetime", ".", "datetime", ".", "utcnow", "(", ")", ")", ":", "if", "not", "self", ".", "Qout_file", "or", "not", "os", ".", "path", ".", ...
This creates a seasonal qinit file from a RAPID qout file. This requires a simulation Qout file with a longer time period of record and to be CF compliant. It takes the average of the current date +- 3 days and goes back as far as possible. Parameters ---------- qinit_fi...
[ "This", "creates", "a", "seasonal", "qinit", "file", "from", "a", "RAPID", "qout", "file", ".", "This", "requires", "a", "simulation", "Qout", "file", "with", "a", "longer", "time", "period", "of", "record", "and", "to", "be", "CF", "compliant", ".", "It...
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/rapid.py#L882-L989
train
erdc/RAPIDpy
RAPIDpy/inflow/CreateInflowFileFromGriddedRunoff.py
CreateInflowFileFromGriddedRunoff.read_in_weight_table
def read_in_weight_table(self, in_weight_table): """ Read in weight table """ print("Reading the weight table...") with open_csv(in_weight_table, "r") as csvfile: reader = csv.reader(csvfile) header_row = next(reader) # check number of ...
python
def read_in_weight_table(self, in_weight_table): """ Read in weight table """ print("Reading the weight table...") with open_csv(in_weight_table, "r") as csvfile: reader = csv.reader(csvfile) header_row = next(reader) # check number of ...
[ "def", "read_in_weight_table", "(", "self", ",", "in_weight_table", ")", ":", "print", "(", "\"Reading the weight table...\"", ")", "with", "open_csv", "(", "in_weight_table", ",", "\"r\"", ")", "as", "csvfile", ":", "reader", "=", "csv", ".", "reader", "(", "...
Read in weight table
[ "Read", "in", "weight", "table" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/inflow/CreateInflowFileFromGriddedRunoff.py#L52-L86
train
erdc/RAPIDpy
RAPIDpy/inflow/CreateInflowFileFromGriddedRunoff.py
CreateInflowFileFromGriddedRunoff._write_lat_lon
def _write_lat_lon(data_out_nc, rivid_lat_lon_z_file): """Add latitude and longitude each netCDF feature Lookup table is a CSV file with rivid, Lat, Lon, columns. Columns must be in that order and these must be the first three columns. """ # only add if user adds ...
python
def _write_lat_lon(data_out_nc, rivid_lat_lon_z_file): """Add latitude and longitude each netCDF feature Lookup table is a CSV file with rivid, Lat, Lon, columns. Columns must be in that order and these must be the first three columns. """ # only add if user adds ...
[ "def", "_write_lat_lon", "(", "data_out_nc", ",", "rivid_lat_lon_z_file", ")", ":", "if", "rivid_lat_lon_z_file", "and", "os", ".", "path", ".", "exists", "(", "rivid_lat_lon_z_file", ")", ":", "lookup_table", "=", "np", ".", "loadtxt", "(", "rivid_lat_lon_z_file"...
Add latitude and longitude each netCDF feature Lookup table is a CSV file with rivid, Lat, Lon, columns. Columns must be in that order and these must be the first three columns.
[ "Add", "latitude", "and", "longitude", "each", "netCDF", "feature", "Lookup", "table", "is", "a", "CSV", "file", "with", "rivid", "Lat", "Lon", "columns", ".", "Columns", "must", "be", "in", "that", "order", "and", "these", "must", "be", "the", "first", ...
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/inflow/CreateInflowFileFromGriddedRunoff.py#L89-L156
train
erdc/RAPIDpy
RAPIDpy/postprocess/goodness_of_fit.py
filter_nan
def filter_nan(s, o): """ this functions removed the data from simulated and observed data whereever the observed data contains nan this is used by all other functions, otherwise they will produce nan as output """ data = np.array([s.flatten(), o.flatten()]) data = ...
python
def filter_nan(s, o): """ this functions removed the data from simulated and observed data whereever the observed data contains nan this is used by all other functions, otherwise they will produce nan as output """ data = np.array([s.flatten(), o.flatten()]) data = ...
[ "def", "filter_nan", "(", "s", ",", "o", ")", ":", "data", "=", "np", ".", "array", "(", "[", "s", ".", "flatten", "(", ")", ",", "o", ".", "flatten", "(", ")", "]", ")", "data", "=", "np", ".", "transpose", "(", "data", ")", "data", "=", "...
this functions removed the data from simulated and observed data whereever the observed data contains nan this is used by all other functions, otherwise they will produce nan as output
[ "this", "functions", "removed", "the", "data", "from", "simulated", "and", "observed", "data", "whereever", "the", "observed", "data", "contains", "nan" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/postprocess/goodness_of_fit.py#L21-L32
train
erdc/RAPIDpy
RAPIDpy/postprocess/goodness_of_fit.py
find_goodness_of_fit
def find_goodness_of_fit(rapid_qout_file, reach_id_file, observed_file, out_analysis_file, daily=False): """ Finds the goodness of fit comparing observed streamflow in a rapid Qout file with simulated flows in a csv file. Parameters ---------- rapid_qout_file: str ...
python
def find_goodness_of_fit(rapid_qout_file, reach_id_file, observed_file, out_analysis_file, daily=False): """ Finds the goodness of fit comparing observed streamflow in a rapid Qout file with simulated flows in a csv file. Parameters ---------- rapid_qout_file: str ...
[ "def", "find_goodness_of_fit", "(", "rapid_qout_file", ",", "reach_id_file", ",", "observed_file", ",", "out_analysis_file", ",", "daily", "=", "False", ")", ":", "reach_id_list", "=", "np", ".", "loadtxt", "(", "reach_id_file", ",", "delimiter", "=", "\",\"", "...
Finds the goodness of fit comparing observed streamflow in a rapid Qout file with simulated flows in a csv file. Parameters ---------- rapid_qout_file: str Path to the RAPID Qout file. reach_id_file: str ath to file with river reach ID's associate with the RAPID Qout file. I...
[ "Finds", "the", "goodness", "of", "fit", "comparing", "observed", "streamflow", "in", "a", "rapid", "Qout", "file", "with", "simulated", "flows", "in", "a", "csv", "file", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/postprocess/goodness_of_fit.py#L183-L271
train
erdc/RAPIDpy
RAPIDpy/postprocess/goodness_of_fit.py
find_goodness_of_fit_csv
def find_goodness_of_fit_csv(observed_simulated_file, out_file=None): """ Finds the goodness of fit comparing observed and simulated flows In the file, the first column is the observed flows and the second column is the simulated flows. Example:: 33.5, 77.2 34.7, 73.0 Paramete...
python
def find_goodness_of_fit_csv(observed_simulated_file, out_file=None): """ Finds the goodness of fit comparing observed and simulated flows In the file, the first column is the observed flows and the second column is the simulated flows. Example:: 33.5, 77.2 34.7, 73.0 Paramete...
[ "def", "find_goodness_of_fit_csv", "(", "observed_simulated_file", ",", "out_file", "=", "None", ")", ":", "observed_simulated_table", "=", "np", ".", "loadtxt", "(", "observed_simulated_file", ",", "ndmin", "=", "2", ",", "delimiter", "=", "\",\"", ",", "usecols"...
Finds the goodness of fit comparing observed and simulated flows In the file, the first column is the observed flows and the second column is the simulated flows. Example:: 33.5, 77.2 34.7, 73.0 Parameters ---------- observed_simulated_file: str Path to the csv file wi...
[ "Finds", "the", "goodness", "of", "fit", "comparing", "observed", "and", "simulated", "flows", "In", "the", "file", "the", "first", "column", "is", "the", "observed", "flows", "and", "the", "second", "column", "is", "the", "simulated", "flows", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/postprocess/goodness_of_fit.py#L274-L341
train
erdc/RAPIDpy
RAPIDpy/helper_functions.py
log
def log(message, severity="INFO", print_debug=True): """Logs, prints, or raises a message. Arguments: message -- message to report severity -- string of one of these values: CRITICAL|ERROR|WARNING|INFO|DEBUG """ print_me = ['WARNING', 'INFO', 'DEBUG'] if severity in pri...
python
def log(message, severity="INFO", print_debug=True): """Logs, prints, or raises a message. Arguments: message -- message to report severity -- string of one of these values: CRITICAL|ERROR|WARNING|INFO|DEBUG """ print_me = ['WARNING', 'INFO', 'DEBUG'] if severity in pri...
[ "def", "log", "(", "message", ",", "severity", "=", "\"INFO\"", ",", "print_debug", "=", "True", ")", ":", "print_me", "=", "[", "'WARNING'", ",", "'INFO'", ",", "'DEBUG'", "]", "if", "severity", "in", "print_me", ":", "if", "severity", "==", "'DEBUG'", ...
Logs, prints, or raises a message. Arguments: message -- message to report severity -- string of one of these values: CRITICAL|ERROR|WARNING|INFO|DEBUG
[ "Logs", "prints", "or", "raises", "a", "message", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/helper_functions.py#L36-L53
train
erdc/RAPIDpy
RAPIDpy/helper_functions.py
csv_to_list
def csv_to_list(csv_file, delimiter=','): """ Reads in a CSV file and returns the contents as list, where every row is stored as a sublist, and each element in the sublist represents 1 cell in the table. """ with open_csv(csv_file) as csv_con: if len(delimiter) > 1: dialect =...
python
def csv_to_list(csv_file, delimiter=','): """ Reads in a CSV file and returns the contents as list, where every row is stored as a sublist, and each element in the sublist represents 1 cell in the table. """ with open_csv(csv_file) as csv_con: if len(delimiter) > 1: dialect =...
[ "def", "csv_to_list", "(", "csv_file", ",", "delimiter", "=", "','", ")", ":", "with", "open_csv", "(", "csv_file", ")", "as", "csv_con", ":", "if", "len", "(", "delimiter", ")", ">", "1", ":", "dialect", "=", "csv", ".", "Sniffer", "(", ")", ".", ...
Reads in a CSV file and returns the contents as list, where every row is stored as a sublist, and each element in the sublist represents 1 cell in the table.
[ "Reads", "in", "a", "CSV", "file", "and", "returns", "the", "contents", "as", "list", "where", "every", "row", "is", "stored", "as", "a", "sublist", "and", "each", "element", "in", "the", "sublist", "represents", "1", "cell", "in", "the", "table", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/helper_functions.py#L56-L70
train
erdc/RAPIDpy
RAPIDpy/helper_functions.py
add_latlon_metadata
def add_latlon_metadata(lat_var, lon_var): """Adds latitude and longitude metadata""" lat_var.long_name = 'latitude' lat_var.standard_name = 'latitude' lat_var.units = 'degrees_north' lat_var.axis = 'Y' lon_var.long_name = 'longitude' lon_var.standard_name = 'longitude' lon_var.units = ...
python
def add_latlon_metadata(lat_var, lon_var): """Adds latitude and longitude metadata""" lat_var.long_name = 'latitude' lat_var.standard_name = 'latitude' lat_var.units = 'degrees_north' lat_var.axis = 'Y' lon_var.long_name = 'longitude' lon_var.standard_name = 'longitude' lon_var.units = ...
[ "def", "add_latlon_metadata", "(", "lat_var", ",", "lon_var", ")", ":", "lat_var", ".", "long_name", "=", "'latitude'", "lat_var", ".", "standard_name", "=", "'latitude'", "lat_var", ".", "units", "=", "'degrees_north'", "lat_var", ".", "axis", "=", "'Y'", "lo...
Adds latitude and longitude metadata
[ "Adds", "latitude", "and", "longitude", "metadata" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/helper_functions.py#L126-L136
train
erdc/RAPIDpy
RAPIDpy/inflow/lsm_rapid_process.py
generate_inflows_from_runoff
def generate_inflows_from_runoff(args): """ prepare runoff inflow file for rapid """ runoff_file_list = args[0] file_index_list = args[1] weight_table_file = args[2] grid_type = args[3] rapid_inflow_file = args[4] rapid_inflow_tool = args[5] mp_lock = args[6] time_start_all ...
python
def generate_inflows_from_runoff(args): """ prepare runoff inflow file for rapid """ runoff_file_list = args[0] file_index_list = args[1] weight_table_file = args[2] grid_type = args[3] rapid_inflow_file = args[4] rapid_inflow_tool = args[5] mp_lock = args[6] time_start_all ...
[ "def", "generate_inflows_from_runoff", "(", "args", ")", ":", "runoff_file_list", "=", "args", "[", "0", "]", "file_index_list", "=", "args", "[", "1", "]", "weight_table_file", "=", "args", "[", "2", "]", "grid_type", "=", "args", "[", "3", "]", "rapid_in...
prepare runoff inflow file for rapid
[ "prepare", "runoff", "inflow", "file", "for", "rapid" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/inflow/lsm_rapid_process.py#L38-L87
train
erdc/RAPIDpy
RAPIDpy/inflow/lsm_rapid_process.py
determine_start_end_timestep
def determine_start_end_timestep(lsm_file_list, file_re_match=None, file_datetime_pattern=None, expected_time_step=None, lsm_grid_info=None): """ Determine the start and end date f...
python
def determine_start_end_timestep(lsm_file_list, file_re_match=None, file_datetime_pattern=None, expected_time_step=None, lsm_grid_info=None): """ Determine the start and end date f...
[ "def", "determine_start_end_timestep", "(", "lsm_file_list", ",", "file_re_match", "=", "None", ",", "file_datetime_pattern", "=", "None", ",", "expected_time_step", "=", "None", ",", "lsm_grid_info", "=", "None", ")", ":", "if", "lsm_grid_info", "is", "None", ":"...
Determine the start and end date from LSM input files
[ "Determine", "the", "start", "and", "end", "date", "from", "LSM", "input", "files" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/inflow/lsm_rapid_process.py#L471-L561
train
erdc/RAPIDpy
RAPIDpy/gis/voronoi.py
_get_voronoi_centroid_array
def _get_voronoi_centroid_array(lsm_lat_array, lsm_lon_array, extent): """ This function generates a voronoi centroid point list from arrays of latitude and longitude """ YMin = extent[2] YMax = extent[3] XMin = extent[0] XMax = extent[1] ptList = [] if (lsm_lat_array.ndim == 2)...
python
def _get_voronoi_centroid_array(lsm_lat_array, lsm_lon_array, extent): """ This function generates a voronoi centroid point list from arrays of latitude and longitude """ YMin = extent[2] YMax = extent[3] XMin = extent[0] XMax = extent[1] ptList = [] if (lsm_lat_array.ndim == 2)...
[ "def", "_get_voronoi_centroid_array", "(", "lsm_lat_array", ",", "lsm_lon_array", ",", "extent", ")", ":", "YMin", "=", "extent", "[", "2", "]", "YMax", "=", "extent", "[", "3", "]", "XMin", "=", "extent", "[", "0", "]", "XMax", "=", "extent", "[", "1"...
This function generates a voronoi centroid point list from arrays of latitude and longitude
[ "This", "function", "generates", "a", "voronoi", "centroid", "point", "list", "from", "arrays", "of", "latitude", "and", "longitude" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/voronoi.py#L19-L86
train
erdc/RAPIDpy
RAPIDpy/gis/voronoi.py
_get_voronoi_poly_points
def _get_voronoi_poly_points(vert_index_list, voronoi_vertices, voronoi_centroid): """ This function returns the corner points for a polygon from scipy voronoi information """ voronoi_poly_points = [] if -1 not in vert_index_list and len(vert_index_list) > 3: ...
python
def _get_voronoi_poly_points(vert_index_list, voronoi_vertices, voronoi_centroid): """ This function returns the corner points for a polygon from scipy voronoi information """ voronoi_poly_points = [] if -1 not in vert_index_list and len(vert_index_list) > 3: ...
[ "def", "_get_voronoi_poly_points", "(", "vert_index_list", ",", "voronoi_vertices", ",", "voronoi_centroid", ")", ":", "voronoi_poly_points", "=", "[", "]", "if", "-", "1", "not", "in", "vert_index_list", "and", "len", "(", "vert_index_list", ")", ">", "3", ":",...
This function returns the corner points for a polygon from scipy voronoi information
[ "This", "function", "returns", "the", "corner", "points", "for", "a", "polygon", "from", "scipy", "voronoi", "information" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/voronoi.py#L89-L146
train
erdc/RAPIDpy
RAPIDpy/gis/voronoi.py
pointsToVoronoiGridShapefile
def pointsToVoronoiGridShapefile(lat, lon, vor_shp_path, extent=None): """ Converts points to shapefile grid via voronoi """ voronoi_centroids = _get_voronoi_centroid_array(lat, lon, extent) # set-up output polygon shp log("Creating output polygon shp {0}" .format(os.path.basename(vor_s...
python
def pointsToVoronoiGridShapefile(lat, lon, vor_shp_path, extent=None): """ Converts points to shapefile grid via voronoi """ voronoi_centroids = _get_voronoi_centroid_array(lat, lon, extent) # set-up output polygon shp log("Creating output polygon shp {0}" .format(os.path.basename(vor_s...
[ "def", "pointsToVoronoiGridShapefile", "(", "lat", ",", "lon", ",", "vor_shp_path", ",", "extent", "=", "None", ")", ":", "voronoi_centroids", "=", "_get_voronoi_centroid_array", "(", "lat", ",", "lon", ",", "extent", ")", "log", "(", "\"Creating output polygon sh...
Converts points to shapefile grid via voronoi
[ "Converts", "points", "to", "shapefile", "grid", "via", "voronoi" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/voronoi.py#L149-L197
train
erdc/RAPIDpy
RAPIDpy/gis/voronoi.py
pointsToVoronoiGridArray
def pointsToVoronoiGridArray(lat, lon, extent=None): """ Converts points to grid array via voronoi """ voronoi_centroids = _get_voronoi_centroid_array(lat, lon, extent) # find nodes surrounding polygon centroid # sort nodes in counterclockwise order # create polygon perimeter through nodes ...
python
def pointsToVoronoiGridArray(lat, lon, extent=None): """ Converts points to grid array via voronoi """ voronoi_centroids = _get_voronoi_centroid_array(lat, lon, extent) # find nodes surrounding polygon centroid # sort nodes in counterclockwise order # create polygon perimeter through nodes ...
[ "def", "pointsToVoronoiGridArray", "(", "lat", ",", "lon", ",", "extent", "=", "None", ")", ":", "voronoi_centroids", "=", "_get_voronoi_centroid_array", "(", "lat", ",", "lon", ",", "extent", ")", "log", "(", "\"Building Voronoi polygons...\"", ")", "voronoi_mana...
Converts points to grid array via voronoi
[ "Converts", "points", "to", "grid", "array", "via", "voronoi" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/voronoi.py#L200-L226
train
erdc/RAPIDpy
RAPIDpy/postprocess/merge.py
ConvertRAPIDOutputToCF._generate_time_values
def _generate_time_values(self): """ Generates time values for out nc file """ # Populate time values log('writing times', 'INFO') d1970 = datetime(1970, 1, 1, tzinfo=utc) time_array = [[int((self.start_datetime - d1970).total_seconds())]] dateti...
python
def _generate_time_values(self): """ Generates time values for out nc file """ # Populate time values log('writing times', 'INFO') d1970 = datetime(1970, 1, 1, tzinfo=utc) time_array = [[int((self.start_datetime - d1970).total_seconds())]] dateti...
[ "def", "_generate_time_values", "(", "self", ")", ":", "log", "(", "'writing times'", ",", "'INFO'", ")", "d1970", "=", "datetime", "(", "1970", ",", "1", ",", "1", ",", "tzinfo", "=", "utc", ")", "time_array", "=", "[", "[", "int", "(", "(", "self",...
Generates time values for out nc file
[ "Generates", "time", "values", "for", "out", "nc", "file" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/postprocess/merge.py#L401-L424
train
erdc/RAPIDpy
RAPIDpy/postprocess/merge.py
ConvertRAPIDOutputToCF.convert
def convert(self): """ Copies data from RAPID netCDF output to a CF-compliant netCDF file. """ try: log('Processing %s ...' % self.rapid_output_file_list[0]) time_start_conversion = datetime.utcnow() # Validate the raw netCDF file ...
python
def convert(self): """ Copies data from RAPID netCDF output to a CF-compliant netCDF file. """ try: log('Processing %s ...' % self.rapid_output_file_list[0]) time_start_conversion = datetime.utcnow() # Validate the raw netCDF file ...
[ "def", "convert", "(", "self", ")", ":", "try", ":", "log", "(", "'Processing %s ...'", "%", "self", ".", "rapid_output_file_list", "[", "0", "]", ")", "time_start_conversion", "=", "datetime", ".", "utcnow", "(", ")", "log", "(", "'validating input netCDF fil...
Copies data from RAPID netCDF output to a CF-compliant netCDF file.
[ "Copies", "data", "from", "RAPID", "netCDF", "output", "to", "a", "CF", "-", "compliant", "netCDF", "file", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/postprocess/merge.py#L495-L543
train
erdc/RAPIDpy
RAPIDpy/gis/muskingum.py
CreateMuskingumKFile
def CreateMuskingumKFile(lambda_k, in_kfac_file, out_k_file): """ Creates muskingum k file from kfac file. Parameters ---------- lambda_k: float The value for lambda given from RAPID after the calibration process. If no calibration h...
python
def CreateMuskingumKFile(lambda_k, in_kfac_file, out_k_file): """ Creates muskingum k file from kfac file. Parameters ---------- lambda_k: float The value for lambda given from RAPID after the calibration process. If no calibration h...
[ "def", "CreateMuskingumKFile", "(", "lambda_k", ",", "in_kfac_file", ",", "out_k_file", ")", ":", "kfac_table", "=", "csv_to_list", "(", "in_kfac_file", ")", "with", "open_csv", "(", "out_k_file", ",", "'w'", ")", "as", "kfile", ":", "k_writer", "=", "csv_writ...
Creates muskingum k file from kfac file. Parameters ---------- lambda_k: float The value for lambda given from RAPID after the calibration process. If no calibration has been performed, 0.35 is reasonable. in_kfac_file: str The path to the input kfac file. out_k_file: str ...
[ "Creates", "muskingum", "k", "file", "from", "kfac", "file", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/muskingum.py#L227-L259
train
erdc/RAPIDpy
RAPIDpy/gis/muskingum.py
CreateMuskingumXFileFromDranageLine
def CreateMuskingumXFileFromDranageLine(in_drainage_line, x_id, out_x_file, file_geodatabase=None): """ Create muskingum X file from drainage line. Parameters ---------- in_draina...
python
def CreateMuskingumXFileFromDranageLine(in_drainage_line, x_id, out_x_file, file_geodatabase=None): """ Create muskingum X file from drainage line. Parameters ---------- in_draina...
[ "def", "CreateMuskingumXFileFromDranageLine", "(", "in_drainage_line", ",", "x_id", ",", "out_x_file", ",", "file_geodatabase", "=", "None", ")", ":", "ogr_drainage_line_shapefile_lyr", ",", "ogr_drainage_line_shapefile", "=", "open_shapefile", "(", "in_drainage_line", ",",...
Create muskingum X file from drainage line. Parameters ---------- in_drainage_line: str Path to the stream network (i.e. Drainage Line) shapefile. x_id: str The name of the muksingum X field (i.e. 'Musk_x'). out_x_file: str The path to the output x file. file_geodatabase...
[ "Create", "muskingum", "X", "file", "from", "drainage", "line", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/muskingum.py#L262-L301
train
erdc/RAPIDpy
RAPIDpy/gis/muskingum.py
CreateConstMuskingumXFile
def CreateConstMuskingumXFile(x_value, in_connectivity_file, out_x_file): """ Create muskingum X file from value that is constant all the way through for each river segment. Parameters ---------- x_value: float Value for the mu...
python
def CreateConstMuskingumXFile(x_value, in_connectivity_file, out_x_file): """ Create muskingum X file from value that is constant all the way through for each river segment. Parameters ---------- x_value: float Value for the mu...
[ "def", "CreateConstMuskingumXFile", "(", "x_value", ",", "in_connectivity_file", ",", "out_x_file", ")", ":", "num_rivers", "=", "0", "with", "open_csv", "(", "in_connectivity_file", ",", "\"r\"", ")", "as", "csvfile", ":", "reader", "=", "csv_reader", "(", "csv...
Create muskingum X file from value that is constant all the way through for each river segment. Parameters ---------- x_value: float Value for the muskingum X parameter [0-0.5]. in_connectivity_file: str The path to the RAPID connectivity file. out_x_file: str The path t...
[ "Create", "muskingum", "X", "file", "from", "value", "that", "is", "constant", "all", "the", "way", "through", "for", "each", "river", "segment", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/muskingum.py#L304-L340
train
erdc/RAPIDpy
RAPIDpy/gis/network.py
StreamIDNextDownIDToConnectivity
def StreamIDNextDownIDToConnectivity(stream_id_array, next_down_id_array, out_csv_file): """ Creates RAPID connect file from stream_id array and next down id array """ list_all = [] max_count_upstream = 0 for hydroid in n...
python
def StreamIDNextDownIDToConnectivity(stream_id_array, next_down_id_array, out_csv_file): """ Creates RAPID connect file from stream_id array and next down id array """ list_all = [] max_count_upstream = 0 for hydroid in n...
[ "def", "StreamIDNextDownIDToConnectivity", "(", "stream_id_array", ",", "next_down_id_array", ",", "out_csv_file", ")", ":", "list_all", "=", "[", "]", "max_count_upstream", "=", "0", "for", "hydroid", "in", "np", ".", "sort", "(", "stream_id_array", ")", ":", "...
Creates RAPID connect file from stream_id array and next down id array
[ "Creates", "RAPID", "connect", "file", "from", "stream_id", "array", "and", "next", "down", "id", "array" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/network.py#L25-L57
train
erdc/RAPIDpy
RAPIDpy/gis/network.py
CreateNetworkConnectivity
def CreateNetworkConnectivity(in_drainage_line, river_id, next_down_id, out_connectivity_file, file_geodatabase=None): """ Creates Network Connectivity input CSV file for RAPID based on th...
python
def CreateNetworkConnectivity(in_drainage_line, river_id, next_down_id, out_connectivity_file, file_geodatabase=None): """ Creates Network Connectivity input CSV file for RAPID based on th...
[ "def", "CreateNetworkConnectivity", "(", "in_drainage_line", ",", "river_id", ",", "next_down_id", ",", "out_connectivity_file", ",", "file_geodatabase", "=", "None", ")", ":", "ogr_drainage_line_shapefile_lyr", ",", "ogr_drainage_line_shapefile", "=", "open_shapefile", "("...
Creates Network Connectivity input CSV file for RAPID based on the Drainage Line shapefile with river ID and next downstream ID fields. Parameters ---------- in_drainage_line: str Path to the stream network (i.e. Drainage Line) shapefile. river_id: str The name of the field with...
[ "Creates", "Network", "Connectivity", "input", "CSV", "file", "for", "RAPID", "based", "on", "the", "Drainage", "Line", "shapefile", "with", "river", "ID", "and", "next", "downstream", "ID", "fields", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/network.py#L60-L115
train
erdc/RAPIDpy
RAPIDpy/gis/network.py
CreateNetworkConnectivityTauDEMTree
def CreateNetworkConnectivityTauDEMTree(network_connectivity_tree_file, out_csv_file): """ Creates Network Connectivity input CSV file for RAPID based on the TauDEM network connectivity tree file """ stream_id_array = [] next_down_id_array = [] with op...
python
def CreateNetworkConnectivityTauDEMTree(network_connectivity_tree_file, out_csv_file): """ Creates Network Connectivity input CSV file for RAPID based on the TauDEM network connectivity tree file """ stream_id_array = [] next_down_id_array = [] with op...
[ "def", "CreateNetworkConnectivityTauDEMTree", "(", "network_connectivity_tree_file", ",", "out_csv_file", ")", ":", "stream_id_array", "=", "[", "]", "next_down_id_array", "=", "[", "]", "with", "open_csv", "(", "network_connectivity_tree_file", ",", "\"r\"", ")", "as",...
Creates Network Connectivity input CSV file for RAPID based on the TauDEM network connectivity tree file
[ "Creates", "Network", "Connectivity", "input", "CSV", "file", "for", "RAPID", "based", "on", "the", "TauDEM", "network", "connectivity", "tree", "file" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/network.py#L118-L139
train
erdc/RAPIDpy
RAPIDpy/gis/network.py
CreateNetworkConnectivityNHDPlus
def CreateNetworkConnectivityNHDPlus(in_drainage_line, out_connectivity_file, file_geodatabase=None): """ Creates Network Connectivity input CSV file for RAPID based on the NHDPlus drainage lines with COMID, FROMNODE, TONODE, and ...
python
def CreateNetworkConnectivityNHDPlus(in_drainage_line, out_connectivity_file, file_geodatabase=None): """ Creates Network Connectivity input CSV file for RAPID based on the NHDPlus drainage lines with COMID, FROMNODE, TONODE, and ...
[ "def", "CreateNetworkConnectivityNHDPlus", "(", "in_drainage_line", ",", "out_connectivity_file", ",", "file_geodatabase", "=", "None", ")", ":", "ogr_drainage_line_shapefile_lyr", ",", "ogr_drainage_line_shapefile", "=", "open_shapefile", "(", "in_drainage_line", ",", "file_...
Creates Network Connectivity input CSV file for RAPID based on the NHDPlus drainage lines with COMID, FROMNODE, TONODE, and DIVERGENCE fields. Parameters ---------- in_drainage_line: str Path to the stream network (i.e. Drainage Line) shapefile. out_connectivity_file: str The pa...
[ "Creates", "Network", "Connectivity", "input", "CSV", "file", "for", "RAPID", "based", "on", "the", "NHDPlus", "drainage", "lines", "with", "COMID", "FROMNODE", "TONODE", "and", "DIVERGENCE", "fields", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/network.py#L142-L247
train
erdc/RAPIDpy
RAPIDpy/gis/network.py
CreateSubsetFile
def CreateSubsetFile(in_drainage_line, river_id, out_riv_bas_id_file, file_geodatabase=None): """ Creates River Basin ID subset input CSV file for RAPID based on the Drainage Line shapefile with river ID and next downstream ID fields Pa...
python
def CreateSubsetFile(in_drainage_line, river_id, out_riv_bas_id_file, file_geodatabase=None): """ Creates River Basin ID subset input CSV file for RAPID based on the Drainage Line shapefile with river ID and next downstream ID fields Pa...
[ "def", "CreateSubsetFile", "(", "in_drainage_line", ",", "river_id", ",", "out_riv_bas_id_file", ",", "file_geodatabase", "=", "None", ")", ":", "ogr_drainage_line_shapefile_lyr", ",", "ogr_drainage_line_shapefile", "=", "open_shapefile", "(", "in_drainage_line", ",", "fi...
Creates River Basin ID subset input CSV file for RAPID based on the Drainage Line shapefile with river ID and next downstream ID fields Parameters ---------- in_drainage_line: str Path to the stream network (i.e. Drainage Line) shapefile. river_id: str The name of the field with...
[ "Creates", "River", "Basin", "ID", "subset", "input", "CSV", "file", "for", "RAPID", "based", "on", "the", "Drainage", "Line", "shapefile", "with", "river", "ID", "and", "next", "downstream", "ID", "fields" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/network.py#L250-L326
train
erdc/RAPIDpy
RAPIDpy/gis/workflow.py
CreateAllStaticECMWFFiles
def CreateAllStaticECMWFFiles(in_catchment, catchment_river_id, rapid_output_folder, rapid_connect_file, file_geodatabase=None ): """ This creates all of the ECMW...
python
def CreateAllStaticECMWFFiles(in_catchment, catchment_river_id, rapid_output_folder, rapid_connect_file, file_geodatabase=None ): """ This creates all of the ECMW...
[ "def", "CreateAllStaticECMWFFiles", "(", "in_catchment", ",", "catchment_river_id", ",", "rapid_output_folder", ",", "rapid_connect_file", ",", "file_geodatabase", "=", "None", ")", ":", "lsm_grid_folder", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path...
This creates all of the ECMWF grid weight tables using an area weighted method based on Esri's RAPID_Toolbox. Parameters ---------- in_catchment: str Path to the Catchment shapefile. catchment_river_id: str The name of the field with the river ID (Ex. 'DrainLnID' or 'LINKNO'). r...
[ "This", "creates", "all", "of", "the", "ECMWF", "grid", "weight", "tables", "using", "an", "area", "weighted", "method", "based", "on", "Esri", "s", "RAPID_Toolbox", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/workflow.py#L151-L226
train
erdc/RAPIDpy
RAPIDpy/gis/workflow.py
CreateAllStaticECMWFRAPIDFiles
def CreateAllStaticECMWFRAPIDFiles(in_drainage_line, river_id, length_id, slope_id, next_down_id, in_catchment, ...
python
def CreateAllStaticECMWFRAPIDFiles(in_drainage_line, river_id, length_id, slope_id, next_down_id, in_catchment, ...
[ "def", "CreateAllStaticECMWFRAPIDFiles", "(", "in_drainage_line", ",", "river_id", ",", "length_id", ",", "slope_id", ",", "next_down_id", ",", "in_catchment", ",", "catchment_river_id", ",", "rapid_output_folder", ",", "kfac_celerity", "=", "1000.0", "/", "3600.0", "...
This creates all of the static RAPID files and ECMWF grid weight tables. Parameters ---------- in_drainage_line: str Path to the stream network (i.e. Drainage Line) shapefile. river_id: str The name of the field with the river ID (Ex. 'HydroID', 'COMID', or 'LINKNO'). length...
[ "This", "creates", "all", "of", "the", "static", "RAPID", "files", "and", "ECMWF", "grid", "weight", "tables", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/workflow.py#L229-L332
train
erdc/RAPIDpy
RAPIDpy/dataset.py
compare_qout_files
def compare_qout_files(dataset1_path, dataset2_path): """ This function compares the output of RAPID Qout and tells you where they are different. """ qout_same = False d1 = RAPIDDataset(dataset1_path) d2 = RAPIDDataset(dataset2_path) if len(d1.get_river_id_array()) != len(d2.get_river_...
python
def compare_qout_files(dataset1_path, dataset2_path): """ This function compares the output of RAPID Qout and tells you where they are different. """ qout_same = False d1 = RAPIDDataset(dataset1_path) d2 = RAPIDDataset(dataset2_path) if len(d1.get_river_id_array()) != len(d2.get_river_...
[ "def", "compare_qout_files", "(", "dataset1_path", ",", "dataset2_path", ")", ":", "qout_same", "=", "False", "d1", "=", "RAPIDDataset", "(", "dataset1_path", ")", "d2", "=", "RAPIDDataset", "(", "dataset2_path", ")", "if", "len", "(", "d1", ".", "get_river_id...
This function compares the output of RAPID Qout and tells you where they are different.
[ "This", "function", "compares", "the", "output", "of", "RAPID", "Qout", "and", "tells", "you", "where", "they", "are", "different", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/dataset.py#L25-L95
train
erdc/RAPIDpy
RAPIDpy/dataset.py
RAPIDDataset.is_time_variable_valid
def is_time_variable_valid(self): """ This function returns whether or not the time variable is valid. Returns ------- boolean True if the time variable is valid, otherwise false. Example:: from RAPIDpy import RAPIDDataset ...
python
def is_time_variable_valid(self): """ This function returns whether or not the time variable is valid. Returns ------- boolean True if the time variable is valid, otherwise false. Example:: from RAPIDpy import RAPIDDataset ...
[ "def", "is_time_variable_valid", "(", "self", ")", ":", "time_var_valid", "=", "False", "if", "'time'", "in", "self", ".", "qout_nc", ".", "variables", ".", "keys", "(", ")", ":", "if", "len", "(", "self", ".", "qout_nc", ".", "dimensions", "[", "'time'"...
This function returns whether or not the time variable is valid. Returns ------- boolean True if the time variable is valid, otherwise false. Example:: from RAPIDpy import RAPIDDataset path_to_rapid_qout = '/path/to/Qout.nc' wi...
[ "This", "function", "returns", "whether", "or", "not", "the", "time", "variable", "is", "valid", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/dataset.py#L248-L288
train
erdc/RAPIDpy
RAPIDpy/dataset.py
RAPIDDataset.get_time_array
def get_time_array(self, datetime_simulation_start=None, simulation_time_step_seconds=None, return_datetime=False, time_index_array=None): """ This method extracts or generates an array of time. The new v...
python
def get_time_array(self, datetime_simulation_start=None, simulation_time_step_seconds=None, return_datetime=False, time_index_array=None): """ This method extracts or generates an array of time. The new v...
[ "def", "get_time_array", "(", "self", ",", "datetime_simulation_start", "=", "None", ",", "simulation_time_step_seconds", "=", "None", ",", "return_datetime", "=", "False", ",", "time_index_array", "=", "None", ")", ":", "if", "datetime_simulation_start", "is", "not...
This method extracts or generates an array of time. The new version of RAPID output has the time array stored. However, the old version requires the user to know when the simulation began and the time step of the output. Parameters ---------- datetime_simulation_start: :...
[ "This", "method", "extracts", "or", "generates", "an", "array", "of", "time", ".", "The", "new", "version", "of", "RAPID", "output", "has", "the", "time", "array", "stored", ".", "However", "the", "old", "version", "requires", "the", "user", "to", "know", ...
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/dataset.py#L296-L412
train
erdc/RAPIDpy
RAPIDpy/dataset.py
RAPIDDataset.get_time_index_range
def get_time_index_range(self, date_search_start=None, date_search_end=None, time_index_start=None, time_index_end=None, time_index=None): """ Generates a time...
python
def get_time_index_range(self, date_search_start=None, date_search_end=None, time_index_start=None, time_index_end=None, time_index=None): """ Generates a time...
[ "def", "get_time_index_range", "(", "self", ",", "date_search_start", "=", "None", ",", "date_search_end", "=", "None", ",", "time_index_start", "=", "None", ",", "time_index_end", "=", "None", ",", "time_index", "=", "None", ")", ":", "time_range", "=", "None...
Generates a time index range based on time bounds given. This is useful for subset data extraction. Parameters ---------- date_search_start: :obj:`datetime.datetime`, optional This is a datetime object with the date of the minimum date for starting. date_...
[ "Generates", "a", "time", "index", "range", "based", "on", "time", "bounds", "given", ".", "This", "is", "useful", "for", "subset", "data", "extraction", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/dataset.py#L414-L532
train
erdc/RAPIDpy
RAPIDpy/dataset.py
RAPIDDataset.get_river_index
def get_river_index(self, river_id): """ This method retrieves the river index in the netCDF dataset corresponding to the river ID. Parameters ---------- river_id: int The ID of the river segment. Returns ------- int: The ...
python
def get_river_index(self, river_id): """ This method retrieves the river index in the netCDF dataset corresponding to the river ID. Parameters ---------- river_id: int The ID of the river segment. Returns ------- int: The ...
[ "def", "get_river_index", "(", "self", ",", "river_id", ")", ":", "try", ":", "return", "np", ".", "where", "(", "self", ".", "get_river_id_array", "(", ")", "==", "river_id", ")", "[", "0", "]", "[", "0", "]", "except", "IndexError", ":", "raise", "...
This method retrieves the river index in the netCDF dataset corresponding to the river ID. Parameters ---------- river_id: int The ID of the river segment. Returns ------- int: The index of the river ID's in the file. Example:: ...
[ "This", "method", "retrieves", "the", "river", "index", "in", "the", "netCDF", "dataset", "corresponding", "to", "the", "river", "ID", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/dataset.py#L555-L586
train
erdc/RAPIDpy
RAPIDpy/dataset.py
RAPIDDataset.get_subset_riverid_index_list
def get_subset_riverid_index_list(self, river_id_list): """ Gets the subset riverid_list from the netcdf file Optional returns include the list of valid river ids in the dataset as well as a list of missing rive rids Parameters ---------- river_id_list: list or :...
python
def get_subset_riverid_index_list(self, river_id_list): """ Gets the subset riverid_list from the netcdf file Optional returns include the list of valid river ids in the dataset as well as a list of missing rive rids Parameters ---------- river_id_list: list or :...
[ "def", "get_subset_riverid_index_list", "(", "self", ",", "river_id_list", ")", ":", "netcdf_river_indices_list", "=", "[", "]", "valid_river_ids", "=", "[", "]", "missing_river_ids", "=", "[", "]", "for", "river_id", "in", "river_id_list", ":", "try", ":", "net...
Gets the subset riverid_list from the netcdf file Optional returns include the list of valid river ids in the dataset as well as a list of missing rive rids Parameters ---------- river_id_list: list or :obj:`numpy.array` Array of river ID's for the river segments you...
[ "Gets", "the", "subset", "riverid_list", "from", "the", "netcdf", "file", "Optional", "returns", "include", "the", "list", "of", "valid", "river", "ids", "in", "the", "dataset", "as", "well", "as", "a", "list", "of", "missing", "rive", "rids" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/dataset.py#L588-L631
train
erdc/RAPIDpy
RAPIDpy/dataset.py
RAPIDDataset.get_qout
def get_qout(self, river_id_array=None, date_search_start=None, date_search_end=None, time_index_start=None, time_index_end=None, time_index=None, time_index_array=None, daily=False, ...
python
def get_qout(self, river_id_array=None, date_search_start=None, date_search_end=None, time_index_start=None, time_index_end=None, time_index=None, time_index_array=None, daily=False, ...
[ "def", "get_qout", "(", "self", ",", "river_id_array", "=", "None", ",", "date_search_start", "=", "None", ",", "date_search_end", "=", "None", ",", "time_index_start", "=", "None", ",", "time_index_end", "=", "None", ",", "time_index", "=", "None", ",", "ti...
This method extracts streamflow data by a single river ID or by a river ID array. It has options to extract by date or by date index. Parameters ---------- river_id_array: :obj:`numpy.array` or list or int, optional A single river ID or an array of river IDs. ...
[ "This", "method", "extracts", "streamflow", "data", "by", "a", "single", "river", "ID", "or", "by", "a", "river", "ID", "array", ".", "It", "has", "options", "to", "extract", "by", "date", "or", "by", "date", "index", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/dataset.py#L633-L732
train
erdc/RAPIDpy
RAPIDpy/dataset.py
RAPIDDataset.get_qout_index
def get_qout_index(self, river_index_array=None, date_search_start=None, date_search_end=None, time_index_start=None, time_index_end=None, time_index=None, tim...
python
def get_qout_index(self, river_index_array=None, date_search_start=None, date_search_end=None, time_index_start=None, time_index_end=None, time_index=None, tim...
[ "def", "get_qout_index", "(", "self", ",", "river_index_array", "=", "None", ",", "date_search_start", "=", "None", ",", "date_search_end", "=", "None", ",", "time_index_start", "=", "None", ",", "time_index_end", "=", "None", ",", "time_index", "=", "None", "...
This method extracts streamflow data by river index. It allows for extracting single or multiple river streamflow arrays It has options to extract by date or by date index. See: :meth:`RAPIDpy.RAPIDDataset.get_qout`
[ "This", "method", "extracts", "streamflow", "data", "by", "river", "index", ".", "It", "allows", "for", "extracting", "single", "or", "multiple", "river", "streamflow", "arrays", "It", "has", "options", "to", "extract", "by", "date", "or", "by", "date", "ind...
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/dataset.py#L734-L819
train
erdc/RAPIDpy
RAPIDpy/dataset.py
RAPIDDataset.write_flows_to_csv
def write_flows_to_csv(self, path_to_output_file, river_index=None, river_id=None, date_search_start=None, date_search_end=None, daily=False, filter_mode="mea...
python
def write_flows_to_csv(self, path_to_output_file, river_index=None, river_id=None, date_search_start=None, date_search_end=None, daily=False, filter_mode="mea...
[ "def", "write_flows_to_csv", "(", "self", ",", "path_to_output_file", ",", "river_index", "=", "None", ",", "river_id", "=", "None", ",", "date_search_start", "=", "None", ",", "date_search_end", "=", "None", ",", "daily", "=", "False", ",", "filter_mode", "="...
Write out RAPID output to CSV file. .. note:: Need either *reach_id* or *reach_index* parameter, but either can be used. Parameters ---------- path_to_output_file: str Path to the output csv file. river_index: :obj:`datetime.datetime`, optional ...
[ "Write", "out", "RAPID", "output", "to", "CSV", "file", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/dataset.py#L821-L946
train
erdc/RAPIDpy
RAPIDpy/dataset.py
RAPIDDataset.write_flows_to_gssha_time_series_xys
def write_flows_to_gssha_time_series_xys(self, path_to_output_file, series_name, series_id, river_index=None, ...
python
def write_flows_to_gssha_time_series_xys(self, path_to_output_file, series_name, series_id, river_index=None, ...
[ "def", "write_flows_to_gssha_time_series_xys", "(", "self", ",", "path_to_output_file", ",", "series_name", ",", "series_id", ",", "river_index", "=", "None", ",", "river_id", "=", "None", ",", "date_search_start", "=", "None", ",", "date_search_end", "=", "None", ...
Write out RAPID output to GSSHA WMS time series xys file. Parameters ---------- path_to_output_file: str Path to the output xys file. series_name: str The name for the series. series_id: int The ID to give the series. river_index: :obj...
[ "Write", "out", "RAPID", "output", "to", "GSSHA", "WMS", "time", "series", "xys", "file", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/dataset.py#L948-L1077
train
erdc/RAPIDpy
RAPIDpy/dataset.py
RAPIDDataset.write_flows_to_gssha_time_series_ihg
def write_flows_to_gssha_time_series_ihg(self, path_to_output_file, connection_list_file, date_search_start=None, date_search_end=None, ...
python
def write_flows_to_gssha_time_series_ihg(self, path_to_output_file, connection_list_file, date_search_start=None, date_search_end=None, ...
[ "def", "write_flows_to_gssha_time_series_ihg", "(", "self", ",", "path_to_output_file", ",", "connection_list_file", ",", "date_search_start", "=", "None", ",", "date_search_end", "=", "None", ",", "daily", "=", "False", ",", "filter_mode", "=", "\"mean\"", ")", ":"...
Write out RAPID output to GSSHA time series ihg file .. note:: See: http://www.gsshawiki.com/Surface_Water_Routing:Introducing_Dischage/Constituent_Hydrographs .. note:: GSSHA project card is CHAN_POINT_INPUT Parameters ---------- path_to_output_file: str Path to t...
[ "Write", "out", "RAPID", "output", "to", "GSSHA", "time", "series", "ihg", "file" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/dataset.py#L1079-L1232
train
erdc/RAPIDpy
RAPIDpy/utilities.py
case_insensitive_file_search
def case_insensitive_file_search(directory, pattern): """ Looks for file with pattern with case insensitive search """ try: return os.path.join( directory, [filename for filename in os.listdir(directory) if re.search(pattern, filename, re.IGNORECASE)][0]) ...
python
def case_insensitive_file_search(directory, pattern): """ Looks for file with pattern with case insensitive search """ try: return os.path.join( directory, [filename for filename in os.listdir(directory) if re.search(pattern, filename, re.IGNORECASE)][0]) ...
[ "def", "case_insensitive_file_search", "(", "directory", ",", "pattern", ")", ":", "try", ":", "return", "os", ".", "path", ".", "join", "(", "directory", ",", "[", "filename", "for", "filename", "in", "os", ".", "listdir", "(", "directory", ")", "if", "...
Looks for file with pattern with case insensitive search
[ "Looks", "for", "file", "with", "pattern", "with", "case", "insensitive", "search" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/utilities.py#L18-L29
train
erdc/RAPIDpy
RAPIDpy/utilities.py
partition
def partition(lst, n): """ Divide list into n equal parts """ q, r = divmod(len(lst), n) indices = [q*i + min(i, r) for i in xrange(n+1)] return [lst[indices[i]:indices[i+1]] for i in xrange(n)], \ [list(xrange(indices[i], indices[i+1])) for i in xrange(n)]
python
def partition(lst, n): """ Divide list into n equal parts """ q, r = divmod(len(lst), n) indices = [q*i + min(i, r) for i in xrange(n+1)] return [lst[indices[i]:indices[i+1]] for i in xrange(n)], \ [list(xrange(indices[i], indices[i+1])) for i in xrange(n)]
[ "def", "partition", "(", "lst", ",", "n", ")", ":", "q", ",", "r", "=", "divmod", "(", "len", "(", "lst", ")", ",", "n", ")", "indices", "=", "[", "q", "*", "i", "+", "min", "(", "i", ",", "r", ")", "for", "i", "in", "xrange", "(", "n", ...
Divide list into n equal parts
[ "Divide", "list", "into", "n", "equal", "parts" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/utilities.py#L32-L39
train
erdc/RAPIDpy
RAPIDpy/utilities.py
get_valid_directory_list
def get_valid_directory_list(input_directory): """ Get a list of folders """ valid_input_directories = [] for directory in os.listdir(input_directory): if os.path.isdir(os.path.join(input_directory, directory)): valid_input_directories.append(directory) else: ...
python
def get_valid_directory_list(input_directory): """ Get a list of folders """ valid_input_directories = [] for directory in os.listdir(input_directory): if os.path.isdir(os.path.join(input_directory, directory)): valid_input_directories.append(directory) else: ...
[ "def", "get_valid_directory_list", "(", "input_directory", ")", ":", "valid_input_directories", "=", "[", "]", "for", "directory", "in", "os", ".", "listdir", "(", "input_directory", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "os", ".", "path", ...
Get a list of folders
[ "Get", "a", "list", "of", "folders" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/utilities.py#L42-L52
train
erdc/RAPIDpy
RAPIDpy/gis/taudem.py
TauDEM._run_mpi_cmd
def _run_mpi_cmd(self, cmd): """ This runs the command you send in """ log("Number of Processes: {0}".format(self.num_processors)) time_start = datetime.utcnow() # Construct the taudem command line. cmd = [self.mpiexec_path, '-n', str(self.num_processors)] + cmd ...
python
def _run_mpi_cmd(self, cmd): """ This runs the command you send in """ log("Number of Processes: {0}".format(self.num_processors)) time_start = datetime.utcnow() # Construct the taudem command line. cmd = [self.mpiexec_path, '-n', str(self.num_processors)] + cmd ...
[ "def", "_run_mpi_cmd", "(", "self", ",", "cmd", ")", ":", "log", "(", "\"Number of Processes: {0}\"", ".", "format", "(", "self", ".", "num_processors", ")", ")", "time_start", "=", "datetime", ".", "utcnow", "(", ")", "cmd", "=", "[", "self", ".", "mpie...
This runs the command you send in
[ "This", "runs", "the", "command", "you", "send", "in" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/taudem.py#L79-L97
train
erdc/RAPIDpy
RAPIDpy/gis/taudem.py
TauDEM._add_prj_file
def _add_prj_file(original_gis_file, new_gis_file): """ Adds projection file """ out_prj_file = "{0}.prj".format(os.path.splitext(new_gis_file)[0]) if original_gis_file.endswith(".shp"): dataset = ogr.Open(original_gis_file) layer = dataset.GetLayer() ...
python
def _add_prj_file(original_gis_file, new_gis_file): """ Adds projection file """ out_prj_file = "{0}.prj".format(os.path.splitext(new_gis_file)[0]) if original_gis_file.endswith(".shp"): dataset = ogr.Open(original_gis_file) layer = dataset.GetLayer() ...
[ "def", "_add_prj_file", "(", "original_gis_file", ",", "new_gis_file", ")", ":", "out_prj_file", "=", "\"{0}.prj\"", ".", "format", "(", "os", ".", "path", ".", "splitext", "(", "new_gis_file", ")", "[", "0", "]", ")", "if", "original_gis_file", ".", "endswi...
Adds projection file
[ "Adds", "projection", "file" ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/taudem.py#L100-L116
train
erdc/RAPIDpy
RAPIDpy/gis/taudem.py
TauDEM.extractSubNetwork
def extractSubNetwork(network_file, out_subset_network_file, outlet_ids, river_id_field, next_down_id_field, river_magnitude_field, safe_mode=True): """ ...
python
def extractSubNetwork(network_file, out_subset_network_file, outlet_ids, river_id_field, next_down_id_field, river_magnitude_field, safe_mode=True): """ ...
[ "def", "extractSubNetwork", "(", "network_file", ",", "out_subset_network_file", ",", "outlet_ids", ",", "river_id_field", ",", "next_down_id_field", ",", "river_magnitude_field", ",", "safe_mode", "=", "True", ")", ":", "network_shapefile", "=", "ogr", ".", "Open", ...
Extracts a subset river network from the main river network based on the outlet IDs. Parameters ---------- network_file: str Path to the stream network shapefile. out_subset_network_file: str Path to the output subset stream network shapefile. out...
[ "Extracts", "a", "subset", "river", "network", "from", "the", "main", "river", "network", "based", "on", "the", "outlet", "IDs", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/taudem.py#L119-L268
train
erdc/RAPIDpy
RAPIDpy/gis/taudem.py
TauDEM.extractLargestSubNetwork
def extractLargestSubNetwork(cls, network_file, out_subset_network_file, river_id_field, next_down_id_field, river_magnitude_field, ...
python
def extractLargestSubNetwork(cls, network_file, out_subset_network_file, river_id_field, next_down_id_field, river_magnitude_field, ...
[ "def", "extractLargestSubNetwork", "(", "cls", ",", "network_file", ",", "out_subset_network_file", ",", "river_id_field", ",", "next_down_id_field", ",", "river_magnitude_field", ",", "safe_mode", "=", "True", ")", ":", "network_shapefile", "=", "ogr", ".", "Open", ...
Extracts the larges sub network from the watershed based on the magnitude parameter. Parameters ---------- network_file: str Path to the stream network shapefile. out_subset_network_file: str Path to the output subset stream network shapefile. riv...
[ "Extracts", "the", "larges", "sub", "network", "from", "the", "watershed", "based", "on", "the", "magnitude", "parameter", "." ]
50e14e130554b254a00ff23b226cd7e4c6cfe91a
https://github.com/erdc/RAPIDpy/blob/50e14e130554b254a00ff23b226cd7e4c6cfe91a/RAPIDpy/gis/taudem.py#L271-L338
train