File: Maskregion.py.test.in

package info (click to toggle)
cdo 2.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 49,836 kB
  • sloc: cpp: 185,271; ansic: 95,766; sh: 7,192; f90: 6,147; makefile: 1,977; ruby: 1,078; csh: 1,028; python: 995; fortran: 319; pascal: 219; perl: 9
file content (88 lines) | stat: -rw-r--r-- 2,350 bytes parent folder | download | duplicates (4)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#! @PYTHON@

from cdoTest import *

FORMAT="-f srv -b 32"

IFILE=DATAPATH + "/bathy4.grb"

test_module=TestModule()

OPERATOR="maskregion"
GRIDTYPES=["regular", "curvilinear", "unstructured"]

f=open("mregion0", "w")
f.write("-180 -90\n")
f.write("180 -90\n")
f.write("180 90\n")
f.write("-180 90\n")
f.close()

f=open("mregion1", "w")
f.write("-31 -9\n")
f.write("51 -9\n")
f.write("51 41\n")
f.write("-31 41\n")
f.close()

f=open("mregion2", "w")
f.write("140 -9\n")
f.write("220 -9\n")
f.write("220 41\n")
f.write("140 41\n")
f.close()

for GRIDTYPE in GRIDTYPES:
    SETGRID=f'-setgridtype,{GRIDTYPE}' if (GRIDTYPE != "regular") else ""
    for INDEX in [0, 1, 2]:
        RFILE=f'{DATAPATH}/{OPERATOR}_r{INDEX}_ref'
        OFILE=f'{OPERATOR}_{GRIDTYPE[0]}{INDEX}_res'

        t=TAPTest(f'{OPERATOR} {GRIDTYPE} region{INDEX}')
        command=f'{CDO} {FORMAT} {OPERATOR},mregion{INDEX} {SETGRID} {IFILE} {OFILE}'
        t.add(command)
        t.add(f'{CDO} diff {OFILE} {RFILE}')
        t.clean(OFILE)
        test_module.add(t)

t.clean("mregion0","mregion1","mregion2")


OPERATOR="masklonlatbox"
GRIDTYPES=["regular", "curvilinear", "unstructured"]

LONLATBOX=["-180,180,-90,90", "-31,51,-9,41", "140,220,-9,41"]

for GRIDTYPE in GRIDTYPES:
    SETGRID=f'-setgridtype,{GRIDTYPE}' if (GRIDTYPE != "regular") else ""
    for INDEX in [0, 1, 2]:
        RFILE=f'{DATAPATH}/{OPERATOR}_r{INDEX}_ref'
        OFILE=f'{OPERATOR}_{GRIDTYPE[0]}{INDEX}_res'

        t=TAPTest(f'{OPERATOR} {GRIDTYPE} lonlatbox{INDEX}')
        command=f'{CDO} {FORMAT} {OPERATOR},{LONLATBOX[INDEX]} {SETGRID} {IFILE} {OFILE}'
        t.add(command)
        t.add(f'{CDO} diff {OFILE} {RFILE}')
        t.clean(OFILE)
        test_module.add(t)


OPERATOR="maskindexbox"
GRIDTYPES=["regular", "curvilinear"]

INDEXBOX=["1,90,1,45", "38,58,21,33"]

for GRIDTYPE in GRIDTYPES:
    SETGRID=f'-setgridtype,{GRIDTYPE}' if (GRIDTYPE != "regular") else ""
    for INDEX in [0, 1]:
        RFILE=f'{DATAPATH}/{OPERATOR}_r{INDEX}_ref'
        OFILE=f'{OPERATOR}_{GRIDTYPE[0]}{INDEX}_res'

        t=TAPTest(f'{OPERATOR} {GRIDTYPE} indexbox{INDEX}')
        command=f'{CDO} {FORMAT} {OPERATOR},{INDEXBOX[INDEX]} {SETGRID} {IFILE} {OFILE}'
        t.add(command)
        t.add(f'{CDO} diff {OFILE} {RFILE}')
        t.clean(OFILE)
        test_module.add(t)

test_module.run()