ECMWFCode4Earth / atmospheric-explorer

repository for 2023 Code for Earth project to develop a tool for exploration of CAMS atmospheric composition datasets
Apache License 2.0
4 stars 0 forks source link

Anomalies and Hovmoeller plots break with multiple countries #21

Closed luigibrancati closed 1 year ago

luigibrancati commented 1 year ago

I selected multiple countries (Italy, Spain, France and Portugal) on the Streamlit app and tried generating the Anomalies and Hovmoeller plots, but they broke. The issue is with the clipping of the xarray dataset most likely.

elisaliv commented 1 year ago

@GiuliaFiantanese and I started investigating this bug tonight. We tried to replicate your error selecting the same countries listed in the issue:

So, these are the next steps to solve this issue:

elisaliv commented 1 year ago

We further investigated the issue. The problem seems to be with Portugal data, as we had already noticed at the beginning. If we try to create the anomalies plot with multiple countries that don't include Portugal, we do not get any error.

In the clipping function (clip_and_concat_countries, line 24 with rio.clip), if we have drop=True as argument we get this error:

NoDataInBounds: No data found in bounds. Data variable: tcno2

If we use drop=False, the function works but there seem to be no data in the anomalies plot (for Portugal only): image

We also tried to create a geospatial plot out of the same data, which supports this idea: image

Strangely enough, we don't have such issues if we select Vatican as a country. So it's probably not a matter of small shapefile, but something else.

Our suggested solution would be to leave drop=False as default. This way, plots wouldn't break anyway. We should also discuss with mentors about this issue.

luigibrancati commented 1 year ago

I agree with everything except with the Latitude Plot: we should provide a clipping based on the bounding box of the country, i.e. the latitudes included in the selection