monocongo/climate_indices

Lat "units" attribute required

Closed this issue · 2 comments

Hi James et al., thanks for the great package.

I'm trying to save the distribution parameters and get the following error which is due to the lat and lon coordinates not having the units attribute. In my netcdf file there are actually no coordinate variables for lat and lon (I know, not ideal) but I managed to calculate the SPI through this package without any dramas. (to confirm, there are lat and lon dimensions, but no corresponding coordinate variables).

AttributeError: 'DataArray' object has no attribute 'units'

Upon looking in the code it seems the units attribute for lat and lon is just required for some global metadata, here and here.

Can I confirm that it's fine to comment these out? I've done so and the package seems to be working fine but just would appreciate a sanity check from someone familiar with all this, before I compute a whole lot of data.

Thanks again.

Yes, these lines can be commented out without causing catastrophe. Maybe we should add a check to make sure the units exist before assigning a non-existent value, which I assume is where the code falls over when those lines aren't commented out?

Thanks for confirming. On the one hand a check would be nice, but unless you go all out to check for everything to prevent crashes like this I think it's ok to just expect users to have decent, CF compliant data. Just my opinion, but it forces everyone to get their house in order (or to modify the code!).