Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1'''A python interface to UNIDATA's UDUNITS-2 package with CF extensions 

2 

3Store, combine and compare physical units and convert numeric values 

4to different units. 

5 

6Units are as defined in UNIDATA's UDUNITS-2 package , except for 

7reference time units (such as 'days since 2000-12-1' in the 

8'proleptic_gregorian' calendar), which are handled by the `cftime` 

9python package. 

10 

11In addition, some units are either new to, modified from, or removed 

12from the standard UDUNITS-2 database in order to be more consistent 

13with the CF conventions. 

14 

15 

16''' 

17 

18__Conventions__ = 'CF-1.8' 

19__author__ = 'David Hassell' 

20__author__ = 'David Hassell' 

21__date__ = '2020-07-02' 

22__version__ = '3.2.8' 

23__cf_version__ = '1.8' 

24 

25from distutils.version import LooseVersion 

26import platform 

27 

28try: 

29 import cftime 

30except ImportError as error1: 

31 raise ImportError(error1) 

32 

33# Check the version of python 

34_minimum_vn = '3.5' 

35if LooseVersion(platform.python_version()) < LooseVersion(_minimum_vn): 

36 raise RuntimeError( 

37 "Bad python version: cfunits requires python version {} or later. " 

38 "Got {}".format( 

39 _minimum_vn, platform.python_version())) 

40 

41# Check the version of cftime 

42_minimum_vn = '1.1.3' 

43if LooseVersion(cftime.__version__) < LooseVersion(_minimum_vn): 

44 raise ValueError( 

45 "Bad cftime version: cfunits requires cftime>={}. Got {} at {}".format( 

46 _minimum_vn, cftime.__version__, cftime.__file__)) 

47 

48from .units import Units 

49