diff --git a/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/CONNECTION_FSV/CONNECTION_FSV.py b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/CONNECTION_FSV/CONNECTION_FSV.py new file mode 100644 index 000000000..bbb5131da --- /dev/null +++ b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/CONNECTION_FSV/CONNECTION_FSV.py @@ -0,0 +1,36 @@ +from flojoy import VisaDevice, flojoy, DataContainer +from flojoy.connection_manager import DeviceConnectionManager +from typing import Optional +from pyvisa import ResourceManager + + +@flojoy() +def CONNECTION_FSV( + device: VisaDevice, + default: Optional[DataContainer] = None, +) -> Optional[DataContainer]: + """The CONNECTION_FSV node connects Flojoy to a FSV network analyzer. + + The connection is made with the VISA address in the Flojoy UI. + + This node should also work with compatible R&S network analyzers. + + Parameters + ---------- + device: VisaDevice + The VISA address to connect to. + + Returns + ------- + DataContainer + None + """ + + rm = ResourceManager("@py") + rohde = rm.open_resource(device.get_id()) + rohde.read_termination = "\n" + rohde.write_termination = "\n" + + DeviceConnectionManager.register_connection(device, rohde) + + return None diff --git a/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/CONNECTION_FSV/app.json b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/CONNECTION_FSV/app.json new file mode 100644 index 000000000..c446823bc --- /dev/null +++ b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/CONNECTION_FSV/app.json @@ -0,0 +1,404 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 380, + "height": 293, + "id": "LINE-437e1ca3-fdc5-43c7-89a4-95766a021c45", + "type": "VISUALIZERS", + "data": { + "id": "LINE-437e1ca3-fdc5-43c7-89a4-95766a021c45", + "label": "LINE", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix|Vector", + "multiple": false, + "desc": "the DataContainer to be visualized" + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": "the DataContainer containing the Plotly Line visualization of the input data" + } + ], + "path": "VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 982.433589812745, + "y": -158.221539428072 + }, + "selected": false, + "positionAbsolute": { + "x": 982.433589812745, + "y": -158.221539428072 + }, + "dragging": true + }, + { + "width": 192, + "height": 192, + "id": "CONNECTION_FSV-6af7f29b-5578-4bb7-97b2-d728dcd68073", + "type": "IO", + "data": { + "id": "CONNECTION_FSV-6af7f29b-5578-4bb7-97b2-d728dcd68073", + "label": "CONNECTION FSV", + "func": "CONNECTION_FSV", + "type": "IO", + "ctrls": { + "device": { + "type": "VisaDevice", + "default": null, + "desc": "The VISA address to connect to.", + "overload": null, + "functionName": "CONNECTION_FSV", + "param": "device", + "value": "TCPIP::169.254.28.160::INSTR" + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "desc": "Optional: None" + } + ], + "path": "IO/INSTRUMENTS/NETWORK_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/CONNECTION_FSV/CONNECTION_FSV.py", + "selected": false + }, + "position": { + "x": -126.41208723832608, + "y": -108.52899007141966 + }, + "selected": false, + "positionAbsolute": { + "x": -126.41208723832608, + "y": -108.52899007141966 + }, + "dragging": true + }, + { + "width": 192, + "height": 192, + "id": "EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0", + "type": "IO", + "data": { + "id": "EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0", + "label": "EXTRACT SWEEP FSV", + "func": "EXTRACT_SWEEP_FSV", + "type": "IO", + "ctrls": { + "connection": { + "type": "VisaConnection", + "default": null, + "desc": "The VISA address (requires the CONNECTION_FSV node).", + "overload": null, + "functionName": "EXTRACT_SWEEP_FSV", + "param": "connection", + "value": "TCPIP::169.254.28.160::INSTR" + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "desc": "OrderedPair: The sweep trace from the FSV is returned." + } + ], + "path": "IO/INSTRUMENTS/NETWORK_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/EXTRACT_SWEEP_FSV/EXTRACT_SWEEP_FSV.py", + "selected": false + }, + "position": { + "x": 698.1125693394696, + "y": -106.79580773233235 + }, + "selected": false, + "positionAbsolute": { + "x": 698.1125693394696, + "y": -106.79580773233235 + }, + "dragging": true + }, + { + "width": 192, + "height": 192, + "id": "INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831f", + "type": "IO", + "data": { + "id": "INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831f", + "label": "INIT SWEEP FSV", + "func": "INIT_SWEEP_FSV", + "type": "IO", + "ctrls": { + "connection": { + "type": "VisaConnection", + "default": null, + "desc": "The VISA address (requires the CONNECTION_FSV node).", + "overload": null, + "functionName": "INIT_SWEEP_FSV", + "param": "connection", + "value": "TCPIP::169.254.28.160::INSTR" + }, + "display": { + "type": "select", + "options": [ + "write", + "view", + "average", + "maxhold", + "minhold", + "blank" + ], + "default": "write", + "desc": "Choose the trace display setting.", + "overload": null, + "functionName": "INIT_SWEEP_FSV", + "param": "display", + "value": "average" + }, + "continuous": { + "type": "bool", + "default": true, + "desc": "Sweep continuously or not.", + "overload": null, + "functionName": "INIT_SWEEP_FSV", + "param": "continuous", + "value": true + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "TextBlob", + "desc": "TextBlob: Display and sweep settings." + } + ], + "path": "IO/INSTRUMENTS/NETWORK_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/INIT_SWEEP_FSV/INIT_SWEEP_FSV.py", + "selected": false + }, + "position": { + "x": 423.16802090780266, + "y": -109.77806957868016 + }, + "selected": false, + "positionAbsolute": { + "x": 423.16802090780266, + "y": -109.77806957868016 + }, + "dragging": true + }, + { + "width": 192, + "height": 192, + "id": "SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370", + "type": "IO", + "data": { + "id": "SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370", + "label": "SWEEP SETTINGS FSV", + "func": "SWEEP_SETTINGS_FSV", + "type": "IO", + "ctrls": { + "connection": { + "type": "VisaConnection", + "default": null, + "desc": "The VISA address (requires the CONNECTION_FSV node).", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "connection", + "value": "TCPIP::169.254.28.160::INSTR" + }, + "span_or_range": { + "type": "select", + "options": [ + "span", + "range" + ], + "default": "range", + "desc": "X axis range, span (center and span) or range (start and stop).", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "span_or_range", + "value": "range" + }, + "center": { + "type": "float", + "default": 100000000, + "desc": "The center of the x axis range, in Hz.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "center", + "value": 86000000 + }, + "span": { + "type": "float", + "default": 10000000, + "desc": "The span of the x axis, in Hz.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "span", + "value": 112000000 + }, + "start": { + "type": "float", + "default": 10000000, + "desc": "The start point of the x axis, in Hz.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "start", + "value": 86000000 + }, + "stop": { + "type": "float", + "default": 100000000, + "desc": "The end point of the x axis, in Hz.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "stop", + "value": 112000000 + }, + "sweep_type": { + "type": "select", + "options": [ + "sweep", + "FFT", + "auto" + ], + "default": "auto", + "desc": "How the FSV sweeps along the x axis range.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "sweep_type", + "value": "auto" + }, + "counts": { + "type": "int", + "default": 10, + "desc": "Number of sweeps to do, (average optional in INIT_SWEEP_FSV).", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "counts", + "value": 100 + }, + "points": { + "type": "int", + "default": 1000, + "desc": "Number of x axis points to sweep.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "points", + "value": 1000 + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "TextBlob", + "desc": "TextBlob: Sweep settings summary." + } + ], + "path": "IO/INSTRUMENTS/NETWORK_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/SWEEP_SETTINGS_FSV/SWEEP_SETTINGS_FSV.py", + "selected": false + }, + "position": { + "x": 150.00876699020785, + "y": -107.85365492861959 + }, + "selected": false, + "positionAbsolute": { + "x": 150.00876699020785, + "y": -107.85365492861959 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "CONNECTION_FSV-6af7f29b-5578-4bb7-97b2-d728dcd68073", + "sourceHandle": "default", + "target": "SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370", + "targetHandle": "default", + "id": "reactflow__edge-CONNECTION_FSV-6af7f29b-5578-4bb7-97b2-d728dcd68073default-SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370default" + }, + { + "source": "SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370", + "sourceHandle": "default", + "target": "INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831f", + "targetHandle": "default", + "id": "reactflow__edge-SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370default-INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831fdefault" + }, + { + "source": "INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831f", + "sourceHandle": "default", + "target": "EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0", + "targetHandle": "default", + "id": "reactflow__edge-INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831fdefault-EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0default" + }, + { + "source": "EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0", + "sourceHandle": "default", + "target": "LINE-437e1ca3-fdc5-43c7-89a4-95766a021c45", + "targetHandle": "default", + "id": "reactflow__edge-EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0default-LINE-437e1ca3-fdc5-43c7-89a4-95766a021c45default" + } + ], + "viewport": { + "x": 1139.470292881633, + "y": 572.2854272048312, + "zoom": 1.2136444284334926 + } + }, + "textNodes": [] +} \ No newline at end of file diff --git a/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/CONNECTION_FSV/example.md b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/CONNECTION_FSV/example.md new file mode 100644 index 000000000..8ae7ca6bd --- /dev/null +++ b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/CONNECTION_FSV/example.md @@ -0,0 +1,5 @@ +In this example, the Rohde & Schwarz FSV Signal Analyzer is used to view the FM radio range (86-110 MHz). + +First 4 FSV nodes were added: `CONNECTION_FSV`, `SWEEP_SETTINGS_FSV`, `INIT_SWEEP_FSV`, and `EXTRACT_SWEEP_FSV`. A `LINE` node was also added. The `VISA address` was set for the 4 instrument nodes. The range of the signal analyzer sweep was set with `SWEEP_SETTINGS_FSV` (`start` = 86, `stop` = 110 MHz). + +The nodes were then connected as shown in the image, and the app was run. diff --git a/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/CONNECTION_FSV/output.jpeg b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/CONNECTION_FSV/output.jpeg new file mode 100644 index 000000000..6987d0626 Binary files /dev/null and b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/CONNECTION_FSV/output.jpeg differ diff --git a/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/CONNECTION_FSV/output_light.jpeg b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/CONNECTION_FSV/output_light.jpeg new file mode 100644 index 000000000..410051106 Binary files /dev/null and b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/CONNECTION_FSV/output_light.jpeg differ diff --git a/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/EXTRACT_SWEEP_FSV/EXTRACT_SWEEP_FSV.py b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/EXTRACT_SWEEP_FSV/EXTRACT_SWEEP_FSV.py new file mode 100644 index 000000000..e8e1ef45f --- /dev/null +++ b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/EXTRACT_SWEEP_FSV/EXTRACT_SWEEP_FSV.py @@ -0,0 +1,41 @@ +from flojoy import flojoy, DataContainer, OrderedPair, VisaConnection +from typing import Optional +from numpy import fromstring +from time import sleep + + +@flojoy(inject_connection=True) +def EXTRACT_SWEEP_FSV( + connection: VisaConnection, + default: Optional[DataContainer] = None, +) -> OrderedPair: + """The EXTRACT_SWEEP_FSV node extracts the sweep trace from a FSV network analyzer. + + Requires a CONNECTION_FSV node at the start of the app to connect with + the instrument. The VISA address will then be listed under 'connection'. + + This node should also work with compatible R&S network analyzers. + + Parameters + ---------- + connection: VisaConnection + The VISA address (requires the CONNECTION_FSV node). + + Returns + ------- + OrderedPair + The sweep trace from the FSV is returned. + """ + + rohde = connection.get_handle() + + # Wait until the sweep count reach the target. + target = rohde.query("SWE:COUN?") + while rohde.query("SWE:COUN:CURR?") != target: + rohde.write("*WAI") + sleep(0.1) + + x = fromstring(rohde.query("TRAC:DATA:X? TRACE1"), sep=",") + y = fromstring(rohde.query("TRAC? TRACE1"), sep=",") + + return OrderedPair(x=x, y=y) diff --git a/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/EXTRACT_SWEEP_FSV/app.json b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/EXTRACT_SWEEP_FSV/app.json new file mode 100644 index 000000000..c446823bc --- /dev/null +++ b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/EXTRACT_SWEEP_FSV/app.json @@ -0,0 +1,404 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 380, + "height": 293, + "id": "LINE-437e1ca3-fdc5-43c7-89a4-95766a021c45", + "type": "VISUALIZERS", + "data": { + "id": "LINE-437e1ca3-fdc5-43c7-89a4-95766a021c45", + "label": "LINE", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix|Vector", + "multiple": false, + "desc": "the DataContainer to be visualized" + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": "the DataContainer containing the Plotly Line visualization of the input data" + } + ], + "path": "VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 982.433589812745, + "y": -158.221539428072 + }, + "selected": false, + "positionAbsolute": { + "x": 982.433589812745, + "y": -158.221539428072 + }, + "dragging": true + }, + { + "width": 192, + "height": 192, + "id": "CONNECTION_FSV-6af7f29b-5578-4bb7-97b2-d728dcd68073", + "type": "IO", + "data": { + "id": "CONNECTION_FSV-6af7f29b-5578-4bb7-97b2-d728dcd68073", + "label": "CONNECTION FSV", + "func": "CONNECTION_FSV", + "type": "IO", + "ctrls": { + "device": { + "type": "VisaDevice", + "default": null, + "desc": "The VISA address to connect to.", + "overload": null, + "functionName": "CONNECTION_FSV", + "param": "device", + "value": "TCPIP::169.254.28.160::INSTR" + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "desc": "Optional: None" + } + ], + "path": "IO/INSTRUMENTS/NETWORK_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/CONNECTION_FSV/CONNECTION_FSV.py", + "selected": false + }, + "position": { + "x": -126.41208723832608, + "y": -108.52899007141966 + }, + "selected": false, + "positionAbsolute": { + "x": -126.41208723832608, + "y": -108.52899007141966 + }, + "dragging": true + }, + { + "width": 192, + "height": 192, + "id": "EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0", + "type": "IO", + "data": { + "id": "EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0", + "label": "EXTRACT SWEEP FSV", + "func": "EXTRACT_SWEEP_FSV", + "type": "IO", + "ctrls": { + "connection": { + "type": "VisaConnection", + "default": null, + "desc": "The VISA address (requires the CONNECTION_FSV node).", + "overload": null, + "functionName": "EXTRACT_SWEEP_FSV", + "param": "connection", + "value": "TCPIP::169.254.28.160::INSTR" + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "desc": "OrderedPair: The sweep trace from the FSV is returned." + } + ], + "path": "IO/INSTRUMENTS/NETWORK_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/EXTRACT_SWEEP_FSV/EXTRACT_SWEEP_FSV.py", + "selected": false + }, + "position": { + "x": 698.1125693394696, + "y": -106.79580773233235 + }, + "selected": false, + "positionAbsolute": { + "x": 698.1125693394696, + "y": -106.79580773233235 + }, + "dragging": true + }, + { + "width": 192, + "height": 192, + "id": "INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831f", + "type": "IO", + "data": { + "id": "INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831f", + "label": "INIT SWEEP FSV", + "func": "INIT_SWEEP_FSV", + "type": "IO", + "ctrls": { + "connection": { + "type": "VisaConnection", + "default": null, + "desc": "The VISA address (requires the CONNECTION_FSV node).", + "overload": null, + "functionName": "INIT_SWEEP_FSV", + "param": "connection", + "value": "TCPIP::169.254.28.160::INSTR" + }, + "display": { + "type": "select", + "options": [ + "write", + "view", + "average", + "maxhold", + "minhold", + "blank" + ], + "default": "write", + "desc": "Choose the trace display setting.", + "overload": null, + "functionName": "INIT_SWEEP_FSV", + "param": "display", + "value": "average" + }, + "continuous": { + "type": "bool", + "default": true, + "desc": "Sweep continuously or not.", + "overload": null, + "functionName": "INIT_SWEEP_FSV", + "param": "continuous", + "value": true + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "TextBlob", + "desc": "TextBlob: Display and sweep settings." + } + ], + "path": "IO/INSTRUMENTS/NETWORK_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/INIT_SWEEP_FSV/INIT_SWEEP_FSV.py", + "selected": false + }, + "position": { + "x": 423.16802090780266, + "y": -109.77806957868016 + }, + "selected": false, + "positionAbsolute": { + "x": 423.16802090780266, + "y": -109.77806957868016 + }, + "dragging": true + }, + { + "width": 192, + "height": 192, + "id": "SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370", + "type": "IO", + "data": { + "id": "SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370", + "label": "SWEEP SETTINGS FSV", + "func": "SWEEP_SETTINGS_FSV", + "type": "IO", + "ctrls": { + "connection": { + "type": "VisaConnection", + "default": null, + "desc": "The VISA address (requires the CONNECTION_FSV node).", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "connection", + "value": "TCPIP::169.254.28.160::INSTR" + }, + "span_or_range": { + "type": "select", + "options": [ + "span", + "range" + ], + "default": "range", + "desc": "X axis range, span (center and span) or range (start and stop).", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "span_or_range", + "value": "range" + }, + "center": { + "type": "float", + "default": 100000000, + "desc": "The center of the x axis range, in Hz.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "center", + "value": 86000000 + }, + "span": { + "type": "float", + "default": 10000000, + "desc": "The span of the x axis, in Hz.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "span", + "value": 112000000 + }, + "start": { + "type": "float", + "default": 10000000, + "desc": "The start point of the x axis, in Hz.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "start", + "value": 86000000 + }, + "stop": { + "type": "float", + "default": 100000000, + "desc": "The end point of the x axis, in Hz.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "stop", + "value": 112000000 + }, + "sweep_type": { + "type": "select", + "options": [ + "sweep", + "FFT", + "auto" + ], + "default": "auto", + "desc": "How the FSV sweeps along the x axis range.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "sweep_type", + "value": "auto" + }, + "counts": { + "type": "int", + "default": 10, + "desc": "Number of sweeps to do, (average optional in INIT_SWEEP_FSV).", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "counts", + "value": 100 + }, + "points": { + "type": "int", + "default": 1000, + "desc": "Number of x axis points to sweep.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "points", + "value": 1000 + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "TextBlob", + "desc": "TextBlob: Sweep settings summary." + } + ], + "path": "IO/INSTRUMENTS/NETWORK_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/SWEEP_SETTINGS_FSV/SWEEP_SETTINGS_FSV.py", + "selected": false + }, + "position": { + "x": 150.00876699020785, + "y": -107.85365492861959 + }, + "selected": false, + "positionAbsolute": { + "x": 150.00876699020785, + "y": -107.85365492861959 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "CONNECTION_FSV-6af7f29b-5578-4bb7-97b2-d728dcd68073", + "sourceHandle": "default", + "target": "SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370", + "targetHandle": "default", + "id": "reactflow__edge-CONNECTION_FSV-6af7f29b-5578-4bb7-97b2-d728dcd68073default-SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370default" + }, + { + "source": "SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370", + "sourceHandle": "default", + "target": "INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831f", + "targetHandle": "default", + "id": "reactflow__edge-SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370default-INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831fdefault" + }, + { + "source": "INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831f", + "sourceHandle": "default", + "target": "EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0", + "targetHandle": "default", + "id": "reactflow__edge-INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831fdefault-EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0default" + }, + { + "source": "EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0", + "sourceHandle": "default", + "target": "LINE-437e1ca3-fdc5-43c7-89a4-95766a021c45", + "targetHandle": "default", + "id": "reactflow__edge-EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0default-LINE-437e1ca3-fdc5-43c7-89a4-95766a021c45default" + } + ], + "viewport": { + "x": 1139.470292881633, + "y": 572.2854272048312, + "zoom": 1.2136444284334926 + } + }, + "textNodes": [] +} \ No newline at end of file diff --git a/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/EXTRACT_SWEEP_FSV/example.md b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/EXTRACT_SWEEP_FSV/example.md new file mode 100644 index 000000000..8ae7ca6bd --- /dev/null +++ b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/EXTRACT_SWEEP_FSV/example.md @@ -0,0 +1,5 @@ +In this example, the Rohde & Schwarz FSV Signal Analyzer is used to view the FM radio range (86-110 MHz). + +First 4 FSV nodes were added: `CONNECTION_FSV`, `SWEEP_SETTINGS_FSV`, `INIT_SWEEP_FSV`, and `EXTRACT_SWEEP_FSV`. A `LINE` node was also added. The `VISA address` was set for the 4 instrument nodes. The range of the signal analyzer sweep was set with `SWEEP_SETTINGS_FSV` (`start` = 86, `stop` = 110 MHz). + +The nodes were then connected as shown in the image, and the app was run. diff --git a/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/EXTRACT_SWEEP_FSV/output.jpeg b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/EXTRACT_SWEEP_FSV/output.jpeg new file mode 100644 index 000000000..6987d0626 Binary files /dev/null and b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/EXTRACT_SWEEP_FSV/output.jpeg differ diff --git a/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/EXTRACT_SWEEP_FSV/output_light.jpeg b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/EXTRACT_SWEEP_FSV/output_light.jpeg new file mode 100644 index 000000000..410051106 Binary files /dev/null and b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/EXTRACT_SWEEP_FSV/output_light.jpeg differ diff --git a/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/INIT_SWEEP_FSV/INIT_SWEEP_FSV.py b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/INIT_SWEEP_FSV/INIT_SWEEP_FSV.py new file mode 100644 index 000000000..e7a869167 --- /dev/null +++ b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/INIT_SWEEP_FSV/INIT_SWEEP_FSV.py @@ -0,0 +1,50 @@ +from flojoy import flojoy, DataContainer, TextBlob, VisaConnection +from typing import Optional, Literal + + +@flojoy(inject_connection=True) +def INIT_SWEEP_FSV( + connection: VisaConnection, + display: Literal[ + "write", + "view", + "average", + "maxhold", + "minhold", + "blank", + ] = "write", + continuous: bool = True, + default: Optional[DataContainer] = None, +) -> TextBlob: + """The INIT_SWEEP_FSV node starts the sweep for the FSV. + + Requires a CONNECTION_FSV node at the start of the app to connect with + the instrument. The VISA address will then be listed under 'connection'. + + This node should also work with compatible R&S network analyzers. + + Parameters + ---------- + connection: VisaConnection + The VISA address (requires the CONNECTION_FSV node). + display: select + Choose the trace display setting. + continuous: bool + Sweep continuously or not. + + Returns + ------- + TextBlob + Display and sweep settings. + """ + + rohde = connection.get_handle() + + rohde.write(f"DISP:TRAC:MODE {display}") + if continuous: + rohde.write("INIT:CONT ON") + else: + rohde.write("INIT:CONT OFF") + rohde.write("INIT") + + return TextBlob(text_blob=f"Display: {display}, Continuous: {continuous}") diff --git a/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/INIT_SWEEP_FSV/app.json b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/INIT_SWEEP_FSV/app.json new file mode 100644 index 000000000..c446823bc --- /dev/null +++ b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/INIT_SWEEP_FSV/app.json @@ -0,0 +1,404 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 380, + "height": 293, + "id": "LINE-437e1ca3-fdc5-43c7-89a4-95766a021c45", + "type": "VISUALIZERS", + "data": { + "id": "LINE-437e1ca3-fdc5-43c7-89a4-95766a021c45", + "label": "LINE", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix|Vector", + "multiple": false, + "desc": "the DataContainer to be visualized" + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": "the DataContainer containing the Plotly Line visualization of the input data" + } + ], + "path": "VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 982.433589812745, + "y": -158.221539428072 + }, + "selected": false, + "positionAbsolute": { + "x": 982.433589812745, + "y": -158.221539428072 + }, + "dragging": true + }, + { + "width": 192, + "height": 192, + "id": "CONNECTION_FSV-6af7f29b-5578-4bb7-97b2-d728dcd68073", + "type": "IO", + "data": { + "id": "CONNECTION_FSV-6af7f29b-5578-4bb7-97b2-d728dcd68073", + "label": "CONNECTION FSV", + "func": "CONNECTION_FSV", + "type": "IO", + "ctrls": { + "device": { + "type": "VisaDevice", + "default": null, + "desc": "The VISA address to connect to.", + "overload": null, + "functionName": "CONNECTION_FSV", + "param": "device", + "value": "TCPIP::169.254.28.160::INSTR" + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "desc": "Optional: None" + } + ], + "path": "IO/INSTRUMENTS/NETWORK_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/CONNECTION_FSV/CONNECTION_FSV.py", + "selected": false + }, + "position": { + "x": -126.41208723832608, + "y": -108.52899007141966 + }, + "selected": false, + "positionAbsolute": { + "x": -126.41208723832608, + "y": -108.52899007141966 + }, + "dragging": true + }, + { + "width": 192, + "height": 192, + "id": "EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0", + "type": "IO", + "data": { + "id": "EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0", + "label": "EXTRACT SWEEP FSV", + "func": "EXTRACT_SWEEP_FSV", + "type": "IO", + "ctrls": { + "connection": { + "type": "VisaConnection", + "default": null, + "desc": "The VISA address (requires the CONNECTION_FSV node).", + "overload": null, + "functionName": "EXTRACT_SWEEP_FSV", + "param": "connection", + "value": "TCPIP::169.254.28.160::INSTR" + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "desc": "OrderedPair: The sweep trace from the FSV is returned." + } + ], + "path": "IO/INSTRUMENTS/NETWORK_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/EXTRACT_SWEEP_FSV/EXTRACT_SWEEP_FSV.py", + "selected": false + }, + "position": { + "x": 698.1125693394696, + "y": -106.79580773233235 + }, + "selected": false, + "positionAbsolute": { + "x": 698.1125693394696, + "y": -106.79580773233235 + }, + "dragging": true + }, + { + "width": 192, + "height": 192, + "id": "INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831f", + "type": "IO", + "data": { + "id": "INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831f", + "label": "INIT SWEEP FSV", + "func": "INIT_SWEEP_FSV", + "type": "IO", + "ctrls": { + "connection": { + "type": "VisaConnection", + "default": null, + "desc": "The VISA address (requires the CONNECTION_FSV node).", + "overload": null, + "functionName": "INIT_SWEEP_FSV", + "param": "connection", + "value": "TCPIP::169.254.28.160::INSTR" + }, + "display": { + "type": "select", + "options": [ + "write", + "view", + "average", + "maxhold", + "minhold", + "blank" + ], + "default": "write", + "desc": "Choose the trace display setting.", + "overload": null, + "functionName": "INIT_SWEEP_FSV", + "param": "display", + "value": "average" + }, + "continuous": { + "type": "bool", + "default": true, + "desc": "Sweep continuously or not.", + "overload": null, + "functionName": "INIT_SWEEP_FSV", + "param": "continuous", + "value": true + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "TextBlob", + "desc": "TextBlob: Display and sweep settings." + } + ], + "path": "IO/INSTRUMENTS/NETWORK_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/INIT_SWEEP_FSV/INIT_SWEEP_FSV.py", + "selected": false + }, + "position": { + "x": 423.16802090780266, + "y": -109.77806957868016 + }, + "selected": false, + "positionAbsolute": { + "x": 423.16802090780266, + "y": -109.77806957868016 + }, + "dragging": true + }, + { + "width": 192, + "height": 192, + "id": "SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370", + "type": "IO", + "data": { + "id": "SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370", + "label": "SWEEP SETTINGS FSV", + "func": "SWEEP_SETTINGS_FSV", + "type": "IO", + "ctrls": { + "connection": { + "type": "VisaConnection", + "default": null, + "desc": "The VISA address (requires the CONNECTION_FSV node).", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "connection", + "value": "TCPIP::169.254.28.160::INSTR" + }, + "span_or_range": { + "type": "select", + "options": [ + "span", + "range" + ], + "default": "range", + "desc": "X axis range, span (center and span) or range (start and stop).", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "span_or_range", + "value": "range" + }, + "center": { + "type": "float", + "default": 100000000, + "desc": "The center of the x axis range, in Hz.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "center", + "value": 86000000 + }, + "span": { + "type": "float", + "default": 10000000, + "desc": "The span of the x axis, in Hz.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "span", + "value": 112000000 + }, + "start": { + "type": "float", + "default": 10000000, + "desc": "The start point of the x axis, in Hz.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "start", + "value": 86000000 + }, + "stop": { + "type": "float", + "default": 100000000, + "desc": "The end point of the x axis, in Hz.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "stop", + "value": 112000000 + }, + "sweep_type": { + "type": "select", + "options": [ + "sweep", + "FFT", + "auto" + ], + "default": "auto", + "desc": "How the FSV sweeps along the x axis range.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "sweep_type", + "value": "auto" + }, + "counts": { + "type": "int", + "default": 10, + "desc": "Number of sweeps to do, (average optional in INIT_SWEEP_FSV).", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "counts", + "value": 100 + }, + "points": { + "type": "int", + "default": 1000, + "desc": "Number of x axis points to sweep.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "points", + "value": 1000 + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "TextBlob", + "desc": "TextBlob: Sweep settings summary." + } + ], + "path": "IO/INSTRUMENTS/NETWORK_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/SWEEP_SETTINGS_FSV/SWEEP_SETTINGS_FSV.py", + "selected": false + }, + "position": { + "x": 150.00876699020785, + "y": -107.85365492861959 + }, + "selected": false, + "positionAbsolute": { + "x": 150.00876699020785, + "y": -107.85365492861959 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "CONNECTION_FSV-6af7f29b-5578-4bb7-97b2-d728dcd68073", + "sourceHandle": "default", + "target": "SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370", + "targetHandle": "default", + "id": "reactflow__edge-CONNECTION_FSV-6af7f29b-5578-4bb7-97b2-d728dcd68073default-SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370default" + }, + { + "source": "SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370", + "sourceHandle": "default", + "target": "INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831f", + "targetHandle": "default", + "id": "reactflow__edge-SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370default-INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831fdefault" + }, + { + "source": "INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831f", + "sourceHandle": "default", + "target": "EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0", + "targetHandle": "default", + "id": "reactflow__edge-INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831fdefault-EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0default" + }, + { + "source": "EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0", + "sourceHandle": "default", + "target": "LINE-437e1ca3-fdc5-43c7-89a4-95766a021c45", + "targetHandle": "default", + "id": "reactflow__edge-EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0default-LINE-437e1ca3-fdc5-43c7-89a4-95766a021c45default" + } + ], + "viewport": { + "x": 1139.470292881633, + "y": 572.2854272048312, + "zoom": 1.2136444284334926 + } + }, + "textNodes": [] +} \ No newline at end of file diff --git a/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/INIT_SWEEP_FSV/example.md b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/INIT_SWEEP_FSV/example.md new file mode 100644 index 000000000..8ae7ca6bd --- /dev/null +++ b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/INIT_SWEEP_FSV/example.md @@ -0,0 +1,5 @@ +In this example, the Rohde & Schwarz FSV Signal Analyzer is used to view the FM radio range (86-110 MHz). + +First 4 FSV nodes were added: `CONNECTION_FSV`, `SWEEP_SETTINGS_FSV`, `INIT_SWEEP_FSV`, and `EXTRACT_SWEEP_FSV`. A `LINE` node was also added. The `VISA address` was set for the 4 instrument nodes. The range of the signal analyzer sweep was set with `SWEEP_SETTINGS_FSV` (`start` = 86, `stop` = 110 MHz). + +The nodes were then connected as shown in the image, and the app was run. diff --git a/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/INIT_SWEEP_FSV/output.jpeg b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/INIT_SWEEP_FSV/output.jpeg new file mode 100644 index 000000000..6987d0626 Binary files /dev/null and b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/INIT_SWEEP_FSV/output.jpeg differ diff --git a/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/INIT_SWEEP_FSV/output_light.jpeg b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/INIT_SWEEP_FSV/output_light.jpeg new file mode 100644 index 000000000..410051106 Binary files /dev/null and b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/INIT_SWEEP_FSV/output_light.jpeg differ diff --git a/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/SWEEP_SETTINGS_FSV/SWEEP_SETTINGS_FSV.py b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/SWEEP_SETTINGS_FSV/SWEEP_SETTINGS_FSV.py new file mode 100644 index 000000000..be3aec872 --- /dev/null +++ b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/SWEEP_SETTINGS_FSV/SWEEP_SETTINGS_FSV.py @@ -0,0 +1,77 @@ +from flojoy import flojoy, DataContainer, TextBlob, VisaConnection +from typing import Optional, Literal + + +@flojoy(inject_connection=True) +def SWEEP_SETTINGS_FSV( + connection: VisaConnection, + span_or_range: Literal["span", "range"] = "range", + center: float = 1e8, + span: float = 1e7, + start: float = 1e7, + stop: float = 1e8, + sweep_type: Literal["sweep", "FFT", "auto"] = "auto", + counts: int = 10, + points: int = 1000, + default: Optional[DataContainer] = None, +) -> TextBlob: + """The SWEEP_SETTINGS_FSV node sets sweep settings for a FSV. + + Note that span/center and start/stop can be used equivalently if: + start = center - (span / 2) and stop = center + (span / 2). + + Requires a CONNECTION_FSV node at the start of the app to connect with + the instrument. The VISA address will then be listed under 'connection'. + + This node should also work with compatible R&S network analyzers. + + Parameters + ---------- + connection: VisaConnection + The VISA address (requires the CONNECTION_FSV node). + span_or_range: select + X axis range, span (center and span) or range (start and stop). + center: float + The center of the x axis range, in Hz. + span: float + The span of the x axis, in Hz. + start: float + The start point of the x axis, in Hz. + stop: float + The end point of the x axis, in Hz. + sweep_type: select + How the FSV sweeps along the x axis range. + counts: int + Number of sweeps to do, (average optional in INIT_SWEEP_FSV). + points: int + Number of x axis points to sweep. + + Returns + ------- + TextBlob + Sweep settings summary. + """ + + rohde = connection.get_handle() + + s = "Sweep settings: " + + if span_or_range == "span": + rohde.write(f"FREQ:CENT {center}") + rohde.write(f"FREQ:SPAN {span}") + s += f"Center: {center} Hz; Span: {span} Hz: " + elif span_or_range == "range": + rohde.write(f"FREQ:STAR {start}") + rohde.write(f"FREQ:STOP {stop}") + s += f"Start: {start} Hz; Stop: {stop} Hz: " + + s += f"Sweep: {sweep_type}: " + if sweep_type == "sweep": + sweep_type = "SWE" + rohde.write(f"SWE:TYPE {sweep_type.upper()}") + + rohde.write(f"SWE:COUN {counts}") + rohde.write(f"SWE:POIN {points}") + s += f"Counts: {counts}; Points: {points}" + + return TextBlob(text_blob=s) diff --git a/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/SWEEP_SETTINGS_FSV/app.json b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/SWEEP_SETTINGS_FSV/app.json new file mode 100644 index 000000000..c446823bc --- /dev/null +++ b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/SWEEP_SETTINGS_FSV/app.json @@ -0,0 +1,404 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 380, + "height": 293, + "id": "LINE-437e1ca3-fdc5-43c7-89a4-95766a021c45", + "type": "VISUALIZERS", + "data": { + "id": "LINE-437e1ca3-fdc5-43c7-89a4-95766a021c45", + "label": "LINE", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix|Vector", + "multiple": false, + "desc": "the DataContainer to be visualized" + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": "the DataContainer containing the Plotly Line visualization of the input data" + } + ], + "path": "VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 982.433589812745, + "y": -158.221539428072 + }, + "selected": false, + "positionAbsolute": { + "x": 982.433589812745, + "y": -158.221539428072 + }, + "dragging": true + }, + { + "width": 192, + "height": 192, + "id": "CONNECTION_FSV-6af7f29b-5578-4bb7-97b2-d728dcd68073", + "type": "IO", + "data": { + "id": "CONNECTION_FSV-6af7f29b-5578-4bb7-97b2-d728dcd68073", + "label": "CONNECTION FSV", + "func": "CONNECTION_FSV", + "type": "IO", + "ctrls": { + "device": { + "type": "VisaDevice", + "default": null, + "desc": "The VISA address to connect to.", + "overload": null, + "functionName": "CONNECTION_FSV", + "param": "device", + "value": "TCPIP::169.254.28.160::INSTR" + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "desc": "Optional: None" + } + ], + "path": "IO/INSTRUMENTS/NETWORK_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/CONNECTION_FSV/CONNECTION_FSV.py", + "selected": false + }, + "position": { + "x": -126.41208723832608, + "y": -108.52899007141966 + }, + "selected": false, + "positionAbsolute": { + "x": -126.41208723832608, + "y": -108.52899007141966 + }, + "dragging": true + }, + { + "width": 192, + "height": 192, + "id": "EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0", + "type": "IO", + "data": { + "id": "EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0", + "label": "EXTRACT SWEEP FSV", + "func": "EXTRACT_SWEEP_FSV", + "type": "IO", + "ctrls": { + "connection": { + "type": "VisaConnection", + "default": null, + "desc": "The VISA address (requires the CONNECTION_FSV node).", + "overload": null, + "functionName": "EXTRACT_SWEEP_FSV", + "param": "connection", + "value": "TCPIP::169.254.28.160::INSTR" + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "desc": "OrderedPair: The sweep trace from the FSV is returned." + } + ], + "path": "IO/INSTRUMENTS/NETWORK_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/EXTRACT_SWEEP_FSV/EXTRACT_SWEEP_FSV.py", + "selected": false + }, + "position": { + "x": 698.1125693394696, + "y": -106.79580773233235 + }, + "selected": false, + "positionAbsolute": { + "x": 698.1125693394696, + "y": -106.79580773233235 + }, + "dragging": true + }, + { + "width": 192, + "height": 192, + "id": "INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831f", + "type": "IO", + "data": { + "id": "INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831f", + "label": "INIT SWEEP FSV", + "func": "INIT_SWEEP_FSV", + "type": "IO", + "ctrls": { + "connection": { + "type": "VisaConnection", + "default": null, + "desc": "The VISA address (requires the CONNECTION_FSV node).", + "overload": null, + "functionName": "INIT_SWEEP_FSV", + "param": "connection", + "value": "TCPIP::169.254.28.160::INSTR" + }, + "display": { + "type": "select", + "options": [ + "write", + "view", + "average", + "maxhold", + "minhold", + "blank" + ], + "default": "write", + "desc": "Choose the trace display setting.", + "overload": null, + "functionName": "INIT_SWEEP_FSV", + "param": "display", + "value": "average" + }, + "continuous": { + "type": "bool", + "default": true, + "desc": "Sweep continuously or not.", + "overload": null, + "functionName": "INIT_SWEEP_FSV", + "param": "continuous", + "value": true + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "TextBlob", + "desc": "TextBlob: Display and sweep settings." + } + ], + "path": "IO/INSTRUMENTS/NETWORK_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/INIT_SWEEP_FSV/INIT_SWEEP_FSV.py", + "selected": false + }, + "position": { + "x": 423.16802090780266, + "y": -109.77806957868016 + }, + "selected": false, + "positionAbsolute": { + "x": 423.16802090780266, + "y": -109.77806957868016 + }, + "dragging": true + }, + { + "width": 192, + "height": 192, + "id": "SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370", + "type": "IO", + "data": { + "id": "SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370", + "label": "SWEEP SETTINGS FSV", + "func": "SWEEP_SETTINGS_FSV", + "type": "IO", + "ctrls": { + "connection": { + "type": "VisaConnection", + "default": null, + "desc": "The VISA address (requires the CONNECTION_FSV node).", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "connection", + "value": "TCPIP::169.254.28.160::INSTR" + }, + "span_or_range": { + "type": "select", + "options": [ + "span", + "range" + ], + "default": "range", + "desc": "X axis range, span (center and span) or range (start and stop).", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "span_or_range", + "value": "range" + }, + "center": { + "type": "float", + "default": 100000000, + "desc": "The center of the x axis range, in Hz.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "center", + "value": 86000000 + }, + "span": { + "type": "float", + "default": 10000000, + "desc": "The span of the x axis, in Hz.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "span", + "value": 112000000 + }, + "start": { + "type": "float", + "default": 10000000, + "desc": "The start point of the x axis, in Hz.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "start", + "value": 86000000 + }, + "stop": { + "type": "float", + "default": 100000000, + "desc": "The end point of the x axis, in Hz.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "stop", + "value": 112000000 + }, + "sweep_type": { + "type": "select", + "options": [ + "sweep", + "FFT", + "auto" + ], + "default": "auto", + "desc": "How the FSV sweeps along the x axis range.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "sweep_type", + "value": "auto" + }, + "counts": { + "type": "int", + "default": 10, + "desc": "Number of sweeps to do, (average optional in INIT_SWEEP_FSV).", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "counts", + "value": 100 + }, + "points": { + "type": "int", + "default": 1000, + "desc": "Number of x axis points to sweep.", + "overload": null, + "functionName": "SWEEP_SETTINGS_FSV", + "param": "points", + "value": 1000 + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "TextBlob", + "desc": "TextBlob: Sweep settings summary." + } + ], + "path": "IO/INSTRUMENTS/NETWORK_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/SWEEP_SETTINGS_FSV/SWEEP_SETTINGS_FSV.py", + "selected": false + }, + "position": { + "x": 150.00876699020785, + "y": -107.85365492861959 + }, + "selected": false, + "positionAbsolute": { + "x": 150.00876699020785, + "y": -107.85365492861959 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "CONNECTION_FSV-6af7f29b-5578-4bb7-97b2-d728dcd68073", + "sourceHandle": "default", + "target": "SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370", + "targetHandle": "default", + "id": "reactflow__edge-CONNECTION_FSV-6af7f29b-5578-4bb7-97b2-d728dcd68073default-SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370default" + }, + { + "source": "SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370", + "sourceHandle": "default", + "target": "INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831f", + "targetHandle": "default", + "id": "reactflow__edge-SWEEP_SETTINGS_FSV-92c0fefc-8488-4a14-b96d-83f4141aa370default-INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831fdefault" + }, + { + "source": "INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831f", + "sourceHandle": "default", + "target": "EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0", + "targetHandle": "default", + "id": "reactflow__edge-INIT_SWEEP_FSV-d8a3c888-310a-437b-b68a-43f6a3d4831fdefault-EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0default" + }, + { + "source": "EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0", + "sourceHandle": "default", + "target": "LINE-437e1ca3-fdc5-43c7-89a4-95766a021c45", + "targetHandle": "default", + "id": "reactflow__edge-EXTRACT_SWEEP_FSV-58bbdf2f-add5-4426-b581-7499196e74f0default-LINE-437e1ca3-fdc5-43c7-89a4-95766a021c45default" + } + ], + "viewport": { + "x": 1139.470292881633, + "y": 572.2854272048312, + "zoom": 1.2136444284334926 + } + }, + "textNodes": [] +} \ No newline at end of file diff --git a/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/SWEEP_SETTINGS_FSV/example.md b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/SWEEP_SETTINGS_FSV/example.md new file mode 100644 index 000000000..8ae7ca6bd --- /dev/null +++ b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/SWEEP_SETTINGS_FSV/example.md @@ -0,0 +1,5 @@ +In this example, the Rohde & Schwarz FSV Signal Analyzer is used to view the FM radio range (86-110 MHz). + +First 4 FSV nodes were added: `CONNECTION_FSV`, `SWEEP_SETTINGS_FSV`, `INIT_SWEEP_FSV`, and `EXTRACT_SWEEP_FSV`. A `LINE` node was also added. The `VISA address` was set for the 4 instrument nodes. The range of the signal analyzer sweep was set with `SWEEP_SETTINGS_FSV` (`start` = 86, `stop` = 110 MHz). + +The nodes were then connected as shown in the image, and the app was run. diff --git a/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/SWEEP_SETTINGS_FSV/output.jpeg b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/SWEEP_SETTINGS_FSV/output.jpeg new file mode 100644 index 000000000..6987d0626 Binary files /dev/null and b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/SWEEP_SETTINGS_FSV/output.jpeg differ diff --git a/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/SWEEP_SETTINGS_FSV/output_light.jpeg b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/SWEEP_SETTINGS_FSV/output_light.jpeg new file mode 100644 index 000000000..410051106 Binary files /dev/null and b/IO/INSTRUMENTS/SIGNAL_ANALYZERS/ROHDE_SCHWARZ/FSV/BASIC/SWEEP_SETTINGS_FSV/output_light.jpeg differ diff --git a/TRANSFORMERS/SIGNAL_PROCESSING/PEAK_DETECTION/PEAK_DETECTION.py b/TRANSFORMERS/SIGNAL_PROCESSING/PEAK_DETECTION/PEAK_DETECTION.py new file mode 100644 index 000000000..e5488498f --- /dev/null +++ b/TRANSFORMERS/SIGNAL_PROCESSING/PEAK_DETECTION/PEAK_DETECTION.py @@ -0,0 +1,95 @@ +from scipy.signal import find_peaks, peak_widths +from flojoy import flojoy, OrderedPair +from typing import TypedDict + + +class resultSplit(TypedDict): + heights: OrderedPair + widths: OrderedPair + + +@flojoy +def PEAK_DETECTION( + default: OrderedPair, + height: float = None, + threshold: float = None, + distance: float = None, + prominence: float = None, + width: float = None, + wlen: float = None, + rel_height: float = None, + plateau_size: float = None, +) -> resultSplit: + """The PEAK_DETECTION node finds peaks based on peak properties. + + The first output returns the peaks heights and the second returns the + peak widths. + + Many of the parameters are based in Samples (number of points) rather than + in the x axis scale. + + Inputs + ------ + default : OrderedPair + The data to find peaks in. + + Parameters + ---------- + height : float, optional + Required height of peaks. Either a number or `None`. + threshold : float, optional + Required threshold of peaks, the vertical distance to its neighboring + samples. Either a number or `None` + distance : float, optional + Required minimal horizontal distance (>= 1) in samples between + neighbouring peaks. Smaller peaks are removed first until the condition + is fulfilled for all remaining peaks. + prominence : float, optional + Required prominence of peaks. Either a number or `None` + width : float, optional + Required width of peaks in samples. Either a number or `None` + wlen : int, optional + Used for calculation of the peaks prominences, thus it is only used if + one of the arguments `prominence` or `width` is given. See argument + `wlen` in `peak_prominences` for a full description of its effects. + rel_height : float, optional + Used for calculation of the peaks width, thus it is only used if `width` + is given. See scipy.signal.peak_widths at docs.scipy.org. + plateau_size : float, optional + Required size of the flat top of peaks in samples. Either a number + or `None` + + Returns + ------- + heights : OrderedPair + x: x axis location for peaks + y: peak heights + widths : OrderedPair + x: x axis location for peaks + y: peak widths + """ + + signal = default.y + freq = default.x + + peaks, _ = find_peaks( + signal, + height=height, + threshold=threshold, + distance=distance, + prominence=prominence, + width=width, + wlen=wlen, + rel_height=rel_height, + plateau_size=plateau_size, + ) + + widths = peak_widths(signal, peaks) + widths = widths[0] * freq.max() / freq.shape[0] # Samples to x axis scale. + + properties = resultSplit( + heights=OrderedPair(x=freq[peaks], y=signal[peaks]), + widths=OrderedPair(x=freq[peaks], y=widths), + ) + + return properties diff --git a/TRANSFORMERS/SIGNAL_PROCESSING/PEAK_DETECTION/PEAK_DETECTION_test_.py b/TRANSFORMERS/SIGNAL_PROCESSING/PEAK_DETECTION/PEAK_DETECTION_test_.py new file mode 100644 index 000000000..1b6fc59ba --- /dev/null +++ b/TRANSFORMERS/SIGNAL_PROCESSING/PEAK_DETECTION/PEAK_DETECTION_test_.py @@ -0,0 +1,19 @@ +import numpy as np +from flojoy import OrderedPair + + +def test_PEAK_DETECTION(mock_flojoy_decorator): + import PEAK_DETECTION + + x = np.linspace(0.0, 2, 1000) + y = np.sin(np.pi * x) + + element = OrderedPair(x=x, y=y) + res = PEAK_DETECTION.PEAK_DETECTION(element) + + heights = res["heights"] + widths = res["widths"] + # PEAK_DETECTION should detect one peak at x = 0.5 y = 1 + assert np.isclose(heights.x[0], 0.5, atol=0.01) + assert np.isclose(heights.y, 1, atol=0.01) + assert np.isclose(widths.y, 0.66, atol=0.01) diff --git a/TRANSFORMERS/SIGNAL_PROCESSING/PEAK_DETECTION/app.json b/TRANSFORMERS/SIGNAL_PROCESSING/PEAK_DETECTION/app.json new file mode 100644 index 000000000..ccb0aa53a --- /dev/null +++ b/TRANSFORMERS/SIGNAL_PROCESSING/PEAK_DETECTION/app.json @@ -0,0 +1,397 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 210, + "height": 96, + "id": "BASIC_OSCILLATOR-6873e667-bd4e-4228-bd9f-c52b7d983e91", + "type": "GENERATORS", + "data": { + "id": "BASIC_OSCILLATOR-6873e667-bd4e-4228-bd9f-c52b7d983e91", + "label": "BASIC OSCILLATOR", + "func": "BASIC_OSCILLATOR", + "type": "GENERATORS", + "ctrls": { + "sample_rate": { + "type": "int", + "default": 100, + "desc": "The number of samples that are taken in a second.", + "overload": null, + "functionName": "BASIC_OSCILLATOR", + "param": "sample_rate", + "value": 50 + }, + "time": { + "type": "int", + "default": 10, + "desc": "The total amount of time of the signal.", + "overload": null, + "functionName": "BASIC_OSCILLATOR", + "param": "time", + "value": 10 + }, + "waveform": { + "type": "select", + "options": [ + "sine", + "square", + "triangle", + "sawtooth" + ], + "default": "sine", + "desc": "The waveform type of the wave.", + "overload": null, + "functionName": "BASIC_OSCILLATOR", + "param": "waveform", + "value": "sine" + }, + "amplitude": { + "type": "float", + "default": 1, + "desc": "The amplitude of the wave.", + "overload": null, + "functionName": "BASIC_OSCILLATOR", + "param": "amplitude", + "value": 1 + }, + "frequency": { + "type": "float", + "default": 1, + "desc": "The wave frequency in radians/2pi.", + "overload": null, + "functionName": "BASIC_OSCILLATOR", + "param": "frequency", + "value": 1 + }, + "offset": { + "type": "float", + "default": 0, + "desc": "The y axis offset of the function.", + "overload": null, + "functionName": "BASIC_OSCILLATOR", + "param": "offset", + "value": 0 + }, + "phase": { + "type": "float", + "default": 0, + "desc": "The x axis offset of the function.", + "overload": null, + "functionName": "BASIC_OSCILLATOR", + "param": "phase", + "value": -1.48 + } + }, + "initCtrls": {}, + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "desc": "x: time domain\ny: generated signal" + } + ], + "path": "GENERATORS/SIMULATIONS/BASIC_OSCILLATOR/BASIC_OSCILLATOR.py", + "selected": false + }, + "position": { + "x": -270.97324932436595, + "y": -234.6036314413538 + }, + "selected": false, + "positionAbsolute": { + "x": -270.97324932436595, + "y": -234.6036314413538 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "LINE-17da5072-cb78-42b3-ac6d-e59939911f8f", + "type": "VISUALIZERS", + "data": { + "id": "LINE-17da5072-cb78-42b3-ac6d-e59939911f8f", + "label": "LINE", + "func": "LINE", + "type": "VISUALIZERS", + "ctrls": {}, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix|Vector", + "multiple": false, + "desc": "the DataContainer to be visualized" + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": "the DataContainer containing the Plotly Line visualization of the input data" + } + ], + "path": "VISUALIZERS/PLOTLY/LINE/LINE.py", + "selected": false + }, + "position": { + "x": 57.56264306491815, + "y": -498.7082738501224 + }, + "selected": false, + "positionAbsolute": { + "x": 57.56264306491815, + "y": -498.7082738501224 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "SCATTER-3c53e37d-bfb8-46b8-a022-923b2c0e339a", + "type": "VISUALIZERS", + "data": { + "id": "SCATTER-3c53e37d-bfb8-46b8-a022-923b2c0e339a", + "label": "SCATTER", + "func": "SCATTER", + "type": "VISUALIZERS", + "ctrls": {}, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix|Vector", + "multiple": false, + "desc": "the DataContainer to be visualized" + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": "the DataContainer containing the Plotly Scatter visualization" + } + ], + "path": "VISUALIZERS/PLOTLY/SCATTER/SCATTER.py", + "selected": false + }, + "position": { + "x": 544.661804041212, + "y": -390.6006635307338 + }, + "selected": false, + "positionAbsolute": { + "x": 544.661804041212, + "y": -390.6006635307338 + }, + "dragging": true + }, + { + "width": 189, + "height": 160, + "id": "PEAK_DETECTION-db707f00-8693-4680-9b75-8a98bd5776f1", + "type": "TRANSFORMERS", + "data": { + "id": "PEAK_DETECTION-db707f00-8693-4680-9b75-8a98bd5776f1", + "label": "PEAK DETECTION", + "func": "PEAK_DETECTION", + "type": "TRANSFORMERS", + "ctrls": { + "height": { + "type": "float", + "default": null, + "desc": "Required height of peaks. Either a number or `None`.", + "overload": null, + "functionName": "PEAK_DETECTION", + "param": "height", + "value": "" + }, + "threshold": { + "type": "float", + "default": null, + "desc": "Required threshold of peaks, the vertical distance to its neighboring\nsamples. Either a number or `None`", + "overload": null, + "functionName": "PEAK_DETECTION", + "param": "threshold", + "value": "" + }, + "distance": { + "type": "float", + "default": null, + "desc": "Required minimal horizontal distance (>= 1) in samples between\nneighbouring peaks. Smaller peaks are removed first until the condition\nis fulfilled for all remaining peaks.", + "overload": null, + "functionName": "PEAK_DETECTION", + "param": "distance", + "value": "" + }, + "prominence": { + "type": "float", + "default": null, + "desc": "Required prominence of peaks. Either a number or `None`", + "overload": null, + "functionName": "PEAK_DETECTION", + "param": "prominence", + "value": "" + }, + "width": { + "type": "float", + "default": null, + "desc": "Required width of peaks in samples. Either a number or `None`", + "overload": null, + "functionName": "PEAK_DETECTION", + "param": "width", + "value": "" + }, + "wlen": { + "type": "float", + "default": null, + "desc": "Used for calculation of the peaks prominences, thus it is only used if\none of the arguments `prominence` or `width` is given. See argument\n`wlen` in `peak_prominences` for a full description of its effects.", + "overload": null, + "functionName": "PEAK_DETECTION", + "param": "wlen", + "value": "" + }, + "rel_height": { + "type": "float", + "default": null, + "desc": "Used for calculation of the peaks width, thus it is only used if `width`\nis given. See scipy.signal.peak_widths at docs.scipy.org.", + "overload": null, + "functionName": "PEAK_DETECTION", + "param": "rel_height", + "value": "" + }, + "plateau_size": { + "type": "float", + "default": null, + "desc": "Required size of the flat top of peaks in samples. Either a number\nor `None`", + "overload": null, + "functionName": "PEAK_DETECTION", + "param": "plateau_size", + "value": "" + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "multiple": false, + "desc": "The data to find peaks in." + } + ], + "outputs": [ + { + "name": "heights", + "id": "heights", + "type": "OrderedPair", + "desc": null + }, + { + "name": "widths", + "id": "widths", + "type": "OrderedPair", + "desc": null + } + ], + "path": "TRANSFORMERS/SIGNAL_PROCESSING/PEAK_DETECTION/PEAK_DETECTION.py", + "selected": false + }, + "position": { + "x": 68.2571846477422, + "y": -130.3741087954212 + }, + "selected": false, + "positionAbsolute": { + "x": 68.2571846477422, + "y": -130.3741087954212 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "SCATTER-b96fc0d7-52e1-4387-80cf-1d7666a0f3a3", + "type": "VISUALIZERS", + "data": { + "id": "SCATTER-b96fc0d7-52e1-4387-80cf-1d7666a0f3a3", + "label": "SCATTER 1", + "func": "SCATTER", + "type": "VISUALIZERS", + "ctrls": {}, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix|Vector", + "multiple": false, + "desc": "the DataContainer to be visualized" + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": "the DataContainer containing the Plotly Scatter visualization" + } + ], + "path": "VISUALIZERS/PLOTLY/SCATTER/SCATTER.py", + "selected": false + }, + "position": { + "x": 540.835615525991, + "y": -73.02430755677514 + }, + "selected": false, + "positionAbsolute": { + "x": 540.835615525991, + "y": -73.02430755677514 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "BASIC_OSCILLATOR-6873e667-bd4e-4228-bd9f-c52b7d983e91", + "sourceHandle": "default", + "target": "LINE-17da5072-cb78-42b3-ac6d-e59939911f8f", + "targetHandle": "default", + "id": "reactflow__edge-BASIC_OSCILLATOR-6873e667-bd4e-4228-bd9f-c52b7d983e91default-LINE-17da5072-cb78-42b3-ac6d-e59939911f8fdefault" + }, + { + "source": "BASIC_OSCILLATOR-6873e667-bd4e-4228-bd9f-c52b7d983e91", + "sourceHandle": "default", + "target": "PEAK_DETECTION-db707f00-8693-4680-9b75-8a98bd5776f1", + "targetHandle": "default", + "id": "reactflow__edge-BASIC_OSCILLATOR-6873e667-bd4e-4228-bd9f-c52b7d983e91default-PEAK_DETECTION-db707f00-8693-4680-9b75-8a98bd5776f1default" + }, + { + "source": "PEAK_DETECTION-db707f00-8693-4680-9b75-8a98bd5776f1", + "sourceHandle": "heights", + "target": "SCATTER-3c53e37d-bfb8-46b8-a022-923b2c0e339a", + "targetHandle": "default", + "id": "reactflow__edge-PEAK_DETECTION-db707f00-8693-4680-9b75-8a98bd5776f1heights-SCATTER-3c53e37d-bfb8-46b8-a022-923b2c0e339adefault" + }, + { + "source": "PEAK_DETECTION-db707f00-8693-4680-9b75-8a98bd5776f1", + "sourceHandle": "widths", + "target": "SCATTER-b96fc0d7-52e1-4387-80cf-1d7666a0f3a3", + "targetHandle": "default", + "id": "reactflow__edge-PEAK_DETECTION-db707f00-8693-4680-9b75-8a98bd5776f1widths-SCATTER-b96fc0d7-52e1-4387-80cf-1d7666a0f3a3default" + } + ], + "viewport": { + "x": 1139.470292881633, + "y": 572.2854272048312, + "zoom": 1.2136444284334926 + } + }, + "textNodes": [] +} \ No newline at end of file diff --git a/TRANSFORMERS/SIGNAL_PROCESSING/PEAK_DETECTION/example.md b/TRANSFORMERS/SIGNAL_PROCESSING/PEAK_DETECTION/example.md new file mode 100644 index 000000000..be62713b8 --- /dev/null +++ b/TRANSFORMERS/SIGNAL_PROCESSING/PEAK_DETECTION/example.md @@ -0,0 +1,9 @@ +This example shows the function of the `PEAK_DETECTION` node. This node detects peaks in signals and returns the peak heights and widths. + +First the need nodes were added: 1 `BASIC_OSCILLATOR`, 1 `LINE`, 1 `PEAK_DETECTION`, and 2 `SCATTER` nodes. + +The `phase` parameter of the `BASIC_OSCILLATOR` node was changed to -1.48. + +The app was run showing the results in the example. Note that although the height and width scatter plots seem to change, they range from 0.998-1.00 and 0.4984-0.499 respecitvely. + +The results show 10 peaks with heights of ~1 and widths of ~0.5. diff --git a/TRANSFORMERS/TYPE_CASTING/ORDERED_PAIR_2_VECTOR/ORDERED_PAIR_2_VECTOR.py b/TRANSFORMERS/TYPE_CASTING/ORDERED_PAIR_2_VECTOR/ORDERED_PAIR_2_VECTOR.py index 08c233193..b2cd90c00 100644 --- a/TRANSFORMERS/TYPE_CASTING/ORDERED_PAIR_2_VECTOR/ORDERED_PAIR_2_VECTOR.py +++ b/TRANSFORMERS/TYPE_CASTING/ORDERED_PAIR_2_VECTOR/ORDERED_PAIR_2_VECTOR.py @@ -1,9 +1,15 @@ from flojoy import flojoy, Vector, OrderedPair +from typing import TypedDict + + +class resultSplit(TypedDict): + x: Vector + y: Vector @flojoy -def ORDERED_PAIR_2_VECTOR(default: OrderedPair) -> Vector: - """The ORDERED_PAIR_2_VECTOR return the y component of an ordered pair as a Vector. +def ORDERED_PAIR_2_VECTOR(default: OrderedPair) -> resultSplit: + """The ORDERED_PAIR_2_VECTOR return the split components of an ordered pair as Vectors. Inputs ------ @@ -12,8 +18,10 @@ def ORDERED_PAIR_2_VECTOR(default: OrderedPair) -> Vector: Returns ------- - Vector - The y component of the input OrderedPair. + x : Vector + Vector from input x + y : Vector + Vector from input y """ - return Vector(v=default.y) + return resultSplit(x=Vector(v=default.x), y=Vector(v=default.y))