source: cows/trunk/cows/service/imps/csmlbackend/csmltests/test_csmllayer.py @ 4351

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows/trunk/cows/service/imps/csmlbackend/csmltests/test_csmllayer.py@4351
Revision 4351, 2.5 KB checked in by domlowe, 12 years ago (diff)

various small changes to csml backend

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