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
fermiPy/fermipy
fermipy/jobs/scatter_gather.py
ScatterGather._run_link
def _run_link(self, stream=sys.stdout, dry_run=False, stage_files=True, resubmit_failed=False): """Internal function that actually runs this link. This checks if input and output files are present. If input files are missing this will raise `OSError` if dry_run is False ...
python
def _run_link(self, stream=sys.stdout, dry_run=False, stage_files=True, resubmit_failed=False): """Internal function that actually runs this link. This checks if input and output files are present. If input files are missing this will raise `OSError` if dry_run is False ...
[ "def", "_run_link", "(", "self", ",", "stream", "=", "sys", ".", "stdout", ",", "dry_run", "=", "False", ",", "stage_files", "=", "True", ",", "resubmit_failed", "=", "False", ")", ":", "if", "resubmit_failed", ":", "self", ".", "args", "[", "'action'", ...
Internal function that actually runs this link. This checks if input and output files are present. If input files are missing this will raise `OSError` if dry_run is False If all output files are present this will skip execution. Parameters ----------- stream : `file` ...
[ "Internal", "function", "that", "actually", "runs", "this", "link", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/scatter_gather.py#L199-L228
fermiPy/fermipy
fermipy/jobs/scatter_gather.py
ScatterGather._invoke
def _invoke(self, argv, stream=sys.stdout, resubmit_failed=False): """Invoke this object to preform a particular action Parameters ---------- argv : list List of command line arguments, passed to helper classes stream : `file` Stream that this function ...
python
def _invoke(self, argv, stream=sys.stdout, resubmit_failed=False): """Invoke this object to preform a particular action Parameters ---------- argv : list List of command line arguments, passed to helper classes stream : `file` Stream that this function ...
[ "def", "_invoke", "(", "self", ",", "argv", ",", "stream", "=", "sys", ".", "stdout", ",", "resubmit_failed", "=", "False", ")", ":", "args", "=", "self", ".", "_run_argparser", "(", "argv", ")", "if", "args", ".", "action", "not", "in", "ACTIONS", "...
Invoke this object to preform a particular action Parameters ---------- argv : list List of command line arguments, passed to helper classes stream : `file` Stream that this function will print to, must have 'write' function. resubmit_faile...
[ "Invoke", "this", "object", "to", "preform", "a", "particular", "action" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/scatter_gather.py#L230-L277
fermiPy/fermipy
fermipy/jobs/scatter_gather.py
ScatterGather.update_args
def update_args(self, override_args): """Update the arguments used to invoke the application Note that this will also update the dictionary of input and output files Parameters ---------- override_args : dict dictionary of arguments to override the current values ...
python
def update_args(self, override_args): """Update the arguments used to invoke the application Note that this will also update the dictionary of input and output files Parameters ---------- override_args : dict dictionary of arguments to override the current values ...
[ "def", "update_args", "(", "self", ",", "override_args", ")", ":", "self", ".", "args", "=", "extract_arguments", "(", "override_args", ",", "self", ".", "args", ")", "self", ".", "_job_configs", "=", "self", ".", "build_job_configs", "(", "self", ".", "ar...
Update the arguments used to invoke the application Note that this will also update the dictionary of input and output files Parameters ---------- override_args : dict dictionary of arguments to override the current values
[ "Update", "the", "arguments", "used", "to", "invoke", "the", "application" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/scatter_gather.py#L279-L294
fermiPy/fermipy
fermipy/jobs/scatter_gather.py
ScatterGather.clear_jobs
def clear_jobs(self, recursive=True): """Clear the self.jobs dictionary that contains information about jobs associated with this `ScatterGather` If recursive is True this will include jobs from all internal `Link` """ if recursive: self._scatter_link.clear_jobs(recu...
python
def clear_jobs(self, recursive=True): """Clear the self.jobs dictionary that contains information about jobs associated with this `ScatterGather` If recursive is True this will include jobs from all internal `Link` """ if recursive: self._scatter_link.clear_jobs(recu...
[ "def", "clear_jobs", "(", "self", ",", "recursive", "=", "True", ")", ":", "if", "recursive", ":", "self", ".", "_scatter_link", ".", "clear_jobs", "(", "recursive", ")", "self", ".", "jobs", ".", "clear", "(", ")" ]
Clear the self.jobs dictionary that contains information about jobs associated with this `ScatterGather` If recursive is True this will include jobs from all internal `Link`
[ "Clear", "the", "self", ".", "jobs", "dictionary", "that", "contains", "information", "about", "jobs", "associated", "with", "this", "ScatterGather" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/scatter_gather.py#L296-L304
fermiPy/fermipy
fermipy/jobs/scatter_gather.py
ScatterGather.get_jobs
def get_jobs(self, recursive=True): """Return a dictionary with all the jobs If recursive is True this will include jobs from all internal `Link` """ if recursive: ret_dict = self.jobs.copy() ret_dict.update(self._scatter_link.get_jobs(recursive)) ret...
python
def get_jobs(self, recursive=True): """Return a dictionary with all the jobs If recursive is True this will include jobs from all internal `Link` """ if recursive: ret_dict = self.jobs.copy() ret_dict.update(self._scatter_link.get_jobs(recursive)) ret...
[ "def", "get_jobs", "(", "self", ",", "recursive", "=", "True", ")", ":", "if", "recursive", ":", "ret_dict", "=", "self", ".", "jobs", ".", "copy", "(", ")", "ret_dict", ".", "update", "(", "self", ".", "_scatter_link", ".", "get_jobs", "(", "recursive...
Return a dictionary with all the jobs If recursive is True this will include jobs from all internal `Link`
[ "Return", "a", "dictionary", "with", "all", "the", "jobs" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/scatter_gather.py#L306-L315
fermiPy/fermipy
fermipy/jobs/scatter_gather.py
ScatterGather.check_status
def check_status(self, stream=sys.stdout, check_once=False, fail_pending=False, fail_running=False, no_wait=False, do_print=True, write_status=False): """Loop to check on the status of all the jobs in job dict. Paramete...
python
def check_status(self, stream=sys.stdout, check_once=False, fail_pending=False, fail_running=False, no_wait=False, do_print=True, write_status=False): """Loop to check on the status of all the jobs in job dict. Paramete...
[ "def", "check_status", "(", "self", ",", "stream", "=", "sys", ".", "stdout", ",", "check_once", "=", "False", ",", "fail_pending", "=", "False", ",", "fail_running", "=", "False", ",", "no_wait", "=", "False", ",", "do_print", "=", "True", ",", "write_s...
Loop to check on the status of all the jobs in job dict. Parameters ----------- stream : `file` Stream that this function will print to, Must have 'write' function. check_once : bool Check status once and exit loop. fail_pending : `bool` ...
[ "Loop", "to", "check", "on", "the", "status", "of", "all", "the", "jobs", "in", "job", "dict", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/scatter_gather.py#L318-L418
fermiPy/fermipy
fermipy/jobs/scatter_gather.py
ScatterGather.run_jobs
def run_jobs(self, stream=sys.stdout, resubmit_failed=False): """Function to dipatch jobs and collect results Parameters ----------- stream : `file` Stream that this function will print to, Must have 'write' function. resubmit_failed : bool R...
python
def run_jobs(self, stream=sys.stdout, resubmit_failed=False): """Function to dipatch jobs and collect results Parameters ----------- stream : `file` Stream that this function will print to, Must have 'write' function. resubmit_failed : bool R...
[ "def", "run_jobs", "(", "self", ",", "stream", "=", "sys", ".", "stdout", ",", "resubmit_failed", "=", "False", ")", ":", "self", ".", "_build_job_dict", "(", ")", "self", ".", "_interface", ".", "_dry_run", "=", "self", ".", "args", "[", "'dry_run'", ...
Function to dipatch jobs and collect results Parameters ----------- stream : `file` Stream that this function will print to, Must have 'write' function. resubmit_failed : bool Resubmit failed jobs. Returns ------- status_vect...
[ "Function", "to", "dipatch", "jobs", "and", "collect", "results" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/scatter_gather.py#L420-L457
fermiPy/fermipy
fermipy/jobs/scatter_gather.py
ScatterGather.resubmit
def resubmit(self, stream=sys.stdout, fail_running=False, resubmit_failed=False): """Function to resubmit failed jobs and collect results Parameters ----------- stream : `file` Stream that this function will print to, Must have 'write' function. fail_run...
python
def resubmit(self, stream=sys.stdout, fail_running=False, resubmit_failed=False): """Function to resubmit failed jobs and collect results Parameters ----------- stream : `file` Stream that this function will print to, Must have 'write' function. fail_run...
[ "def", "resubmit", "(", "self", ",", "stream", "=", "sys", ".", "stdout", ",", "fail_running", "=", "False", ",", "resubmit_failed", "=", "False", ")", ":", "self", ".", "_build_job_dict", "(", ")", "status_vect", "=", "self", ".", "check_status", "(", "...
Function to resubmit failed jobs and collect results Parameters ----------- stream : `file` Stream that this function will print to, Must have 'write' function. fail_running : `bool` If True, consider running jobs as failed resubmit_failed :...
[ "Function", "to", "resubmit", "failed", "jobs", "and", "collect", "results" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/scatter_gather.py#L459-L509
fermiPy/fermipy
fermipy/jobs/scatter_gather.py
ScatterGather.clean_jobs
def clean_jobs(self, recursive=False): """Clean up all the jobs associated with this object. If recursive is True this also clean jobs dispatch by this object.""" self._interface.clean_jobs(self.scatter_link, clean_all=recursive)
python
def clean_jobs(self, recursive=False): """Clean up all the jobs associated with this object. If recursive is True this also clean jobs dispatch by this object.""" self._interface.clean_jobs(self.scatter_link, clean_all=recursive)
[ "def", "clean_jobs", "(", "self", ",", "recursive", "=", "False", ")", ":", "self", ".", "_interface", ".", "clean_jobs", "(", "self", ".", "scatter_link", ",", "clean_all", "=", "recursive", ")" ]
Clean up all the jobs associated with this object. If recursive is True this also clean jobs dispatch by this object.
[ "Clean", "up", "all", "the", "jobs", "associated", "with", "this", "object", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/scatter_gather.py#L511-L517
fermiPy/fermipy
fermipy/jobs/scatter_gather.py
ScatterGather.print_summary
def print_summary(self, stream=sys.stdout, indent="", recurse_level=2): """Print a summary of the activity done by this `Link`. Parameters ---------- stream : `file` Stream to print to indent : str Indentation at start of line recurse_level : i...
python
def print_summary(self, stream=sys.stdout, indent="", recurse_level=2): """Print a summary of the activity done by this `Link`. Parameters ---------- stream : `file` Stream to print to indent : str Indentation at start of line recurse_level : i...
[ "def", "print_summary", "(", "self", ",", "stream", "=", "sys", ".", "stdout", ",", "indent", "=", "\"\"", ",", "recurse_level", "=", "2", ")", ":", "Link", ".", "print_summary", "(", "self", ",", "stream", ",", "indent", ",", "recurse_level", ")", "if...
Print a summary of the activity done by this `Link`. Parameters ---------- stream : `file` Stream to print to indent : str Indentation at start of line recurse_level : int Number of recursion levels to print
[ "Print", "a", "summary", "of", "the", "activity", "done", "by", "this", "Link", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/scatter_gather.py#L544-L564
fermiPy/fermipy
fermipy/jobs/scatter_gather.py
ScatterGather.print_update
def print_update(self, stream=sys.stdout, job_stats=None): """Print an update about the current number of jobs running """ if job_stats is None: job_stats = JobStatusVector() job_det_list = [] job_det_list += self._scatter_link.jobs.values() for job_dets ...
python
def print_update(self, stream=sys.stdout, job_stats=None): """Print an update about the current number of jobs running """ if job_stats is None: job_stats = JobStatusVector() job_det_list = [] job_det_list += self._scatter_link.jobs.values() for job_dets ...
[ "def", "print_update", "(", "self", ",", "stream", "=", "sys", ".", "stdout", ",", "job_stats", "=", "None", ")", ":", "if", "job_stats", "is", "None", ":", "job_stats", "=", "JobStatusVector", "(", ")", "job_det_list", "=", "[", "]", "job_det_list", "+=...
Print an update about the current number of jobs running
[ "Print", "an", "update", "about", "the", "current", "number", "of", "jobs", "running" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/scatter_gather.py#L566-L585
fermiPy/fermipy
fermipy/jobs/scatter_gather.py
ScatterGather.print_failed
def print_failed(self, stream=sys.stderr): """Print list of the failed jobs """ for job_key, job_details in sorted(self.scatter_link.jobs.items()): if job_details.status == JobStatus.failed: stream.write("Failed job %s\n log = %s\n" % (job_key, j...
python
def print_failed(self, stream=sys.stderr): """Print list of the failed jobs """ for job_key, job_details in sorted(self.scatter_link.jobs.items()): if job_details.status == JobStatus.failed: stream.write("Failed job %s\n log = %s\n" % (job_key, j...
[ "def", "print_failed", "(", "self", ",", "stream", "=", "sys", ".", "stderr", ")", ":", "for", "job_key", ",", "job_details", "in", "sorted", "(", "self", ".", "scatter_link", ".", "jobs", ".", "items", "(", ")", ")", ":", "if", "job_details", ".", "...
Print list of the failed jobs
[ "Print", "list", "of", "the", "failed", "jobs" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/scatter_gather.py#L587-L592
fermiPy/fermipy
fermipy/scripts/collect_sources.py
read_sources_from_numpy_file
def read_sources_from_numpy_file(npfile): """ Open a numpy pickle file and read all the new sources into a dictionary Parameters ---------- npfile : file name The input numpy pickle file Returns ------- tab : `~astropy.table.Table` """ srcs = np.load(npfile).flat[0]['sources...
python
def read_sources_from_numpy_file(npfile): """ Open a numpy pickle file and read all the new sources into a dictionary Parameters ---------- npfile : file name The input numpy pickle file Returns ------- tab : `~astropy.table.Table` """ srcs = np.load(npfile).flat[0]['sources...
[ "def", "read_sources_from_numpy_file", "(", "npfile", ")", ":", "srcs", "=", "np", ".", "load", "(", "npfile", ")", ".", "flat", "[", "0", "]", "[", "'sources'", "]", "roi", "=", "ROIModel", "(", ")", "roi", ".", "load_sources", "(", "srcs", ".", "va...
Open a numpy pickle file and read all the new sources into a dictionary Parameters ---------- npfile : file name The input numpy pickle file Returns ------- tab : `~astropy.table.Table`
[ "Open", "a", "numpy", "pickle", "file", "and", "read", "all", "the", "new", "sources", "into", "a", "dictionary" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/collect_sources.py#L11-L27
fermiPy/fermipy
fermipy/scripts/collect_sources.py
read_sources_from_yaml_file
def read_sources_from_yaml_file(yamlfile): """ Open a yaml file and read all the new sources into a dictionary Parameters ---------- yaml : file name The input yaml file Returns ------- tab : `~astropy.table.Table` """ f = open(yamlfile) dd = yaml.load(f) srcs = dd['...
python
def read_sources_from_yaml_file(yamlfile): """ Open a yaml file and read all the new sources into a dictionary Parameters ---------- yaml : file name The input yaml file Returns ------- tab : `~astropy.table.Table` """ f = open(yamlfile) dd = yaml.load(f) srcs = dd['...
[ "def", "read_sources_from_yaml_file", "(", "yamlfile", ")", ":", "f", "=", "open", "(", "yamlfile", ")", "dd", "=", "yaml", ".", "load", "(", "f", ")", "srcs", "=", "dd", "[", "'sources'", "]", "f", ".", "close", "(", ")", "roi", "=", "ROIModel", "...
Open a yaml file and read all the new sources into a dictionary Parameters ---------- yaml : file name The input yaml file Returns ------- tab : `~astropy.table.Table`
[ "Open", "a", "yaml", "file", "and", "read", "all", "the", "new", "sources", "into", "a", "dictionary" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/collect_sources.py#L30-L48
fermiPy/fermipy
fermipy/scripts/collect_sources.py
merge_source_tables
def merge_source_tables(src_tab, tab, all_sources=False, prefix="", suffix="", roi_idx=None): """Append the sources in a table into another table. Parameters ---------- src_tab : `~astropy.table.Table` Master source table that will be appended with the sources in ...
python
def merge_source_tables(src_tab, tab, all_sources=False, prefix="", suffix="", roi_idx=None): """Append the sources in a table into another table. Parameters ---------- src_tab : `~astropy.table.Table` Master source table that will be appended with the sources in ...
[ "def", "merge_source_tables", "(", "src_tab", ",", "tab", ",", "all_sources", "=", "False", ",", "prefix", "=", "\"\"", ",", "suffix", "=", "\"\"", ",", "roi_idx", "=", "None", ")", ":", "if", "roi_idx", "is", "not", "None", "and", "'roi'", "not", "in"...
Append the sources in a table into another table. Parameters ---------- src_tab : `~astropy.table.Table` Master source table that will be appended with the sources in ``tab``. tab : `~astropy.table.Table` Table to be merged into ``src_tab``. all_sources : bool If ...
[ "Append", "the", "sources", "in", "a", "table", "into", "another", "table", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/collect_sources.py#L51-L98
fermiPy/fermipy
fermipy/lightcurve.py
LightCurve.lightcurve
def lightcurve(self, name, **kwargs): """Generate a lightcurve for the named source. The function will complete the basic analysis steps for each bin and perform a likelihood fit for each bin. Extracted values (along with errors) are Integral Flux, spectral model, Spectral index, TS ...
python
def lightcurve(self, name, **kwargs): """Generate a lightcurve for the named source. The function will complete the basic analysis steps for each bin and perform a likelihood fit for each bin. Extracted values (along with errors) are Integral Flux, spectral model, Spectral index, TS ...
[ "def", "lightcurve", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "name", "=", "self", ".", "roi", ".", "get_source_by_name", "(", "name", ")", ".", "name", "# Create schema for method configuration", "schema", "=", "ConfigSchema", "(", "self...
Generate a lightcurve for the named source. The function will complete the basic analysis steps for each bin and perform a likelihood fit for each bin. Extracted values (along with errors) are Integral Flux, spectral model, Spectral index, TS value, pred. # of photons. Note: successful c...
[ "Generate", "a", "lightcurve", "for", "the", "named", "source", ".", "The", "function", "will", "complete", "the", "basic", "analysis", "steps", "for", "each", "bin", "and", "perform", "a", "likelihood", "fit", "for", "each", "bin", ".", "Extracted", "values...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/lightcurve.py#L255-L305
fermiPy/fermipy
fermipy/scripts/intensity_map.py
main
def main(): """ Main function for command line usage """ usage = "usage: %(prog)s [options] " description = "Merge a set of Fermi-LAT files." parser = argparse.ArgumentParser(usage=usage, description=description) parser.add_argument('-o', '--output', default=None, type=str, ...
python
def main(): """ Main function for command line usage """ usage = "usage: %(prog)s [options] " description = "Merge a set of Fermi-LAT files." parser = argparse.ArgumentParser(usage=usage, description=description) parser.add_argument('-o', '--output', default=None, type=str, ...
[ "def", "main", "(", ")", ":", "usage", "=", "\"usage: %(prog)s [options] \"", "description", "=", "\"Merge a set of Fermi-LAT files.\"", "parser", "=", "argparse", ".", "ArgumentParser", "(", "usage", "=", "usage", ",", "description", "=", "description", ")", "parse...
Main function for command line usage
[ "Main", "function", "for", "command", "line", "usage" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/intensity_map.py#L31-L60
fermiPy/fermipy
fermipy/ltcube.py
fill_livetime_hist
def fill_livetime_hist(skydir, tab_sc, tab_gti, zmax, costh_edges): """Generate a sequence of livetime distributions at the sky positions given by ``skydir``. The output of the method are two NxM arrays containing a sequence of histograms for N sky positions and M incidence angle bins where the bin edg...
python
def fill_livetime_hist(skydir, tab_sc, tab_gti, zmax, costh_edges): """Generate a sequence of livetime distributions at the sky positions given by ``skydir``. The output of the method are two NxM arrays containing a sequence of histograms for N sky positions and M incidence angle bins where the bin edg...
[ "def", "fill_livetime_hist", "(", "skydir", ",", "tab_sc", ",", "tab_gti", ",", "zmax", ",", "costh_edges", ")", ":", "if", "len", "(", "tab_gti", ")", "==", "0", ":", "shape", "=", "(", "len", "(", "costh_edges", ")", "-", "1", ",", "len", "(", "s...
Generate a sequence of livetime distributions at the sky positions given by ``skydir``. The output of the method are two NxM arrays containing a sequence of histograms for N sky positions and M incidence angle bins where the bin edges are defined by ``costh_edges``. This method uses the same algorithm...
[ "Generate", "a", "sequence", "of", "livetime", "distributions", "at", "the", "sky", "positions", "given", "by", "skydir", ".", "The", "output", "of", "the", "method", "are", "two", "NxM", "arrays", "containing", "a", "sequence", "of", "histograms", "for", "N...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/ltcube.py#L20-L108
fermiPy/fermipy
fermipy/ltcube.py
LTCube.create
def create(cls, ltfile): """Create a livetime cube from a single file or list of files.""" if not re.search('\.txt?', ltfile) is None: files = np.loadtxt(ltfile, unpack=True, dtype='str') elif not isinstance(ltfile, list): files = glob.glob(ltfile) ltc =...
python
def create(cls, ltfile): """Create a livetime cube from a single file or list of files.""" if not re.search('\.txt?', ltfile) is None: files = np.loadtxt(ltfile, unpack=True, dtype='str') elif not isinstance(ltfile, list): files = glob.glob(ltfile) ltc =...
[ "def", "create", "(", "cls", ",", "ltfile", ")", ":", "if", "not", "re", ".", "search", "(", "'\\.txt?'", ",", "ltfile", ")", "is", "None", ":", "files", "=", "np", ".", "loadtxt", "(", "ltfile", ",", "unpack", "=", "True", ",", "dtype", "=", "'s...
Create a livetime cube from a single file or list of files.
[ "Create", "a", "livetime", "cube", "from", "a", "single", "file", "or", "list", "of", "files", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/ltcube.py#L183-L196
fermiPy/fermipy
fermipy/ltcube.py
LTCube.create_empty
def create_empty(cls, tstart, tstop, fill=0.0, nside=64): """Create an empty livetime cube.""" cth_edges = np.linspace(0, 1.0, 41) domega = utils.edge_to_width(cth_edges) * 2.0 * np.pi hpx = HPX(nside, True, 'CEL', ebins=cth_edges) data = np.ones((len(cth_edges) - 1, hpx.npix)) *...
python
def create_empty(cls, tstart, tstop, fill=0.0, nside=64): """Create an empty livetime cube.""" cth_edges = np.linspace(0, 1.0, 41) domega = utils.edge_to_width(cth_edges) * 2.0 * np.pi hpx = HPX(nside, True, 'CEL', ebins=cth_edges) data = np.ones((len(cth_edges) - 1, hpx.npix)) *...
[ "def", "create_empty", "(", "cls", ",", "tstart", ",", "tstop", ",", "fill", "=", "0.0", ",", "nside", "=", "64", ")", ":", "cth_edges", "=", "np", ".", "linspace", "(", "0", ",", "1.0", ",", "41", ")", "domega", "=", "utils", ".", "edge_to_width",...
Create an empty livetime cube.
[ "Create", "an", "empty", "livetime", "cube", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/ltcube.py#L239-L245
fermiPy/fermipy
fermipy/ltcube.py
LTCube.get_skydir_lthist
def get_skydir_lthist(self, skydir, cth_bins): """Get the livetime distribution (observing profile) for a given sky direction with binning in incidence angle defined by ``cth_bins``. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord` Sky coordinat...
python
def get_skydir_lthist(self, skydir, cth_bins): """Get the livetime distribution (observing profile) for a given sky direction with binning in incidence angle defined by ``cth_bins``. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord` Sky coordinat...
[ "def", "get_skydir_lthist", "(", "self", ",", "skydir", ",", "cth_bins", ")", ":", "ra", "=", "skydir", ".", "ra", ".", "deg", "dec", "=", "skydir", ".", "dec", ".", "deg", "npts", "=", "1", "bins", "=", "utils", ".", "split_bin_edges", "(", "cth_bin...
Get the livetime distribution (observing profile) for a given sky direction with binning in incidence angle defined by ``cth_bins``. Parameters ---------- skydir : `~astropy.coordinates.SkyCoord` Sky coordinate for which the observing profile will be comp...
[ "Get", "the", "livetime", "distribution", "(", "observing", "profile", ")", "for", "a", "given", "sky", "direction", "with", "binning", "in", "incidence", "angle", "defined", "by", "cth_bins", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/ltcube.py#L311-L339
fermiPy/fermipy
fermipy/ltcube.py
LTCube.create_skydir_ltcube
def create_skydir_ltcube(self, skydir, tab_sc, tab_gti, zmax): """Create a new livetime cube by scaling this one by the observing profile ratio in the direction ``skydir``. This method can be used to generate an approximate livetime cube that is accurate in the vicinity of ``skydir``. ...
python
def create_skydir_ltcube(self, skydir, tab_sc, tab_gti, zmax): """Create a new livetime cube by scaling this one by the observing profile ratio in the direction ``skydir``. This method can be used to generate an approximate livetime cube that is accurate in the vicinity of ``skydir``. ...
[ "def", "create_skydir_ltcube", "(", "self", ",", "skydir", ",", "tab_sc", ",", "tab_gti", ",", "zmax", ")", ":", "skydir", "=", "SkyCoord", "(", "np", ".", "array", "(", "[", "skydir", ".", "ra", ".", "deg", "]", ")", ",", "np", ".", "array", "(", ...
Create a new livetime cube by scaling this one by the observing profile ratio in the direction ``skydir``. This method can be used to generate an approximate livetime cube that is accurate in the vicinity of ``skydir``. Parameters ---------- skydir : `~astropy.coordina...
[ "Create", "a", "new", "livetime", "cube", "by", "scaling", "this", "one", "by", "the", "observing", "profile", "ratio", "in", "the", "direction", "skydir", ".", "This", "method", "can", "be", "used", "to", "generate", "an", "approximate", "livetime", "cube",...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/ltcube.py#L341-L380
fermiPy/fermipy
fermipy/ltcube.py
LTCube.write
def write(self, outfile): """Write the livetime cube to a FITS file.""" hdu_pri = fits.PrimaryHDU() hdu_exp = self._create_exp_hdu(self.data) hdu_exp.name = 'EXPOSURE' hdu_exp_wt = self._create_exp_hdu(self._data_wt) hdu_exp_wt.name = 'WEIGHTED_EXPOSURE' cols =...
python
def write(self, outfile): """Write the livetime cube to a FITS file.""" hdu_pri = fits.PrimaryHDU() hdu_exp = self._create_exp_hdu(self.data) hdu_exp.name = 'EXPOSURE' hdu_exp_wt = self._create_exp_hdu(self._data_wt) hdu_exp_wt.name = 'WEIGHTED_EXPOSURE' cols =...
[ "def", "write", "(", "self", ",", "outfile", ")", ":", "hdu_pri", "=", "fits", ".", "PrimaryHDU", "(", ")", "hdu_exp", "=", "self", ".", "_create_exp_hdu", "(", "self", ".", "data", ")", "hdu_exp", ".", "name", "=", "'EXPOSURE'", "hdu_exp_wt", "=", "se...
Write the livetime cube to a FITS file.
[ "Write", "the", "livetime", "cube", "to", "a", "FITS", "file", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/ltcube.py#L407-L435
fermiPy/fermipy
fermipy/scripts/vstack_images.py
main
def main(): """ Main function for command line usage """ usage = "usage: %(prog)s [options] " description = "Merge a set of Fermi-LAT files." parser = argparse.ArgumentParser(usage=usage, description=description) parser.add_argument('-o', '--output', default=None, type=str, ...
python
def main(): """ Main function for command line usage """ usage = "usage: %(prog)s [options] " description = "Merge a set of Fermi-LAT files." parser = argparse.ArgumentParser(usage=usage, description=description) parser.add_argument('-o', '--output', default=None, type=str, ...
[ "def", "main", "(", ")", ":", "usage", "=", "\"usage: %(prog)s [options] \"", "description", "=", "\"Merge a set of Fermi-LAT files.\"", "parser", "=", "argparse", ".", "ArgumentParser", "(", "usage", "=", "usage", ",", "description", "=", "description", ")", "parse...
Main function for command line usage
[ "Main", "function", "for", "command", "line", "usage" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/scripts/vstack_images.py#L10-L45
fermiPy/fermipy
fermipy/plotting.py
make_cube_slice
def make_cube_slice(map_in, loge_bounds): """Extract a slice from a map cube object. """ # FIXME: This functionality should be moved into a slice method of # gammapy.maps axis = map_in.geom.axes[0] i0 = utils.val_to_edge(axis.edges, 10**loge_bounds[0])[0] i1 = utils.val_to_edge(axis.edges, 1...
python
def make_cube_slice(map_in, loge_bounds): """Extract a slice from a map cube object. """ # FIXME: This functionality should be moved into a slice method of # gammapy.maps axis = map_in.geom.axes[0] i0 = utils.val_to_edge(axis.edges, 10**loge_bounds[0])[0] i1 = utils.val_to_edge(axis.edges, 1...
[ "def", "make_cube_slice", "(", "map_in", ",", "loge_bounds", ")", ":", "# FIXME: This functionality should be moved into a slice method of", "# gammapy.maps", "axis", "=", "map_in", ".", "geom", ".", "axes", "[", "0", "]", "i0", "=", "utils", ".", "val_to_edge", "("...
Extract a slice from a map cube object.
[ "Extract", "a", "slice", "from", "a", "map", "cube", "object", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/plotting.py#L343-L355
fermiPy/fermipy
fermipy/plotting.py
SEDPlotter.plot_sed
def plot_sed(sed, showlnl=False, **kwargs): """Render a plot of a spectral energy distribution. Parameters ---------- showlnl : bool Overlay a map of the delta-loglikelihood values vs. flux in each energy bin. cmap : str Color...
python
def plot_sed(sed, showlnl=False, **kwargs): """Render a plot of a spectral energy distribution. Parameters ---------- showlnl : bool Overlay a map of the delta-loglikelihood values vs. flux in each energy bin. cmap : str Color...
[ "def", "plot_sed", "(", "sed", ",", "showlnl", "=", "False", ",", "*", "*", "kwargs", ")", ":", "ax", "=", "kwargs", ".", "pop", "(", "'ax'", ",", "plt", ".", "gca", "(", ")", ")", "cmap", "=", "kwargs", ".", "get", "(", "'cmap'", ",", "'BuGn'"...
Render a plot of a spectral energy distribution. Parameters ---------- showlnl : bool Overlay a map of the delta-loglikelihood values vs. flux in each energy bin. cmap : str Colormap that will be used for the delta-loglikelihood ...
[ "Render", "a", "plot", "of", "a", "spectral", "energy", "distribution", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/plotting.py#L815-L855
fermiPy/fermipy
fermipy/plotting.py
AnalysisPlotter.run
def run(self, gta, mcube_map, **kwargs): """Make all plots.""" prefix = kwargs.get('prefix', 'test') format = kwargs.get('format', self.config['format']) loge_bounds = [None] + self.config['loge_bounds'] for x in loge_bounds: self.make_roi_plots(gta, mcube_map, loge...
python
def run(self, gta, mcube_map, **kwargs): """Make all plots.""" prefix = kwargs.get('prefix', 'test') format = kwargs.get('format', self.config['format']) loge_bounds = [None] + self.config['loge_bounds'] for x in loge_bounds: self.make_roi_plots(gta, mcube_map, loge...
[ "def", "run", "(", "self", ",", "gta", ",", "mcube_map", ",", "*", "*", "kwargs", ")", ":", "prefix", "=", "kwargs", ".", "get", "(", "'prefix'", ",", "'test'", ")", "format", "=", "kwargs", ".", "get", "(", "'format'", ",", "self", ".", "config", ...
Make all plots.
[ "Make", "all", "plots", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/plotting.py#L924-L941
fermiPy/fermipy
fermipy/plotting.py
AnalysisPlotter.make_residmap_plots
def make_residmap_plots(self, maps, roi=None, **kwargs): """Make plots from the output of `~fermipy.gtanalysis.GTAnalysis.residmap`. Parameters ---------- maps : dict Output dictionary of `~fermipy.gtanalysis.GTAnalysis.residmap`. roi : `~fermipy...
python
def make_residmap_plots(self, maps, roi=None, **kwargs): """Make plots from the output of `~fermipy.gtanalysis.GTAnalysis.residmap`. Parameters ---------- maps : dict Output dictionary of `~fermipy.gtanalysis.GTAnalysis.residmap`. roi : `~fermipy...
[ "def", "make_residmap_plots", "(", "self", ",", "maps", ",", "roi", "=", "None", ",", "*", "*", "kwargs", ")", ":", "fmt", "=", "kwargs", ".", "get", "(", "'format'", ",", "self", ".", "config", "[", "'format'", "]", ")", "figsize", "=", "kwargs", ...
Make plots from the output of `~fermipy.gtanalysis.GTAnalysis.residmap`. Parameters ---------- maps : dict Output dictionary of `~fermipy.gtanalysis.GTAnalysis.residmap`. roi : `~fermipy.roi_model.ROIModel` ROI Model object. Generate markers...
[ "Make", "plots", "from", "the", "output", "of", "~fermipy", ".", "gtanalysis", ".", "GTAnalysis", ".", "residmap", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/plotting.py#L943-L1072
fermiPy/fermipy
fermipy/plotting.py
AnalysisPlotter.make_tsmap_plots
def make_tsmap_plots(self, maps, roi=None, **kwargs): """Make plots from the output of `~fermipy.gtanalysis.GTAnalysis.tsmap` or `~fermipy.gtanalysis.GTAnalysis.tscube`. This method generates a 2D sky map for the best-fit test source in sqrt(TS) and Npred. Parameters ...
python
def make_tsmap_plots(self, maps, roi=None, **kwargs): """Make plots from the output of `~fermipy.gtanalysis.GTAnalysis.tsmap` or `~fermipy.gtanalysis.GTAnalysis.tscube`. This method generates a 2D sky map for the best-fit test source in sqrt(TS) and Npred. Parameters ...
[ "def", "make_tsmap_plots", "(", "self", ",", "maps", ",", "roi", "=", "None", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'graticule_radii'", ",", "self", ".", "config", "[", "'graticule_radii'", "]", ")", "kwargs", ".", "setdef...
Make plots from the output of `~fermipy.gtanalysis.GTAnalysis.tsmap` or `~fermipy.gtanalysis.GTAnalysis.tscube`. This method generates a 2D sky map for the best-fit test source in sqrt(TS) and Npred. Parameters ---------- maps : dict Output dictionar...
[ "Make", "plots", "from", "the", "output", "of", "~fermipy", ".", "gtanalysis", ".", "GTAnalysis", ".", "tsmap", "or", "~fermipy", ".", "gtanalysis", ".", "GTAnalysis", ".", "tscube", ".", "This", "method", "generates", "a", "2D", "sky", "map", "for", "the"...
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/plotting.py#L1074-L1157
fermiPy/fermipy
fermipy/plotting.py
AnalysisPlotter.make_roi_plots
def make_roi_plots(self, gta, mcube_tot, **kwargs): """Make various diagnostic plots for the 1D and 2D counts/model distributions. Parameters ---------- prefix : str Prefix that will be appended to all filenames. """ fmt = kwargs.get('format', self...
python
def make_roi_plots(self, gta, mcube_tot, **kwargs): """Make various diagnostic plots for the 1D and 2D counts/model distributions. Parameters ---------- prefix : str Prefix that will be appended to all filenames. """ fmt = kwargs.get('format', self...
[ "def", "make_roi_plots", "(", "self", ",", "gta", ",", "mcube_tot", ",", "*", "*", "kwargs", ")", ":", "fmt", "=", "kwargs", ".", "get", "(", "'format'", ",", "self", ".", "config", "[", "'format'", "]", ")", "figsize", "=", "kwargs", ".", "get", "...
Make various diagnostic plots for the 1D and 2D counts/model distributions. Parameters ---------- prefix : str Prefix that will be appended to all filenames.
[ "Make", "various", "diagnostic", "plots", "for", "the", "1D", "and", "2D", "counts", "/", "model", "distributions", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/plotting.py#L1159-L1251
fermiPy/fermipy
fermipy/plotting.py
AnalysisPlotter._plot_extension
def _plot_extension(self, gta, prefix, src, loge_bounds=None, **kwargs): """Utility function for generating diagnostic plots for the extension analysis.""" # format = kwargs.get('format', self.config['plotting']['format']) if loge_bounds is None: loge_bounds = (self.energie...
python
def _plot_extension(self, gta, prefix, src, loge_bounds=None, **kwargs): """Utility function for generating diagnostic plots for the extension analysis.""" # format = kwargs.get('format', self.config['plotting']['format']) if loge_bounds is None: loge_bounds = (self.energie...
[ "def", "_plot_extension", "(", "self", ",", "gta", ",", "prefix", ",", "src", ",", "loge_bounds", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# format = kwargs.get('format', self.config['plotting']['format'])", "if", "loge_bounds", "is", "None", ":", "loge_bo...
Utility function for generating diagnostic plots for the extension analysis.
[ "Utility", "function", "for", "generating", "diagnostic", "plots", "for", "the", "extension", "analysis", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/plotting.py#L1538-L1600
fermiPy/fermipy
fermipy/jobs/gtlink.py
extract_parameters
def extract_parameters(pil, keys=None): """Extract and return parameter names and values from a pil object Parameters ---------- pil : `Pil` object keys : list List of parameter names, if None, extact all parameters Returns ------- out_dict : dict Dictionary with par...
python
def extract_parameters(pil, keys=None): """Extract and return parameter names and values from a pil object Parameters ---------- pil : `Pil` object keys : list List of parameter names, if None, extact all parameters Returns ------- out_dict : dict Dictionary with par...
[ "def", "extract_parameters", "(", "pil", ",", "keys", "=", "None", ")", ":", "out_dict", "=", "{", "}", "if", "keys", "is", "None", ":", "keys", "=", "pil", ".", "keys", "(", ")", "for", "key", "in", "keys", ":", "try", ":", "out_dict", "[", "key...
Extract and return parameter names and values from a pil object Parameters ---------- pil : `Pil` object keys : list List of parameter names, if None, extact all parameters Returns ------- out_dict : dict Dictionary with parameter name, value pairs
[ "Extract", "and", "return", "parameter", "names", "and", "values", "from", "a", "pil", "object" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/gtlink.py#L14-L39
fermiPy/fermipy
fermipy/jobs/gtlink.py
update_gtapp
def update_gtapp(gtapp, **kwargs): """Update the parameters of the object that can run ScienceTools applications Parameters ---------- gtapp : `GtApp.GtApp` Object that will run the application in question kwargs : arguments used to invoke the application """ for key, val in kwar...
python
def update_gtapp(gtapp, **kwargs): """Update the parameters of the object that can run ScienceTools applications Parameters ---------- gtapp : `GtApp.GtApp` Object that will run the application in question kwargs : arguments used to invoke the application """ for key, val in kwar...
[ "def", "update_gtapp", "(", "gtapp", ",", "*", "*", "kwargs", ")", ":", "for", "key", ",", "val", "in", "kwargs", ".", "items", "(", ")", ":", "if", "key", "in", "[", "'pfiles'", ",", "'scratch'", "]", ":", "continue", "if", "val", "is", "None", ...
Update the parameters of the object that can run ScienceTools applications Parameters ---------- gtapp : `GtApp.GtApp` Object that will run the application in question kwargs : arguments used to invoke the application
[ "Update", "the", "parameters", "of", "the", "object", "that", "can", "run", "ScienceTools", "applications" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/gtlink.py#L42-L64
fermiPy/fermipy
fermipy/jobs/gtlink.py
_set_pfiles
def _set_pfiles(dry_run, **kwargs): """Set the PFILES env var Parameters ---------- dry_run : bool Don't actually run Keyword arguments ----------------- pfiles : str Value to set PFILES Returns ------- pfiles_orig : str Current value of PFILES e...
python
def _set_pfiles(dry_run, **kwargs): """Set the PFILES env var Parameters ---------- dry_run : bool Don't actually run Keyword arguments ----------------- pfiles : str Value to set PFILES Returns ------- pfiles_orig : str Current value of PFILES e...
[ "def", "_set_pfiles", "(", "dry_run", ",", "*", "*", "kwargs", ")", ":", "pfiles_orig", "=", "os", ".", "environ", "[", "'PFILES'", "]", "pfiles", "=", "kwargs", ".", "get", "(", "'pfiles'", ",", "None", ")", "if", "pfiles", ":", "if", "dry_run", ":"...
Set the PFILES env var Parameters ---------- dry_run : bool Don't actually run Keyword arguments ----------------- pfiles : str Value to set PFILES Returns ------- pfiles_orig : str Current value of PFILES envar
[ "Set", "the", "PFILES", "env", "var", "Parameters", "----------" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/gtlink.py#L67-L100
fermiPy/fermipy
fermipy/jobs/gtlink.py
build_gtapp
def build_gtapp(appname, dry_run, **kwargs): """Build an object that can run ScienceTools application Parameters ---------- appname : str Name of the application (e.g., gtbin) dry_run : bool Print command but do not run it kwargs : arguments used to invoke the application ...
python
def build_gtapp(appname, dry_run, **kwargs): """Build an object that can run ScienceTools application Parameters ---------- appname : str Name of the application (e.g., gtbin) dry_run : bool Print command but do not run it kwargs : arguments used to invoke the application ...
[ "def", "build_gtapp", "(", "appname", ",", "dry_run", ",", "*", "*", "kwargs", ")", ":", "pfiles_orig", "=", "_set_pfiles", "(", "dry_run", ",", "*", "*", "kwargs", ")", "gtapp", "=", "GtApp", ".", "GtApp", "(", "appname", ")", "update_gtapp", "(", "gt...
Build an object that can run ScienceTools application Parameters ---------- appname : str Name of the application (e.g., gtbin) dry_run : bool Print command but do not run it kwargs : arguments used to invoke the application Returns `GtApp.GtApp` object that will run the appl...
[ "Build", "an", "object", "that", "can", "run", "ScienceTools", "application" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/gtlink.py#L116-L135
fermiPy/fermipy
fermipy/jobs/gtlink.py
run_gtapp
def run_gtapp(gtapp, stream, dry_run, **kwargs): """Runs one on the ScienceTools apps Taken from fermipy.gtanalysis.run_gtapp by Matt Wood Parameters ---------- gtapp : `GtApp.GtApp` object The application (e.g., gtbin) stream : stream object Must have 'write' function d...
python
def run_gtapp(gtapp, stream, dry_run, **kwargs): """Runs one on the ScienceTools apps Taken from fermipy.gtanalysis.run_gtapp by Matt Wood Parameters ---------- gtapp : `GtApp.GtApp` object The application (e.g., gtbin) stream : stream object Must have 'write' function d...
[ "def", "run_gtapp", "(", "gtapp", ",", "stream", ",", "dry_run", ",", "*", "*", "kwargs", ")", ":", "if", "stream", "is", "None", ":", "stream", "=", "sys", ".", "stdout", "pfiles_orig", "=", "_set_pfiles", "(", "dry_run", ",", "*", "*", "kwargs", ")...
Runs one on the ScienceTools apps Taken from fermipy.gtanalysis.run_gtapp by Matt Wood Parameters ---------- gtapp : `GtApp.GtApp` object The application (e.g., gtbin) stream : stream object Must have 'write' function dry_run : bool Print command but do not run it ...
[ "Runs", "one", "on", "the", "ScienceTools", "apps" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/gtlink.py#L138-L180
fermiPy/fermipy
fermipy/jobs/gtlink.py
Gtlink.update_args
def update_args(self, override_args): """Update the argument used to invoke the application See help for `chain.Link` for details This calls the base class function then fills the parameters of the GtApp object """ Link.update_args(self, override_args) dry_run = overrid...
python
def update_args(self, override_args): """Update the argument used to invoke the application See help for `chain.Link` for details This calls the base class function then fills the parameters of the GtApp object """ Link.update_args(self, override_args) dry_run = overrid...
[ "def", "update_args", "(", "self", ",", "override_args", ")", ":", "Link", ".", "update_args", "(", "self", ",", "override_args", ")", "dry_run", "=", "override_args", ".", "get", "(", "'dry_run'", ",", "False", ")", "if", "self", ".", "__app", "is", "No...
Update the argument used to invoke the application See help for `chain.Link` for details This calls the base class function then fills the parameters of the GtApp object
[ "Update", "the", "argument", "used", "to", "invoke", "the", "application" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/gtlink.py#L208-L223
fermiPy/fermipy
fermipy/jobs/gtlink.py
Gtlink.run_command
def run_command(self, stream=sys.stdout, dry_run=False): """Runs the command for this link. This method can be overridden by sub-classes to invoke a different command Parameters ----------- stream : `file` Must have 'write' function dry_run : bool ...
python
def run_command(self, stream=sys.stdout, dry_run=False): """Runs the command for this link. This method can be overridden by sub-classes to invoke a different command Parameters ----------- stream : `file` Must have 'write' function dry_run : bool ...
[ "def", "run_command", "(", "self", ",", "stream", "=", "sys", ".", "stdout", ",", "dry_run", "=", "False", ")", ":", "return", "run_gtapp", "(", "self", ".", "__app", ",", "stream", ",", "dry_run", ",", "*", "*", "self", ".", "args", ")" ]
Runs the command for this link. This method can be overridden by sub-classes to invoke a different command Parameters ----------- stream : `file` Must have 'write' function dry_run : bool Print command but do not run it
[ "Runs", "the", "command", "for", "this", "link", ".", "This", "method", "can", "be", "overridden", "by", "sub", "-", "classes", "to", "invoke", "a", "different", "command" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/gtlink.py#L229-L241
fermiPy/fermipy
fermipy/jobs/gtlink.py
Gtlink.command_template
def command_template(self): """Build and return a string that can be used as a template invoking this chain from the command line. The actual command can be obtainted by using `self.command_template().format(**self.args)` """ com_out = self.appname for key, val i...
python
def command_template(self): """Build and return a string that can be used as a template invoking this chain from the command line. The actual command can be obtainted by using `self.command_template().format(**self.args)` """ com_out = self.appname for key, val i...
[ "def", "command_template", "(", "self", ")", ":", "com_out", "=", "self", ".", "appname", "for", "key", ",", "val", "in", "self", ".", "args", ".", "items", "(", ")", ":", "if", "key", "in", "self", ".", "_options", ":", "com_out", "+=", "' %s={%s}'"...
Build and return a string that can be used as a template invoking this chain from the command line. The actual command can be obtainted by using `self.command_template().format(**self.args)`
[ "Build", "and", "return", "a", "string", "that", "can", "be", "used", "as", "a", "template", "invoking", "this", "chain", "from", "the", "command", "line", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/gtlink.py#L243-L256
fermiPy/fermipy
fermipy/diffuse/gt_assemble_model.py
InitModel.run_analysis
def run_analysis(self, argv): """ Build the manifest for all the models """ args = self._parser.parse_args(argv) components = Component.build_from_yamlfile(args.comp) NAME_FACTORY.update_base_dict(args.data) model_dict = make_library(**args.__dict__) model_manager...
python
def run_analysis(self, argv): """ Build the manifest for all the models """ args = self._parser.parse_args(argv) components = Component.build_from_yamlfile(args.comp) NAME_FACTORY.update_base_dict(args.data) model_dict = make_library(**args.__dict__) model_manager...
[ "def", "run_analysis", "(", "self", ",", "argv", ")", ":", "args", "=", "self", ".", "_parser", ".", "parse_args", "(", "argv", ")", "components", "=", "Component", ".", "build_from_yamlfile", "(", "args", ".", "comp", ")", "NAME_FACTORY", ".", "update_bas...
Build the manifest for all the models
[ "Build", "the", "manifest", "for", "all", "the", "models" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/gt_assemble_model.py#L46-L61
fermiPy/fermipy
fermipy/diffuse/gt_assemble_model.py
AssembleModel.copy_ccube
def copy_ccube(ccube, outsrcmap, hpx_order): """Copy a counts cube into outsrcmap file reducing the HEALPix order to hpx_order if needed. """ sys.stdout.write(" Copying counts cube from %s to %s\n" % (ccube, outsrcmap)) try: hdulist_in = fits.open(ccube) exce...
python
def copy_ccube(ccube, outsrcmap, hpx_order): """Copy a counts cube into outsrcmap file reducing the HEALPix order to hpx_order if needed. """ sys.stdout.write(" Copying counts cube from %s to %s\n" % (ccube, outsrcmap)) try: hdulist_in = fits.open(ccube) exce...
[ "def", "copy_ccube", "(", "ccube", ",", "outsrcmap", ",", "hpx_order", ")", ":", "sys", ".", "stdout", ".", "write", "(", "\" Copying counts cube from %s to %s\\n\"", "%", "(", "ccube", ",", "outsrcmap", ")", ")", "try", ":", "hdulist_in", "=", "fits", ".",...
Copy a counts cube into outsrcmap file reducing the HEALPix order to hpx_order if needed.
[ "Copy", "a", "counts", "cube", "into", "outsrcmap", "file", "reducing", "the", "HEALPix", "order", "to", "hpx_order", "if", "needed", "." ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/gt_assemble_model.py#L79-L104
fermiPy/fermipy
fermipy/diffuse/gt_assemble_model.py
AssembleModel.append_hdus
def append_hdus(hdulist, srcmap_file, source_names, hpx_order): """Append HEALPix maps to a list Parameters ---------- hdulist : list The list being appended to srcmap_file : str Path to the file containing the HDUs source_names : list of str ...
python
def append_hdus(hdulist, srcmap_file, source_names, hpx_order): """Append HEALPix maps to a list Parameters ---------- hdulist : list The list being appended to srcmap_file : str Path to the file containing the HDUs source_names : list of str ...
[ "def", "append_hdus", "(", "hdulist", ",", "srcmap_file", ",", "source_names", ",", "hpx_order", ")", ":", "sys", ".", "stdout", ".", "write", "(", "\" Extracting %i sources from %s\"", "%", "(", "len", "(", "source_names", ")", ",", "srcmap_file", ")", ")", ...
Append HEALPix maps to a list Parameters ---------- hdulist : list The list being appended to srcmap_file : str Path to the file containing the HDUs source_names : list of str Names of the sources to extract from srcmap_file hpx_order...
[ "Append", "HEALPix", "maps", "to", "a", "list" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/gt_assemble_model.py#L113-L156
fermiPy/fermipy
fermipy/diffuse/gt_assemble_model.py
AssembleModel.assemble_component
def assemble_component(compname, compinfo, hpx_order): """Assemble the source map file for one binning component Parameters ---------- compname : str The key for this component (e.g., E0_PSF3) compinfo : dict Information about this component hpx_...
python
def assemble_component(compname, compinfo, hpx_order): """Assemble the source map file for one binning component Parameters ---------- compname : str The key for this component (e.g., E0_PSF3) compinfo : dict Information about this component hpx_...
[ "def", "assemble_component", "(", "compname", ",", "compinfo", ",", "hpx_order", ")", ":", "sys", ".", "stdout", ".", "write", "(", "\"Working on component %s\\n\"", "%", "compname", ")", "ccube", "=", "compinfo", "[", "'ccube'", "]", "outsrcmap", "=", "compin...
Assemble the source map file for one binning component Parameters ---------- compname : str The key for this component (e.g., E0_PSF3) compinfo : dict Information about this component hpx_order : int Maximum order for maps
[ "Assemble", "the", "source", "map", "file", "for", "one", "binning", "component" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/gt_assemble_model.py#L159-L187
fermiPy/fermipy
fermipy/diffuse/gt_assemble_model.py
AssembleModel.run_analysis
def run_analysis(self, argv): """Assemble the source map file for one binning component FIXME """ args = self._parser.parse_args(argv) manifest = yaml.safe_load(open(args.input)) compname = args.compname value = manifest[compname] self.assemble_component(...
python
def run_analysis(self, argv): """Assemble the source map file for one binning component FIXME """ args = self._parser.parse_args(argv) manifest = yaml.safe_load(open(args.input)) compname = args.compname value = manifest[compname] self.assemble_component(...
[ "def", "run_analysis", "(", "self", ",", "argv", ")", ":", "args", "=", "self", ".", "_parser", ".", "parse_args", "(", "argv", ")", "manifest", "=", "yaml", ".", "safe_load", "(", "open", "(", "args", ".", "input", ")", ")", "compname", "=", "args",...
Assemble the source map file for one binning component FIXME
[ "Assemble", "the", "source", "map", "file", "for", "one", "binning", "component", "FIXME" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/gt_assemble_model.py#L189-L198
fermiPy/fermipy
fermipy/diffuse/gt_assemble_model.py
AssembleModel_SG.build_job_configs
def build_job_configs(self, args): """Hook to build job configurations """ job_configs = {} components = Component.build_from_yamlfile(args['comp']) NAME_FACTORY.update_base_dict(args['data']) models = load_yaml(args['models']) for modelkey in models: ...
python
def build_job_configs(self, args): """Hook to build job configurations """ job_configs = {} components = Component.build_from_yamlfile(args['comp']) NAME_FACTORY.update_base_dict(args['data']) models = load_yaml(args['models']) for modelkey in models: ...
[ "def", "build_job_configs", "(", "self", ",", "args", ")", ":", "job_configs", "=", "{", "}", "components", "=", "Component", ".", "build_from_yamlfile", "(", "args", "[", "'comp'", "]", ")", "NAME_FACTORY", ".", "update_base_dict", "(", "args", "[", "'data'...
Hook to build job configurations
[ "Hook", "to", "build", "job", "configurations" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/gt_assemble_model.py#L223-L248
fermiPy/fermipy
fermipy/diffuse/gt_assemble_model.py
AssembleModelChain._map_arguments
def _map_arguments(self, input_dict): """Map from the top-level arguments to the arguments provided to the indiviudal links """ data = input_dict.get('data') comp = input_dict.get('comp') library = input_dict.get('library') models = input_dict.get('models') hpx_or...
python
def _map_arguments(self, input_dict): """Map from the top-level arguments to the arguments provided to the indiviudal links """ data = input_dict.get('data') comp = input_dict.get('comp') library = input_dict.get('library') models = input_dict.get('models') hpx_or...
[ "def", "_map_arguments", "(", "self", ",", "input_dict", ")", ":", "data", "=", "input_dict", ".", "get", "(", "'data'", ")", "comp", "=", "input_dict", ".", "get", "(", "'comp'", ")", "library", "=", "input_dict", ".", "get", "(", "'library'", ")", "m...
Map from the top-level arguments to the arguments provided to the indiviudal links
[ "Map", "from", "the", "top", "-", "level", "arguments", "to", "the", "arguments", "provided", "to", "the", "indiviudal", "links" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/gt_assemble_model.py#L276-L295
fermiPy/fermipy
fermipy/jobs/target_analysis.py
AnalyzeROI.run_analysis
def run_analysis(self, argv): """Run this analysis""" args = self._parser.parse_args(argv) if not HAVE_ST: raise RuntimeError( "Trying to run fermipy analysis, but don't have ST") gta = GTAnalysis(args.config, logging={'verbosity': 3}, ...
python
def run_analysis(self, argv): """Run this analysis""" args = self._parser.parse_args(argv) if not HAVE_ST: raise RuntimeError( "Trying to run fermipy analysis, but don't have ST") gta = GTAnalysis(args.config, logging={'verbosity': 3}, ...
[ "def", "run_analysis", "(", "self", ",", "argv", ")", ":", "args", "=", "self", ".", "_parser", ".", "parse_args", "(", "argv", ")", "if", "not", "HAVE_ST", ":", "raise", "RuntimeError", "(", "\"Trying to run fermipy analysis, but don't have ST\"", ")", "gta", ...
Run this analysis
[ "Run", "this", "analysis" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/target_analysis.py#L53-L83
fermiPy/fermipy
fermipy/jobs/target_analysis.py
AnalyzeSED.run_analysis
def run_analysis(self, argv): """Run this analysis""" args = self._parser.parse_args(argv) if not HAVE_ST: raise RuntimeError( "Trying to run fermipy analysis, but don't have ST") if is_null(args.skydirs): skydir_dict = None else: ...
python
def run_analysis(self, argv): """Run this analysis""" args = self._parser.parse_args(argv) if not HAVE_ST: raise RuntimeError( "Trying to run fermipy analysis, but don't have ST") if is_null(args.skydirs): skydir_dict = None else: ...
[ "def", "run_analysis", "(", "self", ",", "argv", ")", ":", "args", "=", "self", ".", "_parser", ".", "parse_args", "(", "argv", ")", "if", "not", "HAVE_ST", ":", "raise", "RuntimeError", "(", "\"Trying to run fermipy analysis, but don't have ST\"", ")", "if", ...
Run this analysis
[ "Run", "this", "analysis" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/target_analysis.py#L107-L172
fermiPy/fermipy
fermipy/jobs/target_analysis.py
AnalyzeROI_SG.build_job_configs
def build_job_configs(self, args): """Hook to build job configurations """ job_configs = {} ttype = args['ttype'] (targets_yaml, sim) = NAME_FACTORY.resolve_targetfile(args) if sim is not None: raise ValueError("Found 'sim' argument on AnalyzeROI_SG config.")...
python
def build_job_configs(self, args): """Hook to build job configurations """ job_configs = {} ttype = args['ttype'] (targets_yaml, sim) = NAME_FACTORY.resolve_targetfile(args) if sim is not None: raise ValueError("Found 'sim' argument on AnalyzeROI_SG config.")...
[ "def", "build_job_configs", "(", "self", ",", "args", ")", ":", "job_configs", "=", "{", "}", "ttype", "=", "args", "[", "'ttype'", "]", "(", "targets_yaml", ",", "sim", ")", "=", "NAME_FACTORY", ".", "resolve_targetfile", "(", "args", ")", "if", "sim", ...
Hook to build job configurations
[ "Hook", "to", "build", "job", "configurations" ]
train
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/target_analysis.py#L195-L229
jim-easterbrook/pywws
src/pywws/device_ctypes_hidapi.py
USBDevice.read_data
def read_data(self, size): """Receive data from the device. If the read fails for any reason, an :obj:`IOError` exception is raised. :param size: the number of bytes to read. :type size: int :return: the data received. :rtype: list(int) """ r...
python
def read_data(self, size): """Receive data from the device. If the read fails for any reason, an :obj:`IOError` exception is raised. :param size: the number of bytes to read. :type size: int :return: the data received. :rtype: list(int) """ r...
[ "def", "read_data", "(", "self", ",", "size", ")", ":", "result", "=", "list", "(", ")", "data", "=", "ctypes", ".", "create_string_buffer", "(", "8", ")", "while", "size", ">", "0", ":", "length", "=", "min", "(", "size", ",", "8", ")", "n", "="...
Receive data from the device. If the read fails for any reason, an :obj:`IOError` exception is raised. :param size: the number of bytes to read. :type size: int :return: the data received. :rtype: list(int)
[ "Receive", "data", "from", "the", "device", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/device_ctypes_hidapi.py#L103-L129
jim-easterbrook/pywws
src/pywws/device_ctypes_hidapi.py
USBDevice.write_data
def write_data(self, buf): """Send data to the device. :param buf: the data to send. :type buf: list(int) :return: success status. :rtype: bool """ data = ''.join(map(chr, buf)) size = len(data) if hidapi.hid_write(self.device, ctypes.c_char_p...
python
def write_data(self, buf): """Send data to the device. :param buf: the data to send. :type buf: list(int) :return: success status. :rtype: bool """ data = ''.join(map(chr, buf)) size = len(data) if hidapi.hid_write(self.device, ctypes.c_char_p...
[ "def", "write_data", "(", "self", ",", "buf", ")", ":", "data", "=", "''", ".", "join", "(", "map", "(", "chr", ",", "buf", ")", ")", "size", "=", "len", "(", "data", ")", "if", "hidapi", ".", "hid_write", "(", "self", ".", "device", ",", "ctyp...
Send data to the device. :param buf: the data to send. :type buf: list(int) :return: success status. :rtype: bool
[ "Send", "data", "to", "the", "device", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/device_ctypes_hidapi.py#L131-L148
jim-easterbrook/pywws
src/pywws/forecast.py
zambretti_code
def zambretti_code(params, hourly_data): """Simple implementation of Zambretti forecaster algorithm. Inspired by beteljuice.com Java algorithm, as converted to Python by honeysucklecottage.me.uk, and further information from http://www.meteormetrics.com/zambretti.htm""" north = literal_eval(params.g...
python
def zambretti_code(params, hourly_data): """Simple implementation of Zambretti forecaster algorithm. Inspired by beteljuice.com Java algorithm, as converted to Python by honeysucklecottage.me.uk, and further information from http://www.meteormetrics.com/zambretti.htm""" north = literal_eval(params.g...
[ "def", "zambretti_code", "(", "params", ",", "hourly_data", ")", ":", "north", "=", "literal_eval", "(", "params", ".", "get", "(", "'Zambretti'", ",", "'north'", ",", "'True'", ")", ")", "baro_upper", "=", "float", "(", "params", ".", "get", "(", "'Zamb...
Simple implementation of Zambretti forecaster algorithm. Inspired by beteljuice.com Java algorithm, as converted to Python by honeysucklecottage.me.uk, and further information from http://www.meteormetrics.com/zambretti.htm
[ "Simple", "implementation", "of", "Zambretti", "forecaster", "algorithm", ".", "Inspired", "by", "beteljuice", ".", "com", "Java", "algorithm", "as", "converted", "to", "Python", "by", "honeysucklecottage", ".", "me", ".", "uk", "and", "further", "information", ...
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/forecast.py#L82-L137
jim-easterbrook/pywws
src/pywws/weatherstation.py
CUSBDrive.read_block
def read_block(self, address): """Read 32 bytes from the weather station. If the read fails for any reason, :obj:`None` is returned. :param address: address to read from. :type address: int :return: the data from the weather station. :rtype: list(int) """ ...
python
def read_block(self, address): """Read 32 bytes from the weather station. If the read fails for any reason, :obj:`None` is returned. :param address: address to read from. :type address: int :return: the data from the weather station. :rtype: list(int) """ ...
[ "def", "read_block", "(", "self", ",", "address", ")", ":", "buf", "=", "[", "self", ".", "ReadCommand", ",", "address", "//", "256", ",", "address", "%", "256", ",", "self", ".", "EndMark", ",", "self", ".", "ReadCommand", ",", "address", "//", "256...
Read 32 bytes from the weather station. If the read fails for any reason, :obj:`None` is returned. :param address: address to read from. :type address: int :return: the data from the weather station. :rtype: list(int)
[ "Read", "32", "bytes", "from", "the", "weather", "station", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/weatherstation.py#L325-L351
jim-easterbrook/pywws
src/pywws/weatherstation.py
CUSBDrive.write_byte
def write_byte(self, address, data): """Write a single byte to the weather station. :param address: address to write to. :type address: int :param data: the value to write. :type data: int :return: success status. :rtype: bool """ buf = [ ...
python
def write_byte(self, address, data): """Write a single byte to the weather station. :param address: address to write to. :type address: int :param data: the value to write. :type data: int :return: success status. :rtype: bool """ buf = [ ...
[ "def", "write_byte", "(", "self", ",", "address", ",", "data", ")", ":", "buf", "=", "[", "self", ".", "WriteCommandWord", ",", "address", "//", "256", ",", "address", "%", "256", ",", "self", ".", "EndMark", ",", "self", ".", "WriteCommandWord", ",", ...
Write a single byte to the weather station. :param address: address to write to. :type address: int :param data: the value to write. :type data: int :return: success status. :rtype: bool
[ "Write", "a", "single", "byte", "to", "the", "weather", "station", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/weatherstation.py#L353-L387
jim-easterbrook/pywws
src/pywws/weatherstation.py
WeatherStation.inc_ptr
def inc_ptr(self, ptr): """Get next circular buffer data pointer.""" result = ptr + self.reading_len[self.ws_type] if result >= 0x10000: result = self.data_start return result
python
def inc_ptr(self, ptr): """Get next circular buffer data pointer.""" result = ptr + self.reading_len[self.ws_type] if result >= 0x10000: result = self.data_start return result
[ "def", "inc_ptr", "(", "self", ",", "ptr", ")", ":", "result", "=", "ptr", "+", "self", ".", "reading_len", "[", "self", ".", "ws_type", "]", "if", "result", ">=", "0x10000", ":", "result", "=", "self", ".", "data_start", "return", "result" ]
Get next circular buffer data pointer.
[ "Get", "next", "circular", "buffer", "data", "pointer", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/weatherstation.py#L658-L663
jim-easterbrook/pywws
src/pywws/weatherstation.py
WeatherStation.dec_ptr
def dec_ptr(self, ptr): """Get previous circular buffer data pointer.""" result = ptr - self.reading_len[self.ws_type] if result < self.data_start: result = 0x10000 - self.reading_len[self.ws_type] return result
python
def dec_ptr(self, ptr): """Get previous circular buffer data pointer.""" result = ptr - self.reading_len[self.ws_type] if result < self.data_start: result = 0x10000 - self.reading_len[self.ws_type] return result
[ "def", "dec_ptr", "(", "self", ",", "ptr", ")", ":", "result", "=", "ptr", "-", "self", ".", "reading_len", "[", "self", ".", "ws_type", "]", "if", "result", "<", "self", ".", "data_start", ":", "result", "=", "0x10000", "-", "self", ".", "reading_le...
Get previous circular buffer data pointer.
[ "Get", "previous", "circular", "buffer", "data", "pointer", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/weatherstation.py#L665-L670
jim-easterbrook/pywws
src/pywws/weatherstation.py
WeatherStation.get_raw_data
def get_raw_data(self, ptr, unbuffered=False): """Get raw data from circular buffer. If unbuffered is false then a cached value that was obtained earlier may be returned.""" if unbuffered: self._data_pos = None # round down ptr to a 'block boundary' idx = ptr...
python
def get_raw_data(self, ptr, unbuffered=False): """Get raw data from circular buffer. If unbuffered is false then a cached value that was obtained earlier may be returned.""" if unbuffered: self._data_pos = None # round down ptr to a 'block boundary' idx = ptr...
[ "def", "get_raw_data", "(", "self", ",", "ptr", ",", "unbuffered", "=", "False", ")", ":", "if", "unbuffered", ":", "self", ".", "_data_pos", "=", "None", "# round down ptr to a 'block boundary'", "idx", "=", "ptr", "-", "(", "ptr", "%", "0x20", ")", "ptr"...
Get raw data from circular buffer. If unbuffered is false then a cached value that was obtained earlier may be returned.
[ "Get", "raw", "data", "from", "circular", "buffer", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/weatherstation.py#L672-L702
jim-easterbrook/pywws
src/pywws/weatherstation.py
WeatherStation.get_data
def get_data(self, ptr, unbuffered=False): """Get decoded data from circular buffer. If unbuffered is false then a cached value that was obtained earlier may be returned.""" result = _decode(self.get_raw_data(ptr, unbuffered), self._reading_format[self.ws_type])...
python
def get_data(self, ptr, unbuffered=False): """Get decoded data from circular buffer. If unbuffered is false then a cached value that was obtained earlier may be returned.""" result = _decode(self.get_raw_data(ptr, unbuffered), self._reading_format[self.ws_type])...
[ "def", "get_data", "(", "self", ",", "ptr", ",", "unbuffered", "=", "False", ")", ":", "result", "=", "_decode", "(", "self", ".", "get_raw_data", "(", "ptr", ",", "unbuffered", ")", ",", "self", ".", "_reading_format", "[", "self", ".", "ws_type", "]"...
Get decoded data from circular buffer. If unbuffered is false then a cached value that was obtained earlier may be returned.
[ "Get", "decoded", "data", "from", "circular", "buffer", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/weatherstation.py#L704-L711
jim-easterbrook/pywws
src/pywws/weatherstation.py
WeatherStation.current_pos
def current_pos(self): """Get circular buffer location where current data is being written.""" new_ptr = _decode( self._read_fixed_block(0x0020), self.lo_fix_format['current_pos']) if new_ptr == self._current_ptr: return self._current_ptr if self._current_ptr and ...
python
def current_pos(self): """Get circular buffer location where current data is being written.""" new_ptr = _decode( self._read_fixed_block(0x0020), self.lo_fix_format['current_pos']) if new_ptr == self._current_ptr: return self._current_ptr if self._current_ptr and ...
[ "def", "current_pos", "(", "self", ")", ":", "new_ptr", "=", "_decode", "(", "self", ".", "_read_fixed_block", "(", "0x0020", ")", ",", "self", ".", "lo_fix_format", "[", "'current_pos'", "]", ")", "if", "new_ptr", "==", "self", ".", "_current_ptr", ":", ...
Get circular buffer location where current data is being written.
[ "Get", "circular", "buffer", "location", "where", "current", "data", "is", "being", "written", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/weatherstation.py#L713-L723
jim-easterbrook/pywws
src/pywws/weatherstation.py
WeatherStation.get_raw_fixed_block
def get_raw_fixed_block(self, unbuffered=False): """Get the raw "fixed block" of settings and min/max data.""" if unbuffered or not self._fixed_block: self._fixed_block = self._read_fixed_block() return self._fixed_block
python
def get_raw_fixed_block(self, unbuffered=False): """Get the raw "fixed block" of settings and min/max data.""" if unbuffered or not self._fixed_block: self._fixed_block = self._read_fixed_block() return self._fixed_block
[ "def", "get_raw_fixed_block", "(", "self", ",", "unbuffered", "=", "False", ")", ":", "if", "unbuffered", "or", "not", "self", ".", "_fixed_block", ":", "self", ".", "_fixed_block", "=", "self", ".", "_read_fixed_block", "(", ")", "return", "self", ".", "_...
Get the raw "fixed block" of settings and min/max data.
[ "Get", "the", "raw", "fixed", "block", "of", "settings", "and", "min", "/", "max", "data", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/weatherstation.py#L725-L729
jim-easterbrook/pywws
src/pywws/weatherstation.py
WeatherStation.get_fixed_block
def get_fixed_block(self, keys=[], unbuffered=False): """Get the decoded "fixed block" of settings and min/max data. A subset of the entire block can be selected by keys.""" if unbuffered or not self._fixed_block: self._fixed_block = self._read_fixed_block() format = self.fi...
python
def get_fixed_block(self, keys=[], unbuffered=False): """Get the decoded "fixed block" of settings and min/max data. A subset of the entire block can be selected by keys.""" if unbuffered or not self._fixed_block: self._fixed_block = self._read_fixed_block() format = self.fi...
[ "def", "get_fixed_block", "(", "self", ",", "keys", "=", "[", "]", ",", "unbuffered", "=", "False", ")", ":", "if", "unbuffered", "or", "not", "self", ".", "_fixed_block", ":", "self", ".", "_fixed_block", "=", "self", ".", "_read_fixed_block", "(", ")",...
Get the decoded "fixed block" of settings and min/max data. A subset of the entire block can be selected by keys.
[ "Get", "the", "decoded", "fixed", "block", "of", "settings", "and", "min", "/", "max", "data", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/weatherstation.py#L731-L741
jim-easterbrook/pywws
src/pywws/weatherstation.py
WeatherStation.write_data
def write_data(self, data): """Write a set of single bytes to the weather station. Data must be an array of (ptr, value) pairs.""" # send data for ptr, value in data: self._write_byte(ptr, value) # set 'data changed' self._write_byte(self.fixed_format['data_ch...
python
def write_data(self, data): """Write a set of single bytes to the weather station. Data must be an array of (ptr, value) pairs.""" # send data for ptr, value in data: self._write_byte(ptr, value) # set 'data changed' self._write_byte(self.fixed_format['data_ch...
[ "def", "write_data", "(", "self", ",", "data", ")", ":", "# send data", "for", "ptr", ",", "value", "in", "data", ":", "self", ".", "_write_byte", "(", "ptr", ",", "value", ")", "# set 'data changed'", "self", ".", "_write_byte", "(", "self", ".", "fixed...
Write a set of single bytes to the weather station. Data must be an array of (ptr, value) pairs.
[ "Write", "a", "set", "of", "single", "bytes", "to", "the", "weather", "station", ".", "Data", "must", "be", "an", "array", "of", "(", "ptr", "value", ")", "pairs", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/weatherstation.py#L780-L795
jim-easterbrook/pywws
src/pywws/device_pyusb.py
USBDevice._find_device
def _find_device(self, idVendor, idProduct): """Find a USB device by product and vendor id.""" for bus in usb.busses(): for device in bus.devices: if (device.idVendor == idVendor and device.idProduct == idProduct): return device ...
python
def _find_device(self, idVendor, idProduct): """Find a USB device by product and vendor id.""" for bus in usb.busses(): for device in bus.devices: if (device.idVendor == idVendor and device.idProduct == idProduct): return device ...
[ "def", "_find_device", "(", "self", ",", "idVendor", ",", "idProduct", ")", ":", "for", "bus", "in", "usb", ".", "busses", "(", ")", ":", "for", "device", "in", "bus", ".", "devices", ":", "if", "(", "device", ".", "idVendor", "==", "idVendor", "and"...
Find a USB device by product and vendor id.
[ "Find", "a", "USB", "device", "by", "product", "and", "vendor", "id", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/device_pyusb.py#L106-L113
jim-easterbrook/pywws
src/pywws/device_pyusb.py
USBDevice.read_data
def read_data(self, size): """Receive data from the device. If the read fails for any reason, an :obj:`IOError` exception is raised. :param size: the number of bytes to read. :type size: int :return: the data received. :rtype: list(int) """ r...
python
def read_data(self, size): """Receive data from the device. If the read fails for any reason, an :obj:`IOError` exception is raised. :param size: the number of bytes to read. :type size: int :return: the data received. :rtype: list(int) """ r...
[ "def", "read_data", "(", "self", ",", "size", ")", ":", "result", "=", "self", ".", "devh", ".", "interruptRead", "(", "0x81", ",", "size", ",", "1200", ")", "if", "result", "is", "None", "or", "len", "(", "result", ")", "<", "size", ":", "raise", ...
Receive data from the device. If the read fails for any reason, an :obj:`IOError` exception is raised. :param size: the number of bytes to read. :type size: int :return: the data received. :rtype: list(int)
[ "Receive", "data", "from", "the", "device", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/device_pyusb.py#L115-L133
jim-easterbrook/pywws
src/pywws/device_pyusb.py
USBDevice.write_data
def write_data(self, buf): """Send data to the device. If the write fails for any reason, an :obj:`IOError` exception is raised. :param buf: the data to send. :type buf: list(int) :return: success status. :rtype: bool """ result = self.devh.c...
python
def write_data(self, buf): """Send data to the device. If the write fails for any reason, an :obj:`IOError` exception is raised. :param buf: the data to send. :type buf: list(int) :return: success status. :rtype: bool """ result = self.devh.c...
[ "def", "write_data", "(", "self", ",", "buf", ")", ":", "result", "=", "self", ".", "devh", ".", "controlMsg", "(", "usb", ".", "ENDPOINT_OUT", "+", "usb", ".", "TYPE_CLASS", "+", "usb", ".", "RECIP_INTERFACE", ",", "usb", ".", "REQ_SET_CONFIGURATION", "...
Send data to the device. If the write fails for any reason, an :obj:`IOError` exception is raised. :param buf: the data to send. :type buf: list(int) :return: success status. :rtype: bool
[ "Send", "data", "to", "the", "device", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/device_pyusb.py#L135-L155
jim-easterbrook/pywws
src/pywws/sqlite3data.py
_adapt_WSDateTime
def _adapt_WSDateTime(dt): """Return unix timestamp of the datetime like input. If conversion overflows high, return sint64_max , if underflows, return 0 """ try: ts = int( (dt.replace(tzinfo=pytz.utc) - datetime(1970,1,1,tzinfo=pytz.utc) ).total_seconds()...
python
def _adapt_WSDateTime(dt): """Return unix timestamp of the datetime like input. If conversion overflows high, return sint64_max , if underflows, return 0 """ try: ts = int( (dt.replace(tzinfo=pytz.utc) - datetime(1970,1,1,tzinfo=pytz.utc) ).total_seconds()...
[ "def", "_adapt_WSDateTime", "(", "dt", ")", ":", "try", ":", "ts", "=", "int", "(", "(", "dt", ".", "replace", "(", "tzinfo", "=", "pytz", ".", "utc", ")", "-", "datetime", "(", "1970", ",", "1", ",", "1", ",", "tzinfo", "=", "pytz", ".", "utc"...
Return unix timestamp of the datetime like input. If conversion overflows high, return sint64_max , if underflows, return 0
[ "Return", "unix", "timestamp", "of", "the", "datetime", "like", "input", ".", "If", "conversion", "overflows", "high", "return", "sint64_max", "if", "underflows", "return", "0" ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/sqlite3data.py#L93-L109
jim-easterbrook/pywws
src/pywws/sqlite3data.py
CoreStore._predicate
def _predicate(self, i): """Given a valid datetime or slace, return the predicate portion of the SQL query, a boolean indicating whether multiple items are expected from the result, and a dictionary of parameters for the query """ if isinstance(i, slice): if i.step is...
python
def _predicate(self, i): """Given a valid datetime or slace, return the predicate portion of the SQL query, a boolean indicating whether multiple items are expected from the result, and a dictionary of parameters for the query """ if isinstance(i, slice): if i.step is...
[ "def", "_predicate", "(", "self", ",", "i", ")", ":", "if", "isinstance", "(", "i", ",", "slice", ")", ":", "if", "i", ".", "step", "is", "not", "None", ":", "raise", "TypeError", "(", "\"Slice step not permitted\"", ")", "if", "(", "(", "i", ".", ...
Given a valid datetime or slace, return the predicate portion of the SQL query, a boolean indicating whether multiple items are expected from the result, and a dictionary of parameters for the query
[ "Given", "a", "valid", "datetime", "or", "slace", "return", "the", "predicate", "portion", "of", "the", "SQL", "query", "a", "boolean", "indicating", "whether", "multiple", "items", "are", "expected", "from", "the", "result", "and", "a", "dictionary", "of", ...
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/sqlite3data.py#L282-L330
jim-easterbrook/pywws
src/pywws/sqlite3data.py
CoreStore.update
def update(self, i): """D.update(E) -> None. Update D from iterable E with pre-existing items being overwritten. Elements in E are assumed to be dicts containing the primary key to allow the equivelent of: for k in E: D[k.primary_key] = k """ key_list = ...
python
def update(self, i): """D.update(E) -> None. Update D from iterable E with pre-existing items being overwritten. Elements in E are assumed to be dicts containing the primary key to allow the equivelent of: for k in E: D[k.primary_key] = k """ key_list = ...
[ "def", "update", "(", "self", ",", "i", ")", ":", "key_list", "=", "self", ".", "key_list", "keynone", "=", "{", "key", ":", "None", "for", "key", "in", "key_list", "}", "# Generator which fills in missing data from the original iterator", "def", "datagen", "(",...
D.update(E) -> None. Update D from iterable E with pre-existing items being overwritten. Elements in E are assumed to be dicts containing the primary key to allow the equivelent of: for k in E: D[k.primary_key] = k
[ "D", ".", "update", "(", "E", ")", "-", ">", "None", ".", "Update", "D", "from", "iterable", "E", "with", "pre", "-", "existing", "items", "being", "overwritten", ".", "Elements", "in", "E", "are", "assumed", "to", "be", "dicts", "containing", "the", ...
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/sqlite3data.py#L385-L408
jim-easterbrook/pywws
src/pywws/sqlite3data.py
CoreStore.before
def before(self, i): """Return datetime of newest existing data record whose datetime is < idx. If no such record exists, return None. """ if not isinstance(i, datetime): raise TypeError("'{}' is not a datetime object".format(i)) else: result = self._conne...
python
def before(self, i): """Return datetime of newest existing data record whose datetime is < idx. If no such record exists, return None. """ if not isinstance(i, datetime): raise TypeError("'{}' is not a datetime object".format(i)) else: result = self._conne...
[ "def", "before", "(", "self", ",", "i", ")", ":", "if", "not", "isinstance", "(", "i", ",", "datetime", ")", ":", "raise", "TypeError", "(", "\"'{}' is not a datetime object\"", ".", "format", "(", "i", ")", ")", "else", ":", "result", "=", "self", "."...
Return datetime of newest existing data record whose datetime is < idx. If no such record exists, return None.
[ "Return", "datetime", "of", "newest", "existing", "data", "record", "whose", "datetime", "is", "<", "idx", ".", "If", "no", "such", "record", "exists", "return", "None", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/sqlite3data.py#L424-L439
jim-easterbrook/pywws
src/pywws/sqlite3data.py
CoreStore.keys
def keys(self): """D.keys() -> a set-like object providing a view on D's keys""" return set( row[self._keycol] for row in self._connection.execute( """SELECT DISTINCT {} FROM {} ORDER BY {} ASC;""".format( self.selkeycol, self.table, ...
python
def keys(self): """D.keys() -> a set-like object providing a view on D's keys""" return set( row[self._keycol] for row in self._connection.execute( """SELECT DISTINCT {} FROM {} ORDER BY {} ASC;""".format( self.selkeycol, self.table, ...
[ "def", "keys", "(", "self", ")", ":", "return", "set", "(", "row", "[", "self", ".", "_keycol", "]", "for", "row", "in", "self", ".", "_connection", ".", "execute", "(", "\"\"\"SELECT DISTINCT {} FROM {} ORDER BY {} ASC;\"\"\"", ".", "format", "(", "self", "...
D.keys() -> a set-like object providing a view on D's keys
[ "D", ".", "keys", "()", "-", ">", "a", "set", "-", "like", "object", "providing", "a", "view", "on", "D", "s", "keys" ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/sqlite3data.py#L477-L487
jim-easterbrook/pywws
src/pywws/sqlite3data.py
CoreStore.items
def items(self): """D.items() -> a set-like object providing a view on D's items""" keycol = self._keycol for row in self.__iter__(): yield (row[keycol], dict(row))
python
def items(self): """D.items() -> a set-like object providing a view on D's items""" keycol = self._keycol for row in self.__iter__(): yield (row[keycol], dict(row))
[ "def", "items", "(", "self", ")", ":", "keycol", "=", "self", ".", "_keycol", "for", "row", "in", "self", ".", "__iter__", "(", ")", ":", "yield", "(", "row", "[", "keycol", "]", ",", "dict", "(", "row", ")", ")" ]
D.items() -> a set-like object providing a view on D's items
[ "D", ".", "items", "()", "-", ">", "a", "set", "-", "like", "object", "providing", "a", "view", "on", "D", "s", "items" ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/sqlite3data.py#L516-L520
jim-easterbrook/pywws
src/pywws/sqlite3data.py
CoreStore.clear
def clear(self): """S.clear() -> None -- remove all items from S""" with self._connection as con: con.execute("DELETE FROM {};".format(self.table))
python
def clear(self): """S.clear() -> None -- remove all items from S""" with self._connection as con: con.execute("DELETE FROM {};".format(self.table))
[ "def", "clear", "(", "self", ")", ":", "with", "self", ".", "_connection", "as", "con", ":", "con", ".", "execute", "(", "\"DELETE FROM {};\"", ".", "format", "(", "self", ".", "table", ")", ")" ]
S.clear() -> None -- remove all items from S
[ "S", ".", "clear", "()", "-", ">", "None", "--", "remove", "all", "items", "from", "S" ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/sqlite3data.py#L529-L532
jim-easterbrook/pywws
src/pywws/sqlite3data.py
CoreStore.popitem
def popitem(self): """D.popitem() -> (k, v) Remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty. """ try: value = next(iter(self)) key = value[self._keycol] except StopIteration: raise KeyErr...
python
def popitem(self): """D.popitem() -> (k, v) Remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty. """ try: value = next(iter(self)) key = value[self._keycol] except StopIteration: raise KeyErr...
[ "def", "popitem", "(", "self", ")", ":", "try", ":", "value", "=", "next", "(", "iter", "(", "self", ")", ")", "key", "=", "value", "[", "self", ".", "_keycol", "]", "except", "StopIteration", ":", "raise", "KeyError", "del", "self", "[", "key", "]...
D.popitem() -> (k, v) Remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty.
[ "D", ".", "popitem", "()", "-", ">", "(", "k", "v", ")", "Remove", "and", "return", "some", "(", "key", "value", ")", "pair", "as", "a", "2", "-", "tuple", ";", "but", "raise", "KeyError", "if", "D", "is", "empty", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/sqlite3data.py#L560-L572
jim-easterbrook/pywws
src/pywws/localisation.py
set_locale
def set_locale(lang): """Set the 'locale' used by a program. This affects the entire application, changing the way dates, currencies and numbers are represented. It should not be called from a library routine that may be used in another program. The ``lang`` parameter can be any string that is rec...
python
def set_locale(lang): """Set the 'locale' used by a program. This affects the entire application, changing the way dates, currencies and numbers are represented. It should not be called from a library routine that may be used in another program. The ``lang`` parameter can be any string that is rec...
[ "def", "set_locale", "(", "lang", ")", ":", "# get the default locale", "lc", ",", "encoding", "=", "locale", ".", "getdefaultlocale", "(", ")", "try", ":", "if", "'.'", "in", "lang", ":", "locale", ".", "setlocale", "(", "locale", ".", "LC_ALL", ",", "l...
Set the 'locale' used by a program. This affects the entire application, changing the way dates, currencies and numbers are represented. It should not be called from a library routine that may be used in another program. The ``lang`` parameter can be any string that is recognised by ``locale.setlo...
[ "Set", "the", "locale", "used", "by", "a", "program", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/localisation.py#L141-L166
jim-easterbrook/pywws
src/pywws/localisation.py
set_translation
def set_translation(lang): """Set the translation used by (some) pywws modules. This sets the translation object ``pywws.localisation.translation`` to use a particular language. The ``lang`` parameter can be any string of the form ``en``, ``en_GB`` or ``en_GB.UTF-8``. Anything after a ``.`` charac...
python
def set_translation(lang): """Set the translation used by (some) pywws modules. This sets the translation object ``pywws.localisation.translation`` to use a particular language. The ``lang`` parameter can be any string of the form ``en``, ``en_GB`` or ``en_GB.UTF-8``. Anything after a ``.`` charac...
[ "def", "set_translation", "(", "lang", ")", ":", "global", "translation", "# make list of possible languages, in order of preference", "langs", "=", "list", "(", ")", "if", "lang", ":", "if", "'.'", "in", "lang", ":", "lang", "=", "lang", ".", "split", "(", "'...
Set the translation used by (some) pywws modules. This sets the translation object ``pywws.localisation.translation`` to use a particular language. The ``lang`` parameter can be any string of the form ``en``, ``en_GB`` or ``en_GB.UTF-8``. Anything after a ``.`` character is ignored. In the case of...
[ "Set", "the", "translation", "used", "by", "(", "some", ")", "pywws", "modules", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/localisation.py#L169-L207
jim-easterbrook/pywws
src/pywws/localisation.py
set_application_language
def set_application_language(params): """Set the locale and translation for a pywws program. This function reads the language from the configuration file, then calls :func:`set_locale` and :func:`set_translation`. :param params: a :class:`pywws.storage.params` object. :type params: object ""...
python
def set_application_language(params): """Set the locale and translation for a pywws program. This function reads the language from the configuration file, then calls :func:`set_locale` and :func:`set_translation`. :param params: a :class:`pywws.storage.params` object. :type params: object ""...
[ "def", "set_application_language", "(", "params", ")", ":", "lang", "=", "params", ".", "get", "(", "'config'", ",", "'language'", ",", "None", ")", "if", "lang", ":", "set_locale", "(", "lang", ")", "set_translation", "(", "lang", ")" ]
Set the locale and translation for a pywws program. This function reads the language from the configuration file, then calls :func:`set_locale` and :func:`set_translation`. :param params: a :class:`pywws.storage.params` object. :type params: object
[ "Set", "the", "locale", "and", "translation", "for", "a", "pywws", "program", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/localisation.py#L210-L224
jim-easterbrook/pywws
src/pywws/device_cython_hidapi.py
USBDevice.read_data
def read_data(self, size): """Receive data from the device. If the read fails for any reason, an :obj:`IOError` exception is raised. :param size: the number of bytes to read. :type size: int :return: the data received. :rtype: list(int) """ r...
python
def read_data(self, size): """Receive data from the device. If the read fails for any reason, an :obj:`IOError` exception is raised. :param size: the number of bytes to read. :type size: int :return: the data received. :rtype: list(int) """ r...
[ "def", "read_data", "(", "self", ",", "size", ")", ":", "result", "=", "list", "(", ")", "while", "size", ">", "0", ":", "count", "=", "min", "(", "size", ",", "8", ")", "buf", "=", "self", ".", "hid", ".", "read", "(", "count", ")", "if", "l...
Receive data from the device. If the read fails for any reason, an :obj:`IOError` exception is raised. :param size: the number of bytes to read. :type size: int :return: the data received. :rtype: list(int)
[ "Receive", "data", "from", "the", "device", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/device_cython_hidapi.py#L73-L97
jim-easterbrook/pywws
src/pywws/device_cython_hidapi.py
USBDevice.write_data
def write_data(self, buf): """Send data to the device. :param buf: the data to send. :type buf: list(int) :return: success status. :rtype: bool """ if self.hid.write(buf) != len(buf): raise IOError( 'pywws.device_cython_hidapi.USBD...
python
def write_data(self, buf): """Send data to the device. :param buf: the data to send. :type buf: list(int) :return: success status. :rtype: bool """ if self.hid.write(buf) != len(buf): raise IOError( 'pywws.device_cython_hidapi.USBD...
[ "def", "write_data", "(", "self", ",", "buf", ")", ":", "if", "self", ".", "hid", ".", "write", "(", "buf", ")", "!=", "len", "(", "buf", ")", ":", "raise", "IOError", "(", "'pywws.device_cython_hidapi.USBDevice.write_data failed'", ")", "return", "True" ]
Send data to the device. :param buf: the data to send. :type buf: list(int) :return: success status. :rtype: bool
[ "Send", "data", "to", "the", "device", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/device_cython_hidapi.py#L99-L114
jim-easterbrook/pywws
src/pywws/timezone.py
TimeZone.to_local
def to_local(self, dt): """Convert any timestamp to local time (with tzinfo).""" if dt.tzinfo is None: dt = dt.replace(tzinfo=self.utc) return dt.astimezone(self.local)
python
def to_local(self, dt): """Convert any timestamp to local time (with tzinfo).""" if dt.tzinfo is None: dt = dt.replace(tzinfo=self.utc) return dt.astimezone(self.local)
[ "def", "to_local", "(", "self", ",", "dt", ")", ":", "if", "dt", ".", "tzinfo", "is", "None", ":", "dt", "=", "dt", ".", "replace", "(", "tzinfo", "=", "self", ".", "utc", ")", "return", "dt", ".", "astimezone", "(", "self", ".", "local", ")" ]
Convert any timestamp to local time (with tzinfo).
[ "Convert", "any", "timestamp", "to", "local", "time", "(", "with", "tzinfo", ")", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/timezone.py#L75-L79
jim-easterbrook/pywws
src/pywws/timezone.py
TimeZone.to_utc
def to_utc(self, dt): """Convert any timestamp to UTC (with tzinfo).""" if dt.tzinfo is None: return dt.replace(tzinfo=self.utc) return dt.astimezone(self.utc)
python
def to_utc(self, dt): """Convert any timestamp to UTC (with tzinfo).""" if dt.tzinfo is None: return dt.replace(tzinfo=self.utc) return dt.astimezone(self.utc)
[ "def", "to_utc", "(", "self", ",", "dt", ")", ":", "if", "dt", ".", "tzinfo", "is", "None", ":", "return", "dt", ".", "replace", "(", "tzinfo", "=", "self", ".", "utc", ")", "return", "dt", ".", "astimezone", "(", "self", ".", "utc", ")" ]
Convert any timestamp to UTC (with tzinfo).
[ "Convert", "any", "timestamp", "to", "UTC", "(", "with", "tzinfo", ")", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/timezone.py#L81-L85
jim-easterbrook/pywws
src/pywws/timezone.py
TimeZone.to_naive
def to_naive(self, dt): """Convert any timestamp to pywws (utc, no tzinfo).""" if dt.tzinfo is None: return dt return dt.astimezone(self.utc).replace(tzinfo=None)
python
def to_naive(self, dt): """Convert any timestamp to pywws (utc, no tzinfo).""" if dt.tzinfo is None: return dt return dt.astimezone(self.utc).replace(tzinfo=None)
[ "def", "to_naive", "(", "self", ",", "dt", ")", ":", "if", "dt", ".", "tzinfo", "is", "None", ":", "return", "dt", "return", "dt", ".", "astimezone", "(", "self", ".", "utc", ")", ".", "replace", "(", "tzinfo", "=", "None", ")" ]
Convert any timestamp to pywws (utc, no tzinfo).
[ "Convert", "any", "timestamp", "to", "pywws", "(", "utc", "no", "tzinfo", ")", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/timezone.py#L87-L91
jim-easterbrook/pywws
src/pywws/timezone.py
TimeZone.local_replace
def local_replace(self, dt, use_dst=True, _recurse=False, **kwds): """Return pywws timestamp (utc, no tzinfo) for the most recent local time before the pywws timestamp dt, with datetime replace applied. """ local_time = dt + self.standard_offset if use_dst: d...
python
def local_replace(self, dt, use_dst=True, _recurse=False, **kwds): """Return pywws timestamp (utc, no tzinfo) for the most recent local time before the pywws timestamp dt, with datetime replace applied. """ local_time = dt + self.standard_offset if use_dst: d...
[ "def", "local_replace", "(", "self", ",", "dt", ",", "use_dst", "=", "True", ",", "_recurse", "=", "False", ",", "*", "*", "kwds", ")", ":", "local_time", "=", "dt", "+", "self", ".", "standard_offset", "if", "use_dst", ":", "dst_offset", "=", "self", ...
Return pywws timestamp (utc, no tzinfo) for the most recent local time before the pywws timestamp dt, with datetime replace applied.
[ "Return", "pywws", "timestamp", "(", "utc", "no", "tzinfo", ")", "for", "the", "most", "recent", "local", "time", "before", "the", "pywws", "timestamp", "dt", "with", "datetime", "replace", "applied", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/timezone.py#L93-L118
jim-easterbrook/pywws
src/pywws/storage.py
ParamStore.get
def get(self, section, option, default=None): """Get a parameter value and return a string. If default is specified and section or option are not defined in the file, they are created and set to default, which is then the return value. """ with self._lock: i...
python
def get(self, section, option, default=None): """Get a parameter value and return a string. If default is specified and section or option are not defined in the file, they are created and set to default, which is then the return value. """ with self._lock: i...
[ "def", "get", "(", "self", ",", "section", ",", "option", ",", "default", "=", "None", ")", ":", "with", "self", ".", "_lock", ":", "if", "not", "self", ".", "_config", ".", "has_option", "(", "section", ",", "option", ")", ":", "if", "default", "i...
Get a parameter value and return a string. If default is specified and section or option are not defined in the file, they are created and set to default, which is then the return value.
[ "Get", "a", "parameter", "value", "and", "return", "a", "string", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/storage.py#L107-L120
jim-easterbrook/pywws
src/pywws/storage.py
ParamStore.set
def set(self, section, option, value): """Set option in section to string value.""" with self._lock: self._set(section, option, value)
python
def set(self, section, option, value): """Set option in section to string value.""" with self._lock: self._set(section, option, value)
[ "def", "set", "(", "self", ",", "section", ",", "option", ",", "value", ")", ":", "with", "self", ".", "_lock", ":", "self", ".", "_set", "(", "section", ",", "option", ",", "value", ")" ]
Set option in section to string value.
[ "Set", "option", "in", "section", "to", "string", "value", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/storage.py#L128-L131
jim-easterbrook/pywws
src/pywws/storage.py
ParamStore.unset
def unset(self, section, option): """Remove option from section.""" with self._lock: if not self._config.has_section(section): return if self._config.has_option(section, option): self._config.remove_option(section, option) self._dir...
python
def unset(self, section, option): """Remove option from section.""" with self._lock: if not self._config.has_section(section): return if self._config.has_option(section, option): self._config.remove_option(section, option) self._dir...
[ "def", "unset", "(", "self", ",", "section", ",", "option", ")", ":", "with", "self", ".", "_lock", ":", "if", "not", "self", ".", "_config", ".", "has_section", "(", "section", ")", ":", "return", "if", "self", ".", "_config", ".", "has_option", "("...
Remove option from section.
[ "Remove", "option", "from", "section", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/storage.py#L142-L152
jim-easterbrook/pywws
src/pywws/service/__init__.py
ServiceBase.check_params
def check_params(self, *keys): """Ensure user has set required values in weather.ini. Normally the :py:data:`~ServiceBase.config` names with ``required`` set are checked, but if your uploader has a ``register`` method you may need to check for other data. :param str keys: the :...
python
def check_params(self, *keys): """Ensure user has set required values in weather.ini. Normally the :py:data:`~ServiceBase.config` names with ``required`` set are checked, but if your uploader has a ``register`` method you may need to check for other data. :param str keys: the :...
[ "def", "check_params", "(", "self", ",", "*", "keys", ")", ":", "for", "key", "in", "keys", ":", "if", "not", "self", ".", "params", "[", "key", "]", ":", "raise", "RuntimeError", "(", "'\"{}\" not set in weather.ini'", ".", "format", "(", "key", ")", ...
Ensure user has set required values in weather.ini. Normally the :py:data:`~ServiceBase.config` names with ``required`` set are checked, but if your uploader has a ``register`` method you may need to check for other data. :param str keys: the :py:data:`~ServiceBase.config` names to ...
[ "Ensure", "user", "has", "set", "required", "values", "in", "weather", ".", "ini", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/service/__init__.py#L134-L147
jim-easterbrook/pywws
src/pywws/datastoretransfer.py
monitor
def monitor(i): """Given an iterator, yields data from it but prints progress every 10,000 records""" count = 0 for x in i: count+=1 if count % 10000 == 0: logger.info("%d records so far, current record is %s", count, x["idx"]) yield x
python
def monitor(i): """Given an iterator, yields data from it but prints progress every 10,000 records""" count = 0 for x in i: count+=1 if count % 10000 == 0: logger.info("%d records so far, current record is %s", count, x["idx"]) yield x
[ "def", "monitor", "(", "i", ")", ":", "count", "=", "0", "for", "x", "in", "i", ":", "count", "+=", "1", "if", "count", "%", "10000", "==", "0", ":", "logger", ".", "info", "(", "\"%d records so far, current record is %s\"", ",", "count", ",", "x", "...
Given an iterator, yields data from it but prints progress every 10,000 records
[ "Given", "an", "iterator", "yields", "data", "from", "it", "but", "prints", "progress", "every", "10", "000", "records" ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/datastoretransfer.py#L37-L46
jim-easterbrook/pywws
src/pywws/process.py
calibrate_data
def calibrate_data(params, raw_data, calib_data): """'Calibrate' raw data, using a user-supplied function.""" start = calib_data.before(datetime.max) if start is None: start = datetime.min start = raw_data.after(start + SECOND) if start is None: return start del calib_data[start:...
python
def calibrate_data(params, raw_data, calib_data): """'Calibrate' raw data, using a user-supplied function.""" start = calib_data.before(datetime.max) if start is None: start = datetime.min start = raw_data.after(start + SECOND) if start is None: return start del calib_data[start:...
[ "def", "calibrate_data", "(", "params", ",", "raw_data", ",", "calib_data", ")", ":", "start", "=", "calib_data", ".", "before", "(", "datetime", ".", "max", ")", "if", "start", "is", "None", ":", "start", "=", "datetime", ".", "min", "start", "=", "ra...
Calibrate' raw data, using a user-supplied function.
[ "Calibrate", "raw", "data", "using", "a", "user", "-", "supplied", "function", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/process.py#L521-L548
jim-easterbrook/pywws
src/pywws/process.py
generate_hourly
def generate_hourly(calib_data, hourly_data, process_from): """Generate hourly summaries from calibrated data.""" start = hourly_data.before(datetime.max) if start is None: start = datetime.min start = calib_data.after(start + SECOND) if process_from: if start: start = mi...
python
def generate_hourly(calib_data, hourly_data, process_from): """Generate hourly summaries from calibrated data.""" start = hourly_data.before(datetime.max) if start is None: start = datetime.min start = calib_data.after(start + SECOND) if process_from: if start: start = mi...
[ "def", "generate_hourly", "(", "calib_data", ",", "hourly_data", ",", "process_from", ")", ":", "start", "=", "hourly_data", ".", "before", "(", "datetime", ".", "max", ")", "if", "start", "is", "None", ":", "start", "=", "datetime", ".", "min", "start", ...
Generate hourly summaries from calibrated data.
[ "Generate", "hourly", "summaries", "from", "calibrated", "data", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/process.py#L551-L622
jim-easterbrook/pywws
src/pywws/process.py
generate_daily
def generate_daily(day_end_hour, use_dst, calib_data, hourly_data, daily_data, process_from): """Generate daily summaries from calibrated and hourly data.""" start = daily_data.before(datetime.max) if start is None: start = datetime.min start = calib_data.after(start + SECOND)...
python
def generate_daily(day_end_hour, use_dst, calib_data, hourly_data, daily_data, process_from): """Generate daily summaries from calibrated and hourly data.""" start = daily_data.before(datetime.max) if start is None: start = datetime.min start = calib_data.after(start + SECOND)...
[ "def", "generate_daily", "(", "day_end_hour", ",", "use_dst", ",", "calib_data", ",", "hourly_data", ",", "daily_data", ",", "process_from", ")", ":", "start", "=", "daily_data", ".", "before", "(", "datetime", ".", "max", ")", "if", "start", "is", "None", ...
Generate daily summaries from calibrated and hourly data.
[ "Generate", "daily", "summaries", "from", "calibrated", "and", "hourly", "data", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/process.py#L625-L671
jim-easterbrook/pywws
src/pywws/process.py
generate_monthly
def generate_monthly(rain_day_threshold, day_end_hour, use_dst, daily_data, monthly_data, process_from): """Generate monthly summaries from daily data.""" start = monthly_data.before(datetime.max) if start is None: start = datetime.min start = daily_data.after(start + SECOND...
python
def generate_monthly(rain_day_threshold, day_end_hour, use_dst, daily_data, monthly_data, process_from): """Generate monthly summaries from daily data.""" start = monthly_data.before(datetime.max) if start is None: start = datetime.min start = daily_data.after(start + SECOND...
[ "def", "generate_monthly", "(", "rain_day_threshold", ",", "day_end_hour", ",", "use_dst", ",", "daily_data", ",", "monthly_data", ",", "process_from", ")", ":", "start", "=", "monthly_data", ".", "before", "(", "datetime", ".", "max", ")", "if", "start", "is"...
Generate monthly summaries from daily data.
[ "Generate", "monthly", "summaries", "from", "daily", "data", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/process.py#L674-L728
jim-easterbrook/pywws
src/pywws/process.py
process_data
def process_data(context): """Generate summaries from raw weather station data. The meteorological day end (typically 2100 or 0900 local time) is set in the preferences file ``weather.ini``. The default value is 2100 (2200 during DST), following the historical convention for weather station reading...
python
def process_data(context): """Generate summaries from raw weather station data. The meteorological day end (typically 2100 or 0900 local time) is set in the preferences file ``weather.ini``. The default value is 2100 (2200 during DST), following the historical convention for weather station reading...
[ "def", "process_data", "(", "context", ")", ":", "logger", ".", "info", "(", "'Generating summary data'", ")", "# get time of last record", "last_raw", "=", "context", ".", "raw_data", ".", "before", "(", "datetime", ".", "max", ")", "if", "last_raw", "is", "N...
Generate summaries from raw weather station data. The meteorological day end (typically 2100 or 0900 local time) is set in the preferences file ``weather.ini``. The default value is 2100 (2200 during DST), following the historical convention for weather station readings.
[ "Generate", "summaries", "from", "raw", "weather", "station", "data", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/process.py#L739-L768
jim-easterbrook/pywws
src/pywws/device_libusb1.py
USBDevice.read_data
def read_data(self, size): """Receive data from the device. If the read fails for any reason, an :obj:`IOError` exception is raised. :param size: the number of bytes to read. :type size: int :return: the data received. :rtype: list(int) """ r...
python
def read_data(self, size): """Receive data from the device. If the read fails for any reason, an :obj:`IOError` exception is raised. :param size: the number of bytes to read. :type size: int :return: the data received. :rtype: list(int) """ r...
[ "def", "read_data", "(", "self", ",", "size", ")", ":", "result", "=", "self", ".", "dev", ".", "bulkRead", "(", "0x81", ",", "size", ",", "timeout", "=", "1200", ")", "if", "not", "result", "or", "len", "(", "result", ")", "<", "size", ":", "rai...
Receive data from the device. If the read fails for any reason, an :obj:`IOError` exception is raised. :param size: the number of bytes to read. :type size: int :return: the data received. :rtype: list(int)
[ "Receive", "data", "from", "the", "device", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/device_libusb1.py#L85-L106
jim-easterbrook/pywws
src/pywws/device_libusb1.py
USBDevice.write_data
def write_data(self, buf): """Send data to the device. If the write fails for any reason, an :obj:`IOError` exception is raised. :param buf: the data to send. :type buf: list(int) :return: success status. :rtype: bool """ if sys.version_info[...
python
def write_data(self, buf): """Send data to the device. If the write fails for any reason, an :obj:`IOError` exception is raised. :param buf: the data to send. :type buf: list(int) :return: success status. :rtype: bool """ if sys.version_info[...
[ "def", "write_data", "(", "self", ",", "buf", ")", ":", "if", "sys", ".", "version_info", "[", "0", "]", "<", "3", ":", "str_buf", "=", "''", ".", "join", "(", "map", "(", "chr", ",", "buf", ")", ")", "else", ":", "str_buf", "=", "bytes", "(", ...
Send data to the device. If the write fails for any reason, an :obj:`IOError` exception is raised. :param buf: the data to send. :type buf: list(int) :return: success status. :rtype: bool
[ "Send", "data", "to", "the", "device", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/device_libusb1.py#L108-L134
jim-easterbrook/pywws
src/pywws/filedata.py
CoreStore.before
def before(self, idx): """Return datetime of newest existing data record whose datetime is < idx. Might not even be in the same year! If no such record exists, return None.""" if not isinstance(idx, datetime): raise TypeError("'%s' is not %s" % (idx, datetime)) ...
python
def before(self, idx): """Return datetime of newest existing data record whose datetime is < idx. Might not even be in the same year! If no such record exists, return None.""" if not isinstance(idx, datetime): raise TypeError("'%s' is not %s" % (idx, datetime)) ...
[ "def", "before", "(", "self", ",", "idx", ")", ":", "if", "not", "isinstance", "(", "idx", ",", "datetime", ")", ":", "raise", "TypeError", "(", "\"'%s' is not %s\"", "%", "(", "idx", ",", "datetime", ")", ")", "day", "=", "min", "(", "idx", ".", "...
Return datetime of newest existing data record whose datetime is < idx. Might not even be in the same year! If no such record exists, return None.
[ "Return", "datetime", "of", "newest", "existing", "data", "record", "whose", "datetime", "is", "<", "idx", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/filedata.py#L282-L298
jim-easterbrook/pywws
src/pywws/filedata.py
CoreStore.after
def after(self, idx): """Return datetime of oldest existing data record whose datetime is >= idx. Might not even be in the same year! If no such record exists, return None.""" if not isinstance(idx, datetime): raise TypeError("'%s' is not %s" % (idx, datetime)) ...
python
def after(self, idx): """Return datetime of oldest existing data record whose datetime is >= idx. Might not even be in the same year! If no such record exists, return None.""" if not isinstance(idx, datetime): raise TypeError("'%s' is not %s" % (idx, datetime)) ...
[ "def", "after", "(", "self", ",", "idx", ")", ":", "if", "not", "isinstance", "(", "idx", ",", "datetime", ")", ":", "raise", "TypeError", "(", "\"'%s' is not %s\"", "%", "(", "idx", ",", "datetime", ")", ")", "day", "=", "max", "(", "idx", ".", "d...
Return datetime of oldest existing data record whose datetime is >= idx. Might not even be in the same year! If no such record exists, return None.
[ "Return", "datetime", "of", "oldest", "existing", "data", "record", "whose", "datetime", "is", ">", "=", "idx", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/filedata.py#L300-L316
jim-easterbrook/pywws
src/pywws/filedata.py
CoreStore.nearest
def nearest(self, idx): """Return datetime of record whose datetime is nearest idx.""" hi = self.after(idx) lo = self.before(idx) if hi is None: return lo if lo is None: return hi if abs(hi - idx) < abs(lo - idx): return hi retu...
python
def nearest(self, idx): """Return datetime of record whose datetime is nearest idx.""" hi = self.after(idx) lo = self.before(idx) if hi is None: return lo if lo is None: return hi if abs(hi - idx) < abs(lo - idx): return hi retu...
[ "def", "nearest", "(", "self", ",", "idx", ")", ":", "hi", "=", "self", ".", "after", "(", "idx", ")", "lo", "=", "self", ".", "before", "(", "idx", ")", "if", "hi", "is", "None", ":", "return", "lo", "if", "lo", "is", "None", ":", "return", ...
Return datetime of record whose datetime is nearest idx.
[ "Return", "datetime", "of", "record", "whose", "datetime", "is", "nearest", "idx", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/filedata.py#L318-L328
jim-easterbrook/pywws
src/pywws/filedata.py
CoreStore.clear
def clear(self): """Clears all data from the data store permanently""" for root, dirs, files in os.walk(self._root_dir, topdown=False): for file in files: os.unlink(os.path.join(root, file)) os.rmdir(root) # Get the root dir back and re-initialise to start...
python
def clear(self): """Clears all data from the data store permanently""" for root, dirs, files in os.walk(self._root_dir, topdown=False): for file in files: os.unlink(os.path.join(root, file)) os.rmdir(root) # Get the root dir back and re-initialise to start...
[ "def", "clear", "(", "self", ")", ":", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "self", ".", "_root_dir", ",", "topdown", "=", "False", ")", ":", "for", "file", "in", "files", ":", "os", ".", "unlink", "(", "os", ...
Clears all data from the data store permanently
[ "Clears", "all", "data", "from", "the", "data", "store", "permanently" ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/filedata.py#L427-L436
jim-easterbrook/pywws
src/pywws/device_pyusb1.py
USBDevice.read_data
def read_data(self, size): """Receive data from the device. If the read fails for any reason, an :obj:`IOError` exception is raised. :param size: the number of bytes to read. :type size: int :return: the data received. :rtype: list(int) """ r...
python
def read_data(self, size): """Receive data from the device. If the read fails for any reason, an :obj:`IOError` exception is raised. :param size: the number of bytes to read. :type size: int :return: the data received. :rtype: list(int) """ r...
[ "def", "read_data", "(", "self", ",", "size", ")", ":", "result", "=", "self", ".", "dev", ".", "read", "(", "0x81", ",", "size", ",", "timeout", "=", "1200", ")", "if", "not", "result", "or", "len", "(", "result", ")", "<", "size", ":", "raise",...
Receive data from the device. If the read fails for any reason, an :obj:`IOError` exception is raised. :param size: the number of bytes to read. :type size: int :return: the data received. :rtype: list(int)
[ "Receive", "data", "from", "the", "device", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/device_pyusb1.py#L88-L106
jim-easterbrook/pywws
src/pywws/device_pyusb1.py
USBDevice.write_data
def write_data(self, buf): """Send data to the device. If the write fails for any reason, an :obj:`IOError` exception is raised. :param buf: the data to send. :type buf: list(int) :return: success status. :rtype: bool """ bmRequestType = usb....
python
def write_data(self, buf): """Send data to the device. If the write fails for any reason, an :obj:`IOError` exception is raised. :param buf: the data to send. :type buf: list(int) :return: success status. :rtype: bool """ bmRequestType = usb....
[ "def", "write_data", "(", "self", ",", "buf", ")", ":", "bmRequestType", "=", "usb", ".", "util", ".", "build_request_type", "(", "usb", ".", "util", ".", "ENDPOINT_OUT", ",", "usb", ".", "util", ".", "CTRL_TYPE_CLASS", ",", "usb", ".", "util", ".", "C...
Send data to the device. If the write fails for any reason, an :obj:`IOError` exception is raised. :param buf: the data to send. :type buf: list(int) :return: success status. :rtype: bool
[ "Send", "data", "to", "the", "device", "." ]
train
https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/device_pyusb1.py#L108-L136