@@ -114,6 +114,34 @@ def test_idf_oc_write_simple_model(fixed_format_parser):
114114 assert_almost_equal (results ["x_grid" ], np .array ([2.0 , 2.0 , 2.0 , 2.0 , 4.0 ]))
115115
116116
117+ def test_idf_oc_write_simple_model_clip (fixed_format_parser ):
118+ area , index , svat = grid ()
119+ nodata = - 9999.0
120+ x_min , x_max , y_min , y_max = 1.5 , 4.5 , 1.5 , 3.5
121+
122+ idf_output_control = IdfMapping (area , nodata )
123+ idf_output_control_clip = idf_output_control .clip_box (
124+ x_min = x_min , x_max = x_max , y_min = y_min , y_max = y_max
125+ )
126+
127+ svat_clip = svat .sel (x = slice (x_min , x_max ), y = slice (y_min , y_max ))
128+ index_clip = (svat_clip != 0 ).values .ravel ()
129+
130+ with tempfile .TemporaryDirectory () as output_dir :
131+ output_dir = Path (output_dir )
132+ idf_output_control_clip .write (output_dir , index_clip , svat_clip , None , None )
133+
134+ results = fixed_format_parser (
135+ output_dir / IdfMapping ._file_name , IdfMapping ._metadata_dict
136+ )
137+
138+ assert_equal (results ["svat" ], np .array ([2 , 4 , 5 ]))
139+ assert_equal (results ["rows" ], np .array ([2 , 1 , 1 ]))
140+ assert_equal (results ["columns" ], np .array ([1 , 1 , 3 ]))
141+ assert_almost_equal (results ["y_grid" ], np .array ([3.0 , 2.0 , 2.0 ]))
142+ assert_almost_equal (results ["x_grid" ], np .array ([2.0 , 2.0 , 4.0 ]))
143+
144+
117145def test_idf_oc_mapping_order (fixed_format_parser ):
118146 area , index , svat = grid ()
119147 nodata = - 9999.0
0 commit comments