Commit 4b3db8d8 authored by Moreau Nicolas's avatar Moreau Nicolas
Browse files

Fixes a problem on image generated with mathplotlib : pixel representation was...

Fixes a problem on image generated with mathplotlib : pixel representation was not 1:1 with provided pixel array
parent 57da6f04
......@@ -631,6 +631,9 @@ class DataBlock:
self.__logger.debug("__convertOneSlice2PNG: entering")
self.__logger.debug(f"sliceData is a {type(sliceData)}")
self.__logger.debug("### SLICE data : ")
self.__logger.debug(str(sliceData.shape[0])+ " " +str(sliceData.shape[1]))
palette = DataBlock.getPaletteFromName(palette_name)
N = len(palette)
p_low = None
......@@ -681,14 +684,14 @@ class DataBlock:
if video_mode_name == "direct":
palette = palette_name
elif video_mode_name == "inverse":
palette = palette + "_r"
palette = palette_name + "_r"
else:
raise Exception("Unknown video mode name {}".format(video_mode_name))
if vmin is not None and vmax is not None:
plt.imshow(img_i, cmap=palette, vmin=vmin, vmax=vmax)
plt.imshow(img_i, cmap=palette, aspect="equal", interpolation="none", vmin=vmin, vmax=vmax)
else :
plt.imshow(img_i, cmap=palette)
plt.imshow(img_i, aspect="equal", interpolation="none", cmap=palette)
if os.path.isfile(PNGPath):
os.remove(PNGPath)
......@@ -698,7 +701,7 @@ class DataBlock:
if os.path.isfile(legend_path):
os.remove(legend_path)
plt.savefig(PNGPath, format="png", bbox_inches="tight", pad_inches=0)
plt.imsave(fname=PNGPath, arr=img_i, cmap=palette, format='png')
mpb = plt.pcolormesh(img_i,cmap=palette, vmin=vmin, vmax=vmax)
# draw a new figure and replot the colorbar there
......@@ -769,8 +772,8 @@ class DataBlock:
#"SIMPLE = T "+
#"\n BITPIX = "+str(headerInfos["BITPIX"])+
#"\n NAXIS = 2 "+
#"\n NAXIS1 = "+str(naxis1)+
#"\n NAXIS2 = "+str(naxis2)+
"\n NAXIS1 = "+str(144)+
"\n NAXIS2 = "+str(144)+
"\n CRPIX1 = "+str(headerInfos["CRPIX1"])+
"\n CRPIX2 = "+str(headerInfos["CRPIX2"])+
"\n EQUINOX = 2000.0" +
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment