@@ -597,12 +597,12 @@ def interpolate_to_cartesian(
597597 n_toroidal = ds .sizes [zdim ]
598598
599599 # Create Cartesian grid to interpolate to
600- Xmin = ds ["X_cartesian" ].min ()
601- Xmax = ds ["X_cartesian" ].max ()
602- Ymin = ds ["Y_cartesian" ].min ()
603- Ymax = ds ["Y_cartesian" ].max ()
604- Zmin = ds ["Z_cartesian" ].min ()
605- Zmax = ds ["Z_cartesian" ].max ()
600+ Xmin = ds ["X_cartesian" ].min (). data [()]
601+ Xmax = ds ["X_cartesian" ].max (). data [()]
602+ Ymin = ds ["Y_cartesian" ].min (). data [()]
603+ Ymax = ds ["Y_cartesian" ].max (). data [()]
604+ Zmin = ds ["Z_cartesian" ].min (). data [()]
605+ Zmax = ds ["Z_cartesian" ].max (). data [()]
606606 newX_1d = xr .DataArray (np .linspace (Xmin , Xmax , nX ), dims = "X" )
607607 newX = newX_1d .expand_dims ({"Y" : nY , "Z" : nZ }, axis = [1 , 2 ])
608608 newY_1d = xr .DataArray (np .linspace (Ymin , Ymax , nY ), dims = "Y" )
@@ -614,9 +614,7 @@ def interpolate_to_cartesian(
614614 # Define newzeta in range 0->2*pi
615615 newzeta = np .where (newzeta < 0.0 , newzeta + 2.0 * np .pi , newzeta )
616616
617- from scipy .interpolate import (
618- RegularGridInterpolator ,
619- )
617+ from scipy .interpolate import RegularGridInterpolator
620618
621619 # Create Cylindrical coordinates for intermediate grid
622620 Rcyl_min = float_type (ds ["R" ].min ())
@@ -664,10 +662,7 @@ def interp_single_time(da):
664662 )
665663
666664 print (" do 3d interpolation" )
667- return interp (
668- (newR , newZ , newzeta ),
669- method = "linear" ,
670- )
665+ return interp ((newR , newZ , newzeta ), method = "linear" )
671666
672667 for name , da in ds .data_vars .items ():
673668 print (f"\n interpolating { name } " )
@@ -993,14 +988,7 @@ def to_restart(
993988 # Is this even possible without saving the guard cells?
994989 # Can they be recreated?
995990 restart_datasets , paths = _split_into_restarts (
996- self .data ,
997- variables ,
998- savepath ,
999- nxpe ,
1000- nype ,
1001- tind ,
1002- prefix ,
1003- overwrite ,
991+ self .data , variables , savepath , nxpe , nype , tind , prefix , overwrite
1004992 )
1005993
1006994 with ProgressBar ():
@@ -1357,6 +1345,17 @@ def is_list(variable):
13571345
13581346 return anim
13591347
1348+ def with_cherab_grid (self ):
1349+ """
1350+ Returns a new DataSet with a 'cherab_grid' attribute.
1351+
1352+ If called then the `cherab` package must be available.
1353+ """
1354+ # Import here so Cherab is required only if this method is called
1355+ from .cherab import grid
1356+
1357+ return grid .ds_with_cherab_grid (self .data )
1358+
13601359
13611360def _find_major_vars (data ):
13621361 """
0 commit comments