source: TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/service/imps/test_csmllayer.py @ 3609

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI05-delivery/ows_framework/branches/ows_framework-refactor/ows_common/ows_common/service/imps/test_csmllayer.py@3609
Revision 3609, 2.3 KB checked in by domlowe, 12 years ago (diff)

adding csml implementation code (not complete)

Line 
1import wms_csmllayer
2
3def test_layerMapper():
4    lm=wms_csmllayer.CSMLLayerMapper()
5    print 'building layermap'
6    layers=lm.map(file='/home/dom/hadgem/hadgem1.csml')
7   
8    #for key, layer in layers.items():
9        #print '*********************'
10        #print 'name: %s'%key  #name is currently gml:id..
11        #print 'title: %s'%layer.title
12        #print 'abstract: %s'%layer.abstract
13        #print 'dimensions: %s'%layer.dimensions
14        #for dim in layer.dimensions:
15            #print layer.dimensions[dim].units
16            #print layer.dimensions[dim].extent
17        #print 'units: %s'%layer.units
18        #print 'crss: %s'%layer.crss
19        #print '*********************'
20       
21    #should be 35 features in this file
22    layerid='UkndO02d'
23    assert len(layers) == 35
24    assert layers[layerid].title == 'm1s3i223'
25    assert layers[layerid].abstract=='SURF & BL TOTL MOISTURE FLUX KG/M2/S'
26    assert layers[layerid].units == ['degrees_east', 'degrees_north', 'none', 'days_since_1970-01-01_00:00:0']
27    assert layers[layerid].crss == ['EPSG:4326']
28    assert layers[layerid].dimensions.keys() == ['latitude', 'z0_surface', 'longitude', 'time']
29    #layerid='EAY38o0Z'   #total precip
30    layerid='DiXD05pN' #solar_1
31    print 'getting slab...'
32    slab= layers[layerid].getSlab('EPSG:4324', dimValues={'time':'1999-12-06T12:00:00.0', 'z0_surface':'0'})
33    img=slab.getImage((-80, -160, 80, 160) ,320, 320)
34    img.save("testimage.jpeg", "JPEG")
35    print 'getting slab2...'
36    slab2= layers[layerid].getSlab('EPSG:4324', dimValues={'time':'1998-12-06T12:00:00.0', 'z0_surface':'0'})
37    img2=slab2.getImage((-80, -160, 80, 160) ,320, 320)
38    img2.save("testimage2.jpeg", "JPEG")
39   
40    #Temperature:
41    print 'getting slab3...'
42    layerid = 'RJ1QcBwz'
43    slab3= layers[layerid].getSlab('EPSG:4324', dimValues={'time':'1998-12-06T12:00:00.0', 'height':'0'})
44    img3=slab3.getImage((-80, -160, 80, 160) ,320, 320)
45    img3.save("testimage3.jpeg", "JPEG")
46   
47    print 'getting lots of images'
48    miny=-90
49    minx=-180
50    maxy=90
51    maxx=180
52    for i in range(8):
53        miny=miny+10
54        minx=minx+10
55        maxy=maxy -10
56        maxx=maxx-10
57        img=slab3.getImage((miny, minx, maxy, maxy) ,320, 320)
58        img.save("sequence%s.jpeg"%str(i), "JPEG")
59   
60   
61   
62   
63   
64def main():
65    test_layerMapper()
66   
67if __name__=="__main__":
68    main()
Note: See TracBrowser for help on using the repository browser.