gcp

The GCP package contains tools for interacting with the telescope control system (GCP). This includes both offline tools for processing data products from the GCP (ARCFileReader) and associated container classes (ACUStatus, TrackerStatus), as well as online tools designed for coordination of data taking with the control system (the various data tees and signalling modules).

API Documentation

Frame Objects

Serializable objects that may be stored as entries in G3Frame objects.

class spt3g.gcp.ACUStatus(arg: ACUStatus)
class spt3g.gcp.ACUStatus()

Bases: G3FrameObject

ACU Status information, as reported by the ACU

Signature 1: Copy constructor

Description() str

Long-form human-readable description of the object

Summary() str

Short (one-line) description of the object

property acu_status: int
property az_pos: float
property az_rate: float
property el_pos: float
property el_rate: float
property px_checksum_error_count: int
property px_resync_count: int
property px_resync_timeout_count: int
property px_resyncing: bool
property px_timeout_count: int
property restart_count: int
property state: ACUState
property time: G3Time
class spt3g.gcp.ACUStatusVector()
class spt3g.gcp.ACUStatusVector(arg: ACUStatusVector)
class spt3g.gcp.ACUStatusVector(arg: Iterable)

Bases: _ACUStatusBaseVector, G3FrameObject

Array of ACUStatus objects, usually time-ordered

Signature 2: Copy constructor

append(x: ACUStatus)

Add an item to the end of the list

clear()

Clear the contents

count(x: ACUStatus) int

Return the number of times x appears in the list

extend(L: ACUStatusVector)
extend(L: Iterable) None

Signature 1: Extend the list by appending all the items in the given list

Signature 2: Extend the list by appending all the items in the given list

insert(i: int, x: ACUStatus)

Insert an item at a given position.

pop() ACUStatus
pop(i: int) ACUStatus

Signature 1: Remove and return the last item

Signature 2: Remove and return the item at index i

remove(x: ACUStatus)

Remove the first item from the list whose value is x. It is an error if there is no such item.

class spt3g.gcp.TrackerPointing(arg: TrackerPointing)
class spt3g.gcp.TrackerPointing()

Bases: G3FrameObject

GCP Tracker Pointing

Signature 1: Copy constructor

Description() str

Long-form human-readable description of the object

Summary() str

Short (one-line) description of the object

property encoder_off_x: DoubleVector
property encoder_off_y: DoubleVector
property features: IntVector
property horiz_mount_x: DoubleVector
property horiz_mount_y: DoubleVector
property horiz_off_x: DoubleVector
property horiz_off_y: DoubleVector
property linsens_avg_l1: DoubleVector
property linsens_avg_l2: DoubleVector
property linsens_avg_r1: DoubleVector
property linsens_avg_r2: DoubleVector
property refraction: DoubleVector
property scu_temp: DoubleVector
property telescope_pressure: DoubleVector
property telescope_temp: DoubleVector
property tilts_x: DoubleVector
property tilts_y: DoubleVector
property time: G3TimeVector
class spt3g.gcp.TrackerStatus(arg: TrackerStatus)
class spt3g.gcp.TrackerStatus()

Bases: G3FrameObject

GCP Tracker Status

Signature 1: Copy constructor

Description() str

Long-form human-readable description of the object

Summary() str

Short (one-line) description of the object

property acu_seq: IntVector
property az_command: DoubleVector
property az_pos: DoubleVector
property az_rate: DoubleVector
property az_rate_command: DoubleVector
property el_command: DoubleVector
property el_pos: DoubleVector
property el_rate: DoubleVector
property el_rate_command: DoubleVector
property in_control: BoolVector
property scan_flag: BoolVector
property state: TrackerStateVector
property time: G3TimeVector

Class-like Pipeline Modules

Classes that can be added to G3Pipeline instances, either written as callable objects in Python (see Callable Objects as Functions) or as G3Module-derived classes in C++ (see Writing a module in C++). Aside from adding these into pipelines using the standard Add() method, such objects may also be instantiated outside of pipelines to make use of additional features.

