Skip to content

Commit 443f0ac

Browse files
committed
Add 2 tests to test_sys_subset_data.py.
1 parent 580e0b8 commit 443f0ac

File tree

1 file changed

+72
-1
lines changed

1 file changed

+72
-1
lines changed

python/ctsm/test/test_sys_subset_data.py

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,75 @@ def test_subset_data_reg_amazon(self):
7979
cfg_file,
8080
"--overwrite",
8181
]
82-
subset_data.main()
82+
subset_data.main()
83+
84+
def test_subset_data_reg_infile_detect360(self):
85+
"""
86+
Test subset_data for region with ambiguous longitudes. We specify the longitude type for
87+
lon1 and lon2 but not for the input data files. This should still work as long as the input
88+
data file longitude type is detectable and matches --lon-type.
89+
"""
90+
sys.argv = [
91+
"subset_data",
92+
"region",
93+
"--lat1",
94+
"-12",
95+
"--lat2",
96+
"-7",
97+
"--lon1",
98+
"15",
99+
"--lon2",
100+
"23",
101+
"--lon-type",
102+
"360",
103+
"--reg",
104+
"TMP",
105+
"--create-mesh",
106+
"--create-domain",
107+
"--create-surface",
108+
"--surf-year",
109+
"2000",
110+
"--create-user-mods",
111+
"--outdir",
112+
self.temp_dir_out.name,
113+
"--user-mods-dir",
114+
self.temp_dir_umd.name,
115+
"--overwrite",
116+
]
117+
subset_data.main()
118+
119+
def test_subset_data_reg_infile_detect180_error(self):
120+
"""
121+
Specifying --lon-type 180 but an input file of type 360 should error
122+
"""
123+
sys.argv = [
124+
"subset_data",
125+
"region",
126+
"--lat1",
127+
"-12",
128+
"--lat2",
129+
"-7",
130+
"--lon1",
131+
"15",
132+
"--lon2",
133+
"23",
134+
"--lon-type",
135+
"180",
136+
"--reg",
137+
"TMP",
138+
"--create-mesh",
139+
"--create-domain",
140+
"--create-surface",
141+
"--surf-year",
142+
"2000",
143+
"--create-user-mods",
144+
"--outdir",
145+
self.temp_dir_out.name,
146+
"--user-mods-dir",
147+
self.temp_dir_umd.name,
148+
"--overwrite",
149+
]
150+
with self.assertRaisesRegex(
151+
RuntimeError, r"File lon type \(360\) doesn't match boundary lon type \(180\)"
152+
):
153+
subset_data.main()

0 commit comments

Comments
 (0)