NCAS-CMS / cf-python

A CF-compliant Earth Science data analysis library
http://ncas-cms.github.io/cf-python
MIT License
125 stars 19 forks source link

Improve `cf.Field.__getitem__` performance by not re-calculating axis cyclicity #744

Closed davidhassell closed 7 months ago

davidhassell commented 7 months ago

Currently (v3.16.1), the cyclicty of all axes with dimension coordinates is checked during a Field subspace. This likely entails getting the first and last values if the coordinates, which might be very slow if the values are on (a remote) disk, or need computing.

However, the cyclicity is already known on the subspaced field's Data object (cf.Data._getitem__ updates it), so we can just take it from there and disable the expensive automatic cyclicity check.