Changeset 3627 for TI02-CSML/branches


Ignore:
Timestamp:
17/03/08 14:59:30 (12 years ago)
Author:
spascoe
Message:

This branch contains CSML converted to use cdat_lite-5.

  • convertcdms was run on the source
  • the MA.set_print_limit call was changed to the numpy equivilent
  • The tests were changed to account for the existence of numpy scalar types.

All tests, except the two known to fail, pass on i686 ubuntu.

Location:
TI02-CSML/branches/csml-cdms2
Files:
13 edited
1 copied

Legend:

Unmodified
Added
Removed
  • TI02-CSML/branches/csml-cdms2/API/csmlutils.py

    r3267 r3627  
     1# Adapted for numpy/ma/cdms2 by convertcdms.py 
    12'''csml utils contains useful utility functions that don't belong anywhere else''' 
    23import csml 
     
    131132                rtMessage="%s axis selected value '%s' nudged to nearest value in real axis '%s' ;" % (axisType, value, newValue)        
    132133        #        print rtMessag 
    133         if type(newValue) is float: 
     134        if isinstance(newValue, float): 
    134135            if len(str(int(newValue))) ==14: # it's a time 
    135136                newValue=csml.csmllibs.csmltime.convertValueToCSML(newValue)    
  • TI02-CSML/branches/csml-cdms2/API/genSubset.py

    r3267 r3627  
     1# Adapted for numpy/ma/cdms2 by convertcdms.py 
    12'''getSubset.py contains generic subsetting code that can be reused for multiple features 
    23Dominic Lowe, CCLRC, 31/01/2007''' 
     
    56import csmlutils 
    67import sys 
    7 import Numeric 
     8import numpy.oldnumeric as Numeric 
    89 
    910def checkNeighbours(domain, **kwargs): 
  • TI02-CSML/branches/csml-cdms2/API/ops_AbstractFeature.py

    r3271 r3627  
     1# Adapted for numpy/ma/cdms2 by convertcdms.py 
    12''' ops_AbstractFeature  contains operations for AbstractFeatures 
    23These methods are attached to AbstractFeature instances at runtime. 
     
    67import csml 
    78import csmlutils 
    8 import MA 
     9import numpy.oldnumeric.ma as MA 
    910 
    1011def testmethod(self): 
  • TI02-CSML/branches/csml-cdms2/API/ops_FileExtract.py

    r3267 r3627  
     1# Adapted for numpy/ma/cdms2 by convertcdms.py 
    12''' ops_AbstractFileExtract  contains operations for AbstractFileExtracts which are inherited by any FileExtracts - eg NetCDFExtracts. Methods are attached on the fly.''' 
    23import csml.csmllibs.csmldataiface 
    34import sys 
    4 import Numeric 
    5 import MA 
     5import numpy.oldnumeric as Numeric 
     6import numpy.oldnumeric.ma as MA 
    67 
    78 
  • TI02-CSML/branches/csml-cdms2/API/ops_PointSeriesFeature.py

    r3530 r3627  
     1# Adapted for numpy/ma/cdms2 by convertcdms.py 
    12''' ops_PointSeriesFeature  contains operations for PointSeriesFeatures. These methods are attached to PointSeriesFeature instances at runtime.''' 
    23import csml,sys 
    3 import cdms, MV, MA 
     4import cdms2 as cdms, MV2 as MV, numpy.oldnumeric.ma as MA 
    45 
    56def testmethod(self): 
  • TI02-CSML/branches/csml-cdms2/API/ops_RaggedSectionFeature.py

    r3271 r3627  
     1# Adapted for numpy/ma/cdms2 by convertcdms.py 
    12''' ops_RaggedSectionFeature  contains operations for RaggedSectionFeatures. These methods are attached to GridFeature instances at runtime.''' 
    23import csml 
    3 import MA,MV,Numeric 
    4 import cdms 
     4import numpy.oldnumeric.ma as MA,MV2 as MV,numpy.oldnumeric as Numeric 
     5import cdms2 as cdms 
    56 
    67 
  • TI02-CSML/branches/csml-cdms2/API/ops_TrajectoryFeature.py

    r3271 r3627  
     1# Adapted for numpy/ma/cdms2 by convertcdms.py 
    12''' ops_TrajectoryFeature  contains operations for TrajectoryFeature.These methods are attached to TrajectoryFeature instances at runtime.''' 
    23 
    3 import csml, cdms, MV, MA 
     4import csml, cdms2 as cdms, MV2 as MV, numpy.oldnumeric.ma as MA 
    45import sys 
    56import copy 
  • TI02-CSML/branches/csml-cdms2/csmllibs/NumericTransform.py

    r2473 r3627  
    11#!/usr/bin/python 
     2# Adapted for numpy/ma/cdms2 by convertcdms.py 
    23# Author: Mark Henning <mhen@pml.ac.uk> 
    34# 
     
    1213 
    1314from math import * 
    14 import Numeric 
     15import numpy.oldnumeric as Numeric 
    1516import re 
    1617 
  • TI02-CSML/branches/csml-cdms2/csmllibs/csmlcrs.py

    r3599 r3627  
     1# Adapted for numpy/ma/cdms2 by convertcdms.py 
    12import string 
    23import sys      
     
    379380         
    380381def main(): 
    381     import cdms # just for testing 
     382    import cdms2 as cdms # just for testing 
    382383    #sys.stdout = open("/home/dom/svn/trunk/csml/testfiles/gridseries/crsout.txt", "w") 
    383384    cat=CRSCatalogue() 
  • TI02-CSML/branches/csml-cdms2/csmllibs/csmldataiface.py

    r3279 r3627  
    11#!/usr/bin/env python 
     2# Adapted for numpy/ma/cdms2 by convertcdms.py 
    23 
    34''' 
     
    1314 
    1415import pdb 
    15 import cdms  
    16 import Numeric 
     16import cdms2 as cdms  
     17import numpy.oldnumeric as Numeric 
    1718 
    1819try: 
     
    2425import csml.csmllibs.csmltime 
    2526# This is required to prevent Numeric arrays being truncated when printed. 
    26 import MA 
    27 MA.set_print_limit(0) 
     27import numpy.oldnumeric.ma as MA 
     28#MA.set_print_limit(0) 
     29import numpy; numpy.set_printoptions(threshold=0) 
    2830 
    2931# Generic mathematical expression solver, required by the raw and image 
    3032# interfaces 
    31 import NumericTransform 
     33import numpy.oldnumeric as NumericTransform 
    3234 
    3335try: 
     
    458460            try: 
    459461                attribValue=self.varobj._FillValue 
    460                 attribValue=attribValue.toscalar() 
     462                attribValue=attribValue.item() 
    461463            except: 
    462464                try: 
    463465                    attribValue=self.varobj.missing_value 
    464                     attribValue=attribValue.toscalar() 
     466                    attribValue=attribValue.item() 
    465467                except: 
    466468                    attribValue = None   
     
    543545                            longitudeAxis=subset1.getAxisIndex(lonkey) 
    544546                            #concatenate arrays along longitude               
    545                             subset = cdms.MV.concatenate([subset2,subset1],axis=longitudeAxis) 
     547                            subset = cdms.MV2.concatenate([subset2,subset1],axis=longitudeAxis) 
    546548                        except: 
    547549                            subset=subset1 
     
    646648        if 'endianess' in kwargs: 
    647649            if ((kwargs['endianness'] == 'little' and not Numeric.LittleEndian) or (kwargs['endianness'] == 'big' and Numeric.LittleEndian)): 
    648                 self.data = self.data.byteswapped()     
     650                self.data = self.data.byteswap()     
    649651        # Declare the shape of the array: 
    650652        dimensions = map(int,kwargs['dimensions']) 
  • TI02-CSML/branches/csml-cdms2/csmllibs/netCDFWriter.py

    r3279 r3627  
    1 import cdms,MV 
    2 import Numeric 
     1# Adapted for numpy/ma/cdms2 by convertcdms.py 
     2import cdms2 as cdms,MV2 as MV 
     3import numpy.oldnumeric as Numeric 
    34import csml 
    45import sys 
  • TI02-CSML/branches/csml-cdms2/tests/make_data.py

    r3626 r3627  
     1# Adapted for numpy/ma/cdms2 by convertcdms.py 
    12""" 
    23Create test data on several different grids. 
     
    45""" 
    56 
    6 import cdms 
    7 import Numeric as N 
     7import cdms2 as cdms 
     8import numpy.oldnumeric as N 
    89import os 
    910import random 
  • TI02-CSML/branches/csml-cdms2/tests/test_extract.py

    r2638 r3627  
     1# Adapted for numpy/ma/cdms2 by convertcdms.py 
    12""" 
    23Test CSML subsetToGridSeries against cdms equivilent. 
     
    45""" 
    56 
    6 import csml, cdms 
     7import csml, cdms2 as cdms 
    78import os 
    89import tempfile 
    910 
    1011from unittest import TestCase 
    11 import Numeric as N 
     12import numpy.oldnumeric as N 
     13import numpy 
    1214 
    1315# For image dump 
     
    5254    cmap = cm.get_cmap() 
    5355    a = norm(var) 
    54     img_buf = (cmap(a)*255).astype('b') 
     56    img_buf = (cmap(a)*255).astype('B') 
    5557    (y, x, c) = img_buf.shape 
    5658    img = Image.frombuffer("RGBA", (x, y), img_buf.tostring(), 'raw', 'RGBA', 
     
    305307    def test1(self): 
    306308        var = self._extract1(85, 42.5) 
    307         self.assertEquals(type(var), float) 
     309        self.assertEquals(type(var), numpy.float64) 
    308310        self.assertEquals(var, 85.0+42.5) 
    309311         
    310312    def test2(self): 
    311313        var = self._extract2(85, 42.5) 
    312         self.assertEquals(type(var), float) 
     314        self.assertEquals(type(var), numpy.float64) 
    313315        self.assertEquals(var, 85.0+42.5) 
    314316 
    315317    def test3(self): 
    316318        var = self._extract3(85, 42.5) 
    317         self.assertEquals(type(var), float) 
     319        self.assertEquals(type(var), numpy.float64) 
    318320        self.assertEquals(var, 85.0+42.5) 
    319321 
    320322    def test4(self): 
    321323        var = self._extract4(85, 42.5) 
    322         self.assertEquals(type(var), float) 
     324        self.assertEquals(type(var), numpy.float64) 
    323325        self.assertEquals(var, 85.0+42.5) 
    324326         
     
    361363    def test1(self): 
    362364        var = self._extract1(85, 42.5) 
    363         self.assertEquals(type(var), float) 
     365        self.assertEquals(type(var), numpy.float64) 
    364366         
    365367    def test2(self): 
    366368        var = self._extract2(85, 42.5) 
    367         self.assertEquals(type(var), float) 
     369        self.assertEquals(type(var), numpy.float64) 
    368370         
    369371    def test3(self): 
    370372        var = self._extract3(85, 42.5) 
    371         self.assertEquals(type(var), float) 
     373        self.assertEquals(type(var), numpy.float64) 
    372374         
    373375    def test4(self): 
    374376        var = self._extract4(85, 42.5) 
    375         self.assertEquals(type(var), float) 
     377        self.assertEquals(type(var), numpy.float64) 
    376378                 
Note: See TracChangeset for help on using the changeset viewer.