Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
climix
climix
Commits
213ab9c9
Commit
213ab9c9
authored
Sep 26, 2019
by
Klaus Zimmermann
Browse files
Add basic logging (closes
#108
)
parent
e1ca57fa
Changes
2
Hide whitespace changes
Inline
Side-by-side
climix/index.py
View file @
213ab9c9
# -*- 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
:
...
...
climix/main.py
View file @
213ab9c9
...
...
@@ -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'
])
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment