Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CCS
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marko Mecina
CCS
Commits
fb33fa35
Commit
fb33fa35
authored
1 year ago
by
Marko Mecina
Browse files
Options
Downloads
Patches
Plain Diff
update BadPixelMask class
parent
3e649951
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Ccs/calibrations_SMILE.py
+51
-1
51 additions, 1 deletion
Ccs/calibrations_SMILE.py
with
51 additions
and
1 deletion
Ccs/calibrations_SMILE.py
+
51
−
1
View file @
fb33fa35
...
...
@@ -716,7 +716,7 @@ def calibrate_ext(adu, signal, exception=False):
# return adu if not exception else None
class
BadPixelMask
:
class
_
BadPixelMask
2
:
"""
Convenience functions for handling the SMILE SXI bad pixel mask stored in MRAM
"""
...
...
@@ -724,6 +724,9 @@ class BadPixelMask:
NROWS
=
639
NCOLS
=
384
CCD2_MASK_ADDR
=
0x40654C00
CCD4_MASK_ADDR
=
0x4065CC00
@classmethod
def
from_bytes
(
cls
,
buffer
):
return
np
.
unpackbits
(
bytearray
(
buffer
)).
reshape
((
cls
.
NROWS
,
cls
.
NCOLS
))
...
...
@@ -743,6 +746,53 @@ class BadPixelMask:
return
np
.
zeros
((
cls
.
NROWS
,
cls
.
NCOLS
),
dtype
=
int
)
class
BadPixelMask
:
NROWS
=
639
NCOLS
=
384
CCD2_MASK_ADDR
=
0x40654C00
CCD4_MASK_ADDR
=
0x4065CC00
def
__init__
(
self
):
self
.
_bin_len
=
int
((
self
.
NROWS
*
self
.
NCOLS
)
/
8
)
self
.
_bin
=
bytes
(
self
.
_bin_len
)
@property
def
binary
(
self
):
return
self
.
_bin
@binary.setter
def
binary
(
self
,
data
:
bytes
):
assert
isinstance
(
data
,
bytes
)
assert
len
(
data
)
==
self
.
_bin_len
self
.
_bin
=
data
@property
def
array
(
self
):
return
np
.
unpackbits
(
bytearray
(
self
.
_bin
)).
reshape
((
self
.
NROWS
,
self
.
NCOLS
))
@array.setter
def
array
(
self
,
arr
:
np
.
ndarray
):
assert
isinstance
(
arr
,
np
.
ndarray
)
assert
arr
.
shape
==
(
self
.
NROWS
,
self
.
NCOLS
)
self
.
_bin
=
bytes
(
np
.
packbits
(
arr
))
def
mask_pixel
(
self
,
row
,
col
):
mask
=
self
.
array
mask
[
row
,
col
]
=
1
self
.
array
=
mask
def
unmask_pixel
(
self
,
row
,
col
):
mask
=
self
.
array
mask
[
row
,
col
]
=
0
self
.
array
=
mask
if
__name__
==
'
__main__
'
:
import
matplotlib.pyplot
as
plt
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment