@@ -226,3 +226,27 @@ def test_cross_section(gridpath, datasetpath):
226226 _ = uxds ['RELHUM' ].cross_section (start = (45 , 45 ))
227227 _ = uxds ['RELHUM' ].cross_section (lon = 45 , end = (45 , 45 ))
228228 _ = uxds ['RELHUM' ].cross_section ()
229+
230+
231+ def test_cross_section_cumulative_integrate (gridpath , datasetpath ):
232+ uxds = ux .open_dataset (gridpath ("scrip" , "ne30pg2" , "grid.nc" ), datasetpath ("scrip" , "ne30pg2" , "data.nc" ))
233+ cs = uxds ['RELHUM' ].cross_section (start = (- 45 , - 45 ), end = (45 , 45 ), steps = 6 )
234+ cs = cs .assign_coords (distance = ("steps" , np .linspace (0.0 , 1.0 , cs .sizes ["steps" ])))
235+
236+ cs_ux = ux .UxDataArray (cs , uxgrid = uxds .uxgrid )
237+
238+ result = cs_ux .cumulative_integrate (coord = "distance" )
239+ expected = cs .cumulative_integrate (coord = "distance" )
240+
241+ assert isinstance (result , ux .UxDataArray )
242+ assert result .uxgrid == cs_ux .uxgrid
243+ xr .testing .assert_allclose (result .to_xarray (), expected )
244+
245+
246+ def test_cumulative_integrate_requires_coord (gridpath , datasetpath ):
247+ uxds = ux .open_dataset (gridpath ("scrip" , "ne30pg2" , "grid.nc" ), datasetpath ("scrip" , "ne30pg2" , "data.nc" ))
248+ cs = uxds ['RELHUM' ].cross_section (start = (- 45 , - 45 ), end = (45 , 45 ), steps = 3 )
249+ cs_ux = ux .UxDataArray (cs , uxgrid = uxds .uxgrid )
250+
251+ with pytest .raises (ValueError , match = "Coordinate .* must be specified" ):
252+ cs_ux .cumulative_integrate ()
0 commit comments