|
The new
CDAT
5.0 Beta has
been released. The older version CDAT 4.3 is still available,
although it is not supported anymore, and eventually it will become
obsolete.
New features included in CDAT 5.0:
- new
installation (configure)
- new VCDAT
- Lite mode
- interactive
plot Edit Mode
- TrueType
fonts system
- direct
postscript, PNG,
pdf, other
- MPEG
animation
- improved CDAT
Demo
- new inline
CDAT HELP
CDAT
5.0 uses NumPy
module (the Numeric is no longer supported!) and it works
with Python 2.5+ versions.
Because of the
changes coming with NumPy, CDAT
5.0 has new modules cdms2
and MV2 and the old cdms and MV modules
are now deprecated. The automatic
conversion program is supplied to help you with the transition from the
pre-CDAT 5.0 to the post CDAT 5.0 programming with the new
modules.
The
major change in version 5 is the transition from the Numeric scientific
computing package to the NumPy
package. NumPy is a full replacement and enhancement of Numeric, which
is no longer supported. Since many of the CDMS array objects, such as
Variables and Axes, are extensions of the Numeric array, this
transition is nontrivial. Fortunately NumPy is very similar to Numeric.
In many cases a simple change of module name will be sufficient to
update a script.
Namespace
Changes
In
CDMS Version 5 the cdms2
module interfaces to numpy
and numpy.ma
(the replacement for MA).
For an interim period, the cdms,
MA and Numeric
modules will be retained for backward compatibility, but are
deprecated. The change of namespace reflects the fact that the array
objects are fundamentally different, and in certain instances behave
differently. Also, MV
is now MV2,
cdms2.MV
is an alias for cdms2.MV2,
and regrid
is changed to regrid2.
The following table summarizes these namespace changes for the affected
CDAT modules:
|
Version 4
|
Version
5 |
Compatibility module
|
| cdms |
cdms2 |
cdms |
| MV |
MV2 |
MV |
| regrid |
regrid2 |
regrid |
| Numeric |
numpy |
numpy.oldnumeric |
| MA |
numpy.core.ma
|
numpy.oldnumeric.ma |
| vcs |
vcs |
-
|
| cdutil |
cdutil |
-
|
| genutil |
genutil |
-
|
Converting
scripts with convertcdms.py
The changes needed to convert from cdms/Numeric to cdms2/NumPy are
relatively few and can mostly be automated. You can use the script convertcdms.py,
installed in the bin directory to scan a Python script or directory
and make the automated changes:
Automatic
changes:
1.
import cdms => import cdms2 as cdms
2. import regrid => import regrid2 as regrid
3. import MV => import MV2 as MV
4. import Numeric => import numpy.oldnumeric as Numeric
5. import MA => import numpy.oldnumeric.ma as MA
6. import cdms.MV => import cdms2.MV2
7. from cdms import XX => from cdms2 import XX (similarly for
regrid, MV, MA, and Numeric)
8. from cdms.XX import YY => from cdms2.XX import YY (similarly
for regrid, MV, MA, and Numeric)
9. import cdms as XX => import cdms2 as XX (similarly for
regrid, MV, MA, and Numeric)
10. import cdms.XX => import cdms2.XX (similarly for regrid, MV,
MA, and Numeric)
import XX, cdms, YY => import XX, cdms2 as cdms, YY (similarly
for regrid, MV, MA, and Numeric)
11. MA.Float => Numeric.Float, similarly for MA.Int, MA.NewAxis
12. MA.Numeric => Numeric
13. The 'typecode=' argument in MA and MV functions is changed to
'dtype='
14. XX.mask() => XX.mask
15. XX.mask is None => ((XX.mask is None) or (XX.mask is
MV2.nomask))
16. A keyword argument 'axis=0' is added to MA.sum, MA.average,
MA.product, and MA.repeat
17. The translations in numpy.oldnumeric.alter_code1. This module is
used for most Numeric and MA-related translations. alter_code1 methods
do not have to be executed separately. See the sample chapters
of “Guide to NumPy” at http://numpy.scipy.org .
18. array.typecode() => arr.dtype.char
19. array.size() => arr.size
20. array.mask() => arr.mask
21. Some typecode characters have changed. For example,
‘s’ => ‘h’.
Changes
to be done by hand:
1. Slicing a singleton value from an array returns a scalar, not a 0-D
array. Such scalars have a shape but no length.
2. To test for the type of a scalar extracted from an array, use
isinstance() instead of type().
3. Masked arrays return a special nomask object instead of None when
there is no mask on the array. This applies to getmask() and the
array.mask attribute.
4. Masked array functions have a default axis of Nonel.
The default in previous versions was axis=0.
5. The default datatype in numpy/ma/cdms2 is float. In Numeric/MA/cdms
it was int.
To
run convertcdms.py:
%
convertcdms.py foo.py
saves the original file in foo.orig (if translations are made) and
converts the script.
%
convertcdms.py -r directory
converts all Python and C source code in the directory, and recursively
in subdirectories.
%
convertcdms.py -h
shows all options.
See appendix
D of the
CDMS 5.0 for the detailed info on the transition from Numeric
to NumPy.
|