Skip to content

Survey Instruments

Instrument dataclass

A class for representing circumplex instruments.

ATTRIBUTE DESCRIPTION
scales

Scales

TYPE: Scales

anchors

Anchors

TYPE: Anchors

details

InstrumentDetails

TYPE: InstrumentDetails

items

Items | None = None

TYPE: Items | None

_data

pd.DataFrame | None = None

TYPE: DataFrame | None

from_dict

from_dict(inst_dict)

Compose an Instrument object from a dictionary.

Typically this would be used to load an instrument from one of our built in JSON files. Args: inst_dict: A dictionary containing the instrument's details, scales, anchors, and items.

RETURNS DESCRIPTION
Instrument

An Instrument object.

TYPE: Instrument

Source code in circumplex/instrument.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
def from_dict(inst_dict: dict) -> Instrument:
    """
    Compose an Instrument object from a dictionary.

    Typically this would be used to load an instrument from one of our built in JSON files.
    Args:
        inst_dict: A dictionary containing the instrument's details, scales, anchors, and items.

    Returns:
        Instrument: An Instrument object.
    """
    scales = Scales(
        abbrev=list(inst_dict["scales"].keys()),
        label=[scale["label"] for scale in inst_dict["scales"].values()],
        angle=[scale["angle"] for scale in inst_dict["scales"].values()],
    )
    items = None
    anchors = Anchors(
        value=[int(key) for key in inst_dict["anchors"].keys()],
        label=list(inst_dict["anchors"].values()),
    )
    details = InstrumentDetails(**inst_dict["details"])
    return Instrument(scales, anchors, details, items)

load_instrument

load_instrument(instrument)

Load an instrument from one of our built-in JSON files.

PARAMETER DESCRIPTION
instrument

The name of the instrument to load. Must be one of the following: - CSIP

TYPE: str

RETURNS DESCRIPTION
Instrument

An Instrument object.

TYPE: Instrument

Source code in circumplex/instrument.py
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
def load_instrument(instrument: str) -> Instrument:
    """
    Load an instrument from one of our built-in JSON files.

    Args:
        instrument: The name of the instrument to load. Must be one of the following:
            - CSIP

    Returns:
        Instrument: An Instrument object.
    """
    with open(INSTRUMENT_JSONS[instrument], "r") as f:
        instrument = json.load(f)

    return from_dict(instrument)