Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Caillat Michel
yafits
Commits
21d5fa36
Commit
21d5fa36
authored
Nov 29, 2019
by
Caillat Michel
Browse files
From now all measurements are defined a dict {'value':..., 'unit':...}
parent
d9b11d70
Changes
1
Hide whitespace changes
Inline
Side-by-side
yafitss/DataBlock.py
View file @
21d5fa36
...
...
@@ -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
,
"
levelU
nit"
:
self
.
__header
[
"BUNIT"
]}}
"properties"
:
{
"level"
:
{
"value"
:
level
,
"
u
nit"
:
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
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment