Skip to content

Commit

Permalink
Use .values to convert DataArray to scalar before storing in Region
Browse files Browse the repository at this point in the history
May help speed up copying.
  • Loading branch information
johnomotani committed Jan 20, 2023
1 parent 280a570 commit a39b729
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions xbout/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ def __init__(
ref_yind = ylower_ind
dx = ds["dx"].isel({self.ycoord: ref_yind})
dx_cumsum = dx.cumsum()
self.xinner = dx_cumsum[xinner_ind] - dx[xinner_ind]
self.xouter = dx_cumsum[xouter_ind - 1] + dx[xouter_ind - 1]
self.xinner = (dx_cumsum[xinner_ind] - dx[xinner_ind]).values
self.xouter = (dx_cumsum[xouter_ind - 1] + dx[xouter_ind - 1]).values

# dy is constant in the x-direction, so convert to a 1d array
# Define ref_xind so that we avoid using values from the corner cells, which
Expand All @@ -136,8 +136,8 @@ def __init__(
ref_xind = xinner_ind
dy = ds["dy"].isel(**{self.xcoord: ref_xind})
dy_cumsum = dy.cumsum()
self.ylower = dy_cumsum[ylower_ind] - dy[ylower_ind]
self.yupper = dy_cumsum[yupper_ind - 1]
self.ylower = (dy_cumsum[ylower_ind] - dy[ylower_ind]).values
self.yupper = (dy_cumsum[yupper_ind - 1]).values

def __repr__(self):
result = "<xbout.region.Region>\n"
Expand Down

0 comments on commit a39b729

Please sign in to comment.