Hi!

The height dimension of my data has the unit 'm'. I want to change it to 'km'. I have tried to change this by updating the 'data' attribute for 'height' with one that is multiplied by 0.001 using the ct.cdm_attribute function:

Issue: My intention was to replace the old 'data'-attribute. However, it seems that cdm.update_attributes made a copy (the first list) without replacing the old one, while also putting it a layer too deep, in a nested dictionary. 


I used the following code:

data = ct.cdm.update_attributes(data, coord_attrs={'height': {'data':[float(element) * 0.001 for element in data.coords['height']['data']]}})

The output before updating the attributes is as following:

and the link to the workflow: https://sis-dev.climate.copernicus.eu/toolbox-editor/1474/satellite-humidity-1


Any help would be appreciated!

Thanks.


Huayuan

2 Comments

  1. Hi Huayuan,

    What you have done here is an add attribute to the coordinate variable called 'data', this attribute contains the list you define. You have not updated the data. You can see this if you do a `ncdump -h FILENAME` of the file.

    We do not currently offer a method to convert the units of the coordinate variables within the the toolbox as the intention is to use base-SI units for easy comparisons. It may help to understand why do you want to change the coordinate units?

    Vivien MAVEL  do you have anything to contribute to this topic?

    Thanks,

    Eddy

  2. Hi Edward,

    thank you for your response. The intention was to convert the height-coordinate data to 'km' for an y-axis in a plot.


    Thanks,

    Huayuan