Skip to content
Snippets Groups Projects
Commit 63d1991b authored by Hanna's avatar Hanna
Browse files

remove old source documentation

parent f27c5737
No related branches found
No related tags found
No related merge requests found
Pipeline #686142 passed
......@@ -243,51 +243,6 @@ There are shortcuts for producing a new empty TSFrame that might be useful if yo
SeriesBuffer(offset=16384, offset_end=32768, shape=(2048,), sample_rate=2048, duration=1000000000, data=None)
```
## Example
### Writing a new source element
This [MR](https://git.ligo.org/greg/sgn-ts/-/merge_requests/46) is pending but would make this example simpler
```python
#!/usr/bin/env python3
from dataclasses import dataclass
import numpy
from sgn import Pipeline, NullSink
from sgnts.base import Offset, SeriesBuffer, TSFrame, TSSource, TSSlice, TSSlices
import time
@dataclass
class SineSource(TSSource):
frequency: float = 32
rate: int = 2048
def __post_init__(self):
super().__post_init__()
# FIXME turn these into a helper method
self.num_samples = Offset.sample_stride(self.rate)
self.shape = (self.num_samples,)
def new(self, pad):
time.sleep(1)
# FIXME turn these into a helper method
buf = SeriesBuffer(offset=self.offset[pad], sample_rate=self.rate, data=0, shape=self.shape)
tarr = numpy.arange(self.num_samples) / buf.sample_rate + buf.t0
self.offset[pad] += Offset.fromsamples(self.num_samples, self.rate)
frame = TSFrame(buffers=[buf])
buf.data[:] = numpy.sin(2 * numpy.pi * self.frequency * tarr)
return frame
# FIXME don't require names
src = SineSource(name="sine", source_pad_names = ["H1"], frequency=32, rate=2048)
sink = NullSink(name="fakesink", sink_pad_names = ["H1"])
# Create the Pipeline
p = Pipeline()
# FIXME simplify linking
p.insert(
src,
sink,
link_map={"fakesink:sink:H1": "sine:src:H1"},
)
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment