Hi


I'm following the how-to guide on making a dynamic map, and trying to get it to work with a different dataset. By the way, the new guides and documentation are great and very helpful!


My script works fine with the original dataset, but instead of a nice gridded map it shows a map with blue contours when I use another dataset. In the how-to guide there is a note saying that "If you pass a data array with no name or a non-CDM name, a default blue contour line map will be returned", so perhaps this is to be expected. 


My question is, how to deal with this issue? I've tried to update the attributes and name of my dataset, but to no avail, it still plots as blue contours. Even renaming the data array to give it the same name as the data in the example ('tas') doesn't help, suggesting it is not just a matter of the name being non-CDM. Exactly what attributes would I need to change for my data to be sufficiently CDM-compliant so that it would plot as a grid? 


This is my script with the output of the print statement below.


import cdstoolbox as ct

# Initialise the application
@ct.application(title='Dynamic map', fullscreen=True)
@ct.output.livemap()
def application():
    # Retrieve full resolution temperature data for a single date
    data = ct.catalogue.retrieve(
        'sis-agrometeorological-indicators',
        {
            'variable': '2m_temperature',
            'statistics': 'day_time_maximum',
            'year': '2018',
            'month': '07'
        }
    )
    
    # Plot temperature as a layer on a dynamic map
    print(data)
    plot = ct.livemap.plot(data)

    return plot

Output:

<xarray.DataArray 'tasmax' (time: 31, lat: 1801, lon: 3600)>
dask.array<xarray-tasmax, shape=(31, 1801, 3600), dtype=float32, chunksize=(31, 1801, 3600), chunktype=numpy.ndarray>
Coordinates:
  * time     (time) datetime64[ns] 2018-07-01 2018-07-02 ... 2018-07-31
  * lon      (lon) float64 -180.0 -179.9 -179.8 -179.7 ... 179.7 179.8 179.9
  * lat      (lat) float64 -90.0 -89.9 -89.8 -89.7 -89.6 ... 89.7 89.8 89.9 90.0
Attributes:
    long_name:             Maximum temperature at 2 meter (06-18LT)
    units:                 K
    temporal_aggregation:  Max 06-18LT
    standard_name:         air_temperature
    comment:               maximum near-surface (usually, 2 meter) air temper...
    type:                  real


Many thanks for any pointers!

Rutger


5 Comments

  1. Dear Rutger,

    I am glad you are appreciating the new documentation.

    Regarding the styling of the dynamic maps there is still no way to customise you style.

    In your case though there is a trick to use the Near-Surface Air Temperature style. You just need to change the 'long_name' of your data using ct.cdm.update_attributes():

    import cdstoolbox as ct
    
    # Initialise the application
    @ct.application(title='Dynamic map', fullscreen=True)
    @ct.output.livemap()
    def application():
        # Retrieve full resolution temperature data for a single date
        data = ct.catalogue.retrieve(
            'sis-agrometeorological-indicators',
            {
                'variable': '2m_temperature',
                'statistics': 'day_time_maximum',
                'year': '2018',
                'month': '07'
            }
        )
        
        # Plot temperature as a layer on a dynamic map
        print(data)
        data = ct.cdm.update_attributes(data, {'long_name': 'Near-Surface Air Temperature'})
        plot = ct.livemap.plot(data)
    
        return plot

    This happen to work because your variable and the range of values you are looking at correspond to an existing predefined style.

    Regards.

    Vivien

  2. Dear Vivien


    Perfect, just what I needed, thank you. 


    Rutger


  3. Hi,

    I have the same issue as Rutger encountered. Now we know that the LiveMap is happy if you define a variable as:

    'Near-Surface Air Temperature'


    However, this style isn't suitable for my dataset, I would be interested to know what are the other variables for which  LiveMap has a defined Style? Perhaps one of them is suitable.

  4. Hi,

    If you provide me with the name of the physical variable you are trying to plot or the range of values that your variable takes I might be able to help.

    If you have a workflow to share even better.

    Regards.

    Vivien

  5. Dear Vivien,

    The workflow below illustrates what I am trying to do:

    https://cds.climate.copernicus.eu/toolbox-editor/51058/livemapexample


    In this, I plot the Sea Surface Temperature and the SST anomaly. While the SST plot is fine, you can see that the anomaly plot simply displays contour lines.

    If you comment/uncomment lines 13/14 - you can see the equivalent plots for 2m air temperature and the anomaly plot is a gridded dataset (not contours).

    I would simply like to have a LiveMap Style for SST anomaly the same as the LiveMap Style for Air temperature anomaly.