Commit c562b209 authored by Caillat Michel's avatar Caillat Michel
Browse files

Fixed a bug in the calculations of the cumulative distribution function. Nan...

Fixed a bug in the calculations of the cumulative distribution function. Nan values are not any more taken into account
parent a4c973e7
......@@ -714,7 +714,7 @@ class DataBlock:
aux = [0 for x in range(len(bins))]
for i in range (1, len(aux)):
aux[i] = aux[i-1]+population[i-1]
normfactor = reduce(lambda a,b : a*b, self.__data.shape);
normfactor = np.count_nonzero(~np.isnan(data)) #reduce(lambda a,b : a*b, self.__data.shape);
self.__statistics[key]["cumuldist"] = list(map(lambda x: x/normfactor, aux));
self.__logger.debug(self.__statistics[key]);
self.__logger.debug("__collectStatistics : exiting")
......@@ -1197,6 +1197,43 @@ class DataBlock:
self.__logger.debug("measureContour : exiting")
return result
def measureBox(self, iFREQ, iRA0=None, iRA1=None, iDEC0=None, iDEC1=None):
self.__logger.debug("measureBox: entering")
numDims = len(self.__data.shape)
iDEC0 = iDEC0 if iDEC0 else 0
iDEC1 = iDEC1 if iDEC1 else (self.__data.shape[1] if numDims > 2 else self.__data.shape[0])
iRA0 = iRA0 if iRA0 else 0
iRA1 = iRA1 if iRA1 else (self.__data.shape[2] if numDims > 2 else self.__data.shape[1])
box = self.__getSlice(iFREQ).compute()[iDEC0:iDEC1, iRA0:iRA1]
shape = self.__data.shape
result = {}
bunit = self.__header["BUNIT"]
if bunit == "Jy/beam" :
sumunit = "Jy"
bunit = "Jy/beam"
else:
sumunit = bunit
self.__logger.debug(iRA0);
self.__logger.debug(iRA1);
self.__logger.debug(iDEC0);
self.__logger.debug(iDEC1);
self.__logger.debug(shape)
self.__logger.debug(type(box))
result["sum"] = {"value": np.nansum(box).item() / self.__convert * self.__cdelt , "unit" : sumunit}
result["min"] = {"value": np.nanmin(box).item() , "unit": bunit}
result["max"] = {"value": np.nanmax(box).item() , "unit": bunit}
result["mean"] = {"value": np.nanmean(box).item() , "unit": bunit}
result["stdev"] = {"value": np.nanstd(box).item() , "unit": bunit}
result["numpix"] = {"value": np.count_nonzero(~np.isnan(box)), "unit" : "pixels (!=Nan)"}
result["percentage of total number of pixels"] = {"value": (box.shape[0]*box.shape[1]) / (self.__header["NAXIS1"]*self.__header["NAXIS2"]) * 100, "unit": "%"}
result = {"status":True, "message":"", "result":result}
self.__logger.debug("measureBox : exiting")
return result
#
# End of DataBlock class definition.
#
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