One typical use case is to extract some kind of data from a series of frames:

class ExtractData:
    def __init__(self, key="RawTimestreams"):
        self.key = key
        self.data = []
    def __call__(self, frame):
        if self.key in frame:
            self.data.append(frame[self.key])

# instantiate caching class
extractor = ExtractData()

# use instance in a pipeline
pipe = core.G3Pipeline()
pipe.Add(core.G3Reader, filename="file.g3")
pipe.Add(extractor)
pipe.Run()

# use extracted data in later processing
print(extractor.data)

Another use case may be to call additional methods of a class. For example, the G3Writer class can be used as a context manager, and also report the position of the file pointer after each frame is written:

with core.G3Writer("file.g3") as writer:
    for frame in frames:
        writer(frame)
        print("Bytes written:", writer.tell())

Class-like modules permit a variety of additional features beyond their standard usage in pipelines.

class spt3g.gcp.ARCExtractor.CalibrateFrame(calibration_file=None)[source]

Apply gain / offset / units from G3 cal file

class spt3g.gcp.ARCFileReader(
filename: str,
experiment: Experiment = spt3g.gcp.Experiment.SPT,
timeout: float = -1.0,
track_filename: bool = False,
buffersize: int = 1048576,
)
class spt3g.gcp.ARCFileReader(
filename: StringVector,
experiment: Experiment = spt3g.gcp.Experiment.SPT,
timeout: float = -1.0,
track_filename: bool = False,
buffersize: int = 1048576,
)

Bases: G3Module

Read GCP archive file (or files if you pass an iterable of paths). For non-SPT ARC file formats, please set Experiment to the appropriate value. Set track_filename to True to record the filename for each frame in the ._filename attribute (fragile).

class spt3g.gcp.ARCHKExtractor.UnpackSPTpolHKData[source]

Extracts SPTpol housekeeping information from ARC files

class spt3g.gcp.GCPDataTee.DAQWatchdog(calibrator=False, interval=600, sim=False)[source]

Bases: PagerWatchdog

Watchdog that issues a ping to the GCP pager when the DAQ is operational.

Parameters:

calibrator (bool) – If True, ensure that the calibrator is also running successfully before sending a ping.

data_valid(frame)[source]

Check the incoming frame for completeness.

  • Ensure that all modules in the listed iceboards are reporting.

  • If calibrator is True, ensure that the calibrator sync signal is in the frame.

class spt3g.gcp.GCPDataTee.GCPBoloDataTee(port=50020, verbose=False, bolometers=[])[source]

Module that serves bolometer data to GCP when asked. Once a second, will serve the data from the previous second of bolometer data.

If a boolean key appears in the timepoint frames named “DataOK”, this will be sent to GCP as a data quality indicator for paging.

Send data from the given list of bolometer logical IDs to the GCP.

static PackForGCP(data)[source]
class spt3g.gcp.GCPDataTee.GCPHousekeepingTee(port=50010, verbose=False)[source]

Module that serves housekeeping information to GCP when asked. If a key named “DataOK” exists in the housekeeping frames, will also transmit that information to GCP for paging purposes.

static PackHKToGCP(hk, dataok=True, verbose=False)[source]
class spt3g.gcp.GCPDataTee.GCPSignalledHousekeeping(port=50011, collect_on_start=True)[source]

Module that collects housekeeping data when connected to. If collect_on_start is True (the default), injects an HK frame unconditionally at startup.

class spt3g.gcp.GCPDataTee.PagerWatchdog(name, interval=600, sim=False)[source]

Module that sends a watchdog (ping) message to the GCP pager when the parent process is running successfully. Modify the data_valid method for particular use cases, and call the run method periodically in your application.

data_valid(*args, **kwargs)[source]

Returns True if the watchdog should ping, otherwise False. Arguments are passed to this method from the run method.

