Closed bregeon closed 2 years ago
Simple alignment constants are easily retrieved through the batoid interface:
> rotated_telescope['L1'].coordSys.origin
(array([0. , 0. , 3.39747259]),
> rotated_telescope['L1'].coordSys.rot
array([[ 0.9998477 , 0. , 0.01745241],
[ 0. , 1. , 0. ],
[-0.01745241, 0. , 0.9998477 ]]))
I have defined a kind of GEOM_DICT
, similar to the BEAM_CONFIG
dict:
GEOM_DICT = {'L1': {'shift': [0.001, 0.001, 0.001], 'rotations': [0.1, 0.1, 0.1]},
'L2': {'shift': [0.001, 0.001, 0.001], 'rotations': [0.1, 0.1, 0.1]},
'L3': {'shift': [0.001, 0.001, 0.001], 'rotations': [0.1, 0.1, 0.1]}}
where the shift
vector is just the shifts along x, y and z.
and the rotations
vector contains the Euler rotation angles, around x, y, z.
The idea would then be to have a set of geometry configurations that could be stored in a separate pandas.DataFrame
.
Beam configurations should also be numbered and stored in another separate pandas.DataFrame
.
The spots data data frame would then only report a column for the beam config number and one for the geom config number.
Need to add an id:
GEOM_CONFIG_0 = {'geom_id': 0,
'L1': {'shift': [0.0, 0.0, 0.0], 'rotations': [0., 0., 0.]},
'L2': {'shift': [0.0, 0.0, 0.0], 'rotations': [0., 0., 0.]},
'L3': {'shift': [0.0, 0.0, 0.0], 'rotations': [0., 0., 0.]},
'Filter': {'shift': [0.0, 0.0, 0.0], 'rotations': [0., 0., 0.]},
'Detector': {'shift': [0.0, 0.0, 0.0], 'rotations': [0., 0., 0.]}}
gd0 = pd.DataFrame(data=GEOM_CONFIG_0)
geom_id | L1 | L2 | L3 | Filter | Detector |
---|---|---|---|---|---|
0 | [0.0, 0.0, 0.0] | [0.0, 0.0, 0.0] | [0.0, 0.0, 0.0] | [0.0, 0.0, 0.0] | [0.0, 0.0, 0.0] |
0 | [0.0, 0.0, 0.0] | [0.0, 0.0, 0.0] | [0.0, 0.0, 0.0] | [0.0, 0.0, 0.0] | [0.0, 0.0, 0.0] |
gc = pd.concat([gd0, gd, gd2])
gc.sort_values('geom_id')
geom_id | L1 | L2 | L3 | Filter | Detector |
---|---|---|---|---|---|
0 | [0.0, 0.0, 0.0] | [0.0, 0.0, 0.0] | [0.0, 0.0, 0.0] | [0.0, 0.0, 0.0] | [0.0, 0.0, 0.0] |
0 | [0.0, 0.0, 0.0] | [0.0, 0.0, 0.0] | [0.0, 0.0, 0.0] | [0.0, 0.0, 0.0] | [0.0, 0.0, 0.0] |
1 | NaN | [0.1, 0.0, 0.0] | NaN | NaN | NaN |
100 | [0.001, 0.001, 0.001] | [0.001, 0.001, 0.001] | [0.001, 0.001, 0.001] | NaN | NaN |
100 | [0.1, 0.1, 0.1] | [0.1, 0.1, 0.1] | [0.1, 0.1, 0.1] | NaN | NaN |
newf=gc[gc['geom_id']==100]
geom_id | L1 | L2 | L3 | Filter | Detector |
---|---|---|---|---|---|
100 | [0.001, 0.001, 0.001] | [0.001, 0.001, 0.001] | [0.001, 0.001, 0.001] | NaN | NaN |
100 | [0.1, 0.1, 0.1] | [0.1, 0.1, 0.1] | [0.1, 0.1, 0.1] | NaN | NaN |
# get shifts dict way
> gc[gc['geom_id']==100]['L1']['shift']
[0.001, 0.001, 0.001]
To dictionnary:
> h=newf.to_dict()
{'geom_id': {'shift': 100, 'rotations': 100},
'L1': {'shift': [0.001, 0.001, 0.001], 'rotations': [0.1, 0.1, 0.1]},
'L2': {'shift': [0.001, 0.001, 0.001], 'rotations': [0.1, 0.1, 0.1]},
'L3': {'shift': [0.001, 0.001, 0.001], 'rotations': [0.1, 0.1, 0.1]},
'Filter': {'shift': nan, 'rotations': nan},
'Detector': {'shift': nan, 'rotations': nan}}
Fixing the geom_id
:
h['geom_id']=h['geom_id']['shift']
{'geom_id': 100,
'L1': {'shift': [0.001, 0.001, 0.001], 'rotations': [0.1, 0.1, 0.1]},
'L2': {'shift': [0.001, 0.001, 0.001], 'rotations': [0.1, 0.1, 0.1]},
'L3': {'shift': [0.001, 0.001, 0.001], 'rotations': [0.1, 0.1, 0.1]},
'Filter': {'shift': nan, 'rotations': nan},
'Detector': {'shift': nan, 'rotations': nan}}
a
batoid
telescope is a batoid object defined as a CompoundOptic, that is basically accessible as dictionaries and lists of parameters:when simulating a given telescope geometry, how should I store that information and how do I get simple set of "alignment" constants from that?