When using `ct.climate.daily_max()` I am receiving this error when using `ct.chart.line` and  `@ct.output.livefigure()` `"JSON.parse: unexpected character at line 1 column 5311 of the JSON data"` examination of the JSON output https://cds.climate.copernicus.eu/cache-compute-0011/cache/data9/eb42e4ca-caab-4cec-8198-d1a4538f0838.json suggests that `NaN` values are being incorrectly serialized resulting in invalid JSON. Unfortunately I was unable to find the Open Source CDS Toolbox repository so as to examine the serialization and ct.climate.daily_max code, and help offer potential solutions (push request). Assuming that the underlying function might be something like http://xarray.pydata.org/en/stable/generated/xarray.Dataset.resample.html it seems that `NaN` values are a valid response when there is no data available in the resampling period, thus I guess the solution is to convert Python `NaN` values to `null`.

code: https://cds.climate.copernicus.eu/toolbox-editor/34002/climate-dashboards-datasets-1-1

1 Comment

  1. Dear Edward,

    Thanks for your post.

    It looks like you have NaN values because the ranges you are defining are not defined correctly. Days for the retrieve should be defined as range(1, 32) instead of range(1, 31). Remember that in Python the range(start, stop) only goes until stop - 1. This mean you did not retrieved any 31st of the month and the daily max for the 31st of the month are all NaNs.

    Here is a working version of your script.

    https://cds.climate.copernicus.eu/toolbox-editor/168/climate-dashboards-datasets-1-1

    Regards.

    Vivien