Is there a way to customize the style of the layers in a livemap?  I try to render the data with predefined colormap.
How can I achieve this?  I tried 'ct.livemap.plot( {'data': data, 'cmap': 'magma'}, title=title, click_kwargs={'data': data})'.

I always see the same blue iso-lines ...

The complete script is 

import cdstoolbox as ct

VARIABLES = ['ice_days', 'wet_days']

def _get_data_at(data, location):
    lat = location['lat']
    lon = location['lon']
    data_sel = ct.geo.extract_point(data, lon=lon, lat=lat)
    yearly_sum = ct.cube.groupby_reduce(data_sel, group='time.year', how='sum', dim='time', squeeze=False)
    return yearly_sum

    
@ct.child(position='floating')
@ct.output.livefigure()
def _handle_map_clicked(**kwargs):
    location = kwargs.get('location')
    data = kwargs.get('data')
    data_at = _get_data_at(data, location)
    print('data_at: ', data_at)
    fig = ct.chart.bar(data_at, layout_kwargs={"height": 200})
    #fig.update_layout(autosize=False, width=800, height=800)
    return fig

@ct.application(title='Plot Map')
@ct.input.dropdown('variable', label='Variable', values=VARIABLES)
@ct.output.livemap(height=65, click_on_map=_handle_map_clicked)
def plot_map(variable):
    data = ct.catalogue.retrieve(
        'sis-agroclimatic-indicators',
        {
            'origin': 'ipsl_cm5a_lr_model',
            'variable': variable,
            'experiment': 'historical',
            'temporal_aggregation': '10_day',
            'period': '198101_201012',
        }
    )   

    title = '{}'.format(' '.join([text.capitalize() for text in variable.split('_')]))
    print('data', data)   
    fig = ct.livemap.plot( 
        {'data': data, 'cmap': 'magma'}, title=title, click_kwargs={'data': data})
    return fig


3 Comments

  1. Dear Roeland,

    That is a nice app you have there!

    Unfortunately, for now, only variables with a predefined style are rendered with a style.

    Any other variable get the default blue lines and there is no way to path a custom style through the current interface. An interface taking custom styles in input is currently under discussion. You could also submit a custom style to ECMWF for the variable you are trying to plot.

    Best Regards.

    Vivien


  2. Thx!

    What do you mean with 'a predefined style'?  Can I add some style meta-data or transform the data to render it differently?


    kr,

    Roeland

  3. Would it be possible to adjust the size of the font for the blue lines? They are quite hard to read in the default size.