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
727b04d5
Commit
727b04d5
authored
1 year ago
by
Marko Mecina
Browse files
Options
Downloads
Patches
Plain Diff
flip CCD4 nodes in merged view (ED and FT)
parent
37664e85
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Ccs/tools/dataprocessing/smile_raw_ce_converter.py
+27
-25
27 additions, 25 deletions
Ccs/tools/dataprocessing/smile_raw_ce_converter.py
with
27 additions
and
25 deletions
Ccs/tools/dataprocessing/smile_raw_ce_converter.py
+
27
−
25
View file @
727b04d5
#!/usr/bin/env python
#!/usr/bin/env python
3
"""
Convert unprocessed CE raw data to FITS files. Product type is determined (guessed) based on CE size.
...
...
@@ -12,8 +12,12 @@ import numpy as np
from
astropy.io
import
fits
# expected CE sizes in bytes
SIZE_FF
=
4511
*
4608
*
2
SIZE_FT
=
639
*
384
*
2
# 1 node
NROWS_FF
=
4511
NCOLS_FF
=
4608
NROWS_FT
=
639
NCOLS_FT
=
384
SIZE_FF
=
NROWS_FF
*
NCOLS_FF
*
2
SIZE_FT
=
NROWS_FT
*
NCOLS_FT
*
2
# 1 node
SIZE_ED
=
64
# 1 event
FILE_PREFIX
=
'
SMILE_SXI_L1
'
...
...
@@ -49,7 +53,7 @@ def convert_ce(cefile, fitsfile=None):
def
mk_ff
(
data
):
# create uint16 array from raw data and reshape
arr
=
np
.
frombuffer
(
data
,
dtype
=
'
>H
'
).
reshape
(
4511
,
-
1
)
arr
=
np
.
frombuffer
(
data
,
dtype
=
'
>H
'
).
reshape
(
NROWS_FF
,
NCOLS_FF
)
fnode
=
arr
[:,
::
2
]
enode
=
arr
[:,
1
::
2
][:,
::
-
1
]
ff
=
np
.
concatenate
((
fnode
,
enode
),
axis
=
1
)
...
...
@@ -62,23 +66,16 @@ def mk_ff(data):
def
mk_ft
(
data
):
arr
=
np
.
frombuffer
(
data
,
dtype
=
'
>H
'
).
reshape
(
-
1
,
639
,
384
)
arr
=
np
.
frombuffer
(
data
,
dtype
=
'
>H
'
).
reshape
(
-
1
,
NROWS_FT
,
NCOLS_FT
)
hdl
=
_mk_hdl
(
'
FT
'
)
for
n
in
range
(
arr
.
shape
[
0
]):
hdl
.
append
(
fits
.
ImageHDU
(
data
=
arr
[
n
,
:,
:],
name
=
'
FT_CCD_NODE_{}
'
.
format
(
n
)))
# arrange all nodes to full CCD
view
# arrange all nodes to full CCD
if
arr
.
shape
[
0
]
==
4
:
n00
=
arr
[
0
,
:,
:]
# CCD2 F-side
n01
=
arr
[
1
,
:,
::
-
1
]
# CCD2 E-side
n10
=
arr
[
2
,
::
-
1
,
:]
# CCD4 F-side
n11
=
arr
[
3
,
::
-
1
,
::
-
1
]
# CCD4 E-side
n0
=
np
.
concatenate
((
n00
,
n01
),
1
)
n1
=
np
.
concatenate
((
n10
,
n11
),
1
)
nn
=
np
.
concatenate
((
n0
,
n1
),
0
)
# [::-1, :]
nn
=
_assemble_ft_frames_to_fp_view
(
arr
)
hdl
.
append
(
fits
.
ImageHDU
(
data
=
nn
,
name
=
'
FULLCCD
'
))
...
...
@@ -87,14 +84,14 @@ def mk_ft(data):
def
mk_ed
(
data
):
# reshape into array of evt packets
arr
=
np
.
frombuffer
(
data
,
dtype
=
'
>H
'
).
reshape
(
-
1
,
3
2
)
arr
=
np
.
frombuffer
(
data
,
dtype
=
'
>H
'
).
reshape
(
-
1
,
SIZE_ED
//
2
)
hdl
=
_mk_hdl
(
'
FT
'
)
ts
=
int
(
hdl
[
'
PRIMARY
'
].
header
[
'
OBS_ID
'
])
bindata
=
np
.
array
([
_mk_bin_entry
(
evt
,
ts
)
for
evt
in
arr
],
dtype
=
ED_BIN_DTYPE
)
# also add an HDU with event map
nodes
=
np
.
zeros
((
2
,
2
,
639
,
384
))
nodes
=
np
.
zeros
((
2
,
2
,
NROWS_FT
,
NCOLS_FT
))
nodes
[:]
=
np
.
nan
for
_
,
_
,
ccd
,
col
,
row
,
node
,
fx
in
bindata
:
...
...
@@ -103,15 +100,7 @@ def mk_ed(data):
except
:
print
(
col
,
row
,
'
FAILED
'
)
n00
=
nodes
[
0
,
0
,
:,
:]
# CCD2 F-side
n01
=
nodes
[
0
,
1
,
:,
:][:,
::
-
1
]
# CCD2 E-side
n10
=
nodes
[
1
,
0
,
:,
:][::
-
1
,
:]
# CCD4 F-side
n11
=
nodes
[
1
,
1
,
:,
:][::
-
1
,
::
-
1
]
# CCD4 E-side
n0
=
np
.
concatenate
((
n00
,
n01
),
1
)
n1
=
np
.
concatenate
((
n10
,
n11
),
1
)
ed_img
=
np
.
concatenate
((
n0
,
n1
),
0
)
# [::-1, :]
ed_img
=
_assemble_ft_frames_to_fp_view
(
nodes
)
hdl
.
append
(
fits
.
ImageHDU
(
data
=
ed_img
,
name
=
'
EVTMAP
'
))
...
...
@@ -129,6 +118,19 @@ def _mk_bin_entry(data, timestamp):
return
timestamp
,
fc
,
ccdnr
,
col
,
row
,
node
,
evts
def
_assemble_ft_frames_to_fp_view
(
arr3d
):
n00
=
arr3d
[
0
,
:,
:]
# CCD2 F-side (lower left in FP view)
n01
=
arr3d
[
1
,
:,
::
-
1
]
# CCD2 E-side (lower right in FP view)
n10
=
arr3d
[
2
,
::
-
1
,
::
-
1
]
# CCD4 F-side (upper right in FP view)
n11
=
arr3d
[
3
,
::
-
1
,
:]
# CCD4 E-side (upper left in FP view)
n0
=
np
.
concatenate
((
n00
,
n01
),
axis
=
1
)
# CCD2
n1
=
np
.
concatenate
((
n11
,
n10
),
axis
=
1
)
# CCD4
return
np
.
concatenate
((
n0
,
n1
),
axis
=
0
)
def
_mk_hdl
(
dmode
):
hdl
=
fits
.
HDUList
()
phdu
=
fits
.
PrimaryHDU
()
...
...
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