1.5.1.1.2.1.3. polar2grid.core.script_utils module

Helper functions and classes used by multiple polar2grid scripts.

author:

David Hoese (davidh)

contact:

david.hoese@ssec.wisc.edu

organization:

Space Science and Engineering Center (SSEC)

copyright:

Copyright (c) 2013 University of Wisconsin SSEC. All rights reserved.

date:

Sept 2014

license:

GNU GPLv3

class polar2grid.core.script_utils.ArgumentParser(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True, allow_abbrev=True, exit_on_error=True)[source]

Bases: ArgumentParser

_get_group_actions(group)[source]

Get all the options/actions in a group including those from subgroups of the provided group.

Note

This does not group the subgroup options as their own dictionaries.

parse_args(*args, **kwargs)[source]

Parse arguments to support custom polar2grid ‘subgroup’ behavior.

Parameters:
  • subgroup_titles – Groups and their arguments that will be put in a separate dictionary in the ‘subgroup_args’ attribute

  • global_keywords – Keywords/arguments that should be added to all subgroup dictionaries

class polar2grid.core.script_utils.ExtendAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]

Bases: Action

Similar to the ‘append’ action, but expects multiple elements instead of just one.

class polar2grid.core.script_utils.ExtendConstAction(option_strings, dest, nargs=0, **kwargs)[source]

Bases: Action

Similar to the ‘append’ action, but expects multiple elements instead of just one.

class polar2grid.core.script_utils.NumpyDtypeList(iterable=(), /)[source]

Bases: list

Magic list to allow dtype objects to match string versions of themselves.

class polar2grid.core.script_utils.SatPyWarningFilter(name='')[source]

Bases: Filter

filter(record)[source]

Determine if the specified record is to be logged.

Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.

class polar2grid.core.script_utils.ThirdPartyFilter(ignored_packages, level=30, name='')[source]

Bases: Filter

filter(record)[source]

Determine if the specified record is to be logged.

Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.

polar2grid.core.script_utils.create_basic_parser(*args, **kwargs)[source]
polar2grid.core.script_utils.create_exc_handler(glue_name)[source]
polar2grid.core.script_utils.rename_log_file(new_filename)[source]

Rename the file handler for the root logger and the traceback logger.

polar2grid.core.script_utils.setup_logging(console_level=20, log_filename='polar2grid.log', log_numpy=True)[source]

Set up the logger to the console to the logging level defined in the command line (default INFO).

Sets up a file logging for everything, regardless of command line level specified. Adds extra logger for tracebacks to go to the log file if the exception is caught. See exc_handler for more information.

Parameters:
  • console_level – Python logging level integer (ex. logging.INFO).

  • log_filename – Log messages to console and specified log_filename (None for no file log)

  • log_numpy – Tell numpy to log invalid values encountered