Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
closes #590
Browse files Browse the repository at this point in the history
  • Loading branch information
forman committed Apr 17, 2018
1 parent d984f15 commit 5bd1fb7
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Version 2.0.0.dev9 (in dev)

* Representative default variables [#590](https://github.com/CCI-Tools/cate/issues/590).
* Tasks are no longer executed in parallel [#606](https://github.com/CCI-Tools/cate/issues/606).
* WebAPI service problem in CLI [#600](https://github.com/CCI-Tools/cate/issues/600)
* Improve error messages and handling [#393](https://github.com/CCI-Tools/cate/issues/393),
Expand Down
7 changes: 6 additions & 1 deletion cate/conf/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

from .defaults import GLOBAL_CONF_FILE, LOCAL_CONF_FILE, LOCATION_FILE, VERSION_CONF_FILE, \
VARIABLE_DISPLAY_SETTINGS, DEFAULT_DATA_PATH, DEFAULT_VERSION_DATA_PATH, DEFAULT_COLOR_MAP, DEFAULT_RES_PATTERN, \
WEBAPI_USE_WORKSPACE_IMAGERY_CACHE
WEBAPI_USE_WORKSPACE_IMAGERY_CACHE, DEFAULT_VARIABLES

_CONFIG = None

Expand Down Expand Up @@ -91,6 +91,11 @@ def get_default_res_pattern() -> str:
return default_res_pattern


def is_default_variable(var_name: str) -> bool:
default_variables = get_config().get('default_variables', DEFAULT_VARIABLES)
return var_name in default_variables


def get_variable_display_settings(var_name: str) -> Optional[Dict[str, Any]]:
"""
Get the global variable display settings which is a combination of defaults.
Expand Down
16 changes: 14 additions & 2 deletions cate/conf/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@
#: By default, WebAPI service will auto-exit after 5 seconds if all workspaces are closed, if WebAPI auto-exit enabled
WEBAPI_ON_ALL_CLOSED_AUTO_STOP_AFTER = 5.0


DEFAULT_VARIABLES = {
'absorbing_aerosol_index', # Aerosol CCI
'cfc', # Cloud CCI
'lccs_class', # LC CCI
'kd_490', # OC CCI
'O3_du', # Ozone CCI
'sm', # Soil Moisture CCI
'analysed_sst', # SST CCI
}


VARIABLE_DISPLAY_SETTINGS = {
# LC CCI
'lccs_class': dict(color_map='land_cover_cci'),
Expand All @@ -94,7 +106,7 @@
'MODISA_nobs_sum': dict(display_min=1, display_max=500),
'SeaWiFS_nobs_sum': dict(display_min=1, display_max=500),

# CLOUD CCI
# Cloud CCI
'cfc': dict(color_map="bone", display_min=0, display_max=1),

# SST CCI
Expand All @@ -104,7 +116,7 @@
'sea_ice_fraction': dict(display_min=0., display_max=1.),
'sea_ice_fraction_error': dict(display_min=0., display_max=0.2),

# AEROSOL CCI
# Aerosol CCI
'absorbing_aerosol_index': dict(color_map="bwr", display_min=-2, display_max=2),
'solar_zenith_angle': dict(color_map="bwr", display_min=35, display_max=80),
'number_of_observations': dict(color_map="gray", display_min=0, display_max=150),
Expand Down
11 changes: 11 additions & 0 deletions cate/conf/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@
]


# Configure any default variables of a dataset that will be initially selected and displayed first.
# 'default_display_variables' is a list comprising variable name sets. Each set may represent
# multiple similar datasets.
# default_variables = {
# 'cfc', # Cloud CCI
# 'lccs_class', # Land Cover CCI
# 'analysed_sst', # Sea Surface Temperature CCI
# }


# Configure / overwrite default variable display settings as used in various plot_<type>() operations
# and in the Cate Desktop GUI.
# Each entry maps a variable name to a dictionary with the following entries:
Expand All @@ -125,3 +135,4 @@
# https://matplotlib.org/examples/color/colormaps_reference.html
# default_color_map = 'jet'
default_color_map = 'inferno'

3 changes: 2 additions & 1 deletion cate/core/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,8 @@ def _get_xarray_variable_descriptor(cls, variable: xr.DataArray, is_coord=False)
'shape': variable.shape,
'chunkSizes': get_chunk_size(variable),
'attributes': Workspace._attrs_to_json_dict(attrs),
'isCoord': is_coord
'isCoord': is_coord,
'isDefault': conf.is_default_variable(variable.name),
}

if not is_coord:
Expand Down
6 changes: 6 additions & 0 deletions test/conf/test_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ def test_get_variable_display_settings(self):
self.assertIsNotNone(settings)
self.assertIn('color_map', settings)

def test_is_default_variable(self):
self.assertTrue(conf.is_default_variable('lccs_class'))
self.assertTrue(conf.is_default_variable('analysed_sst'))
self.assertTrue(conf.is_default_variable('cfc'))
self.assertFalse(conf.is_default_variable('bibo'))

def test_get_default_res_prefix(self):
default_res_prefix = conf.get_default_res_pattern()
self.assertIsNotNone(default_res_prefix)
Expand Down

0 comments on commit 5bd1fb7

Please sign in to comment.