Skip to content

Commit

Permalink
working version on archer2 for high resolution images
Browse files Browse the repository at this point in the history
  • Loading branch information
qixia committed Oct 17, 2024
1 parent 0f0fd09 commit 70c3362
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
18 changes: 17 additions & 1 deletion xbout/boutdataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,13 +394,29 @@ def y_interp_func(
data, poloidal_distance_in, poloidal_distance_out, method=None
):
interp_func = interp1d(
poloidal_distance_in, data, kind=method, assume_sorted=True
poloidal_distance_in, data, kind=method, assume_sorted=True, fill_value="extrapolate"
)
return interp_func(poloidal_distance_out)

# Need to give different name to output dimension to avoid clash
new_ycoord = ycoord + "_interpolate_to_new_grid_new_ycoord"
poloidal_distance = poloidal_distance.rename({ycoord: new_ycoord})
#poloidal_distance.values[:,-1] = da["poloidal_distance"][:,-1]*0.999
#print("data size:", da.shape)
#print("org_pol_dis size:", da["poloidal_distance"].shape)
#print("new_pol_dis size:", poloidal_distance.shape)
#SZxy = da["poloidal_distance"].shape
#for i in range(SZxy[0]):
# #if poloidal_distance[i,0] < da["poloidal_distance"][i,0] :
# # print('found x_new! x, ybndry=',i, poloidal_distance[i,0].values, da["poloidal_distance"][i,0].values)
# #if poloidal_distance[i,-1] > da["poloidal_distance"][i,-1]:
# # print('found x_new! x, ybndry=',i, poloidal_distance[i,-1].values, da["poloidal_distance"][i,-1].values)
# a = all(x < y for x,y in zip(da["poloidal_distance"][i,:], da["poloidal_distance"][i,1:]))
# if a == False:
# print('not monotonic increasing!, i_a=',i)
# b = all(x < y for x,y in zip(poloidal_distance[i,:], poloidal_distance[i,1:]))
# if b == False:
# print('not monotonic increasing!, i_b=',i)
result = xr.apply_ufunc(
y_interp_func,
da,
Expand Down
10 changes: 7 additions & 3 deletions xbout/plotting/plotfuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def plot2d_wrapper(
vmax=None,
aspect=None,
extend=None,
hide_colorbar=False,
**kwargs
):
"""
Expand Down Expand Up @@ -219,7 +220,8 @@ def plot2d_wrapper(
# re-make sm with new cmap
sm = plt.cm.ScalarMappable(norm=norm, cmap=cmap)
sm.set_array([])
fig.colorbar(sm, ticks=levels, ax=ax, extend=extend)
if hide_colorbar == False:
fig.colorbar(sm, ticks=levels, ax=ax, extend=extend)
elif method is xr.plot.contour:
# create colormap to be shared by all regions
norm = matplotlib.colors.Normalize(vmin=levels[0], vmax=levels[-1])
Expand All @@ -238,7 +240,8 @@ def plot2d_wrapper(
sm = plt.cm.ScalarMappable(norm=norm, cmap=cmap)
sm.set_array([])
cmap = sm.get_cmap()
fig.colorbar(sm, ax=ax, extend=extend)
if hide_colorbar == False:
fig.colorbar(sm, ax=ax, extend=extend)

if method is xr.plot.pcolormesh:
if "infer_intervals" not in kwargs:
Expand Down Expand Up @@ -274,7 +277,8 @@ def plot2d_wrapper(
]

if method is xr.plot.contour:
fig.colorbar(artists[0], ax=ax)
if hide_colorbar == False:
fig.colorbar(artists[0], ax=ax)

if gridlines is not None:
# convert gridlines to dict
Expand Down

0 comments on commit 70c3362

Please sign in to comment.