File: Transform.py

package info (click to toggle)
cf-python 1.3.2+dfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, stretch
  • size: 7,996 kB
  • sloc: python: 51,733; ansic: 2,736; makefile: 78; sh: 2
file content (46 lines) | stat: -rw-r--r-- 1,568 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import cf
import numpy
import os
import time

def test():
    start_time = time.time()
    print '----------------------------------------------------------'
    print 'cf.Transform'
    print '----------------------------------------------------------'

    filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                            "test_file.nc")
    f = cf.read(filename)[0]

    t = cf.Transform(name='atmosphere_hybrid_height_coordinate',
                     a='aux0', b='aux1', orog=f,
                     coord_terms=('a', 'b'))
    print t.dump(complete=True)
    print t
    t.inspect()
    print
    assert t.equals(t.copy(), traceback=True), "Transform not equal to itself"

    # Create a rotated_latitude_longitude grid mapping transform
    t = cf.Transform(name='rotated_latitude_longitude',
                     grid_north_pole_latitude=38.0,
                     grid_north_pole_longitude=190.0)
    print t.dump(complete=True)
    print t
    t.inspect()
    print
    assert t.equals(t.copy(), traceback=True), "Transform not equal to itself"

    time_elapsed = (time.time() - start_time)/60.0
    print
    print '---------------------------------------------------------------------------'
    print 'All cf.Transform tests passed for cf version', cf.__version__
    print 'Running from', os.path.abspath(cf.__file__)
    print 'Time elapsed: %f minutes' % time_elapsed
    print '---------------------------------------------------------------------------' 
    print
#--- End: def

if __name__ == "__main__":
    test()