Debian Codegraph @

test/pytest_open.py

raw symbols SCIP
1 ###############################################################################
2 # pytest_open.py: open raster dataset and calculate basic statistics
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/23 - Created by Pieter Kempeneers ([email protected])
12 # Change log
13
14 # Test1: simple open and close
15 # Open an existing JP2 raster dataset
16 # get maximum pixel value in raster dataset
17 # close raster dataset
18
19 import argparse
20 import jiplib as jl
21
22 parser=argparse.ArgumentParser()
23 parser.add_argument("-input","--input",help="Path of the input file",dest="input",required=True,type=str)
24 args = parser.parse_args()
25
26 jim0=jl.createJim(args.input)
27 # Get basic statistics of the raster datasets
28 theStats=jim0.getStats({'function':['min','max','mean']})
29 if max(theStats['min'])!=0:
30 print("Failed: getMin()")
31 elif min(theStats['max'])!=73:
32 print("Failed: getMax()")
33 elif theStats['mean'][0]<16.9 or theStats['mean'][0]>17:
34 print("Failed: getMean()")
35 else:
36 print("Success: open raster dataset and calculate basic statistics")
37 jim0.close()