Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-8889: Add detector z-offsets #416

Merged
merged 2 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion doc/lsst.obs.lsst/adding-a-camera.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ To add a new camera (e.g., ``fooCam``, made up of 9 CCDs in a single
default to 0.0 and the yaw entry is not generated. These offsets
are interpreted relative to the nominal positions given in cameraHeader.yaml
for each type of raft, as adjusted for the centre of the raft; these
values are therefore reasonable.
values are therefore reasonable. (Note that offsets here and elsewhere may
either be specified as 2-tuples, in which case the z-offset is inferred to be
0.0, or directly as 3-tuples with their z-offset explicit).

The yaw (rotation in the plane of the detector) is measured in degrees,
anticlockwise as shown in cameraGeomUtils.plotFocalPlane (i.e. with ``R00`` in
Expand Down
4 changes: 2 additions & 2 deletions policy/lsstCam/R00W.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ R00W :

geometryWithinRaft :
SW0 : {
offset : [2.5, 1.4375],
offset : [2.5, 1.4375, -1.5], # extrafocal
yaw : 0.0,
}
SW1 : {
offset : [2.5, 3.5625],
offset : [2.5, 3.5625, 1.5], # intrafocal
yaw : 180.0,
}

Expand Down
4 changes: 2 additions & 2 deletions policy/lsstCam/R04W.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ R04W :

geometryWithinRaft :
SW0 : {
offset : [2.5, 1.4375],
offset : [2.5, 1.4375, -1.5], # extrafocal
yaw : 0.0,
}
SW1 : {
offset : [2.5, 3.5625],
offset : [2.5, 3.5625, 1.5], # intrafocal
yaw : 180.0,
}

Expand Down
4 changes: 2 additions & 2 deletions policy/lsstCam/R40W.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ R40W :

geometryWithinRaft :
SW0 : {
offset : [2.5, 1.4375],
offset : [2.5, 1.4375, -1.5], # extrafocal
yaw : 0.0,
}
SW1 : {
offset : [2.5, 3.5625],
offset : [2.5, 3.5625, 1.5], # intrafocal
yaw : 180.0,
}

Expand Down
4 changes: 2 additions & 2 deletions policy/lsstCam/R44W.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ R44W :

geometryWithinRaft :
SW0 : {
offset : [2.5, 1.4375],
offset : [2.5, 1.4375, -1.5], # extrafocal
yaw : 0.0,
}
SW1 : {
offset : [2.5, 3.5625],
offset : [2.5, 3.5625, 1.5], # intrafocal
yaw : 180.0,
}

Expand Down
20 changes: 14 additions & 6 deletions python/lsst/obs/lsst/script/generateCamera.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,23 @@ def applyRaftYaw(offset, raftYaw):
Parameters
----------
offset : `list` of `float`
A list of the offsets to rotate: [x, y]
A list of the offsets to rotate: [x, y, z]
raftYaw : `float`
Raft yaw angle in degrees.

Returns
-------
offsets : `list` of `float
2-item sequence of floats containing the rotated offsets.
3-item sequence of floats containing the rotated offsets.
"""
if raftYaw == 0.:
return offset
new_offset = np.zeros(2, dtype=np.float)
new_offset = np.zeros(3, dtype=np.float)
sinTheta = np.sin(np.radians(raftYaw))
cosTheta = np.cos(np.radians(raftYaw))
new_offset[0] = cosTheta*offset[0] - sinTheta*offset[1]
new_offset[1] = sinTheta*offset[0] + cosTheta*offset[1]
new_offset[2] = offset[2]
return new_offset


Expand Down Expand Up @@ -232,6 +233,8 @@ def indent():
nindent += 1

raftOffset = perRaftData["offset"]
if len(raftOffset) == 2:
raftOffset.append(0.0) # Default offset_z is 0.0
id0 = perRaftData['id0']
try:
raftYaw = perRaftData['yaw']
Expand All @@ -242,9 +245,11 @@ def indent():
for ccdName, ccdLayout in ccds.items():
if ccdName in geometryWithinRaft:
doffset = geometryWithinRaft[ccdName]['offset']
if len(doffset) == 2:
doffset.append(0.0) # Default offset_z is 0.0
yaw = geometryWithinRaft[ccdName]['yaw'] + raftYaw
else:
doffset = (0.0, 0.0,)
doffset = (0.0, 0.0, 0.0)
yaw = None

print(indent(), "%s_%s : " % (raftNameMap.get(raftName, raftName), ccdName), file=fd)
Expand All @@ -256,10 +261,13 @@ def indent():
print(indent(), "serial : %s" % (raftCcdData['ccdSerials'][ccdName]), file=fd)
print(indent(), "physicalType : %s" % (detectorType), file=fd)
print(indent(), "refpos : %s" % (ccdLayout['refpos']), file=fd)
if len(ccdLayout['offset']) == 2:
ccdLayout['offset'].append(0.0) # Default offset_z is 0.0
ccdLayoutOffset = applyRaftYaw([el1+el2 for el1, el2 in zip(ccdLayout['offset'], doffset)],
raftYaw)
print(indent(), "offset : [%g, %g]" % (ccdLayoutOffset[0] + raftOffset[0],
ccdLayoutOffset[1] + raftOffset[1]),
print(indent(), "offset : [%g, %g, %g]" % (ccdLayoutOffset[0] + raftOffset[0],
ccdLayoutOffset[1] + raftOffset[1],
ccdLayoutOffset[2] + raftOffset[2]),
file=fd)
if yaw is not None:
print(indent(), "yaw : %g" % (yaw), file=fd)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_generateCamera.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ def testGenerateCamera(self):
self.assertEqual([x for x in content['CCDs'] if 'W_' in x], [])
self.assertEqual(content["name"], "LSSTCam")
self.assertEqual(content["plateScale"], 20.0)
# SW0 is extrafocal is negative-z in DVCS
self.assertEqual(content["CCDs"]["R04_SW0"]["offset"][2], -1.5)

def testFailures(self):
with self.assertRaises(RuntimeError):
Expand Down