Changeset 3627
- Timestamp:
- 17/03/08 14:59:30 (13 years ago)
- 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 1 2 '''csml utils contains useful utility functions that don't belong anywhere else''' 2 3 import csml … … 131 132 rtMessage="%s axis selected value '%s' nudged to nearest value in real axis '%s' ;" % (axisType, value, newValue) 132 133 # print rtMessag 133 if type(newValue) is float:134 if isinstance(newValue, float): 134 135 if len(str(int(newValue))) ==14: # it's a time 135 136 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 1 2 '''getSubset.py contains generic subsetting code that can be reused for multiple features 2 3 Dominic Lowe, CCLRC, 31/01/2007''' … … 5 6 import csmlutils 6 7 import sys 7 import Numeric8 import numpy.oldnumeric as Numeric 8 9 9 10 def checkNeighbours(domain, **kwargs): -
TI02-CSML/branches/csml-cdms2/API/ops_AbstractFeature.py
r3271 r3627 1 # Adapted for numpy/ma/cdms2 by convertcdms.py 1 2 ''' ops_AbstractFeature contains operations for AbstractFeatures 2 3 These methods are attached to AbstractFeature instances at runtime. … … 6 7 import csml 7 8 import csmlutils 8 import MA9 import numpy.oldnumeric.ma as MA 9 10 10 11 def testmethod(self): -
TI02-CSML/branches/csml-cdms2/API/ops_FileExtract.py
r3267 r3627 1 # Adapted for numpy/ma/cdms2 by convertcdms.py 1 2 ''' ops_AbstractFileExtract contains operations for AbstractFileExtracts which are inherited by any FileExtracts - eg NetCDFExtracts. Methods are attached on the fly.''' 2 3 import csml.csmllibs.csmldataiface 3 4 import sys 4 import Numeric5 import MA5 import numpy.oldnumeric as Numeric 6 import numpy.oldnumeric.ma as MA 6 7 7 8 -
TI02-CSML/branches/csml-cdms2/API/ops_PointSeriesFeature.py
r3530 r3627 1 # Adapted for numpy/ma/cdms2 by convertcdms.py 1 2 ''' ops_PointSeriesFeature contains operations for PointSeriesFeatures. These methods are attached to PointSeriesFeature instances at runtime.''' 2 3 import csml,sys 3 import cdms , MV,MA4 import cdms2 as cdms, MV2 as MV, numpy.oldnumeric.ma as MA 4 5 5 6 def testmethod(self): -
TI02-CSML/branches/csml-cdms2/API/ops_RaggedSectionFeature.py
r3271 r3627 1 # Adapted for numpy/ma/cdms2 by convertcdms.py 1 2 ''' ops_RaggedSectionFeature contains operations for RaggedSectionFeatures. These methods are attached to GridFeature instances at runtime.''' 2 3 import csml 3 import MA,MV,Numeric4 import cdms 4 import numpy.oldnumeric.ma as MA,MV2 as MV,numpy.oldnumeric as Numeric 5 import cdms2 as cdms 5 6 6 7 -
TI02-CSML/branches/csml-cdms2/API/ops_TrajectoryFeature.py
r3271 r3627 1 # Adapted for numpy/ma/cdms2 by convertcdms.py 1 2 ''' ops_TrajectoryFeature contains operations for TrajectoryFeature.These methods are attached to TrajectoryFeature instances at runtime.''' 2 3 3 import csml, cdms , MV,MA4 import csml, cdms2 as cdms, MV2 as MV, numpy.oldnumeric.ma as MA 4 5 import sys 5 6 import copy -
TI02-CSML/branches/csml-cdms2/csmllibs/NumericTransform.py
r2473 r3627 1 1 #!/usr/bin/python 2 # Adapted for numpy/ma/cdms2 by convertcdms.py 2 3 # Author: Mark Henning <mhen@pml.ac.uk> 3 4 # … … 12 13 13 14 from math import * 14 import Numeric15 import numpy.oldnumeric as Numeric 15 16 import re 16 17 -
TI02-CSML/branches/csml-cdms2/csmllibs/csmlcrs.py
r3599 r3627 1 # Adapted for numpy/ma/cdms2 by convertcdms.py 1 2 import string 2 3 import sys … … 379 380 380 381 def main(): 381 import cdms # just for testing382 import cdms2 as cdms # just for testing 382 383 #sys.stdout = open("/home/dom/svn/trunk/csml/testfiles/gridseries/crsout.txt", "w") 383 384 cat=CRSCatalogue() -
TI02-CSML/branches/csml-cdms2/csmllibs/csmldataiface.py
r3279 r3627 1 1 #!/usr/bin/env python 2 # Adapted for numpy/ma/cdms2 by convertcdms.py 2 3 3 4 ''' … … 13 14 14 15 import pdb 15 import cdms 16 import Numeric16 import cdms2 as cdms 17 import numpy.oldnumeric as Numeric 17 18 18 19 try: … … 24 25 import csml.csmllibs.csmltime 25 26 # This is required to prevent Numeric arrays being truncated when printed. 26 import MA 27 MA.set_print_limit(0) 27 import numpy.oldnumeric.ma as MA 28 #MA.set_print_limit(0) 29 import numpy; numpy.set_printoptions(threshold=0) 28 30 29 31 # Generic mathematical expression solver, required by the raw and image 30 32 # interfaces 31 import NumericTransform33 import numpy.oldnumeric as NumericTransform 32 34 33 35 try: … … 458 460 try: 459 461 attribValue=self.varobj._FillValue 460 attribValue=attribValue. toscalar()462 attribValue=attribValue.item() 461 463 except: 462 464 try: 463 465 attribValue=self.varobj.missing_value 464 attribValue=attribValue. toscalar()466 attribValue=attribValue.item() 465 467 except: 466 468 attribValue = None … … 543 545 longitudeAxis=subset1.getAxisIndex(lonkey) 544 546 #concatenate arrays along longitude 545 subset = cdms.MV .concatenate([subset2,subset1],axis=longitudeAxis)547 subset = cdms.MV2.concatenate([subset2,subset1],axis=longitudeAxis) 546 548 except: 547 549 subset=subset1 … … 646 648 if 'endianess' in kwargs: 647 649 if ((kwargs['endianness'] == 'little' and not Numeric.LittleEndian) or (kwargs['endianness'] == 'big' and Numeric.LittleEndian)): 648 self.data = self.data.byteswap ped()650 self.data = self.data.byteswap() 649 651 # Declare the shape of the array: 650 652 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 2 import cdms2 as cdms,MV2 as MV 3 import numpy.oldnumeric as Numeric 3 4 import csml 4 5 import sys -
TI02-CSML/branches/csml-cdms2/tests/make_data.py
r3626 r3627 1 # Adapted for numpy/ma/cdms2 by convertcdms.py 1 2 """ 2 3 Create test data on several different grids. … … 4 5 """ 5 6 6 import cdms 7 import Numeric as N7 import cdms2 as cdms 8 import numpy.oldnumeric as N 8 9 import os 9 10 import random -
TI02-CSML/branches/csml-cdms2/tests/test_extract.py
r2638 r3627 1 # Adapted for numpy/ma/cdms2 by convertcdms.py 1 2 """ 2 3 Test CSML subsetToGridSeries against cdms equivilent. … … 4 5 """ 5 6 6 import csml, cdms 7 import csml, cdms2 as cdms 7 8 import os 8 9 import tempfile 9 10 10 11 from unittest import TestCase 11 import Numeric as N 12 import numpy.oldnumeric as N 13 import numpy 12 14 13 15 # For image dump … … 52 54 cmap = cm.get_cmap() 53 55 a = norm(var) 54 img_buf = (cmap(a)*255).astype(' b')56 img_buf = (cmap(a)*255).astype('B') 55 57 (y, x, c) = img_buf.shape 56 58 img = Image.frombuffer("RGBA", (x, y), img_buf.tostring(), 'raw', 'RGBA', … … 305 307 def test1(self): 306 308 var = self._extract1(85, 42.5) 307 self.assertEquals(type(var), float)309 self.assertEquals(type(var), numpy.float64) 308 310 self.assertEquals(var, 85.0+42.5) 309 311 310 312 def test2(self): 311 313 var = self._extract2(85, 42.5) 312 self.assertEquals(type(var), float)314 self.assertEquals(type(var), numpy.float64) 313 315 self.assertEquals(var, 85.0+42.5) 314 316 315 317 def test3(self): 316 318 var = self._extract3(85, 42.5) 317 self.assertEquals(type(var), float)319 self.assertEquals(type(var), numpy.float64) 318 320 self.assertEquals(var, 85.0+42.5) 319 321 320 322 def test4(self): 321 323 var = self._extract4(85, 42.5) 322 self.assertEquals(type(var), float)324 self.assertEquals(type(var), numpy.float64) 323 325 self.assertEquals(var, 85.0+42.5) 324 326 … … 361 363 def test1(self): 362 364 var = self._extract1(85, 42.5) 363 self.assertEquals(type(var), float)365 self.assertEquals(type(var), numpy.float64) 364 366 365 367 def test2(self): 366 368 var = self._extract2(85, 42.5) 367 self.assertEquals(type(var), float)369 self.assertEquals(type(var), numpy.float64) 368 370 369 371 def test3(self): 370 372 var = self._extract3(85, 42.5) 371 self.assertEquals(type(var), float)373 self.assertEquals(type(var), numpy.float64) 372 374 373 375 def test4(self): 374 376 var = self._extract4(85, 42.5) 375 self.assertEquals(type(var), float)377 self.assertEquals(type(var), numpy.float64) 376 378
Note: See TracChangeset
for help on using the changeset viewer.