page(msg)[source]

Issue a page to the GCP pager process. Called by the user for immediate notification of errors.

ping()[source]

Send a watchdog ping message to the GCP pager process. This method is called by the run method at regular intervals whenever the data_valid method returns True.

run(*args, **kwargs)[source]

When called, issues a watchdog ping message if the interval time has passed, and the data_valid method returns True. All input arguments are passed to the data_valid method for validation.

send(cmd)[source]

Send a command to the GCP pager process, and return the response.

host = 'sptnet.spt'
port = 50040
timeout = 20
class spt3g.gcp.GCPMuxDataDecoder()

Bases: G3Module

Extracts contents of receiver registers in SPTpol-style ARC files into a wiring map and timepoint frames. This is designed to convert SPTpol-style data in which GCP records bolometer data into the ARC files into a format equivalent to that for SPT-3G.

For old (100d SPTpol) data not containing wiring information, insert a wiring map into the pipeline ahead of this module. The board_serial should be set to a real (positive) value for all bolometer channels and -1 for the calibrator sync readout.

Function-like Pipeline Modules

Python functions that can be added to G3Pipeline instances. Such functions may also be called directly with a G3Frame object as the first argument, and do not necessarily need to be used in a pipeline. See Python Modules as Functions for more detail.

spt3g.gcp.ARCExtractor.AddBenchData(f)[source]

Add the optical bench positions to the frame.

spt3g.gcp.ARCExtractor.DecryptFeatureBit(f)[source]

Unpacks the GCP feature flags

spt3g.gcp.ARCExtractor.UnpackACUData(f)[source]

Extracts ACU status information to ACUStatus key in frame

spt3g.gcp.ARCExtractor.UnpackCryoData(f)[source]

Extracts cryo information into CryoStatus key

spt3g.gcp.ARCExtractor.UnpackMuxData(f)[source]

Add the DFMux data to the frame.

spt3g.gcp.ARCExtractor.UnpackPTData(f)[source]

Extracts pulse tube status information to PTStatus key in frame

spt3g.gcp.ARCExtractor.UnpackTrackerData(f, rewrite_source_from_feature_bits=True)[source]

Extracts tracker status information to frame into the TrackerStatus key, along with the observation processing handled by UnpackTrackerMinimal.

If rewrite_source_from_feature_bits is True (the default), will try to rewrite source names if DecryptFeatureBit() has been run and either “elnod”, “calibrator”, or “noise” is present in the feature bit list to that value.

spt3g.gcp.ARCExtractor.UnpackTrackerMinimal(f, rewrite_source_from_feature_bits=True)[source]

Construct SourceName and ObservationId keys from frame.

If rewrite_source_from_feature_bits is True (the default), will try to rewrite source names if DecryptFeatureBit() has been run and either “elnod”, “calibrator”, or “noise” is present in the feature bit list to that value.

spt3g.gcp.ARCExtractor.UnpackTrackerPointingData(f)[source]

Extracts tracker registers relevant to online and offline pointing. Calibration values (offsets and multiplicative constants) are from gcp/control/conf/spt/cal.

spt3g.gcp.ARCExtractor.UnpackWeatherData(f)[source]

Extracts weather status information to Weather key in frame

spt3g.gcp.ARCExtractor.UpdateLinearSensorDeltas(f)[source]
spt3g.gcp.InfluxDB.WriteDB(fr, client, fields=None)[source]

Write points to the database for each field

Parameters:
  • client – InfluxDB client

  • fields – Which gcp fields to add to database. See parse_field for options. If None, add all.

Pipeline Segments

Python functions that combine a sequence of pipeline modules, and can be added to G3Pipeline instances. See Pipeline Segments for more detail.

spt3g.gcp.ARCExtractor.ARCExtract(pipe)

Extract GCP registers into native objects

Equivalent to

