Commit 21d5fa36 authored by Caillat Michel's avatar Caillat Michel
Browse files

From now all measurements are defined a dict {'value':..., 'unit':...}

parent d9b11d70
......@@ -1138,13 +1138,13 @@ class DataBlock:
for level in levels:
slice_bw = np.zeros(shape, dtype=np.uint8)
slice_bw[slice >= level] = 127
contours, _ = cv2.findContours(slice_bw, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
contours, _ = cv2.findContours(slice_bw, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
for contour in contours :
pts = [x[0] for x in contour.tolist()]
#pts = [[x[0], shape[0] - x[1] -1] for x in pts]
feature = {"type":"LineString", \
"coordinates": pts,\
"properties": {"level" : level, "levelUnit" : self.__header["BUNIT"]}}
"properties": {"level" : {"value": level, "unit" : self.__header["BUNIT"]}}}
features.append(feature)
contours_geojson = { "type": "FeatureCollection", "features" : features }
......@@ -1173,14 +1173,14 @@ class DataBlock:
sumunit = "Jy"
else:
sumunit = bunit
result["sum"] = "%11.4g %s" % ((np.sum(accum) / self.__convert * self.__cdelt) , sumunit)
result["min"] = "%11.4g %s" % ((np.min(accum)) , bunit)
result["max"] = "%11.4g %s" % ((np.max(accum)) , bunit)
result["mean"] = "%11.4g %s" % ((np.mean(accum)), bunit)
result["stdev"] = "%11.4g %s" % ((np.std(accum)), bunit)
result["numpix"] = "%d pixels" % accum.shape[0]
result["percentage of total number of pixels"] = "%9.2g%%" % (accum.shape[0] / (shape[0]*shape[1]) * 100)
result["boundingRect"] = f"{bdr} (x, y, width and height in pixels)"
result["sum"] = {"value": np.sum(accum).item() / self.__convert * self.__cdelt , "unit" : sumunit}
result["min"] = {"value": np.min(accum).item() , "unit": bunit}
result["max"] = {"value": np.max(accum).item() , "unit": bunit}
result["mean"] = {"value": np.mean(accum).item() , "unit": bunit}
result["stdev"] = {"value": np.std(accum).item() , "unit": bunit}
result["numpix"] = {"value": accum.shape[0], "unit" : "pixels"}
result["percentage of total number of pixels"] = {"value": accum.shape[0] / (shape[0]*shape[1]) * 100, "unit": "%"}
result["boundingRect"] = {"value" :bdr, "unit" :"pixels"}
result = {"status":True, "message":"", "result":result}
......
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