repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
SuperCowPowers/workbench | workbench/server/neo_db.py | NeoDB.add_rel | def add_rel(self, source_node_id, target_node_id, rel):
"""Add a relationship between nodes.
Args:
source_node_id: Node Id for the source node.
target_node_id: Node Id for the target node.
rel: Name of the relationship 'contains'
"""
# Add the relati... | python | def add_rel(self, source_node_id, target_node_id, rel):
"""Add a relationship between nodes.
Args:
source_node_id: Node Id for the source node.
target_node_id: Node Id for the target node.
rel: Name of the relationship 'contains'
"""
# Add the relati... | [
"def",
"add_rel",
"(",
"self",
",",
"source_node_id",
",",
"target_node_id",
",",
"rel",
")",
":",
"# Add the relationship",
"n1_ref",
"=",
"self",
".",
"graph_db",
".",
"get_indexed_node",
"(",
"'Node'",
",",
"'node_id'",
",",
"source_node_id",
")",
"n2_ref",
... | Add a relationship between nodes.
Args:
source_node_id: Node Id for the source node.
target_node_id: Node Id for the target node.
rel: Name of the relationship 'contains' | [
"Add",
"a",
"relationship",
"between",
"nodes",
"."
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/neo_db.py#L55-L73 |
SuperCowPowers/workbench | workbench/server/neo_db.py | NeoDBStub.add_node | def add_node(self, node_id, name, labels):
"""NeoDB Stub."""
print 'NeoDB Stub getting called...'
print '%s %s %s %s' % (self, node_id, name, labels) | python | def add_node(self, node_id, name, labels):
"""NeoDB Stub."""
print 'NeoDB Stub getting called...'
print '%s %s %s %s' % (self, node_id, name, labels) | [
"def",
"add_node",
"(",
"self",
",",
"node_id",
",",
"name",
",",
"labels",
")",
":",
"print",
"'NeoDB Stub getting called...'",
"print",
"'%s %s %s %s'",
"%",
"(",
"self",
",",
"node_id",
",",
"name",
",",
"labels",
")"
] | NeoDB Stub. | [
"NeoDB",
"Stub",
"."
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/neo_db.py#L88-L91 |
SuperCowPowers/workbench | workbench/server/neo_db.py | NeoDBStub.add_rel | def add_rel(self, source_node_id, target_node_id, rel):
"""NeoDB Stub."""
print 'NeoDB Stub getting called...'
print '%s %s %s %s' % (self, source_node_id, target_node_id, rel) | python | def add_rel(self, source_node_id, target_node_id, rel):
"""NeoDB Stub."""
print 'NeoDB Stub getting called...'
print '%s %s %s %s' % (self, source_node_id, target_node_id, rel) | [
"def",
"add_rel",
"(",
"self",
",",
"source_node_id",
",",
"target_node_id",
",",
"rel",
")",
":",
"print",
"'NeoDB Stub getting called...'",
"print",
"'%s %s %s %s'",
"%",
"(",
"self",
",",
"source_node_id",
",",
"target_node_id",
",",
"rel",
")"
] | NeoDB Stub. | [
"NeoDB",
"Stub",
"."
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/neo_db.py#L98-L101 |
SuperCowPowers/workbench | workbench/utils/tail_file.py | tail_file | def tail_file(filename):
''' Tail a file using pygtail. Note: this could probably be improved '''
with make_temp_file() as offset_file:
while True:
for line in pygtail.Pygtail(filename, offset_file=offset_file):
yield line
time.sleep(1.0) | python | def tail_file(filename):
''' Tail a file using pygtail. Note: this could probably be improved '''
with make_temp_file() as offset_file:
while True:
for line in pygtail.Pygtail(filename, offset_file=offset_file):
yield line
time.sleep(1.0) | [
"def",
"tail_file",
"(",
"filename",
")",
":",
"with",
"make_temp_file",
"(",
")",
"as",
"offset_file",
":",
"while",
"True",
":",
"for",
"line",
"in",
"pygtail",
".",
"Pygtail",
"(",
"filename",
",",
"offset_file",
"=",
"offset_file",
")",
":",
"yield",
... | Tail a file using pygtail. Note: this could probably be improved | [
"Tail",
"a",
"file",
"using",
"pygtail",
".",
"Note",
":",
"this",
"could",
"probably",
"be",
"improved"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/utils/tail_file.py#L25-L31 |
SuperCowPowers/workbench | workbench/workers/view_pe.py | ViewPE.execute | def execute(self, input_data):
''' Execute the ViewPE worker '''
# Just a small check to make sure we haven't been called on the wrong file type
if (input_data['meta']['type_tag'] != 'exe'):
return {'error': self.__class__.__name__+': called on '+input_data['meta']['type_tag']}
... | python | def execute(self, input_data):
''' Execute the ViewPE worker '''
# Just a small check to make sure we haven't been called on the wrong file type
if (input_data['meta']['type_tag'] != 'exe'):
return {'error': self.__class__.__name__+': called on '+input_data['meta']['type_tag']}
... | [
"def",
"execute",
"(",
"self",
",",
"input_data",
")",
":",
"# Just a small check to make sure we haven't been called on the wrong file type",
"if",
"(",
"input_data",
"[",
"'meta'",
"]",
"[",
"'type_tag'",
"]",
"!=",
"'exe'",
")",
":",
"return",
"{",
"'error'",
":"... | Execute the ViewPE worker | [
"Execute",
"the",
"ViewPE",
"worker"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/view_pe.py#L9-L24 |
SuperCowPowers/workbench | workbench/workers/view_pe.py | ViewPE.safe_get | def safe_get(data, key_list):
''' Safely access dictionary keys when plugin may have failed '''
for key in key_list:
data = data.get(key, {})
return data if data else 'plugin_failed' | python | def safe_get(data, key_list):
''' Safely access dictionary keys when plugin may have failed '''
for key in key_list:
data = data.get(key, {})
return data if data else 'plugin_failed' | [
"def",
"safe_get",
"(",
"data",
",",
"key_list",
")",
":",
"for",
"key",
"in",
"key_list",
":",
"data",
"=",
"data",
".",
"get",
"(",
"key",
",",
"{",
"}",
")",
"return",
"data",
"if",
"data",
"else",
"'plugin_failed'"
] | Safely access dictionary keys when plugin may have failed | [
"Safely",
"access",
"dictionary",
"keys",
"when",
"plugin",
"may",
"have",
"failed"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/view_pe.py#L28-L32 |
SuperCowPowers/workbench | workbench/utils/pcap_streamer.py | TCPDumpToWorkbench.execute | def execute(self):
''' Begin capturing PCAPs and sending them to workbench '''
# Create a temporary directory
self.temp_dir = tempfile.mkdtemp()
os.chdir(self.temp_dir)
# Spin up the directory watcher
DirWatcher(self.temp_dir, self.file_created)
# Spin up tcpdu... | python | def execute(self):
''' Begin capturing PCAPs and sending them to workbench '''
# Create a temporary directory
self.temp_dir = tempfile.mkdtemp()
os.chdir(self.temp_dir)
# Spin up the directory watcher
DirWatcher(self.temp_dir, self.file_created)
# Spin up tcpdu... | [
"def",
"execute",
"(",
"self",
")",
":",
"# Create a temporary directory",
"self",
".",
"temp_dir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"os",
".",
"chdir",
"(",
"self",
".",
"temp_dir",
")",
"# Spin up the directory watcher",
"DirWatcher",
"(",
"self",
... | Begin capturing PCAPs and sending them to workbench | [
"Begin",
"capturing",
"PCAPs",
"and",
"sending",
"them",
"to",
"workbench"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/utils/pcap_streamer.py#L59-L70 |
SuperCowPowers/workbench | workbench/utils/pcap_streamer.py | TCPDumpToWorkbench.file_created | def file_created(self, filepath):
''' File created callback '''
# Send the on-deck pcap to workbench
if self.on_deck:
self.store_file(self.on_deck)
os.remove(self.on_deck)
# Now put the newly created file on-deck
self.on_deck = filepath | python | def file_created(self, filepath):
''' File created callback '''
# Send the on-deck pcap to workbench
if self.on_deck:
self.store_file(self.on_deck)
os.remove(self.on_deck)
# Now put the newly created file on-deck
self.on_deck = filepath | [
"def",
"file_created",
"(",
"self",
",",
"filepath",
")",
":",
"# Send the on-deck pcap to workbench",
"if",
"self",
".",
"on_deck",
":",
"self",
".",
"store_file",
"(",
"self",
".",
"on_deck",
")",
"os",
".",
"remove",
"(",
"self",
".",
"on_deck",
")",
"#... | File created callback | [
"File",
"created",
"callback"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/utils/pcap_streamer.py#L72-L81 |
SuperCowPowers/workbench | workbench/utils/pcap_streamer.py | TCPDumpToWorkbench.store_file | def store_file(self, filename):
''' Store a file into workbench '''
# Spin up workbench
self.workbench = zerorpc.Client(timeout=300, heartbeat=60)
self.workbench.connect("tcp://127.0.0.1:4242")
# Open the file and send it to workbench
storage_name = "streamin... | python | def store_file(self, filename):
''' Store a file into workbench '''
# Spin up workbench
self.workbench = zerorpc.Client(timeout=300, heartbeat=60)
self.workbench.connect("tcp://127.0.0.1:4242")
# Open the file and send it to workbench
storage_name = "streamin... | [
"def",
"store_file",
"(",
"self",
",",
"filename",
")",
":",
"# Spin up workbench",
"self",
".",
"workbench",
"=",
"zerorpc",
".",
"Client",
"(",
"timeout",
"=",
"300",
",",
"heartbeat",
"=",
"60",
")",
"self",
".",
"workbench",
".",
"connect",
"(",
"\"t... | Store a file into workbench | [
"Store",
"a",
"file",
"into",
"workbench"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/utils/pcap_streamer.py#L83-L98 |
yfpeng/bioc | bioc/encoder.py | encode_document | def encode_document(obj):
"""Encode a single document."""
warnings.warn("deprecated. Please use bioc.biocxml.encoder.encode_document", DeprecationWarning)
return bioc.biocxml.encoder.encode_document(obj) | python | def encode_document(obj):
"""Encode a single document."""
warnings.warn("deprecated. Please use bioc.biocxml.encoder.encode_document", DeprecationWarning)
return bioc.biocxml.encoder.encode_document(obj) | [
"def",
"encode_document",
"(",
"obj",
")",
":",
"warnings",
".",
"warn",
"(",
"\"deprecated. Please use bioc.biocxml.encoder.encode_document\"",
",",
"DeprecationWarning",
")",
"return",
"bioc",
".",
"biocxml",
".",
"encoder",
".",
"encode_document",
"(",
"obj",
")"
] | Encode a single document. | [
"Encode",
"a",
"single",
"document",
"."
] | train | https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/encoder.py#L10-L13 |
yfpeng/bioc | bioc/encoder.py | encode_passage | def encode_passage(obj):
"""Encode a single passage."""
warnings.warn("deprecated. Please use bioc.biocxml.encoder.encode_passage", DeprecationWarning)
return bioc.biocxml.encoder.encode_passage(obj) | python | def encode_passage(obj):
"""Encode a single passage."""
warnings.warn("deprecated. Please use bioc.biocxml.encoder.encode_passage", DeprecationWarning)
return bioc.biocxml.encoder.encode_passage(obj) | [
"def",
"encode_passage",
"(",
"obj",
")",
":",
"warnings",
".",
"warn",
"(",
"\"deprecated. Please use bioc.biocxml.encoder.encode_passage\"",
",",
"DeprecationWarning",
")",
"return",
"bioc",
".",
"biocxml",
".",
"encoder",
".",
"encode_passage",
"(",
"obj",
")"
] | Encode a single passage. | [
"Encode",
"a",
"single",
"passage",
"."
] | train | https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/encoder.py#L16-L19 |
yfpeng/bioc | bioc/encoder.py | encode_sentence | def encode_sentence(obj):
"""Encode a single sentence."""
warnings.warn("deprecated. Please use bioc.biocxml.encoder.encode_sentence", DeprecationWarning)
return bioc.biocxml.encoder.encode_sentence(obj) | python | def encode_sentence(obj):
"""Encode a single sentence."""
warnings.warn("deprecated. Please use bioc.biocxml.encoder.encode_sentence", DeprecationWarning)
return bioc.biocxml.encoder.encode_sentence(obj) | [
"def",
"encode_sentence",
"(",
"obj",
")",
":",
"warnings",
".",
"warn",
"(",
"\"deprecated. Please use bioc.biocxml.encoder.encode_sentence\"",
",",
"DeprecationWarning",
")",
"return",
"bioc",
".",
"biocxml",
".",
"encoder",
".",
"encode_sentence",
"(",
"obj",
")"
] | Encode a single sentence. | [
"Encode",
"a",
"single",
"sentence",
"."
] | train | https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/encoder.py#L22-L25 |
yfpeng/bioc | bioc/encoder.py | encode_annotation | def encode_annotation(obj):
"""Encode a single annotation."""
warnings.warn("deprecated. Please use bioc.biocxml.encoder.encode_annotation",
DeprecationWarning)
return bioc.biocxml.encoder.encode_annotation(obj) | python | def encode_annotation(obj):
"""Encode a single annotation."""
warnings.warn("deprecated. Please use bioc.biocxml.encoder.encode_annotation",
DeprecationWarning)
return bioc.biocxml.encoder.encode_annotation(obj) | [
"def",
"encode_annotation",
"(",
"obj",
")",
":",
"warnings",
".",
"warn",
"(",
"\"deprecated. Please use bioc.biocxml.encoder.encode_annotation\"",
",",
"DeprecationWarning",
")",
"return",
"bioc",
".",
"biocxml",
".",
"encoder",
".",
"encode_annotation",
"(",
"obj",
... | Encode a single annotation. | [
"Encode",
"a",
"single",
"annotation",
"."
] | train | https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/encoder.py#L28-L32 |
yfpeng/bioc | bioc/encoder.py | encode_relation | def encode_relation(obj):
"""Encode a single relation."""
warnings.warn("deprecated. Please use bioc.biocxml.encoder.encode_relation", DeprecationWarning)
return bioc.biocxml.encoder.encode_relation(obj) | python | def encode_relation(obj):
"""Encode a single relation."""
warnings.warn("deprecated. Please use bioc.biocxml.encoder.encode_relation", DeprecationWarning)
return bioc.biocxml.encoder.encode_relation(obj) | [
"def",
"encode_relation",
"(",
"obj",
")",
":",
"warnings",
".",
"warn",
"(",
"\"deprecated. Please use bioc.biocxml.encoder.encode_relation\"",
",",
"DeprecationWarning",
")",
"return",
"bioc",
".",
"biocxml",
".",
"encoder",
".",
"encode_relation",
"(",
"obj",
")"
] | Encode a single relation. | [
"Encode",
"a",
"single",
"relation",
"."
] | train | https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/encoder.py#L35-L38 |
SuperCowPowers/workbench | workbench/workers/mem_pslist.py | MemoryImagePSList.parse_eprocess | def parse_eprocess(self, eprocess_data):
"""Parse the EProcess object we get from some rekall output"""
Name = eprocess_data['_EPROCESS']['Cybox']['Name']
PID = eprocess_data['_EPROCESS']['Cybox']['PID']
PPID = eprocess_data['_EPROCESS']['Cybox']['Parent_PID']
return {'Name': Nam... | python | def parse_eprocess(self, eprocess_data):
"""Parse the EProcess object we get from some rekall output"""
Name = eprocess_data['_EPROCESS']['Cybox']['Name']
PID = eprocess_data['_EPROCESS']['Cybox']['PID']
PPID = eprocess_data['_EPROCESS']['Cybox']['Parent_PID']
return {'Name': Nam... | [
"def",
"parse_eprocess",
"(",
"self",
",",
"eprocess_data",
")",
":",
"Name",
"=",
"eprocess_data",
"[",
"'_EPROCESS'",
"]",
"[",
"'Cybox'",
"]",
"[",
"'Name'",
"]",
"PID",
"=",
"eprocess_data",
"[",
"'_EPROCESS'",
"]",
"[",
"'Cybox'",
"]",
"[",
"'PID'",
... | Parse the EProcess object we get from some rekall output | [
"Parse",
"the",
"EProcess",
"object",
"we",
"get",
"from",
"some",
"rekall",
"output"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/mem_pslist.py#L24-L29 |
SuperCowPowers/workbench | workbench/workers/unzip.py | Unzip.execute | def execute(self, input_data):
''' Execute the Unzip worker '''
raw_bytes = input_data['sample']['raw_bytes']
zipfile_output = zipfile.ZipFile(StringIO(raw_bytes))
payload_md5s = []
for name in zipfile_output.namelist():
filename = os.path.basename(name)
p... | python | def execute(self, input_data):
''' Execute the Unzip worker '''
raw_bytes = input_data['sample']['raw_bytes']
zipfile_output = zipfile.ZipFile(StringIO(raw_bytes))
payload_md5s = []
for name in zipfile_output.namelist():
filename = os.path.basename(name)
p... | [
"def",
"execute",
"(",
"self",
",",
"input_data",
")",
":",
"raw_bytes",
"=",
"input_data",
"[",
"'sample'",
"]",
"[",
"'raw_bytes'",
"]",
"zipfile_output",
"=",
"zipfile",
".",
"ZipFile",
"(",
"StringIO",
"(",
"raw_bytes",
")",
")",
"payload_md5s",
"=",
"... | Execute the Unzip worker | [
"Execute",
"the",
"Unzip",
"worker"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/unzip.py#L20-L28 |
SuperCowPowers/workbench | workbench/workers/mem_dlllist.py | MemoryImageDllList.execute | def execute(self, input_data):
''' Execute method '''
# Spin up the rekall adapter
adapter = RekallAdapter()
adapter.set_plugin_name(self.plugin_name)
rekall_output = adapter.execute(input_data)
# Process the output data
for line in rekall_output:
i... | python | def execute(self, input_data):
''' Execute method '''
# Spin up the rekall adapter
adapter = RekallAdapter()
adapter.set_plugin_name(self.plugin_name)
rekall_output = adapter.execute(input_data)
# Process the output data
for line in rekall_output:
i... | [
"def",
"execute",
"(",
"self",
",",
"input_data",
")",
":",
"# Spin up the rekall adapter",
"adapter",
"=",
"RekallAdapter",
"(",
")",
"adapter",
".",
"set_plugin_name",
"(",
"self",
".",
"plugin_name",
")",
"rekall_output",
"=",
"adapter",
".",
"execute",
"(",
... | Execute method | [
"Execute",
"method"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/mem_dlllist.py#L32-L64 |
SuperCowPowers/workbench | workbench_apps/workbench_cli/help_content.py | WorkbenchShellHelp.help_cli | def help_cli(self):
""" Help on Workbench CLI """
help = '%sWelcome to Workbench CLI Help:%s' % (color.Yellow, color.Normal)
help += '\n\t%s> help cli_basic %s for getting started help' % (color.Green, color.LightBlue)
help += '\n\t%s> help workers %s for help on available workers' % (co... | python | def help_cli(self):
""" Help on Workbench CLI """
help = '%sWelcome to Workbench CLI Help:%s' % (color.Yellow, color.Normal)
help += '\n\t%s> help cli_basic %s for getting started help' % (color.Green, color.LightBlue)
help += '\n\t%s> help workers %s for help on available workers' % (co... | [
"def",
"help_cli",
"(",
"self",
")",
":",
"help",
"=",
"'%sWelcome to Workbench CLI Help:%s'",
"%",
"(",
"color",
".",
"Yellow",
",",
"color",
".",
"Normal",
")",
"help",
"+=",
"'\\n\\t%s> help cli_basic %s for getting started help'",
"%",
"(",
"color",
".",
"Gree... | Help on Workbench CLI | [
"Help",
"on",
"Workbench",
"CLI"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/help_content.py#L13-L24 |
SuperCowPowers/workbench | workbench_apps/workbench_cli/help_content.py | WorkbenchShellHelp.help_cli_basic | def help_cli_basic(self):
""" Help for Workbench CLI Basics """
help = '%sWorkbench: Getting started...' % (color.Yellow)
help += '\n%sLoad in a sample:' % (color.Green)
help += '\n\t%s> load_sample /path/to/file' % (color.LightBlue)
help += '\n\n%sNotice the prompt now shows t... | python | def help_cli_basic(self):
""" Help for Workbench CLI Basics """
help = '%sWorkbench: Getting started...' % (color.Yellow)
help += '\n%sLoad in a sample:' % (color.Green)
help += '\n\t%s> load_sample /path/to/file' % (color.LightBlue)
help += '\n\n%sNotice the prompt now shows t... | [
"def",
"help_cli_basic",
"(",
"self",
")",
":",
"help",
"=",
"'%sWorkbench: Getting started...'",
"%",
"(",
"color",
".",
"Yellow",
")",
"help",
"+=",
"'\\n%sLoad in a sample:'",
"%",
"(",
"color",
".",
"Green",
")",
"help",
"+=",
"'\\n\\t%s> load_sample /path/to/... | Help for Workbench CLI Basics | [
"Help",
"for",
"Workbench",
"CLI",
"Basics"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/help_content.py#L26-L37 |
SuperCowPowers/workbench | workbench_apps/workbench_cli/help_content.py | WorkbenchShellHelp.help_cli_search | def help_cli_search(self):
""" Help for Workbench CLI Search """
help = '%sSearch: %s returns sample_sets, a sample_set is a set/list of md5s.' % (color.Yellow, color.Green)
help += '\n\n\t%sSearch for all samples in the database that are known bad pe files,' % (color.Green)
help += '\... | python | def help_cli_search(self):
""" Help for Workbench CLI Search """
help = '%sSearch: %s returns sample_sets, a sample_set is a set/list of md5s.' % (color.Yellow, color.Green)
help += '\n\n\t%sSearch for all samples in the database that are known bad pe files,' % (color.Green)
help += '\... | [
"def",
"help_cli_search",
"(",
"self",
")",
":",
"help",
"=",
"'%sSearch: %s returns sample_sets, a sample_set is a set/list of md5s.'",
"%",
"(",
"color",
".",
"Yellow",
",",
"color",
".",
"Green",
")",
"help",
"+=",
"'\\n\\n\\t%sSearch for all samples in the database that... | Help for Workbench CLI Search | [
"Help",
"for",
"Workbench",
"CLI",
"Search"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/help_content.py#L39-L50 |
SuperCowPowers/workbench | workbench_apps/workbench_cli/help_content.py | WorkbenchShellHelp.help_dataframe | def help_dataframe(self):
""" Help for making a DataFrame with Workbench CLI """
help = '%sMaking a DataFrame: %s how to make a dataframe from raw data (pcap, memory, pe files)' % (color.Yellow, color.Green)
help += '\n\t%sNote: for memory_image and pe_files see > help dataframe_memory or dataf... | python | def help_dataframe(self):
""" Help for making a DataFrame with Workbench CLI """
help = '%sMaking a DataFrame: %s how to make a dataframe from raw data (pcap, memory, pe files)' % (color.Yellow, color.Green)
help += '\n\t%sNote: for memory_image and pe_files see > help dataframe_memory or dataf... | [
"def",
"help_dataframe",
"(",
"self",
")",
":",
"help",
"=",
"'%sMaking a DataFrame: %s how to make a dataframe from raw data (pcap, memory, pe files)'",
"%",
"(",
"color",
".",
"Yellow",
",",
"color",
".",
"Green",
")",
"help",
"+=",
"'\\n\\t%sNote: for memory_image and pe... | Help for making a DataFrame with Workbench CLI | [
"Help",
"for",
"making",
"a",
"DataFrame",
"with",
"Workbench",
"CLI"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/help_content.py#L52-L69 |
SuperCowPowers/workbench | workbench_apps/workbench_cli/help_content.py | WorkbenchShellHelp.help_dataframe_memory | def help_dataframe_memory(self):
""" Help for making a DataFrame with Workbench CLI """
help = '%sMaking a DataFrame: %s how to make a dataframe from memory_forensics sample' % (color.Yellow, color.Green)
help += '\n\n%sMemory Images Example:' % (color.Green)
help += '\n\t%s> load_samp... | python | def help_dataframe_memory(self):
""" Help for making a DataFrame with Workbench CLI """
help = '%sMaking a DataFrame: %s how to make a dataframe from memory_forensics sample' % (color.Yellow, color.Green)
help += '\n\n%sMemory Images Example:' % (color.Green)
help += '\n\t%s> load_samp... | [
"def",
"help_dataframe_memory",
"(",
"self",
")",
":",
"help",
"=",
"'%sMaking a DataFrame: %s how to make a dataframe from memory_forensics sample'",
"%",
"(",
"color",
".",
"Yellow",
",",
"color",
".",
"Green",
")",
"help",
"+=",
"'\\n\\n%sMemory Images Example:'",
"%",... | Help for making a DataFrame with Workbench CLI | [
"Help",
"for",
"making",
"a",
"DataFrame",
"with",
"Workbench",
"CLI"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/help_content.py#L71-L78 |
SuperCowPowers/workbench | workbench_apps/workbench_cli/help_content.py | WorkbenchShellHelp.help_dataframe_pe | def help_dataframe_pe(self):
""" Help for making a DataFrame with Workbench CLI """
help = '%sMaking a DataFrame: %s how to make a dataframe from pe files' % (color.Yellow, color.Green)
help += '\n\n%sPE Files Example (loading a directory):' % (color.Green)
help += '\n\t%s> load_sample... | python | def help_dataframe_pe(self):
""" Help for making a DataFrame with Workbench CLI """
help = '%sMaking a DataFrame: %s how to make a dataframe from pe files' % (color.Yellow, color.Green)
help += '\n\n%sPE Files Example (loading a directory):' % (color.Green)
help += '\n\t%s> load_sample... | [
"def",
"help_dataframe_pe",
"(",
"self",
")",
":",
"help",
"=",
"'%sMaking a DataFrame: %s how to make a dataframe from pe files'",
"%",
"(",
"color",
".",
"Yellow",
",",
"color",
".",
"Green",
")",
"help",
"+=",
"'\\n\\n%sPE Files Example (loading a directory):'",
"%",
... | Help for making a DataFrame with Workbench CLI | [
"Help",
"for",
"making",
"a",
"DataFrame",
"with",
"Workbench",
"CLI"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/help_content.py#L80-L96 |
SuperCowPowers/workbench | workbench_apps/workbench_cli/help_content.py | WorkbenchShellHelp._all_help_methods | def _all_help_methods(self):
""" Returns a list of all the Workbench commands"""
methods = {name:method for name, method in inspect.getmembers(self, predicate=inspect.isroutine) if not name.startswith('_')}
return methods | python | def _all_help_methods(self):
""" Returns a list of all the Workbench commands"""
methods = {name:method for name, method in inspect.getmembers(self, predicate=inspect.isroutine) if not name.startswith('_')}
return methods | [
"def",
"_all_help_methods",
"(",
"self",
")",
":",
"methods",
"=",
"{",
"name",
":",
"method",
"for",
"name",
",",
"method",
"in",
"inspect",
".",
"getmembers",
"(",
"self",
",",
"predicate",
"=",
"inspect",
".",
"isroutine",
")",
"if",
"not",
"name",
... | Returns a list of all the Workbench commands | [
"Returns",
"a",
"list",
"of",
"all",
"the",
"Workbench",
"commands"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/help_content.py#L101-L104 |
SuperCowPowers/workbench | workbench/workers/view_pcap_deep.py | ViewPcapDeep.execute | def execute(self, input_data):
''' ViewPcapDeep execute method '''
# Copy info from input
view = input_data['view_pcap']
# Grab a couple of handles
extracted_files = input_data['view_pcap']['extracted_files']
# Dump a couple of fields
del view['extracted_files'... | python | def execute(self, input_data):
''' ViewPcapDeep execute method '''
# Copy info from input
view = input_data['view_pcap']
# Grab a couple of handles
extracted_files = input_data['view_pcap']['extracted_files']
# Dump a couple of fields
del view['extracted_files'... | [
"def",
"execute",
"(",
"self",
",",
"input_data",
")",
":",
"# Copy info from input",
"view",
"=",
"input_data",
"[",
"'view_pcap'",
"]",
"# Grab a couple of handles",
"extracted_files",
"=",
"input_data",
"[",
"'view_pcap'",
"]",
"[",
"'extracted_files'",
"]",
"# D... | ViewPcapDeep execute method | [
"ViewPcapDeep",
"execute",
"method"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/view_pcap_deep.py#L16-L32 |
SuperCowPowers/workbench | workbench/workers/view_customer.py | ViewCustomer.execute | def execute(self, input_data):
''' Execute Method '''
# View on all the meta data files in the sample
fields = ['filename', 'md5', 'length', 'customer', 'import_time', 'type_tag']
view = {key:input_data['meta'][key] for key in fields}
return view | python | def execute(self, input_data):
''' Execute Method '''
# View on all the meta data files in the sample
fields = ['filename', 'md5', 'length', 'customer', 'import_time', 'type_tag']
view = {key:input_data['meta'][key] for key in fields}
return view | [
"def",
"execute",
"(",
"self",
",",
"input_data",
")",
":",
"# View on all the meta data files in the sample",
"fields",
"=",
"[",
"'filename'",
",",
"'md5'",
",",
"'length'",
",",
"'customer'",
",",
"'import_time'",
",",
"'type_tag'",
"]",
"view",
"=",
"{",
"ke... | Execute Method | [
"Execute",
"Method"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/view_customer.py#L7-L13 |
SuperCowPowers/workbench | workbench/workers/help_base.py | HelpBase.execute | def execute(self, input_data):
""" Info objects all have a type_tag of ('help','worker','command', or 'other') """
input_data = input_data['info']
type_tag = input_data['type_tag']
if type_tag == 'help':
return {'help': input_data['help'], 'type_tag': input_data['type_tag']}
... | python | def execute(self, input_data):
""" Info objects all have a type_tag of ('help','worker','command', or 'other') """
input_data = input_data['info']
type_tag = input_data['type_tag']
if type_tag == 'help':
return {'help': input_data['help'], 'type_tag': input_data['type_tag']}
... | [
"def",
"execute",
"(",
"self",
",",
"input_data",
")",
":",
"input_data",
"=",
"input_data",
"[",
"'info'",
"]",
"type_tag",
"=",
"input_data",
"[",
"'type_tag'",
"]",
"if",
"type_tag",
"==",
"'help'",
":",
"return",
"{",
"'help'",
":",
"input_data",
"[",
... | Info objects all have a type_tag of ('help','worker','command', or 'other') | [
"Info",
"objects",
"all",
"have",
"a",
"type_tag",
"of",
"(",
"help",
"worker",
"command",
"or",
"other",
")"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/help_base.py#L8-L24 |
yfpeng/bioc | bioc/biocjson/decoder.py | parse_collection | def parse_collection(obj: dict) -> BioCCollection:
"""Deserialize a dict obj to a BioCCollection object"""
collection = BioCCollection()
collection.source = obj['source']
collection.date = obj['date']
collection.key = obj['key']
collection.infons = obj['infons']
for doc in obj['docume... | python | def parse_collection(obj: dict) -> BioCCollection:
"""Deserialize a dict obj to a BioCCollection object"""
collection = BioCCollection()
collection.source = obj['source']
collection.date = obj['date']
collection.key = obj['key']
collection.infons = obj['infons']
for doc in obj['docume... | [
"def",
"parse_collection",
"(",
"obj",
":",
"dict",
")",
"->",
"BioCCollection",
":",
"collection",
"=",
"BioCCollection",
"(",
")",
"collection",
".",
"source",
"=",
"obj",
"[",
"'source'",
"]",
"collection",
".",
"date",
"=",
"obj",
"[",
"'date'",
"]",
... | Deserialize a dict obj to a BioCCollection object | [
"Deserialize",
"a",
"dict",
"obj",
"to",
"a",
"BioCCollection",
"object"
] | train | https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/biocjson/decoder.py#L14-L23 |
yfpeng/bioc | bioc/biocjson/decoder.py | parse_annotation | def parse_annotation(obj: dict) -> BioCAnnotation:
"""Deserialize a dict obj to a BioCAnnotation object"""
ann = BioCAnnotation()
ann.id = obj['id']
ann.infons = obj['infons']
ann.text = obj['text']
for loc in obj['locations']:
ann.add_location(BioCLocation(loc['offset'], loc['len... | python | def parse_annotation(obj: dict) -> BioCAnnotation:
"""Deserialize a dict obj to a BioCAnnotation object"""
ann = BioCAnnotation()
ann.id = obj['id']
ann.infons = obj['infons']
ann.text = obj['text']
for loc in obj['locations']:
ann.add_location(BioCLocation(loc['offset'], loc['len... | [
"def",
"parse_annotation",
"(",
"obj",
":",
"dict",
")",
"->",
"BioCAnnotation",
":",
"ann",
"=",
"BioCAnnotation",
"(",
")",
"ann",
".",
"id",
"=",
"obj",
"[",
"'id'",
"]",
"ann",
".",
"infons",
"=",
"obj",
"[",
"'infons'",
"]",
"ann",
".",
"text",
... | Deserialize a dict obj to a BioCAnnotation object | [
"Deserialize",
"a",
"dict",
"obj",
"to",
"a",
"BioCAnnotation",
"object"
] | train | https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/biocjson/decoder.py#L26-L34 |
yfpeng/bioc | bioc/biocjson/decoder.py | parse_relation | def parse_relation(obj: dict) -> BioCRelation:
"""Deserialize a dict obj to a BioCRelation object"""
rel = BioCRelation()
rel.id = obj['id']
rel.infons = obj['infons']
for node in obj['nodes']:
rel.add_node(BioCNode(node['refid'], node['role']))
return rel | python | def parse_relation(obj: dict) -> BioCRelation:
"""Deserialize a dict obj to a BioCRelation object"""
rel = BioCRelation()
rel.id = obj['id']
rel.infons = obj['infons']
for node in obj['nodes']:
rel.add_node(BioCNode(node['refid'], node['role']))
return rel | [
"def",
"parse_relation",
"(",
"obj",
":",
"dict",
")",
"->",
"BioCRelation",
":",
"rel",
"=",
"BioCRelation",
"(",
")",
"rel",
".",
"id",
"=",
"obj",
"[",
"'id'",
"]",
"rel",
".",
"infons",
"=",
"obj",
"[",
"'infons'",
"]",
"for",
"node",
"in",
"ob... | Deserialize a dict obj to a BioCRelation object | [
"Deserialize",
"a",
"dict",
"obj",
"to",
"a",
"BioCRelation",
"object"
] | train | https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/biocjson/decoder.py#L37-L44 |
yfpeng/bioc | bioc/biocjson/decoder.py | parse_sentence | def parse_sentence(obj: dict) -> BioCSentence:
"""Deserialize a dict obj to a BioCSentence object"""
sentence = BioCSentence()
sentence.offset = obj['offset']
sentence.infons = obj['infons']
sentence.text = obj['text']
for annotation in obj['annotations']:
sentence.add_annotation(... | python | def parse_sentence(obj: dict) -> BioCSentence:
"""Deserialize a dict obj to a BioCSentence object"""
sentence = BioCSentence()
sentence.offset = obj['offset']
sentence.infons = obj['infons']
sentence.text = obj['text']
for annotation in obj['annotations']:
sentence.add_annotation(... | [
"def",
"parse_sentence",
"(",
"obj",
":",
"dict",
")",
"->",
"BioCSentence",
":",
"sentence",
"=",
"BioCSentence",
"(",
")",
"sentence",
".",
"offset",
"=",
"obj",
"[",
"'offset'",
"]",
"sentence",
".",
"infons",
"=",
"obj",
"[",
"'infons'",
"]",
"senten... | Deserialize a dict obj to a BioCSentence object | [
"Deserialize",
"a",
"dict",
"obj",
"to",
"a",
"BioCSentence",
"object"
] | train | https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/biocjson/decoder.py#L47-L57 |
yfpeng/bioc | bioc/biocjson/decoder.py | parse_passage | def parse_passage(obj: dict) -> BioCPassage:
"""Deserialize a dict obj to a BioCPassage object"""
passage = BioCPassage()
passage.offset = obj['offset']
passage.infons = obj['infons']
if 'text' in obj:
passage.text = obj['text']
for sentence in obj['sentences']:
passage.a... | python | def parse_passage(obj: dict) -> BioCPassage:
"""Deserialize a dict obj to a BioCPassage object"""
passage = BioCPassage()
passage.offset = obj['offset']
passage.infons = obj['infons']
if 'text' in obj:
passage.text = obj['text']
for sentence in obj['sentences']:
passage.a... | [
"def",
"parse_passage",
"(",
"obj",
":",
"dict",
")",
"->",
"BioCPassage",
":",
"passage",
"=",
"BioCPassage",
"(",
")",
"passage",
".",
"offset",
"=",
"obj",
"[",
"'offset'",
"]",
"passage",
".",
"infons",
"=",
"obj",
"[",
"'infons'",
"]",
"if",
"'tex... | Deserialize a dict obj to a BioCPassage object | [
"Deserialize",
"a",
"dict",
"obj",
"to",
"a",
"BioCPassage",
"object"
] | train | https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/biocjson/decoder.py#L60-L73 |
yfpeng/bioc | bioc/biocjson/decoder.py | parse_doc | def parse_doc(obj: dict) -> BioCDocument:
"""Deserialize a dict obj to a BioCDocument object"""
doc = BioCDocument()
doc.id = obj['id']
doc.infons = obj['infons']
for passage in obj['passages']:
doc.add_passage(parse_passage(passage))
for annotation in obj['annotations']:
... | python | def parse_doc(obj: dict) -> BioCDocument:
"""Deserialize a dict obj to a BioCDocument object"""
doc = BioCDocument()
doc.id = obj['id']
doc.infons = obj['infons']
for passage in obj['passages']:
doc.add_passage(parse_passage(passage))
for annotation in obj['annotations']:
... | [
"def",
"parse_doc",
"(",
"obj",
":",
"dict",
")",
"->",
"BioCDocument",
":",
"doc",
"=",
"BioCDocument",
"(",
")",
"doc",
".",
"id",
"=",
"obj",
"[",
"'id'",
"]",
"doc",
".",
"infons",
"=",
"obj",
"[",
"'infons'",
"]",
"for",
"passage",
"in",
"obj"... | Deserialize a dict obj to a BioCDocument object | [
"Deserialize",
"a",
"dict",
"obj",
"to",
"a",
"BioCDocument",
"object"
] | train | https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/biocjson/decoder.py#L76-L87 |
yfpeng/bioc | bioc/biocjson/decoder.py | load | def load(fp, **kwargs) -> BioCCollection:
"""
Deserialize fp (a .read()-supporting text file or binary file containing a JSON document) to
a BioCCollection object
Args:
fp: a file containing a JSON document
**kwargs:
Returns:
BioCCollection: a collection
"""
... | python | def load(fp, **kwargs) -> BioCCollection:
"""
Deserialize fp (a .read()-supporting text file or binary file containing a JSON document) to
a BioCCollection object
Args:
fp: a file containing a JSON document
**kwargs:
Returns:
BioCCollection: a collection
"""
... | [
"def",
"load",
"(",
"fp",
",",
"*",
"*",
"kwargs",
")",
"->",
"BioCCollection",
":",
"obj",
"=",
"json",
".",
"load",
"(",
"fp",
",",
"*",
"*",
"kwargs",
")",
"return",
"parse_collection",
"(",
"obj",
")"
] | Deserialize fp (a .read()-supporting text file or binary file containing a JSON document) to
a BioCCollection object
Args:
fp: a file containing a JSON document
**kwargs:
Returns:
BioCCollection: a collection | [
"Deserialize",
"fp",
"(",
"a",
".",
"read",
"()",
"-",
"supporting",
"text",
"file",
"or",
"binary",
"file",
"containing",
"a",
"JSON",
"document",
")",
"to",
"a",
"BioCCollection",
"object",
"Args",
":",
"fp",
":",
"a",
"file",
"containing",
"a",
"JSON"... | train | https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/biocjson/decoder.py#L90-L103 |
yfpeng/bioc | bioc/biocjson/decoder.py | loads | def loads(s: str, **kwargs) -> BioCCollection:
"""
Deserialize s (a str, bytes or bytearray instance containing a JSON document) to
a BioCCollection object.
Args:
s(str):
**kwargs:
Returns:
BioCCollection: a collection
"""
obj = json.loads(s, **kwargs)
... | python | def loads(s: str, **kwargs) -> BioCCollection:
"""
Deserialize s (a str, bytes or bytearray instance containing a JSON document) to
a BioCCollection object.
Args:
s(str):
**kwargs:
Returns:
BioCCollection: a collection
"""
obj = json.loads(s, **kwargs)
... | [
"def",
"loads",
"(",
"s",
":",
"str",
",",
"*",
"*",
"kwargs",
")",
"->",
"BioCCollection",
":",
"obj",
"=",
"json",
".",
"loads",
"(",
"s",
",",
"*",
"*",
"kwargs",
")",
"return",
"parse_collection",
"(",
"obj",
")"
] | Deserialize s (a str, bytes or bytearray instance containing a JSON document) to
a BioCCollection object.
Args:
s(str):
**kwargs:
Returns:
BioCCollection: a collection | [
"Deserialize",
"s",
"(",
"a",
"str",
"bytes",
"or",
"bytearray",
"instance",
"containing",
"a",
"JSON",
"document",
")",
"to",
"a",
"BioCCollection",
"object",
".",
"Args",
":",
"s",
"(",
"str",
")",
":",
"**",
"kwargs",
":",
"Returns",
":",
"BioCCollect... | train | https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/biocjson/decoder.py#L106-L119 |
SuperCowPowers/workbench | workbench/workers/pcap_http_graph.py | PcapHTTPGraph.execute | def execute(self, input_data):
''' Okay this worker is going build graphs from PCAP Bro output logs '''
# Grab the Bro log handles from the input
bro_logs = input_data['pcap_bro']
# Weird log
if 'weird_log' in bro_logs:
stream = self.workbench.stream_sample(bro_logs... | python | def execute(self, input_data):
''' Okay this worker is going build graphs from PCAP Bro output logs '''
# Grab the Bro log handles from the input
bro_logs = input_data['pcap_bro']
# Weird log
if 'weird_log' in bro_logs:
stream = self.workbench.stream_sample(bro_logs... | [
"def",
"execute",
"(",
"self",
",",
"input_data",
")",
":",
"# Grab the Bro log handles from the input",
"bro_logs",
"=",
"input_data",
"[",
"'pcap_bro'",
"]",
"# Weird log",
"if",
"'weird_log'",
"in",
"bro_logs",
":",
"stream",
"=",
"self",
".",
"workbench",
".",... | Okay this worker is going build graphs from PCAP Bro output logs | [
"Okay",
"this",
"worker",
"is",
"going",
"build",
"graphs",
"from",
"PCAP",
"Bro",
"output",
"logs"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/pcap_http_graph.py#L45-L66 |
SuperCowPowers/workbench | workbench/workers/pcap_http_graph.py | PcapHTTPGraph.http_log_graph | def http_log_graph(self, stream):
''' Build up a graph (nodes and edges from a Bro http.log) '''
print 'Entering http_log_graph...'
for row in list(stream):
# Skip '-' hosts
if (row['id.orig_h'] == '-'):
continue
# Add the originating host
... | python | def http_log_graph(self, stream):
''' Build up a graph (nodes and edges from a Bro http.log) '''
print 'Entering http_log_graph...'
for row in list(stream):
# Skip '-' hosts
if (row['id.orig_h'] == '-'):
continue
# Add the originating host
... | [
"def",
"http_log_graph",
"(",
"self",
",",
"stream",
")",
":",
"print",
"'Entering http_log_graph...'",
"for",
"row",
"in",
"list",
"(",
"stream",
")",
":",
"# Skip '-' hosts",
"if",
"(",
"row",
"[",
"'id.orig_h'",
"]",
"==",
"'-'",
")",
":",
"continue",
"... | Build up a graph (nodes and edges from a Bro http.log) | [
"Build",
"up",
"a",
"graph",
"(",
"nodes",
"and",
"edges",
"from",
"a",
"Bro",
"http",
".",
"log",
")"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/pcap_http_graph.py#L68-L86 |
SuperCowPowers/workbench | workbench/workers/pcap_http_graph.py | PcapHTTPGraph.files_log_graph | def files_log_graph(self, stream):
''' Build up a graph (nodes and edges from a Bro dns.log) '''
for row in list(stream):
# dataframes['files_log'][['md5','mime_type','missing_bytes','rx_hosts','source','tx_hosts']]
# If the mime-type is interesting add the uri and ... | python | def files_log_graph(self, stream):
''' Build up a graph (nodes and edges from a Bro dns.log) '''
for row in list(stream):
# dataframes['files_log'][['md5','mime_type','missing_bytes','rx_hosts','source','tx_hosts']]
# If the mime-type is interesting add the uri and ... | [
"def",
"files_log_graph",
"(",
"self",
",",
"stream",
")",
":",
"for",
"row",
"in",
"list",
"(",
"stream",
")",
":",
"# dataframes['files_log'][['md5','mime_type','missing_bytes','rx_hosts','source','tx_hosts']]",
"# If the mime-type is interesting add the uri and the host->uri->ho... | Build up a graph (nodes and edges from a Bro dns.log) | [
"Build",
"up",
"a",
"graph",
"(",
"nodes",
"and",
"edges",
"from",
"a",
"Bro",
"dns",
".",
"log",
")"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/pcap_http_graph.py#L118-L154 |
SuperCowPowers/workbench | workbench/server/dir_watcher.py | DirWatcher.register_callbacks | def register_callbacks(self, on_create, on_modify, on_delete):
""" Register callbacks for file creation, modification, and deletion """
self.on_create = on_create
self.on_modify = on_modify
self.on_delete = on_delete | python | def register_callbacks(self, on_create, on_modify, on_delete):
""" Register callbacks for file creation, modification, and deletion """
self.on_create = on_create
self.on_modify = on_modify
self.on_delete = on_delete | [
"def",
"register_callbacks",
"(",
"self",
",",
"on_create",
",",
"on_modify",
",",
"on_delete",
")",
":",
"self",
".",
"on_create",
"=",
"on_create",
"self",
".",
"on_modify",
"=",
"on_modify",
"self",
".",
"on_delete",
"=",
"on_delete"
] | Register callbacks for file creation, modification, and deletion | [
"Register",
"callbacks",
"for",
"file",
"creation",
"modification",
"and",
"deletion"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/dir_watcher.py#L21-L25 |
SuperCowPowers/workbench | workbench/server/dir_watcher.py | DirWatcher._start_monitoring | def _start_monitoring(self):
""" Internal method that monitors the directory for changes """
# Grab all the timestamp info
before = self._file_timestamp_info(self.path)
while True:
gevent.sleep(1)
after = self._file_timestamp_info(self.path)
... | python | def _start_monitoring(self):
""" Internal method that monitors the directory for changes """
# Grab all the timestamp info
before = self._file_timestamp_info(self.path)
while True:
gevent.sleep(1)
after = self._file_timestamp_info(self.path)
... | [
"def",
"_start_monitoring",
"(",
"self",
")",
":",
"# Grab all the timestamp info",
"before",
"=",
"self",
".",
"_file_timestamp_info",
"(",
"self",
".",
"path",
")",
"while",
"True",
":",
"gevent",
".",
"sleep",
"(",
"1",
")",
"after",
"=",
"self",
".",
"... | Internal method that monitors the directory for changes | [
"Internal",
"method",
"that",
"monitors",
"the",
"directory",
"for",
"changes"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/dir_watcher.py#L31-L57 |
SuperCowPowers/workbench | workbench/server/dir_watcher.py | DirWatcher._file_timestamp_info | def _file_timestamp_info(self, path):
""" Grab all the timestamps for the files in the directory """
files = [os.path.join(path, fname) for fname in os.listdir(path) if '.py' in fname]
return dict ([(fname, os.path.getmtime(fname)) for fname in files]) | python | def _file_timestamp_info(self, path):
""" Grab all the timestamps for the files in the directory """
files = [os.path.join(path, fname) for fname in os.listdir(path) if '.py' in fname]
return dict ([(fname, os.path.getmtime(fname)) for fname in files]) | [
"def",
"_file_timestamp_info",
"(",
"self",
",",
"path",
")",
":",
"files",
"=",
"[",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"fname",
")",
"for",
"fname",
"in",
"os",
".",
"listdir",
"(",
"path",
")",
"if",
"'.py'",
"in",
"fname",
"]",
... | Grab all the timestamps for the files in the directory | [
"Grab",
"all",
"the",
"timestamps",
"for",
"the",
"files",
"in",
"the",
"directory"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/dir_watcher.py#L59-L62 |
SuperCowPowers/workbench | workbench/workers/timeout_corner/yara_sigs.py | YaraSigs.get_rules_from_disk | def get_rules_from_disk(self):
''' Recursively traverse the yara/rules directory for rules '''
# Try to find the yara rules directory relative to the worker
my_dir = os.path.dirname(os.path.realpath(__file__))
yara_rule_path = os.path.join(my_dir, 'yara/rules')
if not os.path.ex... | python | def get_rules_from_disk(self):
''' Recursively traverse the yara/rules directory for rules '''
# Try to find the yara rules directory relative to the worker
my_dir = os.path.dirname(os.path.realpath(__file__))
yara_rule_path = os.path.join(my_dir, 'yara/rules')
if not os.path.ex... | [
"def",
"get_rules_from_disk",
"(",
"self",
")",
":",
"# Try to find the yara rules directory relative to the worker",
"my_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"__file__",
")",
")",
"yara_rule_path",
"=",
"os",... | Recursively traverse the yara/rules directory for rules | [
"Recursively",
"traverse",
"the",
"yara",
"/",
"rules",
"directory",
"for",
"rules"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/timeout_corner/yara_sigs.py#L52-L67 |
SuperCowPowers/workbench | workbench/workers/timeout_corner/yara_sigs.py | YaraSigs.execute | def execute(self, input_data):
''' yara worker execute method '''
raw_bytes = input_data['sample']['raw_bytes']
matches = self.rules.match_data(raw_bytes)
# The matches data is organized in the following way
# {'filename1': [match_list], 'filename2': [match_list]}
# matc... | python | def execute(self, input_data):
''' yara worker execute method '''
raw_bytes = input_data['sample']['raw_bytes']
matches = self.rules.match_data(raw_bytes)
# The matches data is organized in the following way
# {'filename1': [match_list], 'filename2': [match_list]}
# matc... | [
"def",
"execute",
"(",
"self",
",",
"input_data",
")",
":",
"raw_bytes",
"=",
"input_data",
"[",
"'sample'",
"]",
"[",
"'raw_bytes'",
"]",
"matches",
"=",
"self",
".",
"rules",
".",
"match_data",
"(",
"raw_bytes",
")",
"# The matches data is organized in the fol... | yara worker execute method | [
"yara",
"worker",
"execute",
"method"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/timeout_corner/yara_sigs.py#L69-L95 |
SuperCowPowers/workbench | workbench/clients/upload_file_chunks.py | chunks | def chunks(data, chunk_size):
""" Yield chunk_size chunks from data."""
for i in xrange(0, len(data), chunk_size):
yield data[i:i+chunk_size] | python | def chunks(data, chunk_size):
""" Yield chunk_size chunks from data."""
for i in xrange(0, len(data), chunk_size):
yield data[i:i+chunk_size] | [
"def",
"chunks",
"(",
"data",
",",
"chunk_size",
")",
":",
"for",
"i",
"in",
"xrange",
"(",
"0",
",",
"len",
"(",
"data",
")",
",",
"chunk_size",
")",
":",
"yield",
"data",
"[",
"i",
":",
"i",
"+",
"chunk_size",
"]"
] | Yield chunk_size chunks from data. | [
"Yield",
"chunk_size",
"chunks",
"from",
"data",
"."
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/clients/upload_file_chunks.py#L9-L12 |
SuperCowPowers/workbench | workbench/clients/upload_file_chunks.py | run | def run():
"""This client pushes a file into Workbench."""
# Grab server args
args = client_helper.grab_server_args()
# Start up workbench connection
workbench = zerorpc.Client(timeout=300, heartbeat=60)
workbench.connect('tcp://'+args['server']+':'+args['port'])
# Upload the files in... | python | def run():
"""This client pushes a file into Workbench."""
# Grab server args
args = client_helper.grab_server_args()
# Start up workbench connection
workbench = zerorpc.Client(timeout=300, heartbeat=60)
workbench.connect('tcp://'+args['server']+':'+args['port'])
# Upload the files in... | [
"def",
"run",
"(",
")",
":",
"# Grab server args",
"args",
"=",
"client_helper",
".",
"grab_server_args",
"(",
")",
"# Start up workbench connection",
"workbench",
"=",
"zerorpc",
".",
"Client",
"(",
"timeout",
"=",
"300",
",",
"heartbeat",
"=",
"60",
")",
"wo... | This client pushes a file into Workbench. | [
"This",
"client",
"pushes",
"a",
"file",
"into",
"Workbench",
"."
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/clients/upload_file_chunks.py#L14-L39 |
SuperCowPowers/workbench | workbench/workers/yara_sigs.py | get_rules_from_disk | def get_rules_from_disk():
''' Recursively traverse the yara/rules directory for rules '''
# Try to find the yara rules directory relative to the worker
my_dir = os.path.dirname(os.path.realpath(__file__))
yara_rule_path = os.path.join(my_dir, 'yara/rules')
if not os.path.exists(yara_rule_path):
... | python | def get_rules_from_disk():
''' Recursively traverse the yara/rules directory for rules '''
# Try to find the yara rules directory relative to the worker
my_dir = os.path.dirname(os.path.realpath(__file__))
yara_rule_path = os.path.join(my_dir, 'yara/rules')
if not os.path.exists(yara_rule_path):
... | [
"def",
"get_rules_from_disk",
"(",
")",
":",
"# Try to find the yara rules directory relative to the worker",
"my_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"__file__",
")",
")",
"yara_rule_path",
"=",
"os",
".",
... | Recursively traverse the yara/rules directory for rules | [
"Recursively",
"traverse",
"the",
"yara",
"/",
"rules",
"directory",
"for",
"rules"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/yara_sigs.py#L9-L21 |
SuperCowPowers/workbench | workbench/workers/pcap_bro.py | PcapBro.setup_pcap_inputs | def setup_pcap_inputs(self, input_data):
''' Write the PCAPs to disk for Bro to process and return the pcap filenames '''
# Setup the pcap in the input data for processing by Bro. The input
# may be either an individual sample or a sample set.
file_list = []
if 'sample' in input... | python | def setup_pcap_inputs(self, input_data):
''' Write the PCAPs to disk for Bro to process and return the pcap filenames '''
# Setup the pcap in the input data for processing by Bro. The input
# may be either an individual sample or a sample set.
file_list = []
if 'sample' in input... | [
"def",
"setup_pcap_inputs",
"(",
"self",
",",
"input_data",
")",
":",
"# Setup the pcap in the input data for processing by Bro. The input",
"# may be either an individual sample or a sample set.",
"file_list",
"=",
"[",
"]",
"if",
"'sample'",
"in",
"input_data",
":",
"raw_byte... | Write the PCAPs to disk for Bro to process and return the pcap filenames | [
"Write",
"the",
"PCAPs",
"to",
"disk",
"for",
"Bro",
"to",
"process",
"and",
"return",
"the",
"pcap",
"filenames"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/pcap_bro.py#L29-L52 |
SuperCowPowers/workbench | workbench/workers/pcap_bro.py | PcapBro.execute | def execute(self, input_data):
''' Execute '''
# Get the bro script path (workers/bro/__load__.bro)
script_path = self.bro_script_dir
# Create a temporary directory
with self.goto_temp_directory() as temp_dir:
# Get the pcap inputs (filenames)
print 'pc... | python | def execute(self, input_data):
''' Execute '''
# Get the bro script path (workers/bro/__load__.bro)
script_path = self.bro_script_dir
# Create a temporary directory
with self.goto_temp_directory() as temp_dir:
# Get the pcap inputs (filenames)
print 'pc... | [
"def",
"execute",
"(",
"self",
",",
"input_data",
")",
":",
"# Get the bro script path (workers/bro/__load__.bro)",
"script_path",
"=",
"self",
".",
"bro_script_dir",
"# Create a temporary directory",
"with",
"self",
".",
"goto_temp_directory",
"(",
")",
"as",
"temp_dir",... | Execute | [
"Execute"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/pcap_bro.py#L54-L111 |
SuperCowPowers/workbench | workbench/workers/pcap_bro.py | PcapBro.subprocess_manager | def subprocess_manager(self, exec_args):
''' Bro subprocess manager '''
try:
sp = gevent.subprocess.Popen(exec_args, stdout=gevent.subprocess.PIPE, stderr=gevent.subprocess.PIPE)
except OSError:
raise RuntimeError('Could not run bro executable (either not installed or not... | python | def subprocess_manager(self, exec_args):
''' Bro subprocess manager '''
try:
sp = gevent.subprocess.Popen(exec_args, stdout=gevent.subprocess.PIPE, stderr=gevent.subprocess.PIPE)
except OSError:
raise RuntimeError('Could not run bro executable (either not installed or not... | [
"def",
"subprocess_manager",
"(",
"self",
",",
"exec_args",
")",
":",
"try",
":",
"sp",
"=",
"gevent",
".",
"subprocess",
".",
"Popen",
"(",
"exec_args",
",",
"stdout",
"=",
"gevent",
".",
"subprocess",
".",
"PIPE",
",",
"stderr",
"=",
"gevent",
".",
"... | Bro subprocess manager | [
"Bro",
"subprocess",
"manager"
] | train | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/pcap_bro.py#L113-L125 |
mfcloud/python-zvm-sdk | smtLayer/getVM.py | getConsole | def getConsole(rh):
"""
Get the virtual machine's console output.
Input:
Request Handle with the following properties:
function - 'CMDVM'
subfunction - 'CMD'
userid - userid of the virtual machine
Output:
Request Handle updated with the results.
... | python | def getConsole(rh):
"""
Get the virtual machine's console output.
Input:
Request Handle with the following properties:
function - 'CMDVM'
subfunction - 'CMD'
userid - userid of the virtual machine
Output:
Request Handle updated with the results.
... | [
"def",
"getConsole",
"(",
"rh",
")",
":",
"rh",
".",
"printSysLog",
"(",
"\"Enter getVM.getConsole\"",
")",
"# Transfer the console to this virtual machine.",
"parms",
"=",
"[",
"\"-T\"",
",",
"rh",
".",
"userid",
"]",
"results",
"=",
"invokeSMCLI",
"(",
"rh",
"... | Get the virtual machine's console output.
Input:
Request Handle with the following properties:
function - 'CMDVM'
subfunction - 'CMD'
userid - userid of the virtual machine
Output:
Request Handle updated with the results.
Return code - 0: ok, non-zero... | [
"Get",
"the",
"virtual",
"machine",
"s",
"console",
"output",
"."
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/getVM.py#L152-L283 |
mfcloud/python-zvm-sdk | smtLayer/getVM.py | getDirectory | def getDirectory(rh):
"""
Get the virtual machine's directory statements.
Input:
Request Handle with the following properties:
function - 'CMDVM'
subfunction - 'CMD'
userid - userid of the virtual machine
Output:
Request Handle updated with the resul... | python | def getDirectory(rh):
"""
Get the virtual machine's directory statements.
Input:
Request Handle with the following properties:
function - 'CMDVM'
subfunction - 'CMD'
userid - userid of the virtual machine
Output:
Request Handle updated with the resul... | [
"def",
"getDirectory",
"(",
"rh",
")",
":",
"rh",
".",
"printSysLog",
"(",
"\"Enter getVM.getDirectory\"",
")",
"parms",
"=",
"[",
"\"-T\"",
",",
"rh",
".",
"userid",
"]",
"results",
"=",
"invokeSMCLI",
"(",
"rh",
",",
"\"Image_Query_DM\"",
",",
"parms",
"... | Get the virtual machine's directory statements.
Input:
Request Handle with the following properties:
function - 'CMDVM'
subfunction - 'CMD'
userid - userid of the virtual machine
Output:
Request Handle updated with the results.
Return code - 0: ok, no... | [
"Get",
"the",
"virtual",
"machine",
"s",
"directory",
"statements",
"."
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/getVM.py#L286-L314 |
mfcloud/python-zvm-sdk | smtLayer/getVM.py | getStatus | def getStatus(rh):
"""
Get the basic status of a virtual machine.
Input:
Request Handle with the following properties:
function - 'CMDVM'
subfunction - 'CMD'
userid - userid of the virtual machine
Output:
Request Handle updated with the results.
... | python | def getStatus(rh):
"""
Get the basic status of a virtual machine.
Input:
Request Handle with the following properties:
function - 'CMDVM'
subfunction - 'CMD'
userid - userid of the virtual machine
Output:
Request Handle updated with the results.
... | [
"def",
"getStatus",
"(",
"rh",
")",
":",
"rh",
".",
"printSysLog",
"(",
"\"Enter getVM.getStatus, userid: \"",
"+",
"rh",
".",
"userid",
")",
"results",
"=",
"isLoggedOn",
"(",
"rh",
",",
"rh",
".",
"userid",
")",
"if",
"results",
"[",
"'rc'",
"]",
"!=",... | Get the basic status of a virtual machine.
Input:
Request Handle with the following properties:
function - 'CMDVM'
subfunction - 'CMD'
userid - userid of the virtual machine
Output:
Request Handle updated with the results.
Return code - 0: ok, non-zer... | [
"Get",
"the",
"basic",
"status",
"of",
"a",
"virtual",
"machine",
"."
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/getVM.py#L317-L392 |
mfcloud/python-zvm-sdk | smtLayer/getVM.py | extract_fcp_data | def extract_fcp_data(raw_data, status):
"""
extract data from smcli System_WWPN_Query output.
Input:
raw data returned from smcli
Output:
data extracted would be like:
'status:Free \n
fcp_dev_no:1D2F\n
physical_wwpn:C05076E9928051D1\n
channel_path_id:8B\n
npiv_wwp... | python | def extract_fcp_data(raw_data, status):
"""
extract data from smcli System_WWPN_Query output.
Input:
raw data returned from smcli
Output:
data extracted would be like:
'status:Free \n
fcp_dev_no:1D2F\n
physical_wwpn:C05076E9928051D1\n
channel_path_id:8B\n
npiv_wwp... | [
"def",
"extract_fcp_data",
"(",
"raw_data",
",",
"status",
")",
":",
"raw_data",
"=",
"raw_data",
".",
"split",
"(",
"'\\n'",
")",
"# clear blank lines",
"data",
"=",
"[",
"]",
"for",
"i",
"in",
"raw_data",
":",
"i",
"=",
"i",
".",
"strip",
"(",
"' \\n... | extract data from smcli System_WWPN_Query output.
Input:
raw data returned from smcli
Output:
data extracted would be like:
'status:Free \n
fcp_dev_no:1D2F\n
physical_wwpn:C05076E9928051D1\n
channel_path_id:8B\n
npiv_wwpn': 'NONE'\n
status:Free\n
fcp_dev_no:1D2... | [
"extract",
"data",
"from",
"smcli",
"System_WWPN_Query",
"output",
".",
"Input",
":",
"raw",
"data",
"returned",
"from",
"smcli",
"Output",
":",
"data",
"extracted",
"would",
"be",
"like",
":",
"status",
":",
"Free",
"\\",
"n",
"fcp_dev_no",
":",
"1D2F",
"... | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/getVM.py#L539-L576 |
mfcloud/python-zvm-sdk | smtLayer/getVM.py | fcpinfo | def fcpinfo(rh):
"""
Get fcp info and filter by the status.
Input:
Request Handle with the following properties:
function - 'GETVM'
subfunction - 'FCPINFO'
userid - userid of the virtual machine
parms['status'] - The status for filter results.
... | python | def fcpinfo(rh):
"""
Get fcp info and filter by the status.
Input:
Request Handle with the following properties:
function - 'GETVM'
subfunction - 'FCPINFO'
userid - userid of the virtual machine
parms['status'] - The status for filter results.
... | [
"def",
"fcpinfo",
"(",
"rh",
")",
":",
"rh",
".",
"printSysLog",
"(",
"\"Enter changeVM.dedicate\"",
")",
"parms",
"=",
"[",
"\"-T\"",
",",
"rh",
".",
"userid",
"]",
"hideList",
"=",
"[",
"]",
"results",
"=",
"invokeSMCLI",
"(",
"rh",
",",
"\"System_WWPN... | Get fcp info and filter by the status.
Input:
Request Handle with the following properties:
function - 'GETVM'
subfunction - 'FCPINFO'
userid - userid of the virtual machine
parms['status'] - The status for filter results.
Output:
Request Han... | [
"Get",
"fcp",
"info",
"and",
"filter",
"by",
"the",
"status",
"."
] | train | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/getVM.py#L579-L618 |
Chilipp/psyplot | psyplot/data.py | _no_auto_update_getter | def _no_auto_update_getter(self):
""":class:`bool`. Boolean controlling whether the :meth:`start_update`
method is automatically called by the :meth:`update` method
Examples
--------
You can disable the automatic update via
>>> with data.no_auto_update:
... data.update(time=1)... | python | def _no_auto_update_getter(self):
""":class:`bool`. Boolean controlling whether the :meth:`start_update`
method is automatically called by the :meth:`update` method
Examples
--------
You can disable the automatic update via
>>> with data.no_auto_update:
... data.update(time=1)... | [
"def",
"_no_auto_update_getter",
"(",
"self",
")",
":",
"if",
"getattr",
"(",
"self",
",",
"'_no_auto_update'",
",",
"None",
")",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_no_auto_update",
"else",
":",
"self",
".",
"_no_auto_update",
"=",
"utils",
... | :class:`bool`. Boolean controlling whether the :meth:`start_update`
method is automatically called by the :meth:`update` method
Examples
--------
You can disable the automatic update via
>>> with data.no_auto_update:
... data.update(time=1)
... data.start_update()
... | [
":",
"class",
":",
"bool",
".",
"Boolean",
"controlling",
"whether",
"the",
":",
"meth",
":",
"start_update",
"method",
"is",
"automatically",
"called",
"by",
"the",
":",
"meth",
":",
"update",
"method"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L52-L74 |
Chilipp/psyplot | psyplot/data.py | _infer_interval_breaks | def _infer_interval_breaks(coord):
"""
>>> _infer_interval_breaks(np.arange(5))
array([-0.5, 0.5, 1.5, 2.5, 3.5, 4.5])
Taken from xarray.plotting.plot module
"""
coord = np.asarray(coord)
deltas = 0.5 * (coord[1:] - coord[:-1])
first = coord[0] - deltas[0]
last = coord[-1] + de... | python | def _infer_interval_breaks(coord):
"""
>>> _infer_interval_breaks(np.arange(5))
array([-0.5, 0.5, 1.5, 2.5, 3.5, 4.5])
Taken from xarray.plotting.plot module
"""
coord = np.asarray(coord)
deltas = 0.5 * (coord[1:] - coord[:-1])
first = coord[0] - deltas[0]
last = coord[-1] + de... | [
"def",
"_infer_interval_breaks",
"(",
"coord",
")",
":",
"coord",
"=",
"np",
".",
"asarray",
"(",
"coord",
")",
"deltas",
"=",
"0.5",
"*",
"(",
"coord",
"[",
"1",
":",
"]",
"-",
"coord",
"[",
":",
"-",
"1",
"]",
")",
"first",
"=",
"coord",
"[",
... | >>> _infer_interval_breaks(np.arange(5))
array([-0.5, 0.5, 1.5, 2.5, 3.5, 4.5])
Taken from xarray.plotting.plot module | [
">>>",
"_infer_interval_breaks",
"(",
"np",
".",
"arange",
"(",
"5",
"))",
"array",
"(",
"[",
"-",
"0",
".",
"5",
"0",
".",
"5",
"1",
".",
"5",
"2",
".",
"5",
"3",
".",
"5",
"4",
".",
"5",
"]",
")"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L77-L88 |
Chilipp/psyplot | psyplot/data.py | _get_variable_names | def _get_variable_names(arr):
"""Return the variable names of an array"""
if VARIABLELABEL in arr.dims:
return arr.coords[VARIABLELABEL].tolist()
else:
return arr.name | python | def _get_variable_names(arr):
"""Return the variable names of an array"""
if VARIABLELABEL in arr.dims:
return arr.coords[VARIABLELABEL].tolist()
else:
return arr.name | [
"def",
"_get_variable_names",
"(",
"arr",
")",
":",
"if",
"VARIABLELABEL",
"in",
"arr",
".",
"dims",
":",
"return",
"arr",
".",
"coords",
"[",
"VARIABLELABEL",
"]",
".",
"tolist",
"(",
")",
"else",
":",
"return",
"arr",
".",
"name"
] | Return the variable names of an array | [
"Return",
"the",
"variable",
"names",
"of",
"an",
"array"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L91-L96 |
Chilipp/psyplot | psyplot/data.py | setup_coords | def setup_coords(arr_names=None, sort=[], dims={}, **kwargs):
"""
Sets up the arr_names dictionary for the plot
Parameters
----------
arr_names: string, list of strings or dictionary
Set the unique array names of the resulting arrays and (optionally)
dimensions.
- if string... | python | def setup_coords(arr_names=None, sort=[], dims={}, **kwargs):
"""
Sets up the arr_names dictionary for the plot
Parameters
----------
arr_names: string, list of strings or dictionary
Set the unique array names of the resulting arrays and (optionally)
dimensions.
- if string... | [
"def",
"setup_coords",
"(",
"arr_names",
"=",
"None",
",",
"sort",
"=",
"[",
"]",
",",
"dims",
"=",
"{",
"}",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"OrderedDict",
"(",
"arr_names",
")",
"except",
"(",
"ValueError",
",",
"TypeError"... | Sets up the arr_names dictionary for the plot
Parameters
----------
arr_names: string, list of strings or dictionary
Set the unique array names of the resulting arrays and (optionally)
dimensions.
- if string: same as list of strings (see below). Strings may
include {0} w... | [
"Sets",
"up",
"the",
"arr_names",
"dictionary",
"for",
"the",
"plot"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L113-L187 |
Chilipp/psyplot | psyplot/data.py | to_slice | def to_slice(arr):
"""Test whether `arr` is an integer array that can be replaced by a slice
Parameters
----------
arr: numpy.array
Numpy integer array
Returns
-------
slice or None
If `arr` could be converted to an array, this is returned, otherwise
`None` is retur... | python | def to_slice(arr):
"""Test whether `arr` is an integer array that can be replaced by a slice
Parameters
----------
arr: numpy.array
Numpy integer array
Returns
-------
slice or None
If `arr` could be converted to an array, this is returned, otherwise
`None` is retur... | [
"def",
"to_slice",
"(",
"arr",
")",
":",
"if",
"isinstance",
"(",
"arr",
",",
"slice",
")",
":",
"return",
"arr",
"if",
"len",
"(",
"arr",
")",
"==",
"1",
":",
"return",
"slice",
"(",
"arr",
"[",
"0",
"]",
",",
"arr",
"[",
"0",
"]",
"+",
"1",... | Test whether `arr` is an integer array that can be replaced by a slice
Parameters
----------
arr: numpy.array
Numpy integer array
Returns
-------
slice or None
If `arr` could be converted to an array, this is returned, otherwise
`None` is returned
See Also
----... | [
"Test",
"whether",
"arr",
"is",
"an",
"integer",
"array",
"that",
"can",
"be",
"replaced",
"by",
"a",
"slice"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L190-L213 |
Chilipp/psyplot | psyplot/data.py | get_index_from_coord | def get_index_from_coord(coord, base_index):
"""Function to return the coordinate as integer, integer array or slice
If `coord` is zero-dimensional, the corresponding integer in `base_index`
will be supplied. Otherwise it is first tried to return a slice, if that
does not work an integer array with the... | python | def get_index_from_coord(coord, base_index):
"""Function to return the coordinate as integer, integer array or slice
If `coord` is zero-dimensional, the corresponding integer in `base_index`
will be supplied. Otherwise it is first tried to return a slice, if that
does not work an integer array with the... | [
"def",
"get_index_from_coord",
"(",
"coord",
",",
"base_index",
")",
":",
"try",
":",
"values",
"=",
"coord",
".",
"values",
"except",
"AttributeError",
":",
"values",
"=",
"coord",
"if",
"values",
".",
"ndim",
"==",
"0",
":",
"return",
"base_index",
".",
... | Function to return the coordinate as integer, integer array or slice
If `coord` is zero-dimensional, the corresponding integer in `base_index`
will be supplied. Otherwise it is first tried to return a slice, if that
does not work an integer array with the corresponding indices is returned.
Parameters
... | [
"Function",
"to",
"return",
"the",
"coordinate",
"as",
"integer",
"integer",
"array",
"or",
"slice"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L216-L245 |
Chilipp/psyplot | psyplot/data.py | get_tdata | def get_tdata(t_format, files):
"""
Get the time information from file names
Parameters
----------
t_format: str
The string that can be used to get the time information in the files.
Any numeric datetime format string (e.g. %Y, %m, %H) can be used, but
not non-numeric string... | python | def get_tdata(t_format, files):
"""
Get the time information from file names
Parameters
----------
t_format: str
The string that can be used to get the time information in the files.
Any numeric datetime format string (e.g. %Y, %m, %H) can be used, but
not non-numeric string... | [
"def",
"get_tdata",
"(",
"t_format",
",",
"files",
")",
":",
"def",
"median",
"(",
"arr",
")",
":",
"return",
"arr",
".",
"min",
"(",
")",
"+",
"(",
"arr",
".",
"max",
"(",
")",
"-",
"arr",
".",
"min",
"(",
")",
")",
"/",
"2",
"import",
"re",... | Get the time information from file names
Parameters
----------
t_format: str
The string that can be used to get the time information in the files.
Any numeric datetime format string (e.g. %Y, %m, %H) can be used, but
not non-numeric strings like %b, etc. See [1]_ for the datetime fo... | [
"Get",
"the",
"time",
"information",
"from",
"file",
"names"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L261-L301 |
Chilipp/psyplot | psyplot/data.py | to_netcdf | def to_netcdf(ds, *args, **kwargs):
"""
Store the given dataset as a netCDF file
This functions works essentially the same as the usual
:meth:`xarray.Dataset.to_netcdf` method but can also encode absolute time
units
Parameters
----------
ds: xarray.Dataset
The dataset to store
... | python | def to_netcdf(ds, *args, **kwargs):
"""
Store the given dataset as a netCDF file
This functions works essentially the same as the usual
:meth:`xarray.Dataset.to_netcdf` method but can also encode absolute time
units
Parameters
----------
ds: xarray.Dataset
The dataset to store
... | [
"def",
"to_netcdf",
"(",
"ds",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"to_update",
"=",
"{",
"}",
"for",
"v",
",",
"obj",
"in",
"six",
".",
"iteritems",
"(",
"ds",
".",
"variables",
")",
":",
"units",
"=",
"obj",
".",
"attrs",
"."... | Store the given dataset as a netCDF file
This functions works essentially the same as the usual
:meth:`xarray.Dataset.to_netcdf` method but can also encode absolute time
units
Parameters
----------
ds: xarray.Dataset
The dataset to store
%(xarray.Dataset.to_netcdf.parameters)s | [
"Store",
"the",
"given",
"dataset",
"as",
"a",
"netCDF",
"file"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L309-L335 |
Chilipp/psyplot | psyplot/data.py | _get_fname_nio | def _get_fname_nio(store):
"""Try to get the file name from the NioDataStore store"""
try:
f = store.ds.file
except AttributeError:
return None
try:
return f.path
except AttributeError:
return None | python | def _get_fname_nio(store):
"""Try to get the file name from the NioDataStore store"""
try:
f = store.ds.file
except AttributeError:
return None
try:
return f.path
except AttributeError:
return None | [
"def",
"_get_fname_nio",
"(",
"store",
")",
":",
"try",
":",
"f",
"=",
"store",
".",
"ds",
".",
"file",
"except",
"AttributeError",
":",
"return",
"None",
"try",
":",
"return",
"f",
".",
"path",
"except",
"AttributeError",
":",
"return",
"None"
] | Try to get the file name from the NioDataStore store | [
"Try",
"to",
"get",
"the",
"file",
"name",
"from",
"the",
"NioDataStore",
"store"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L351-L360 |
Chilipp/psyplot | psyplot/data.py | get_filename_ds | def get_filename_ds(ds, dump=True, paths=None, **kwargs):
"""
Return the filename of the corresponding to a dataset
This method returns the path to the `ds` or saves the dataset
if there exists no filename
Parameters
----------
ds: xarray.Dataset
The dataset you want the path infor... | python | def get_filename_ds(ds, dump=True, paths=None, **kwargs):
"""
Return the filename of the corresponding to a dataset
This method returns the path to the `ds` or saves the dataset
if there exists no filename
Parameters
----------
ds: xarray.Dataset
The dataset you want the path infor... | [
"def",
"get_filename_ds",
"(",
"ds",
",",
"dump",
"=",
"True",
",",
"paths",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"tempfile",
"import",
"NamedTemporaryFile",
"# if already specified, return that filename",
"if",
"ds",
".",
"psy",
".",
"_file... | Return the filename of the corresponding to a dataset
This method returns the path to the `ds` or saves the dataset
if there exists no filename
Parameters
----------
ds: xarray.Dataset
The dataset you want the path information for
dump: bool
If True and the dataset has not been... | [
"Return",
"the",
"filename",
"of",
"the",
"corresponding",
"to",
"a",
"dataset"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L416-L524 |
Chilipp/psyplot | psyplot/data.py | open_dataset | def open_dataset(filename_or_obj, decode_cf=True, decode_times=True,
decode_coords=True, engine=None, gridfile=None, **kwargs):
"""
Open an instance of :class:`xarray.Dataset`.
This method has the same functionality as the :func:`xarray.open_dataset`
method except that is supports an a... | python | def open_dataset(filename_or_obj, decode_cf=True, decode_times=True,
decode_coords=True, engine=None, gridfile=None, **kwargs):
"""
Open an instance of :class:`xarray.Dataset`.
This method has the same functionality as the :func:`xarray.open_dataset`
method except that is supports an a... | [
"def",
"open_dataset",
"(",
"filename_or_obj",
",",
"decode_cf",
"=",
"True",
",",
"decode_times",
"=",
"True",
",",
"decode_coords",
"=",
"True",
",",
"engine",
"=",
"None",
",",
"gridfile",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# use the absol... | Open an instance of :class:`xarray.Dataset`.
This method has the same functionality as the :func:`xarray.open_dataset`
method except that is supports an additional 'gdal' engine to open
gdal Rasters (e.g. GeoTiffs) and that is supports absolute time units like
``'day as %Y%m%d.%f'`` (if `decode_cf` and... | [
"Open",
"an",
"instance",
"of",
":",
"class",
":",
"xarray",
".",
"Dataset",
"."
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1926-L1963 |
Chilipp/psyplot | psyplot/data.py | open_mfdataset | def open_mfdataset(paths, decode_cf=True, decode_times=True,
decode_coords=True, engine=None, gridfile=None,
t_format=None, **kwargs):
"""
Open multiple files as a single dataset.
This function is essentially the same as the :func:`xarray.open_mfdataset`
function b... | python | def open_mfdataset(paths, decode_cf=True, decode_times=True,
decode_coords=True, engine=None, gridfile=None,
t_format=None, **kwargs):
"""
Open multiple files as a single dataset.
This function is essentially the same as the :func:`xarray.open_mfdataset`
function b... | [
"def",
"open_mfdataset",
"(",
"paths",
",",
"decode_cf",
"=",
"True",
",",
"decode_times",
"=",
"True",
",",
"decode_coords",
"=",
"True",
",",
"engine",
"=",
"None",
",",
"gridfile",
"=",
"None",
",",
"t_format",
"=",
"None",
",",
"*",
"*",
"kwargs",
... | Open multiple files as a single dataset.
This function is essentially the same as the :func:`xarray.open_mfdataset`
function but (as the :func:`open_dataset`) supports additional decoding
and the ``'gdal'`` engine.
You can further specify the `t_format` parameter to get the time
information from th... | [
"Open",
"multiple",
"files",
"as",
"a",
"single",
"dataset",
"."
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1982-L2027 |
Chilipp/psyplot | psyplot/data.py | _open_ds_from_store | def _open_ds_from_store(fname, store_mod=None, store_cls=None, **kwargs):
"""Open a dataset and return it"""
if isinstance(fname, xr.Dataset):
return fname
if not isstring(fname):
try: # test iterable
fname[0]
except TypeError:
pass
else:
... | python | def _open_ds_from_store(fname, store_mod=None, store_cls=None, **kwargs):
"""Open a dataset and return it"""
if isinstance(fname, xr.Dataset):
return fname
if not isstring(fname):
try: # test iterable
fname[0]
except TypeError:
pass
else:
... | [
"def",
"_open_ds_from_store",
"(",
"fname",
",",
"store_mod",
"=",
"None",
",",
"store_cls",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"fname",
",",
"xr",
".",
"Dataset",
")",
":",
"return",
"fname",
"if",
"not",
"isstrin... | Open a dataset and return it | [
"Open",
"a",
"dataset",
"and",
"return",
"it"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L4738-L4760 |
Chilipp/psyplot | psyplot/data.py | Signal.disconnect | def disconnect(self, func=None):
"""Disconnect a function call to the signal. If None, all connections
are disconnected"""
if func is None:
self._connections = []
else:
self._connections.remove(func) | python | def disconnect(self, func=None):
"""Disconnect a function call to the signal. If None, all connections
are disconnected"""
if func is None:
self._connections = []
else:
self._connections.remove(func) | [
"def",
"disconnect",
"(",
"self",
",",
"func",
"=",
"None",
")",
":",
"if",
"func",
"is",
"None",
":",
"self",
".",
"_connections",
"=",
"[",
"]",
"else",
":",
"self",
".",
"_connections",
".",
"remove",
"(",
"func",
")"
] | Disconnect a function call to the signal. If None, all connections
are disconnected | [
"Disconnect",
"a",
"function",
"call",
"to",
"the",
"signal",
".",
"If",
"None",
"all",
"connections",
"are",
"disconnected"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L390-L396 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.logger | def logger(self):
""":class:`logging.Logger` of this instance"""
try:
return self._logger
except AttributeError:
name = '%s.%s' % (self.__module__, self.__class__.__name__)
self._logger = logging.getLogger(name)
self.logger.debug('Initializing...')... | python | def logger(self):
""":class:`logging.Logger` of this instance"""
try:
return self._logger
except AttributeError:
name = '%s.%s' % (self.__module__, self.__class__.__name__)
self._logger = logging.getLogger(name)
self.logger.debug('Initializing...')... | [
"def",
"logger",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_logger",
"except",
"AttributeError",
":",
"name",
"=",
"'%s.%s'",
"%",
"(",
"self",
".",
"__module__",
",",
"self",
".",
"__class__",
".",
"__name__",
")",
"self",
".",
"_logg... | :class:`logging.Logger` of this instance | [
":",
"class",
":",
"logging",
".",
"Logger",
"of",
"this",
"instance"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L535-L543 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.get_decoder | def get_decoder(cls, ds, var):
"""
Class method to get the right decoder class that can decode the
given dataset and variable
Parameters
----------
%(CFDecoder.can_decode.parameters)s
Returns
-------
CFDecoder
The decoder for the give... | python | def get_decoder(cls, ds, var):
"""
Class method to get the right decoder class that can decode the
given dataset and variable
Parameters
----------
%(CFDecoder.can_decode.parameters)s
Returns
-------
CFDecoder
The decoder for the give... | [
"def",
"get_decoder",
"(",
"cls",
",",
"ds",
",",
"var",
")",
":",
"for",
"decoder_cls",
"in",
"cls",
".",
"_registry",
":",
"if",
"decoder_cls",
".",
"can_decode",
"(",
"ds",
",",
"var",
")",
":",
"return",
"decoder_cls",
"(",
"ds",
")",
"return",
"... | Class method to get the right decoder class that can decode the
given dataset and variable
Parameters
----------
%(CFDecoder.can_decode.parameters)s
Returns
-------
CFDecoder
The decoder for the given dataset that can decode the variable
... | [
"Class",
"method",
"to",
"get",
"the",
"right",
"decoder",
"class",
"that",
"can",
"decode",
"the",
"given",
"dataset",
"and",
"variable"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L601-L618 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.decode_coords | def decode_coords(ds, gridfile=None):
"""
Sets the coordinates and bounds in a dataset
This static method sets those coordinates and bounds that are marked
marked in the netCDF attributes as coordinates in :attr:`ds` (without
deleting them from the variable attributes because th... | python | def decode_coords(ds, gridfile=None):
"""
Sets the coordinates and bounds in a dataset
This static method sets those coordinates and bounds that are marked
marked in the netCDF attributes as coordinates in :attr:`ds` (without
deleting them from the variable attributes because th... | [
"def",
"decode_coords",
"(",
"ds",
",",
"gridfile",
"=",
"None",
")",
":",
"def",
"add_attrs",
"(",
"obj",
")",
":",
"if",
"'coordinates'",
"in",
"obj",
".",
"attrs",
":",
"extra_coords",
".",
"update",
"(",
"obj",
".",
"attrs",
"[",
"'coordinates'",
"... | Sets the coordinates and bounds in a dataset
This static method sets those coordinates and bounds that are marked
marked in the netCDF attributes as coordinates in :attr:`ds` (without
deleting them from the variable attributes because this information is
necessary for visualizing the da... | [
"Sets",
"the",
"coordinates",
"and",
"bounds",
"in",
"a",
"dataset"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L623-L664 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.is_triangular | def is_triangular(self, var):
"""
Test if a variable is on a triangular grid
This method first checks the `grid_type` attribute of the variable (if
existent) whether it is equal to ``"unstructered"``, then it checks
whether the bounds are not two-dimensional.
Parameters... | python | def is_triangular(self, var):
"""
Test if a variable is on a triangular grid
This method first checks the `grid_type` attribute of the variable (if
existent) whether it is equal to ``"unstructered"``, then it checks
whether the bounds are not two-dimensional.
Parameters... | [
"def",
"is_triangular",
"(",
"self",
",",
"var",
")",
":",
"warn",
"(",
"\"The 'is_triangular' method is depreceated and will be removed \"",
"\"soon! Use the 'is_unstructured' method!\"",
",",
"DeprecationWarning",
",",
"stacklevel",
"=",
"1",
")",
"return",
"str",
"(",
... | Test if a variable is on a triangular grid
This method first checks the `grid_type` attribute of the variable (if
existent) whether it is equal to ``"unstructered"``, then it checks
whether the bounds are not two-dimensional.
Parameters
----------
var: xarray.Variable o... | [
"Test",
"if",
"a",
"variable",
"is",
"on",
"a",
"triangular",
"grid"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L669-L690 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.get_cell_node_coord | def get_cell_node_coord(self, var, coords=None, axis='x', nans=None):
"""
Checks whether the bounds in the variable attribute are triangular
Parameters
----------
var: xarray.Variable or xarray.DataArray
The variable to check
coords: dict
Coordina... | python | def get_cell_node_coord(self, var, coords=None, axis='x', nans=None):
"""
Checks whether the bounds in the variable attribute are triangular
Parameters
----------
var: xarray.Variable or xarray.DataArray
The variable to check
coords: dict
Coordina... | [
"def",
"get_cell_node_coord",
"(",
"self",
",",
"var",
",",
"coords",
"=",
"None",
",",
"axis",
"=",
"'x'",
",",
"nans",
"=",
"None",
")",
":",
"if",
"coords",
"is",
"None",
":",
"coords",
"=",
"self",
".",
"ds",
".",
"coords",
"axis",
"=",
"axis",... | Checks whether the bounds in the variable attribute are triangular
Parameters
----------
var: xarray.Variable or xarray.DataArray
The variable to check
coords: dict
Coordinates to use. If None, the coordinates of the dataset in the
:attr:`ds` attribut... | [
"Checks",
"whether",
"the",
"bounds",
"in",
"the",
"variable",
"attribute",
"are",
"triangular"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L696-L749 |
Chilipp/psyplot | psyplot/data.py | CFDecoder._get_coord_cell_node_coord | def _get_coord_cell_node_coord(self, coord, coords=None, nans=None,
var=None):
"""
Get the boundaries of an unstructed coordinate
Parameters
----------
coord: xr.Variable
The coordinate whose bounds should be returned
%(CFDe... | python | def _get_coord_cell_node_coord(self, coord, coords=None, nans=None,
var=None):
"""
Get the boundaries of an unstructed coordinate
Parameters
----------
coord: xr.Variable
The coordinate whose bounds should be returned
%(CFDe... | [
"def",
"_get_coord_cell_node_coord",
"(",
"self",
",",
"coord",
",",
"coords",
"=",
"None",
",",
"nans",
"=",
"None",
",",
"var",
"=",
"None",
")",
":",
"bounds",
"=",
"coord",
".",
"attrs",
".",
"get",
"(",
"'bounds'",
")",
"if",
"bounds",
"is",
"no... | Get the boundaries of an unstructed coordinate
Parameters
----------
coord: xr.Variable
The coordinate whose bounds should be returned
%(CFDecoder.get_cell_node_coord.parameters.no_var|axis)s
Returns
-------
%(CFDecoder.get_cell_node_coord.returns)s | [
"Get",
"the",
"boundaries",
"of",
"an",
"unstructed",
"coordinate"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L755-L790 |
Chilipp/psyplot | psyplot/data.py | CFDecoder._check_triangular_bounds | def _check_triangular_bounds(self, var, coords=None, axis='x', nans=None):
"""
Checks whether the bounds in the variable attribute are triangular
Parameters
----------
%(CFDecoder.get_cell_node_coord.parameters)s
Returns
-------
bool or None
... | python | def _check_triangular_bounds(self, var, coords=None, axis='x', nans=None):
"""
Checks whether the bounds in the variable attribute are triangular
Parameters
----------
%(CFDecoder.get_cell_node_coord.parameters)s
Returns
-------
bool or None
... | [
"def",
"_check_triangular_bounds",
"(",
"self",
",",
"var",
",",
"coords",
"=",
"None",
",",
"axis",
"=",
"'x'",
",",
"nans",
"=",
"None",
")",
":",
"# !!! WILL BE REMOVED IN THE NEAR FUTURE! !!!",
"bounds",
"=",
"self",
".",
"get_cell_node_coord",
"(",
"var",
... | Checks whether the bounds in the variable attribute are triangular
Parameters
----------
%(CFDecoder.get_cell_node_coord.parameters)s
Returns
-------
bool or None
True, if unstructered, None if it could not be determined
xarray.Coordinate or None
... | [
"Checks",
"whether",
"the",
"bounds",
"in",
"the",
"variable",
"attribute",
"are",
"triangular"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L795-L815 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.is_unstructured | def is_unstructured(self, var):
"""
Test if a variable is on an unstructered grid
Parameters
----------
%(CFDecoder.is_triangular.parameters)s
Returns
-------
%(CFDecoder.is_triangular.returns)s
Notes
-----
Currently this is the ... | python | def is_unstructured(self, var):
"""
Test if a variable is on an unstructered grid
Parameters
----------
%(CFDecoder.is_triangular.parameters)s
Returns
-------
%(CFDecoder.is_triangular.returns)s
Notes
-----
Currently this is the ... | [
"def",
"is_unstructured",
"(",
"self",
",",
"var",
")",
":",
"if",
"str",
"(",
"var",
".",
"attrs",
".",
"get",
"(",
"'grid_type'",
")",
")",
"==",
"'unstructured'",
":",
"return",
"True",
"xcoord",
"=",
"self",
".",
"get_x",
"(",
"var",
")",
"if",
... | Test if a variable is on an unstructered grid
Parameters
----------
%(CFDecoder.is_triangular.parameters)s
Returns
-------
%(CFDecoder.is_triangular.returns)s
Notes
-----
Currently this is the same as :meth:`is_triangular` method, but may
... | [
"Test",
"if",
"a",
"variable",
"is",
"on",
"an",
"unstructered",
"grid"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L818-L840 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.is_circumpolar | def is_circumpolar(self, var):
"""
Test if a variable is on a circumpolar grid
Parameters
----------
%(CFDecoder.is_triangular.parameters)s
Returns
-------
%(CFDecoder.is_triangular.returns)s"""
xcoord = self.get_x(var)
return xcoord is n... | python | def is_circumpolar(self, var):
"""
Test if a variable is on a circumpolar grid
Parameters
----------
%(CFDecoder.is_triangular.parameters)s
Returns
-------
%(CFDecoder.is_triangular.returns)s"""
xcoord = self.get_x(var)
return xcoord is n... | [
"def",
"is_circumpolar",
"(",
"self",
",",
"var",
")",
":",
"xcoord",
"=",
"self",
".",
"get_x",
"(",
"var",
")",
"return",
"xcoord",
"is",
"not",
"None",
"and",
"xcoord",
".",
"ndim",
"==",
"2"
] | Test if a variable is on a circumpolar grid
Parameters
----------
%(CFDecoder.is_triangular.parameters)s
Returns
-------
%(CFDecoder.is_triangular.returns)s | [
"Test",
"if",
"a",
"variable",
"is",
"on",
"a",
"circumpolar",
"grid"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L843-L855 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.get_variable_by_axis | def get_variable_by_axis(self, var, axis, coords=None):
"""Return the coordinate matching the specified axis
This method uses to ``'axis'`` attribute in coordinates to return the
corresponding coordinate of the given variable
Possible types
--------------
var: xarray.Va... | python | def get_variable_by_axis(self, var, axis, coords=None):
"""Return the coordinate matching the specified axis
This method uses to ``'axis'`` attribute in coordinates to return the
corresponding coordinate of the given variable
Possible types
--------------
var: xarray.Va... | [
"def",
"get_variable_by_axis",
"(",
"self",
",",
"var",
",",
"axis",
",",
"coords",
"=",
"None",
")",
":",
"axis",
"=",
"axis",
".",
"lower",
"(",
")",
"if",
"axis",
"not",
"in",
"list",
"(",
"'xyzt'",
")",
":",
"raise",
"ValueError",
"(",
"\"Axis mu... | Return the coordinate matching the specified axis
This method uses to ``'axis'`` attribute in coordinates to return the
corresponding coordinate of the given variable
Possible types
--------------
var: xarray.Variable
The variable to get the dimension for
ax... | [
"Return",
"the",
"coordinate",
"matching",
"the",
"specified",
"axis"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L857-L950 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.get_x | def get_x(self, var, coords=None):
"""
Get the x-coordinate of a variable
This method searches for the x-coordinate in the :attr:`ds`. It first
checks whether there is one dimension that holds an ``'axis'``
attribute with 'X', otherwise it looks whether there is an intersection
... | python | def get_x(self, var, coords=None):
"""
Get the x-coordinate of a variable
This method searches for the x-coordinate in the :attr:`ds`. It first
checks whether there is one dimension that holds an ``'axis'``
attribute with 'X', otherwise it looks whether there is an intersection
... | [
"def",
"get_x",
"(",
"self",
",",
"var",
",",
"coords",
"=",
"None",
")",
":",
"coords",
"=",
"coords",
"or",
"self",
".",
"ds",
".",
"coords",
"coord",
"=",
"self",
".",
"get_variable_by_axis",
"(",
"var",
",",
"'x'",
",",
"coords",
")",
"if",
"co... | Get the x-coordinate of a variable
This method searches for the x-coordinate in the :attr:`ds`. It first
checks whether there is one dimension that holds an ``'axis'``
attribute with 'X', otherwise it looks whether there is an intersection
between the :attr:`x` attribute and the variabl... | [
"Get",
"the",
"x",
"-",
"coordinate",
"of",
"a",
"variable"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L955-L981 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.get_xname | def get_xname(self, var, coords=None):
"""Get the name of the x-dimension
This method gives the name of the x-dimension (which is not necessarily
the name of the coordinate if the variable has a coordinate attribute)
Parameters
----------
var: xarray.Variables
... | python | def get_xname(self, var, coords=None):
"""Get the name of the x-dimension
This method gives the name of the x-dimension (which is not necessarily
the name of the coordinate if the variable has a coordinate attribute)
Parameters
----------
var: xarray.Variables
... | [
"def",
"get_xname",
"(",
"self",
",",
"var",
",",
"coords",
"=",
"None",
")",
":",
"if",
"coords",
"is",
"not",
"None",
":",
"coord",
"=",
"self",
".",
"get_variable_by_axis",
"(",
"var",
",",
"'x'",
",",
"coords",
")",
"if",
"coord",
"is",
"not",
... | Get the name of the x-dimension
This method gives the name of the x-dimension (which is not necessarily
the name of the coordinate if the variable has a coordinate attribute)
Parameters
----------
var: xarray.Variables
The variable to get the dimension for
c... | [
"Get",
"the",
"name",
"of",
"the",
"x",
"-",
"dimension"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L983-L1017 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.get_y | def get_y(self, var, coords=None):
"""
Get the y-coordinate of a variable
This method searches for the y-coordinate in the :attr:`ds`. It first
checks whether there is one dimension that holds an ``'axis'``
attribute with 'Y', otherwise it looks whether there is an intersection
... | python | def get_y(self, var, coords=None):
"""
Get the y-coordinate of a variable
This method searches for the y-coordinate in the :attr:`ds`. It first
checks whether there is one dimension that holds an ``'axis'``
attribute with 'Y', otherwise it looks whether there is an intersection
... | [
"def",
"get_y",
"(",
"self",
",",
"var",
",",
"coords",
"=",
"None",
")",
":",
"coords",
"=",
"coords",
"or",
"self",
".",
"ds",
".",
"coords",
"coord",
"=",
"self",
".",
"get_variable_by_axis",
"(",
"var",
",",
"'y'",
",",
"coords",
")",
"if",
"co... | Get the y-coordinate of a variable
This method searches for the y-coordinate in the :attr:`ds`. It first
checks whether there is one dimension that holds an ``'axis'``
attribute with 'Y', otherwise it looks whether there is an intersection
between the :attr:`y` attribute and the variabl... | [
"Get",
"the",
"y",
"-",
"coordinate",
"of",
"a",
"variable"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1022-L1049 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.get_yname | def get_yname(self, var, coords=None):
"""Get the name of the y-dimension
This method gives the name of the y-dimension (which is not necessarily
the name of the coordinate if the variable has a coordinate attribute)
Parameters
----------
var: xarray.Variables
... | python | def get_yname(self, var, coords=None):
"""Get the name of the y-dimension
This method gives the name of the y-dimension (which is not necessarily
the name of the coordinate if the variable has a coordinate attribute)
Parameters
----------
var: xarray.Variables
... | [
"def",
"get_yname",
"(",
"self",
",",
"var",
",",
"coords",
"=",
"None",
")",
":",
"if",
"coords",
"is",
"not",
"None",
":",
"coord",
"=",
"self",
".",
"get_variable_by_axis",
"(",
"var",
",",
"'y'",
",",
"coords",
")",
"if",
"coord",
"is",
"not",
... | Get the name of the y-dimension
This method gives the name of the y-dimension (which is not necessarily
the name of the coordinate if the variable has a coordinate attribute)
Parameters
----------
var: xarray.Variables
The variable to get the dimension for
c... | [
"Get",
"the",
"name",
"of",
"the",
"y",
"-",
"dimension"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1051-L1088 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.get_z | def get_z(self, var, coords=None):
"""
Get the vertical (z-) coordinate of a variable
This method searches for the z-coordinate in the :attr:`ds`. It first
checks whether there is one dimension that holds an ``'axis'``
attribute with 'Z', otherwise it looks whether there is an i... | python | def get_z(self, var, coords=None):
"""
Get the vertical (z-) coordinate of a variable
This method searches for the z-coordinate in the :attr:`ds`. It first
checks whether there is one dimension that holds an ``'axis'``
attribute with 'Z', otherwise it looks whether there is an i... | [
"def",
"get_z",
"(",
"self",
",",
"var",
",",
"coords",
"=",
"None",
")",
":",
"coords",
"=",
"coords",
"or",
"self",
".",
"ds",
".",
"coords",
"coord",
"=",
"self",
".",
"get_variable_by_axis",
"(",
"var",
",",
"'z'",
",",
"coords",
")",
"if",
"co... | Get the vertical (z-) coordinate of a variable
This method searches for the z-coordinate in the :attr:`ds`. It first
checks whether there is one dimension that holds an ``'axis'``
attribute with 'Z', otherwise it looks whether there is an intersection
between the :attr:`z` attribute and... | [
"Get",
"the",
"vertical",
"(",
"z",
"-",
")",
"coordinate",
"of",
"a",
"variable"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1093-L1123 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.get_zname | def get_zname(self, var, coords=None):
"""Get the name of the z-dimension
This method gives the name of the z-dimension (which is not necessarily
the name of the coordinate if the variable has a coordinate attribute)
Parameters
----------
var: xarray.Variables
... | python | def get_zname(self, var, coords=None):
"""Get the name of the z-dimension
This method gives the name of the z-dimension (which is not necessarily
the name of the coordinate if the variable has a coordinate attribute)
Parameters
----------
var: xarray.Variables
... | [
"def",
"get_zname",
"(",
"self",
",",
"var",
",",
"coords",
"=",
"None",
")",
":",
"if",
"coords",
"is",
"not",
"None",
":",
"coord",
"=",
"self",
".",
"get_variable_by_axis",
"(",
"var",
",",
"'z'",
",",
"coords",
")",
"if",
"coord",
"is",
"not",
... | Get the name of the z-dimension
This method gives the name of the z-dimension (which is not necessarily
the name of the coordinate if the variable has a coordinate attribute)
Parameters
----------
var: xarray.Variables
The variable to get the dimension for
c... | [
"Get",
"the",
"name",
"of",
"the",
"z",
"-",
"dimension"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1125-L1166 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.get_t | def get_t(self, var, coords=None):
"""
Get the time coordinate of a variable
This method searches for the time coordinate in the :attr:`ds`. It
first checks whether there is one dimension that holds an ``'axis'``
attribute with 'T', otherwise it looks whether there is an interse... | python | def get_t(self, var, coords=None):
"""
Get the time coordinate of a variable
This method searches for the time coordinate in the :attr:`ds`. It
first checks whether there is one dimension that holds an ``'axis'``
attribute with 'T', otherwise it looks whether there is an interse... | [
"def",
"get_t",
"(",
"self",
",",
"var",
",",
"coords",
"=",
"None",
")",
":",
"coords",
"=",
"coords",
"or",
"self",
".",
"ds",
".",
"coords",
"coord",
"=",
"self",
".",
"get_variable_by_axis",
"(",
"var",
",",
"'t'",
",",
"coords",
")",
"if",
"co... | Get the time coordinate of a variable
This method searches for the time coordinate in the :attr:`ds`. It
first checks whether there is one dimension that holds an ``'axis'``
attribute with 'T', otherwise it looks whether there is an intersection
between the :attr:`t` attribute and the v... | [
"Get",
"the",
"time",
"coordinate",
"of",
"a",
"variable"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1171-L1208 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.get_tname | def get_tname(self, var, coords=None):
"""Get the name of the t-dimension
This method gives the name of the time dimension
Parameters
----------
var: xarray.Variables
The variable to get the dimension for
coords: dict
The coordinates to use for c... | python | def get_tname(self, var, coords=None):
"""Get the name of the t-dimension
This method gives the name of the time dimension
Parameters
----------
var: xarray.Variables
The variable to get the dimension for
coords: dict
The coordinates to use for c... | [
"def",
"get_tname",
"(",
"self",
",",
"var",
",",
"coords",
"=",
"None",
")",
":",
"if",
"coords",
"is",
"not",
"None",
":",
"coord",
"=",
"self",
".",
"get_variable_by_axis",
"(",
"var",
",",
"'t'",
",",
"coords",
")",
"if",
"coord",
"is",
"not",
... | Get the name of the t-dimension
This method gives the name of the time dimension
Parameters
----------
var: xarray.Variables
The variable to get the dimension for
coords: dict
The coordinates to use for checking the axis attribute. If None,
t... | [
"Get",
"the",
"name",
"of",
"the",
"t",
"-",
"dimension"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1210-L1243 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.get_idims | def get_idims(self, arr, coords=None):
"""Get the coordinates in the :attr:`ds` dataset as int or slice
This method returns a mapping from the coordinate names of the given
`arr` to an integer, slice or an array of integer that represent the
coordinates in the :attr:`ds` dataset and can... | python | def get_idims(self, arr, coords=None):
"""Get the coordinates in the :attr:`ds` dataset as int or slice
This method returns a mapping from the coordinate names of the given
`arr` to an integer, slice or an array of integer that represent the
coordinates in the :attr:`ds` dataset and can... | [
"def",
"get_idims",
"(",
"self",
",",
"arr",
",",
"coords",
"=",
"None",
")",
":",
"if",
"coords",
"is",
"None",
":",
"coords",
"=",
"arr",
".",
"coords",
"else",
":",
"coords",
"=",
"{",
"label",
":",
"coord",
"for",
"label",
",",
"coord",
"in",
... | Get the coordinates in the :attr:`ds` dataset as int or slice
This method returns a mapping from the coordinate names of the given
`arr` to an integer, slice or an array of integer that represent the
coordinates in the :attr:`ds` dataset and can be used to extract the
given `arr` via th... | [
"Get",
"the",
"coordinates",
"in",
"the",
":",
"attr",
":",
"ds",
"dataset",
"as",
"int",
"or",
"slice"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1245-L1282 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.get_coord_idims | def get_coord_idims(self, coords):
"""Get the slicers for the given coordinates from the base dataset
This method converts `coords` to slicers (list of
integers or ``slice`` objects)
Parameters
----------
coords: dict
A subset of the ``ds.coords`` attribute ... | python | def get_coord_idims(self, coords):
"""Get the slicers for the given coordinates from the base dataset
This method converts `coords` to slicers (list of
integers or ``slice`` objects)
Parameters
----------
coords: dict
A subset of the ``ds.coords`` attribute ... | [
"def",
"get_coord_idims",
"(",
"self",
",",
"coords",
")",
":",
"ret",
"=",
"dict",
"(",
"(",
"label",
",",
"get_index_from_coord",
"(",
"coord",
",",
"self",
".",
"ds",
".",
"indexes",
"[",
"label",
"]",
")",
")",
"for",
"label",
",",
"coord",
"in",... | Get the slicers for the given coordinates from the base dataset
This method converts `coords` to slicers (list of
integers or ``slice`` objects)
Parameters
----------
coords: dict
A subset of the ``ds.coords`` attribute of the base dataset
:attr:`ds`
... | [
"Get",
"the",
"slicers",
"for",
"the",
"given",
"coordinates",
"from",
"the",
"base",
"dataset"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1284-L1305 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.get_plotbounds | def get_plotbounds(self, coord, kind=None, ignore_shape=False):
"""
Get the bounds of a coordinate
This method first checks the ``'bounds'`` attribute of the given
`coord` and if it fails, it calculates them.
Parameters
----------
coord: xarray.Coordinate
... | python | def get_plotbounds(self, coord, kind=None, ignore_shape=False):
"""
Get the bounds of a coordinate
This method first checks the ``'bounds'`` attribute of the given
`coord` and if it fails, it calculates them.
Parameters
----------
coord: xarray.Coordinate
... | [
"def",
"get_plotbounds",
"(",
"self",
",",
"coord",
",",
"kind",
"=",
"None",
",",
"ignore_shape",
"=",
"False",
")",
":",
"if",
"'bounds'",
"in",
"coord",
".",
"attrs",
":",
"bounds",
"=",
"self",
".",
"ds",
".",
"coords",
"[",
"coord",
".",
"attrs"... | Get the bounds of a coordinate
This method first checks the ``'bounds'`` attribute of the given
`coord` and if it fails, it calculates them.
Parameters
----------
coord: xarray.Coordinate
The coordinate to get the bounds for
kind: str
The interpo... | [
"Get",
"the",
"bounds",
"of",
"a",
"coordinate"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1310-L1348 |
Chilipp/psyplot | psyplot/data.py | CFDecoder._get_plotbounds_from_cf | def _get_plotbounds_from_cf(coord, bounds):
"""
Get plot bounds from the bounds stored as defined by CFConventions
Parameters
----------
coord: xarray.Coordinate
The coordinate to get the bounds for
bounds: xarray.DataArray
The bounds as inferred ... | python | def _get_plotbounds_from_cf(coord, bounds):
"""
Get plot bounds from the bounds stored as defined by CFConventions
Parameters
----------
coord: xarray.Coordinate
The coordinate to get the bounds for
bounds: xarray.DataArray
The bounds as inferred ... | [
"def",
"_get_plotbounds_from_cf",
"(",
"coord",
",",
"bounds",
")",
":",
"if",
"bounds",
".",
"shape",
"[",
":",
"-",
"1",
"]",
"!=",
"coord",
".",
"shape",
"or",
"bounds",
".",
"shape",
"[",
"-",
"1",
"]",
"!=",
"2",
":",
"raise",
"ValueError",
"(... | Get plot bounds from the bounds stored as defined by CFConventions
Parameters
----------
coord: xarray.Coordinate
The coordinate to get the bounds for
bounds: xarray.DataArray
The bounds as inferred from the attributes of the given `coord`
Returns
... | [
"Get",
"plot",
"bounds",
"from",
"the",
"bounds",
"stored",
"as",
"defined",
"by",
"CFConventions"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1352-L1380 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.get_triangles | def get_triangles(self, var, coords=None, convert_radian=True,
copy=False, src_crs=None, target_crs=None,
nans=None, stacklevel=1):
"""
Get the triangles for the variable
Parameters
----------
var: xarray.Variable or xarray.DataArray
... | python | def get_triangles(self, var, coords=None, convert_radian=True,
copy=False, src_crs=None, target_crs=None,
nans=None, stacklevel=1):
"""
Get the triangles for the variable
Parameters
----------
var: xarray.Variable or xarray.DataArray
... | [
"def",
"get_triangles",
"(",
"self",
",",
"var",
",",
"coords",
"=",
"None",
",",
"convert_radian",
"=",
"True",
",",
"copy",
"=",
"False",
",",
"src_crs",
"=",
"None",
",",
"target_crs",
"=",
"None",
",",
"nans",
"=",
"None",
",",
"stacklevel",
"=",
... | Get the triangles for the variable
Parameters
----------
var: xarray.Variable or xarray.DataArray
The variable to use
coords: dict
Alternative coordinates to use. If None, the coordinates of the
:attr:`ds` dataset are used
convert_radian: bool... | [
"Get",
"the",
"triangles",
"for",
"the",
"variable"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1388-L1454 |
Chilipp/psyplot | psyplot/data.py | CFDecoder._infer_interval_breaks | def _infer_interval_breaks(coord, kind=None):
"""
Interpolate the bounds from the data in coord
Parameters
----------
%(CFDecoder.get_plotbounds.parameters.no_ignore_shape)s
Returns
-------
%(CFDecoder.get_plotbounds.returns)s
Notes
----... | python | def _infer_interval_breaks(coord, kind=None):
"""
Interpolate the bounds from the data in coord
Parameters
----------
%(CFDecoder.get_plotbounds.parameters.no_ignore_shape)s
Returns
-------
%(CFDecoder.get_plotbounds.returns)s
Notes
----... | [
"def",
"_infer_interval_breaks",
"(",
"coord",
",",
"kind",
"=",
"None",
")",
":",
"if",
"coord",
".",
"ndim",
"==",
"1",
":",
"return",
"_infer_interval_breaks",
"(",
"coord",
")",
"elif",
"coord",
".",
"ndim",
"==",
"2",
":",
"from",
"scipy",
".",
"i... | Interpolate the bounds from the data in coord
Parameters
----------
%(CFDecoder.get_plotbounds.parameters.no_ignore_shape)s
Returns
-------
%(CFDecoder.get_plotbounds.returns)s
Notes
-----
this currently only works for rectilinear grids | [
"Interpolate",
"the",
"bounds",
"from",
"the",
"data",
"in",
"coord"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1460-L1483 |
Chilipp/psyplot | psyplot/data.py | CFDecoder._decode_ds | def _decode_ds(cls, ds, gridfile=None, decode_coords=True,
decode_times=True):
"""
Static method to decode coordinates and time informations
This method interpretes absolute time informations (stored with units
``'day as %Y%m%d.%f'``) and coordinates
Paramete... | python | def _decode_ds(cls, ds, gridfile=None, decode_coords=True,
decode_times=True):
"""
Static method to decode coordinates and time informations
This method interpretes absolute time informations (stored with units
``'day as %Y%m%d.%f'``) and coordinates
Paramete... | [
"def",
"_decode_ds",
"(",
"cls",
",",
"ds",
",",
"gridfile",
"=",
"None",
",",
"decode_coords",
"=",
"True",
",",
"decode_times",
"=",
"True",
")",
":",
"if",
"decode_coords",
":",
"ds",
"=",
"cls",
".",
"decode_coords",
"(",
"ds",
",",
"gridfile",
"="... | Static method to decode coordinates and time informations
This method interpretes absolute time informations (stored with units
``'day as %Y%m%d.%f'``) and coordinates
Parameters
----------
%(CFDecoder.decode_coords.parameters)s
decode_times : bool, optional
... | [
"Static",
"method",
"to",
"decode",
"coordinates",
"and",
"time",
"informations"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1488-L1518 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.decode_ds | def decode_ds(cls, ds, *args, **kwargs):
"""
Static method to decode coordinates and time informations
This method interpretes absolute time informations (stored with units
``'day as %Y%m%d.%f'``) and coordinates
Parameters
----------
%(CFDecoder._decode_ds.para... | python | def decode_ds(cls, ds, *args, **kwargs):
"""
Static method to decode coordinates and time informations
This method interpretes absolute time informations (stored with units
``'day as %Y%m%d.%f'``) and coordinates
Parameters
----------
%(CFDecoder._decode_ds.para... | [
"def",
"decode_ds",
"(",
"cls",
",",
"ds",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"decoder_cls",
"in",
"cls",
".",
"_registry",
"+",
"[",
"CFDecoder",
"]",
":",
"ds",
"=",
"decoder_cls",
".",
"_decode_ds",
"(",
"ds",
",",
"*",
... | Static method to decode coordinates and time informations
This method interpretes absolute time informations (stored with units
``'day as %Y%m%d.%f'``) and coordinates
Parameters
----------
%(CFDecoder._decode_ds.parameters)s
Returns
-------
xarray.Data... | [
"Static",
"method",
"to",
"decode",
"coordinates",
"and",
"time",
"informations"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1522-L1539 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.correct_dims | def correct_dims(self, var, dims={}, remove=True):
"""Expands the dimensions to match the dims in the variable
Parameters
----------
var: xarray.Variable
The variable to get the data for
dims: dict
a mapping from dimension to the slices
remove: bo... | python | def correct_dims(self, var, dims={}, remove=True):
"""Expands the dimensions to match the dims in the variable
Parameters
----------
var: xarray.Variable
The variable to get the data for
dims: dict
a mapping from dimension to the slices
remove: bo... | [
"def",
"correct_dims",
"(",
"self",
",",
"var",
",",
"dims",
"=",
"{",
"}",
",",
"remove",
"=",
"True",
")",
":",
"method_mapping",
"=",
"{",
"'x'",
":",
"self",
".",
"get_xname",
",",
"'z'",
":",
"self",
".",
"get_zname",
",",
"'t'",
":",
"self",
... | Expands the dimensions to match the dims in the variable
Parameters
----------
var: xarray.Variable
The variable to get the data for
dims: dict
a mapping from dimension to the slices
remove: bool
If True, dimensions in `dims` that are not in t... | [
"Expands",
"the",
"dimensions",
"to",
"match",
"the",
"dims",
"in",
"the",
"variable"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1541-L1576 |
Chilipp/psyplot | psyplot/data.py | CFDecoder.standardize_dims | def standardize_dims(self, var, dims={}):
"""Replace the coordinate names through x, y, z and t
Parameters
----------
var: xarray.Variable
The variable to use the dimensions of
dims: dict
The dictionary to use for replacing the original dimensions
... | python | def standardize_dims(self, var, dims={}):
"""Replace the coordinate names through x, y, z and t
Parameters
----------
var: xarray.Variable
The variable to use the dimensions of
dims: dict
The dictionary to use for replacing the original dimensions
... | [
"def",
"standardize_dims",
"(",
"self",
",",
"var",
",",
"dims",
"=",
"{",
"}",
")",
":",
"dims",
"=",
"dict",
"(",
"dims",
")",
"name_map",
"=",
"{",
"self",
".",
"get_xname",
"(",
"var",
",",
"self",
".",
"ds",
".",
"coords",
")",
":",
"'x'",
... | Replace the coordinate names through x, y, z and t
Parameters
----------
var: xarray.Variable
The variable to use the dimensions of
dims: dict
The dictionary to use for replacing the original dimensions
Returns
-------
dict
Th... | [
"Replace",
"the",
"coordinate",
"names",
"through",
"x",
"y",
"z",
"and",
"t"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1578-L1600 |
Chilipp/psyplot | psyplot/data.py | UGridDecoder.get_mesh | def get_mesh(self, var, coords=None):
"""Get the mesh variable for the given `var`
Parameters
----------
var: xarray.Variable
The data source whith the ``'mesh'`` attribute
coords: dict
The coordinates to use. If None, the coordinates of the dataset of
... | python | def get_mesh(self, var, coords=None):
"""Get the mesh variable for the given `var`
Parameters
----------
var: xarray.Variable
The data source whith the ``'mesh'`` attribute
coords: dict
The coordinates to use. If None, the coordinates of the dataset of
... | [
"def",
"get_mesh",
"(",
"self",
",",
"var",
",",
"coords",
"=",
"None",
")",
":",
"mesh",
"=",
"var",
".",
"attrs",
".",
"get",
"(",
"'mesh'",
")",
"if",
"mesh",
"is",
"None",
":",
"return",
"None",
"if",
"coords",
"is",
"None",
":",
"coords",
"=... | Get the mesh variable for the given `var`
Parameters
----------
var: xarray.Variable
The data source whith the ``'mesh'`` attribute
coords: dict
The coordinates to use. If None, the coordinates of the dataset of
this decoder is used
Returns
... | [
"Get",
"the",
"mesh",
"variable",
"for",
"the",
"given",
"var"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1621-L1641 |
Chilipp/psyplot | psyplot/data.py | UGridDecoder.get_triangles | def get_triangles(self, var, coords=None, convert_radian=True, copy=False,
src_crs=None, target_crs=None, nans=None, stacklevel=1):
"""
Get the of the given coordinate.
Parameters
----------
%(CFDecoder.get_triangles.parameters)s
Returns
--... | python | def get_triangles(self, var, coords=None, convert_radian=True, copy=False,
src_crs=None, target_crs=None, nans=None, stacklevel=1):
"""
Get the of the given coordinate.
Parameters
----------
%(CFDecoder.get_triangles.parameters)s
Returns
--... | [
"def",
"get_triangles",
"(",
"self",
",",
"var",
",",
"coords",
"=",
"None",
",",
"convert_radian",
"=",
"True",
",",
"copy",
"=",
"False",
",",
"src_crs",
"=",
"None",
",",
"target_crs",
"=",
"None",
",",
"nans",
"=",
"None",
",",
"stacklevel",
"=",
... | Get the of the given coordinate.
Parameters
----------
%(CFDecoder.get_triangles.parameters)s
Returns
-------
%(CFDecoder.get_triangles.returns)s
Notes
-----
If the ``'location'`` attribute is set to ``'node'``, a delaunay
triangulation ... | [
"Get",
"the",
"of",
"the",
"given",
"coordinate",
"."
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1662-L1734 |
Chilipp/psyplot | psyplot/data.py | UGridDecoder.get_cell_node_coord | def get_cell_node_coord(self, var, coords=None, axis='x', nans=None):
"""
Checks whether the bounds in the variable attribute are triangular
Parameters
----------
%(CFDecoder.get_cell_node_coord.parameters)s
Returns
-------
%(CFDecoder.get_cell_node_coor... | python | def get_cell_node_coord(self, var, coords=None, axis='x', nans=None):
"""
Checks whether the bounds in the variable attribute are triangular
Parameters
----------
%(CFDecoder.get_cell_node_coord.parameters)s
Returns
-------
%(CFDecoder.get_cell_node_coor... | [
"def",
"get_cell_node_coord",
"(",
"self",
",",
"var",
",",
"coords",
"=",
"None",
",",
"axis",
"=",
"'x'",
",",
"nans",
"=",
"None",
")",
":",
"if",
"coords",
"is",
"None",
":",
"coords",
"=",
"self",
".",
"ds",
".",
"coords",
"idims",
"=",
"self"... | Checks whether the bounds in the variable attribute are triangular
Parameters
----------
%(CFDecoder.get_cell_node_coord.parameters)s
Returns
-------
%(CFDecoder.get_cell_node_coord.returns)s | [
"Checks",
"whether",
"the",
"bounds",
"in",
"the",
"variable",
"attribute",
"are",
"triangular"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1737-L1799 |
Chilipp/psyplot | psyplot/data.py | UGridDecoder.decode_coords | def decode_coords(ds, gridfile=None):
"""
Reimplemented to set the mesh variables as coordinates
Parameters
----------
%(CFDecoder.decode_coords.parameters)s
Returns
-------
%(CFDecoder.decode_coords.returns)s"""
extra_coords = set(ds.coords)
... | python | def decode_coords(ds, gridfile=None):
"""
Reimplemented to set the mesh variables as coordinates
Parameters
----------
%(CFDecoder.decode_coords.parameters)s
Returns
-------
%(CFDecoder.decode_coords.returns)s"""
extra_coords = set(ds.coords)
... | [
"def",
"decode_coords",
"(",
"ds",
",",
"gridfile",
"=",
"None",
")",
":",
"extra_coords",
"=",
"set",
"(",
"ds",
".",
"coords",
")",
"for",
"var",
"in",
"six",
".",
"itervalues",
"(",
"ds",
".",
"variables",
")",
":",
"if",
"'mesh'",
"in",
"var",
... | Reimplemented to set the mesh variables as coordinates
Parameters
----------
%(CFDecoder.decode_coords.parameters)s
Returns
-------
%(CFDecoder.decode_coords.returns)s | [
"Reimplemented",
"to",
"set",
"the",
"mesh",
"variables",
"as",
"coordinates"
] | train | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L1803-L1840 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.