pipe.Add(spt3g.gcp.ARCExtractor.CalibrateFrame)
pipe.Add(spt3g.gcp.ARCExtractor.UnpackACUData)
pipe.Add(spt3g.gcp.ARCExtractor.UnpackTrackerPointingData)
pipe.Add(spt3g.gcp.ARCExtractor.UpdateLinearSensorDeltas)
pipe.Add(spt3g.gcp.ARCExtractor.DecryptFeatureBit)
pipe.Add(spt3g.gcp.ARCExtractor.UnpackTrackerData)
pipe.Add(spt3g.gcp.ARCExtractor.AddBenchData)
pipe.Add(spt3g.gcp.ARCExtractor.UnpackCryoData)
pipe.Add(spt3g.gcp.ARCExtractor.UnpackPTData)
pipe.Add(spt3g.gcp.ARCExtractor.UnpackMuxData)
pipe.Add(spt3g.gcp.ARCExtractor.UnpackWeatherData)
spt3g.gcp.ARCExtractor.ARCExtractMinimal(pipe)

Extract bare minimum GCP registers into native objects.

Includes only GCPFeatureBits, SourceName and ObservationID keys. Use ARCExtract to calibrate and extract the complete frame.

Equivalent to

pipe.Add(spt3g.gcp.ARCExtractor.DecryptFeatureBit)
pipe.Add(spt3g.gcp.ARCExtractor.UnpackTrackerMinimal)
spt3g.gcp.InfluxDB.UpdateDB(pipe, client=None, fields=None)

Update InfluxDB with data in frame

Parameters:
  • client – InfluxDB client

  • fields – Which gcp fields to add to database. See parse_field for options. If None, add all.

Equivalent to

pipe.Add(spt3g.gcp.ARCExtractor.ARCExtract)
pipe.Add(spt3g.gcp.InfluxDB.WriteDB, client=None, fields=None)

Useful Classes

Various Python and C++ classes that are part of the public API.

class spt3g.gcp.ACUState(value: int)
IDLE = spt3g.gcp.ACUState.IDLE
RESYNC = spt3g.gcp.ACUState.RESYNC
TRACKING = spt3g.gcp.ACUState.TRACKING
WAIT_RESTART = spt3g.gcp.ACUState.WAIT_RESTART
property name: str
names: dict

Mapping of enum names to objects.

{'IDLE': spt3g.gcp.ACUState.IDLE,
 'RESYNC': spt3g.gcp.ACUState.RESYNC,
 'TRACKING': spt3g.gcp.ACUState.TRACKING,
 'WAIT_RESTART': spt3g.gcp.ACUState.WAIT_RESTART}
property value: int
values: dict

Mapping of enum values to objects.

{0: spt3g.gcp.ACUState.IDLE,
 1: spt3g.gcp.ACUState.TRACKING,
 2: spt3g.gcp.ACUState.WAIT_RESTART,
 3: spt3g.gcp.ACUState.RESYNC}
class spt3g.gcp.ARCFile.ARCFile(path, extract=False)[source]

Iterable class for ARC files, as created by GCP. Loop through frames by doing something like:

f = gcp.ARCFile('/path/to/arc.dat')
for frame in f:
    print( frame )

An entire file can also be read into an indexable list by doing:

f = list(gcp.ARCFile('/path/to/arc.dat'))
next()[source]
class spt3g.gcp.CalFile.CalFileReader(calibration_file=None)[source]

For now just reads a G3 calibration file and loads the contents into a dictionary

readCalFile(calfile=None)[source]
class spt3g.gcp.Experiment(value: int)

Experiment identifier, to choose the correct storage schema when parsing arcfile frames

BK = spt3g.gcp.Experiment.BK
PB = spt3g.gcp.Experiment.PB
SPT = spt3g.gcp.Experiment.SPT
property name: str
names: dict

Mapping of enum names to objects.

