# pwc_signal

Source: https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/pwc_signal

```python
Graph.pwc_signal(values, duration, *, name=None)
```

Create a piecewise-constant signal (scalar-valued function of time).

Use this function to create a piecewise-constant signal in which the
constant segments all have the same duration.

### Parameters
* **values** (*np.ndarray* *or* [*Tensor*](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Tensor.md#boulderopal.graph.Tensor)) – The values $\{\alpha_n\}$ of the $N$ constant segments.
  These can represent either a single sequence of segment values or a
  batch of them. To create a batch of
  $B_1 \times \ldots \times B_n$ signals, represent these
  values as a tensor of shape
  $B_1 \times \ldots \times B_n \times N$.
* **duration** (*float*) – The total duration $\tau$ of the signal.
* **name** (*str* *or* *None* *,* *optional*) – The name of the node.
### Returns
The piecewise-constant function of time $\alpha(t)$, satisfying
$\alpha(t)=\alpha_n$ for $t_{n-1}\leq t\leq t_n$, where
$t_n=n\tau/N$ (where $N$ is the number of values
in $\{\alpha_n\}$). If you provide a batch of values, the
returned Pwc represents a corresponding batch of
$B_1 \times \ldots \times B_n$ functions $\alpha(t)$.
### Return type
[Pwc](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Pwc.md#boulderopal.graph.Pwc)

### SEE ALSO
[`Graph.complex_pwc_signal`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/complex_pwc_signal.md#boulderopal.graph.Graph.complex_pwc_signal)
: Create complex Pwc signals from their moduli and phases.

[`Graph.pwc`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/pwc.md#boulderopal.graph.Graph.pwc)
: Corresponding operation with support for segments of different durations.

[`Graph.pwc_operator`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/pwc_operator.md#boulderopal.graph.Graph.pwc_operator)
: Create Pwc operators.

[`Graph.pwc_sum`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/pwc_sum.md#boulderopal.graph.Graph.pwc_sum)
: Sum multiple Pwcs.

[`Graph.symmetrize_pwc`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/symmetrize_pwc.md#boulderopal.graph.Graph.symmetrize_pwc)
: Symmetrize Pwcs.

## Notes

For more information on Pwc nodes see the [Working with time-dependent functions in
Boulder Opal](https://docs.q-ctrl.com/boulder-opal/topics/working-with-time-dependent-functions-in-boulder-opal) topic.

## Examples

Create a piecewise-constant signal with uniform segment duration.

```pycon
>>> graph.pwc_signal(duration=0.1, values=np.array([2, 3]), name="signal")
<Pwc: name="signal", operation_name="pwc_signal", value_shape=(), batch_shape=()>
>>> result = bo.execute_graph(graph=graph, output_node_names="signal")
>>> result["output"]["signal"]
{
    'durations': array([0.05, 0.05]),
    'values': array([2., 3.]),
    'time_dimension': 0
}
```

See more examples in the [Get familiar with graphs](https://docs.q-ctrl.com/boulder-opal/tutorials/get-familiar-with-graphs) tutorial.
