Debian Codegraph @

test/pytest_composite.py

raw symbols SCIP
1 ###############################################################################
2 # pytest_composite.py: composite min/max
3 # Author(s): [email protected]
4 # Copyright (c) 2016-2019 European Union (Joint Research Centre)
5 # License EUPLv1.2
6 #
7 # This file is part of jiplib
8 ###############################################################################
9
10 # History
11 # 2017/10/24 - Created by Pieter Kempeneers ([email protected])
12 # Change log
13
14
15 import argparse
16 import os
17 import jiplib as jl
18
19 parser=argparse.ArgumentParser()
20 parser.add_argument("-input","--input",help="Path of the raster dataset",dest="input",required=True,type=str)
21 args = parser.parse_args()
22
23 try:
24 jim0=jl.createJim(args.input)
25 stats0=jim0.getStats({'function':['min','max'], 'band':0})
26 stats5=jim0.getStats({'function':['min','max'], 'band':5})
27 stats10=jim0.getStats({'function':['min','max'], 'band':10})
28 jl0=jl.JimList([jim0.cropBand({'band':0}),jim0.cropBand({'band':5}),jim0.cropBand({'band':10})])
29 print("stack bands")
30 # jimstack=jl0.stackBand({'verbose':2})
31 jimstack=jl0.stackBand()
32 print("creating min composite")
33 jim1=jl0.composite({'crule':'minband'}).clearNoData()
34 print("get min statistics")
35 statmin=jim1.getStats({'function':['min']})
36 if statmin['min']>min(stats0['min'],stats5['min'],stats10['min']):
37 print("Failed: min",statmin['min'],stats0['min'],stats5['min'],stats10['min'])
38 throw()
39 print("creating statistics profile")
40 jimsp=jimstack.statProfile({'function':'min'})
41 if not jim1.isEqual(jimsp):
42 print("Failed: statProfile min")
43 throw()
44 print("creating max composite")
45 jim1=jl0.composite({'crule':'maxband'}).clearNoData()
46 jl0.close()
47 print("get max statistics")
48 statmax=jim1.getStats({'function':['max']})
49 if statmax['max']<max(stats0['min'],stats5['min'],stats10['min']):
50 print("Failed: max",statsc['max'],stats0['max'],stats5['max'],stats10['max'])
51 throw()
52 print("creating statistics profile")
53 jimsp=jimstack.statProfile({'function':'max'})
54 if not jim1.isEqual(jimsp):
55 print("Failed: statProfile max")
56 throw()
57 jl0.close()
58 jim1.close()
59 jimsp.close()
60 print("Success: composite min/max")
61 except:
62 print("Failed: composite min/max")