{'BK': spt3g.gcp.Experiment.BK,
 'PB': spt3g.gcp.Experiment.PB,
 'SPT': spt3g.gcp.Experiment.SPT}
property value: int
values: dict

Mapping of enum values to objects.

{0: spt3g.gcp.Experiment.SPT,
 1: spt3g.gcp.Experiment.PB,
 2: spt3g.gcp.Experiment.BK}
class spt3g.gcp.GCPLogger(
port: int = 50030,
default_loglevel: G3LogLevel = spt3g.core.G3LogLevel.LOG_NOTICE,
)

Bases: G3Logger

Logger that relays error messages to the GCP mediator over TCP

property trim_file_names: bool

Show only file leaves

class spt3g.gcp.TrackerState(value: int)
HALTED = spt3g.gcp.TrackerState.HALTED
LACKING = spt3g.gcp.TrackerState.LACKING
SLEWING = spt3g.gcp.TrackerState.SLEWING
TIME_ERROR = spt3g.gcp.TrackerState.TIME_ERROR
TOO_HIGH = spt3g.gcp.TrackerState.TOO_HIGH
TOO_LOW = spt3g.gcp.TrackerState.TOO_LOW
TRACKING = spt3g.gcp.TrackerState.TRACKING
UPDATING = spt3g.gcp.TrackerState.UPDATING
property name: str
names: dict

Mapping of enum names to objects.

{'HALTED': spt3g.gcp.TrackerState.HALTED,
 'LACKING': spt3g.gcp.TrackerState.LACKING,
 'SLEWING': spt3g.gcp.TrackerState.SLEWING,
 'TIME_ERROR': spt3g.gcp.TrackerState.TIME_ERROR,
 'TOO_HIGH': spt3g.gcp.TrackerState.TOO_HIGH,
 'TOO_LOW': spt3g.gcp.TrackerState.TOO_LOW,
 'TRACKING': spt3g.gcp.TrackerState.TRACKING,
 'UPDATING': spt3g.gcp.TrackerState.UPDATING}
property value: int
values: dict

Mapping of enum values to objects.

{0: spt3g.gcp.TrackerState.LACKING,
 1: spt3g.gcp.TrackerState.TIME_ERROR,
 2: spt3g.gcp.TrackerState.UPDATING,
 3: spt3g.gcp.TrackerState.HALTED,
 4: spt3g.gcp.TrackerState.SLEWING,
 5: spt3g.gcp.TrackerState.TRACKING,
 6: spt3g.gcp.TrackerState.TOO_LOW,
 7: spt3g.gcp.TrackerState.TOO_HIGH}
class spt3g.gcp.TrackerStateVector()
class spt3g.gcp.TrackerStateVector(arg: TrackerStateVector)
class spt3g.gcp.TrackerStateVector(arg: Iterable)

Signature 2: Copy constructor

append(x: TrackerState)

Add an item to the end of the list

clear()

Clear the contents

count(x: TrackerState) int

Return the number of times x appears in the list

extend(L: TrackerStateVector)
extend(L: Iterable) None

Signature 1: Extend the list by appending all the items in the given list

Signature 2: Extend the list by appending all the items in the given list

insert(i: int, x: TrackerState)

Insert an item at a given position.

pop() TrackerState
pop(i: int) TrackerState

Signature 1: Remove and return the last item

Signature 2: Remove and return the item at index i

remove(x: TrackerState)

Remove the first item from the list whose value is x. It is an error if there is no such item.

Useful Functions

Various Python and C++ functions that are part of the public API.

spt3g.gcp.CalFile.create_g3_cal_file(
path,
read_from_gcp=True,
extra_dict=None,
use_extra_info=True,
gcp_cal_file=None,
)[source]

Create a G3 register calibration file. Usually reads in calibration and units from a GCP cal file then adds extra information that isn’t in the GCP one. This extra information can be handed to the routine as a dict (note format below); otherwise, the hard-coded extra info will be used. (Feel free to edit this hard-coded info.)