Commit 213ab9c9 authored by Klaus Zimmermann's avatar Klaus Zimmermann
Browse files

Add basic logging (closes #108)

parent e1ca57fa
# -*- coding: utf-8 -*-
import logging
import iris
from .aggregators import PointLocalAggregator
......@@ -16,9 +18,13 @@ class Index:
def __call__(self, cube, sliced_mode=False):
logging.info('Adding coord categorisation.')
coord_name = self.period.add_coord_categorisation(cube)
logging.info('Extracting period cube')
sub_cube = cube.extract(self.period.constraint)
logging.info('Preparing cube')
self.index_function.prepare(sub_cube)
logging.info('Setting up aggregation')
aggregated = sub_cube.aggregated_by(coord_name, self.aggregator,
period=self.period)
if sliced_mode:
......
......@@ -17,6 +17,9 @@ from .index import Index
from .index_functions import SUPPORTED_OPERATORS, SUPPORTED_REDUCERS
from .period import PeriodSpecification
import logging
logging.basicConfig(level=logging.INFO)
MISSVAL = 1.0e20
......@@ -161,11 +164,17 @@ def build_output_filename(index, datafiles, output_template):
def do_main(requested_indices, datafiles, output_template, sliced_mode):
logging.info('Loading metadata')
metadata = load_metadata()
logging.info('Preparing indices')
indices = prepare_indices(metadata['indices'], requested_indices)
for index in indices:
logging.info(f'Starting calculations for index {index}')
logging.info('Building output filename')
output_filename = build_output_filename(index, datafiles, output_template)
logging.info('Preparing input data')
input_data = prepare_input_data(datafiles)
logging.info('Calculating index')
result = index(input_data, sliced_mode=sliced_mode)
iris.save(result, output_filename, fill_value=MISSVAL,
local_keys=['proposed_standard_name'])
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment