icenet package#

Subpackages#

Submodules#

icenet.exceptions module#

exception icenet.exceptions.CredentialsNotFoundError[source]#

Bases: Exception

Covers scenarios where a credential file has not been found

icenet.utils module#

class icenet.utils.Hemisphere(value)[source]#

Bases: Flag

Representation of hemispheres & both with bitwise operations.

An enum.Flag derived class representing the different hemispheres

(north, south, or both), providing methods to check which hemisphere is selected via bitwise operations:

& (AND), | (OR), ^ (XOR), and ~ (INVERT)

BOTH = 3#
NONE = 0#
NORTH = 1#
SOUTH = 2#
class icenet.utils.HemisphereMixin[source]#

Bases: object

A mixin relating to Hemisphere checking.

_hemisphere#

Represents the bitmask value of the hemisphere. Defaults to Hemisphere.NONE (i.e., 0).

Type:

int

property both: int#

The bitmask value representing both hemispheres.

property hemisphere: int#

The bitmask value representing the hemisphere.

property hemisphere_loc: list#

Get a list of latitude and longitude extent representing the hemisphere’s location.

property hemisphere_str: list#

A list of strings representing the selected hemispheres.

property north: bool#

A flag indicating if _hemisphere is north. True if the hemisphere is north, False otherwise.

property south: bool#

A flag indicating if _hemisphere is south. True if the hemisphere is south, False otherwise.

class icenet.utils.LogFormat(str_format: str = '[%(asctime)-17s :%(levelname)-8s] - %(message)s', date_format: str = '%d-%m-%y %T')[source]#

Bases: object

Creates a logging formatter for use across IceNet.

date_format: str = '%d-%m-%y %T'#
formatter: Formatter#
str_format: str = '[%(asctime)-17s :%(levelname)-8s] - %(message)s'#
icenet.utils.check_pytorch_import(logger: Logger) bool[source]#

Check for availability of pytorch module

Parameters:

logger – A Logger instance

Returns:

Whether torch was successfully imported

Return type:

pytorch_available

Example

>>> logger = setup_module_logging(__name__)
>>> pytorch_available = check_pytorch_import(logger)
icenet.utils.run_command(command: str, dry: bool = False) object[source]#

Run a shell command

A wrapper in case we want some additional handling to go in here

Parameters:
  • command – Command to run in shell.

  • dry (optional) – Whether to do a dry run or to run actual command. Default is False.

Returns:

subprocess.CompletedProcess return of the executed command.

icenet.utils.setup_logging(func, log_format='[%(asctime)-17s :%(levelname)-8s] - %(message)s')[source]#
icenet.utils.setup_module_logging(module_name: str, level: int = None)[source]#

Configure logger based on input name

Parameters:
  • module_name – Name for the logger

  • level – Logging level, can be int, or constants from logging module (e.g. logging.INFO)

Returns:

A configured Logger instance

Module contents#

Top-level package for IceNet.