Skip to content

Commit

Permalink
Update ultralite data (#504)
Browse files Browse the repository at this point in the history
* Initial commit, trying things to get ultralite data working

* Cleaned up application.yml, added script and required files to run
ultralite data

* Undo changes and remove prints

* Make unit tests pass

* Added use of RemoveLogs to make run even smaller
  • Loading branch information
dlcaballero16 authored Nov 26, 2024
1 parent 92a9766 commit c61cf12
Show file tree
Hide file tree
Showing 8 changed files with 698 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/snapred/backend/data/LocalDataService.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,8 +801,9 @@ def readDetectorState(self, runId: str) -> DetectorState:
detectorState = None
pvFile = self._readPVFile(runId)
wav_value = None
wav_key_1 = "entry/DASlogs/BL3:Chop:Gbl:WavelengthReq/value"
wav_key_2 = "entry/DASlogs/BL3:Chop:Skf1:WavelengthUserReq/value"
logsLocation = Config["constants.logsLocation"]
wav_key_1 = f"{logsLocation}/BL3:Chop:Gbl:WavelengthReq/value"
wav_key_2 = f"{logsLocation}/BL3:Chop:Skf1:WavelengthUserReq/value"

if wav_key_1 in pvFile:
wav_value = pvFile.get(wav_key_1)[0]
Expand All @@ -813,11 +814,11 @@ def readDetectorState(self, runId: str) -> DetectorState:

try:
detectorState = DetectorState(
arc=[pvFile.get("entry/DASlogs/det_arc1/value")[0], pvFile.get("entry/DASlogs/det_arc2/value")[0]],
arc=[pvFile.get(f"{logsLocation}/det_arc1/value")[0], pvFile.get(f"{logsLocation}/det_arc2/value")[0]],
wav=wav_value,
freq=pvFile.get("entry/DASlogs/BL3:Det:TH:BL:Frequency/value")[0],
guideStat=pvFile.get("entry/DASlogs/BL3:Mot:OpticsPos:Pos/value")[0],
lin=[pvFile.get("entry/DASlogs/det_lin1/value")[0], pvFile.get("entry/DASlogs/det_lin2/value")[0]],
freq=pvFile.get(f"{logsLocation}/BL3:Det:TH:BL:Frequency/value")[0],
guideStat=pvFile.get(f"{logsLocation}/BL3:Mot:OpticsPos:Pos/value")[0],
lin=[pvFile.get(f"{logsLocation}/det_lin1/value")[0], pvFile.get(f"{logsLocation}/det_lin2/value")[0]],
)
except (TypeError, KeyError) as e:
raise ValueError(f"Could not find all required logs in file '{self._constructPVFilePath(runId)}': {e}")
Expand Down
10 changes: 10 additions & 0 deletions src/snapred/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,23 @@ instrument:
# Here "{IPTS}" will be substituted with the IPTS-directory name for a specified <runNumber>
home: ${instrument.home}/{IPTS}/shared/SNAPRed

# Swap the commented out fields when using ultralite data
config: ${instrument.calibration.home}/SNAPInstPrm.json
native:
pixelResolution: 1179648
# pixelResolution: 72
definition:
file: ${module.root}/resources/SNAP_Definition.xml
# file: ${module.root}/resources/ultralite/CRACKLE_Definition.xml
lite:
pixelResolution: 18432
# pixelResolution: 18
definition:
file: ${module.root}/resources/SNAPLite_Definition.xml
# file: ${module.root}/resources/ultralite/CRACKLELite_Definition.xml
map:
file: ${instrument.calibration.home}/Powder/LiteGroupMap.hdf
# file: ${module.root}/resources/ultralite/CRACKLELiteDataMap.xml
startingRunNumber: 10000
minimumRunNumber: 46342
maxNumberOfRuns: 10
Expand Down Expand Up @@ -190,6 +196,10 @@ constants:
PeakIntensityFractionThreshold: 0.05
m2cm: 10000.0 # conversion factor for m^2 to cm^2
maskedPixelThreshold: 0.15
# Swap these when running with ultralite data
logsLocation: "entry/DASlogs"
# logsLocation: "/mantid_workspace_1/logs"


CrystallographicInfo:
crystalDMin: 0.4
Expand Down
21 changes: 21 additions & 0 deletions src/snapred/resources/ultralite/CRACKLEFocGroup_Column.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<detector-grouping idf-date="2018-05-01T00:00:01" instrument="CRACKLE">
<group ID="1">
<detids>0-11</detids>
</group>
<group ID="2">
<detids>12-23</detids>
</group>
<group ID="3">
<detids>24-35</detids>
</group>
<group ID="4">
<detids>36-47</detids>
</group>
<group ID="5">
<detids>48-59</detids>
</group>
<group ID="6">
<detids>60-71</detids>
</group>
</detector-grouping>
59 changes: 59 additions & 0 deletions src/snapred/resources/ultralite/CRACKLELiteDataMap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0"?>
<detector-grouping idf-date="2018-05-01T00:00:01" instrument="fakeSNAP">
<!-- EAST -->
<group ID="1">
<detids>0,1,2,3</detids>
</group>
<group ID="2">
<detids>4,5,6,7</detids>
</group>
<group ID="3">
<detids>8,9,10,11</detids>
</group>
<group ID="4">
<detids>12,13,14,15</detids>
</group>
<group ID="5">
<detids>16,17,18,19</detids>
</group>
<group ID="6">
<detids>20,21,22,23</detids>
</group>
<group ID="7">
<detids>24,25,26,27</detids>
</group>
<group ID="8">
<detids>28,29,30,31</detids>
</group>
<group ID="9">
<detids>32,33,34,35</detids>
</group>
<!-- EAST -->
<group ID="10">
<detids>36,37,38,39</detids>
</group>
<group ID="11">
<detids>40,41,42,43</detids>
</group>
<group ID="12">
<detids>44,45,46,47</detids>
</group>
<group ID="13">
<detids>48,49,50,51</detids>
</group>
<group ID="14">
<detids>52,53,54,55</detids>
</group>
<group ID="15">
<detids>56,57,58,59</detids>
</group>
<group ID="16">
<detids>60,61,62,63</detids>
</group>
<group ID="17">
<detids>64,65,66,67</detids>
</group>
<group ID="18">
<detids>68,69,70,71</detids>
</group>
</detector-grouping>
237 changes: 237 additions & 0 deletions src/snapred/resources/ultralite/CRACKLELite_Definition.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- For help on the notation used to specify an Instrument Definition File
see http://www.mantidproject.org/IDF -->
<instrument xmlns="http://www.mantidproject.org/IDF/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mantidproject.org/IDF/1.0 http://schema.mantidproject.org/IDF/1.0/IDFSchema.xsd"
name="CRACKLELite" valid-from="1970-01-01 00:00:00">
<!--
THIS IS A FAKE INSTRUMENT DEFINITION FOR TESTING ONLY
It is the Lite version of CRACKLE, grouping 2x2 pixel banks to single superpixel
-->
<!--DEFAULTS-->
<defaults>
<length unit="metre"/>
<angle unit="degree"/>
<reference-frame>
<along-beam axis="z"/>
<pointing-up axis="y"/>
<handedness val="right"/>
<theta-sign axis="x"/>
</reference-frame>
</defaults>

<!--SOURCE-->
<component type="source">
<location z="-15.0"/>
</component>
<type name="source" is="Source"/>

<!--SAMPLE-->
<component type="sample-position">
<location y="0.0" x="0.0" z="0.0"/>
</component>
<type name="sample-position" is="SamplePos"/>

<!--
the monitor was removed due to inconsistencies with
loading the instrument into a created sample workspace
-->

<!--DETECTORS-->

<component type="East">
<location >
<parameter name="roty">
<logfile id="det_arc2" eq="180.0+value"/>
</parameter>
<parameter name="r-position">
<logfile id="det_lin2" eq="0.5+value" />
</parameter>
<parameter name="t-position">
<logfile id="det_arc2" />
</parameter>
</location>
</component>
<component type="West">
<location >
<parameter name="roty">
<logfile id="det_arc1" eq="180.0+value"/>
</parameter>
<parameter name="r-position">
<logfile id="det_lin1" eq="0.5+value" />
</parameter>
<parameter name="t-position">
<logfile id="det_arc1" />
</parameter>
</location>
</component>

<type name="East">
<component type="Column1">
<location/>
</component>
<component type="Column2">
<location/>
</component>
<component type="Column3">
<location/>
</component>
</type>
<type name="West">
<component type="Column4">
<location/>
</component>
<component type="Column5">
<location/>
</component>
<component type="Column6">
<location/>
</component>
</type>

<type name="Column1">
<component type="pixel" idlist="0" >
<location name="bank13">
<trans x="-0.167548" y="+0.167548" />
</location>
</component>
<component type="pixel" idlist="1">
<location name="bank12">
<trans x="-0.167548" y="0" />
</location>
</component>
<component type="pixel" idlist="2">
<location name="bank11">
<trans x="-0.167548" y="-0.167548" />
</location>
</component>
</type>

<type name="Column2">
<component type="pixel" idlist="3">
<location name="bank23">
<trans x="0" y="+0.167548" />
</location>
</component>
<component type="pixel" idlist="4">
<location name="bank22">
<trans x="0" y="0" />
</location>
</component>
<component type="pixel" idlist="5">
<location name="bank21">
<trans x="0" y="-0.167548" />
</location>
</component>
</type>

<type name="Column3">
<component type="pixel" idlist="6">
<location name="bank33">
<trans x="+0.167548" y="+0.167548" />
</location>
</component>
<component type="pixel" idlist="7">
<location name="bank32">
<trans x="+0.167548" y="0" />
</location>
</component>
<component type="pixel" idlist="8">
<location name="bank31">
<trans x="+0.167548" y="-0.167548" />
</location>
</component>
</type>

<type name="Column4">
<component type="pixel" idlist="9">
<location name="bank63">
<trans x="-0.167548" y="+0.167548" />
</location>
</component>
<component type="pixel" idlist="10">
<location name="bank62">
<trans x="-0.167548" y="0" />
</location>
</component>
<component type="pixel" idlist="11">
<location name="bank61">
<trans x="-0.167548" y="-0.167548" />
</location>
</component>
</type>

<type name="Column5">
<component type="pixel" idlist="12">
<location name="bank53">
<trans x="0" y="+0.167548" />
</location>
</component>
<component type="pixel" idlist="13">
<location name="bank52">
<trans x="0" y="0" />
</location>
</component>
<component type="pixel" idlist="14">
<location name="bank51">
<trans x="0" y="-0.167548" />
</location>
</component>
</type>

<type name="Column6">
<component type="pixel" idlist="15">
<location name="bank43">
<trans x="+0.167548" y="+0.167548" />
</location>
</component>
<component type="pixel" idlist="16">
<location name="bank42">
<trans x="+0.167548" y="0" />
</location>
</component>
<component type="pixel" idlist="17">
<location name="bank41">
<trans x="+0.167548" y="-0.167548" />
</location>
</component>
</type>

<!-- Rectangular Detector Panel -->
<type name="panel" is="rectangular_detector" type="pixel"
xpixels="1" xstart="-0.001" xstep="+0.001"
ypixels="1" ystart="-0.078795" ystep="+0.079104" >
<properties/>
</type>

<idlist idname="0"><id val="0" /></idlist>
<idlist idname="1"><id val="1" /></idlist>
<idlist idname="2"><id val="2" /></idlist>
<idlist idname="3"><id val="3" /></idlist>
<idlist idname="4"><id val="4" /></idlist>
<idlist idname="5"><id val="5" /></idlist>
<idlist idname="6"><id val="6" /></idlist>
<idlist idname="7"><id val="7" /></idlist>
<idlist idname="8"><id val="8" /></idlist>
<idlist idname="9"><id val="9" /></idlist>
<idlist idname="10"><id val="10" /></idlist>
<idlist idname="11"><id val="11" /></idlist>
<idlist idname="12"><id val="12" /></idlist>
<idlist idname="13"><id val="13" /></idlist>
<idlist idname="14"><id val="14" /></idlist>
<idlist idname="15"><id val="15" /></idlist>
<idlist idname="16"><id val="16" /></idlist>
<idlist idname="17"><id val="17" /></idlist>

<!-- Pixel for Detectors-->
<type name="pixel" is="detector">
<cuboid id="pixel-shape">
<left-front-bottom-point y="-0.079104" x="-0.0005" z="0.0"/>
<left-front-top-point y="+0.079104" x="-0.0005" z="0.0"/>
<left-back-bottom-point y="-0.079104" x="-0.0005" z="0.0001"/>
<right-front-bottom-point y="-0.079104" x="+0.0005" z="0.0"/>
</cuboid>
<algebra val="pixel-shape"/>
</type>
</instrument>
Loading

0 comments on commit c61cf12

Please sign in to comment.