Skip to content

Commit 9354fa9

Browse files
committed
Initial commit
1 parent 83f1fb8 commit 9354fa9

File tree

1 file changed

+51
-5
lines changed

1 file changed

+51
-5
lines changed

python/lsst/summit/extras/fastStarTrackerAnalysis.py

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import lsst.geom as geom
3535
from lsst.summit.utils.starTracker import (
3636
dayObsSeqNumFrameNumFromFilename,
37+
dayObsSeqNumFromFilename,
3738
fastCam,
3839
getRawDataDirForDayObs,
3940
isStreamingModeFile,
@@ -44,6 +45,7 @@
4445

4546
__all__ = (
4647
"getStreamingSequences",
48+
"getRegularSequences",
4749
"getFlux",
4850
"getBackgroundLevel",
4951
"countOverThresholdPixels",
@@ -115,6 +117,44 @@ def getStreamingSequences(dayObs):
115117

116118
return data
117119

120+
def getRegularSequences(dayObs):
121+
"""Get the regular sequences for a dayObs.
122+
123+
Note that this will need rewriting very soon once the way the data is
124+
organised on disk is changed.
125+
126+
Parameters
127+
----------
128+
dayObs : `int`
129+
The dayObs.
130+
131+
Returns
132+
-------
133+
sequences : `dict` [`int`, `list`]
134+
The streaming sequences in a dict, keyed by sequence number, with each
135+
value being a list of the files in that sequence.
136+
"""
137+
site = getSite()
138+
if site in ["rubin-devl", "staff-rsp"]:
139+
rootDataPath = "/sdf/data/rubin/offline/s3-backup/lfa/"
140+
elif site == "summit":
141+
rootDataPath = "/project"
142+
else:
143+
raise ValueError(f"Finding StarTracker data isn't supported at {site}")
144+
145+
dataDir = getRawDataDirForDayObs(rootDataPath, fastCam, dayObs)
146+
files = glob.glob(os.path.join(dataDir, "*.fits"))
147+
regularFiles = [f for f in files if not isStreamingModeFile(f)]
148+
print(f"Found {len(regularFiles)} regular files on dayObs {dayObs}")
149+
150+
data = {}
151+
for file in regularFiles:
152+
seqNum = int(file.split('/')[-1].split("_")[3].split('.')[0])
153+
data[seqNum] = file
154+
data = sorted(data.items())
155+
156+
return data
157+
118158

119159
def getFlux(cutout, backgroundLevel=0):
120160
"""Get the flux inside a cutout, subtracting the image-background.
@@ -281,7 +321,7 @@ def __getattribute__(self):
281321
return np.nan
282322

283323

284-
def findFastStarTrackerImageSources(filename, boxSize, attachCutouts=True):
324+
def findFastStarTrackerImageSources(filename, boxSize, attachCutouts=True, streaming=True):
285325
"""Analyze a single FastStarTracker image.
286326
287327
Parameters
@@ -293,6 +333,10 @@ def findFastStarTrackerImageSources(filename, boxSize, attachCutouts=True):
293333
attachCutouts : `bool`, optional
294334
Attach the cutouts to the ``Source`` objects? Useful for
295335
debug/plotting but adds memory usage.
336+
streaming : `bool`, optional
337+
True if these are streaming data
338+
False if they are regular data.
339+
296340
297341
Returns
298342
-------
@@ -307,9 +351,11 @@ def findFastStarTrackerImageSources(filename, boxSize, attachCutouts=True):
307351
footprintSet = detectObjectsInExp(exp)
308352
footprints = footprintSet.getFootprints()
309353
bgMean, bgStd = getBackgroundLevel(exp)
310-
311-
dayObs, seqNum, frameNum = dayObsSeqNumFrameNumFromFilename(filename)
312-
354+
if streaming:
355+
dayObs, seqNum, frameNum = dayObsSeqNumFrameNumFromFilename(filename)
356+
else:
357+
dayObs, seqNum = dayObsSeqNumFromFilename(filename)
358+
frameNum = 0
313359
sources = []
314360
if len(footprints) == 0:
315361
sources = [NanSource()]
@@ -498,7 +544,7 @@ def plotSourceMovement(results, sourceIndex=0, allowInconsistent=False):
498544

499545
allDayObs = set(s.dayObs for s in sources)
500546
allSeqNums = set(s.seqNum for s in sources)
501-
if len(allDayObs) > 1 or len(allSeqNums) > 1:
547+
if len(allDayObs) > 1:# or len(allSeqNums) > 1:
502548
raise ValueError(
503549
"The sources are from multiple days or sequences, found"
504550
f" {allDayObs} dayObs and {allSeqNums} seqNum values."

0 commit comments

Comments
 (0)