How to use the nansat.tools.add_logger function in nansat

To help you get started, we’ve selected a few nansat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nansencenter / nansat / nansat / nansat.py View on Github external
Level of logging verbosity.

        Notes
        --------
            self.logger
                adds logging.Logger
            self.filename
                adds full path to input file
            self.name
                adds name of file
            self.path
                adds path to file

        """
        # create logger
        self.logger = add_logger('Nansat', log_level)
        # set input file name
        self.filename = filename
        # name, for compatibility with some Domain methods
        self.name = os.path.basename(filename)
        self.path = os.path.dirname(filename)
github nansencenter / nansat / nansat / nansat.py View on Github external
def _import_mappers(log_level=None):
    """Import available mappers into a dictionary

    Returns
    --------
    nansat_mappers : dict
        key  : mapper name
        value: class Mapper(VRT) from the mappers module

    """
    logger = add_logger('import_mappers', logLevel=log_level)
    # import built-in mappers
    import nansat.mappers
    mapper_packages = [nansat.mappers]

    # import user-defined mappers (if any)
    try:
        import nansat_mappers as nansat_mappers_pkg
    except ImportError:
        pass
    else:
        logger.info('User defined mappers found in %s' % nansat_mappers_pkg.__path__)
        mapper_packages = [nansat_mappers_pkg, nansat.mappers]

    # create ordered dict for mappers
    nansat_mappers = OrderedDict()
    for mapper_package in mapper_packages:
github nansencenter / nansat / nansat / vrt.py View on Github external
def __init__(self, x_size=1, y_size=1, metadata=None, nomem=False, **kwargs):
        """Init VRT object with all attributes"""
        if metadata is None:
            metadata = dict()

        # essential attributes
        self.logger = add_logger('Nansat')
        self.driver = gdal.GetDriverByName(str('VRT'))
        self.filename = str(VRT._make_filename(nomem=nomem))
        self.band_vrts = dict()
        self.tps = False
        self.vrt = None

        # create dataset
        self.dataset = self.driver.Create(self.filename, x_size, y_size, bands=0)
        self.dataset.SetMetadata(metadata)
        self.dataset.FlushCache()
github nansencenter / nansat / nansat / nansat.py View on Github external
def _import_mappers(logLevel=None):
    ''' Import available mappers into a dictionary

    Returns
    --------
    nansatMappers : dict
        key  : mapper name
        value: class Mapper(VRT) from the mapper module

    '''
    logger = add_logger('import_mappers', logLevel=logLevel)
    # import built-in mappers
    import nansat.mappers
    mappersPackages = [nansat.mappers]

    # import user-defined mappers (if any)
    try:
        import nansat_mappers
    except:
        pass
    else:
        logger.info('User defined mappers found in %s'
                    % nansat_mappers.__path__)
        mappersPackages = [nansat_mappers, nansat.mappers]

    # create ordered dict for mappers
    nansatMappers = OrderedDict()
github nansencenter / nansat / nansat / nansat.py View on Github external
# create a Nansat object in memory with one band from input array <a>.
        # <p> is a dictionary with metadata for the band

        a = n[1]
        # fetch data from Nansat object from the first band

        a = n['band_name']
        # fetch data from the band which has name 'band_name'

        '''
        # check the arguments
        if fileName == '' and domain is None:
            raise OptionError('Either fileName or domain is required.')

        # create logger
        self.logger = add_logger('Nansat', logLevel)

        # empty dict of VRTs with added bands
        self.addedBands = {}

        # set input file name
        self.fileName = fileName
        # name, for compatibility with some Domain methods
        self.name = os.path.basename(fileName)
        self.path = os.path.dirname(fileName)

        # create self.vrt from a file using mapper or...
        if fileName != '':
            # Make original VRT object with mapping of variables
            self.vrt = self._get_mapper(mapperName, **kwargs)
        # ...create using array, domain, and parameters
        else:</p></a>