From 70c33625f48002d954d2e879e89a7df60da53d8c Mon Sep 17 00:00:00 2001 From: qixia Date: Thu, 17 Oct 2024 13:30:40 +0100 Subject: [PATCH] working version on archer2 for high resolution images --- xbout/boutdataarray.py | 18 +++++++++++++++++- xbout/plotting/plotfuncs.py | 10 +++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/xbout/boutdataarray.py b/xbout/boutdataarray.py index cc09c3f1..99800c25 100644 --- a/xbout/boutdataarray.py +++ b/xbout/boutdataarray.py @@ -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, diff --git a/xbout/plotting/plotfuncs.py b/xbout/plotting/plotfuncs.py index 580c9399..90dc7156 100644 --- a/xbout/plotting/plotfuncs.py +++ b/xbout/plotting/plotfuncs.py @@ -92,6 +92,7 @@ def plot2d_wrapper( vmax=None, aspect=None, extend=None, + hide_colorbar=False, **kwargs ): """ @@ -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]) @@ -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: @@ -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