Commit 9b8c95d7 authored by Caillat Michel's avatar Caillat Michel
Browse files

Added bins edges to determine the contours levels

parent 2acbfc42
......@@ -726,7 +726,7 @@ class DataBlock:
self.__logger.debug("getSlice: exiting")
return x
def getSlice(self, iFREQ, step=1):
self.__logger.debug("getSlice: entering")
result = dict()
......@@ -1066,32 +1066,30 @@ class DataBlock:
iRA0 = iRA0 if iRA0 else 0
iRA1 = iRA1 if iRA1 else (self.__data.shape[2] if numDims > 2 else self.__data.shape[1])
levels = None
quantiles = [0.99]
for key, value in kwargs.items():
if key == 'levels':
levels = value
elif key == 'quantiles':
quantiles = value
self.__logger.debug("levels = %r, quantiles = %r" % (levels, quantiles))
# Get the data to be contoured
slice = self.__getSlice(iFREQ)[iDEC0:iDEC1, iRA0:iRA1]
self.__logger.debug("slice shape %r", slice.shape)
#self.__logger.debug("%r,%r" % (da.min(slice[!da.isnan(slice)]).compute(), da.max(slice[!da.isnan(slice)]).compute()))
# Determine the contours levels.
if not levels:
levels = [np.quantile(slice[~da.isnan(slice)].compute(), quantiles[0])]
levels = None
quantiles = None
numberOfBins = None
for key, value in kwargs.items():
if key == 'levels':
levels = value
elif key == 'quantiles':
levels = [np.quantile(slice[~da.isnan(slice)].compute(), quantile) for quantile in value]
elif key == 'numberOfBins':
levels = np.histogram_bin_edges(slice[~da.isnan(slice)].compute(), value)
self.__logger.debug('levels %r' % levels)
self.__logger.debug("levels = %r" % (levels))
# Produce the contours.
features = []
fig, ax = pp.subplots()
CS = ax.contour(np.arange(slice.shape[1]), np.arange(slice.shape[0]), slice, levels)
features = []
for set in CS.allsegs:
for c in set :
feature = {"type":"LineString", "coordinates": [[round(x[0]), round(x[1])] for x in c.tolist()]}
......
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