Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions examples/generate/sources/data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
time,y
0.0,0.0
0.1,0.09983341664682815
0.2,0.19866933079506122
0.30000000000000004,0.2955202066613396
0.4,0.3894183423086505
0.5,0.479425538604203
0.6000000000000001,0.5646424733950355
0.7000000000000001,0.6442176872376911
0.8,0.7173560908995228
0.9,0.7833269096274834
1.0,0.8414709848078965
1.1,0.8912073600614354
1.2000000000000002,0.9320390859672264
1.3,0.963558185417193
1.4000000000000001,0.9854497299884603
1.5,0.9974949866040544
1.6,0.9995736030415051
1.7000000000000002,0.9916648104524686
1.8,0.9738476308781951
1.9000000000000001,0.9463000876874145
2.0,0.9092974268256817
2.1,0.8632093666488737
2.2,0.8084964038195901
2.3000000000000003,0.74570521217672
2.4000000000000004,0.6754631805511506
2.5,0.5984721441039565
2.6,0.5155013718214642
2.7,0.4273798802338298
2.8000000000000003,0.33498815015590466
2.9000000000000004,0.23924932921398198
3.0,0.1411200080598672
3.1,0.04158066243329049
3.2,-0.058374143427580086
3.3000000000000003,-0.15774569414324865
3.4000000000000004,-0.25554110202683167
3.5,-0.35078322768961984
3.6,-0.44252044329485246
3.7,-0.5298361409084934
3.8000000000000003,-0.6118578909427193
3.9000000000000004,-0.6877661591839741
4.0,-0.7568024953079282
4.1000000000000005,-0.8182771110644108
4.2,-0.8715757724135882
4.3,-0.9161659367494549
4.4,-0.951602073889516
4.5,-0.977530117665097
4.6000000000000005,-0.9936910036334645
4.7,-0.9999232575641008
4.800000000000001,-0.9961646088358406
4.9,-0.9824526126243325
5.0,-0.9589242746631385
5.1000000000000005,-0.9258146823277321
5.2,-0.8834546557201531
5.300000000000001,-0.8322674422239008
5.4,-0.7727644875559871
5.5,-0.7055403255703919
5.6000000000000005,-0.6312666378723208
5.7,-0.5506855425976376
5.800000000000001,-0.4646021794137566
5.9,-0.373876664830236
6.0,-0.27941549819892586
6.1000000000000005,-0.18216250427209502
6.2,-0.0830894028174964
6.300000000000001,0.0168139004843506
6.4,0.11654920485049364
6.5,0.21511998808781552
6.6000000000000005,0.3115413635133787
6.7,0.4048499206165983
6.800000000000001,0.49411335113860894
6.9,0.5784397643882001
7.0,0.6569865987187891
7.1000000000000005,0.7289690401258765
7.2,0.7936678638491531
7.300000000000001,0.8504366206285648
7.4,0.8987080958116269
7.5,0.9379999767747389
7.6000000000000005,0.9679196720314865
7.7,0.9881682338770004
7.800000000000001,0.998543345374605
7.9,0.998941341839772
8.0,0.9893582466233818
8.1,0.9698898108450863
8.200000000000001,0.9407305566797726
8.3,0.9021718337562933
8.4,0.8545989080882804
8.5,0.7984871126234903
8.6,0.7343970978741133
8.700000000000001,0.662969230082182
8.8,0.5849171928917617
8.9,0.5010208564578846
9.0,0.4121184852417566
9.1,0.3190983623493521
9.200000000000001,0.22288991410024592
9.3,0.1244544235070617
9.4,0.024775425453357765
9.5,-0.0751511204618093
9.600000000000001,-0.1743267812229814
9.700000000000001,-0.2717606264109442
9.8,-0.3664791292519284
9.9,-0.45753589377532133
Binary file added examples/generate/sources/data.npy
Binary file not shown.
Binary file added examples/generate/sources/data.npz
Binary file not shown.
20 changes: 20 additions & 0 deletions examples/generate/sources/layout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 1
blocks:
npz:
x: -305.0
y: -59.0
orientation: normal
width: 120.0
height: 60.0
npy:
x: -300.0
y: 15.0
orientation: normal
width: 120.0
height: 60.0
csv:
x: -295.0
y: 95.0
orientation: normal
width: 120.0
height: 60.0
11 changes: 11 additions & 0 deletions examples/generate/sources/model.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
blocks:
- name: npz
category: sources
type: file_source
- name: npy
category: sources
type: file_source
- name: csv
category: sources
type: file_source
connections: []
23 changes: 23 additions & 0 deletions examples/generate/sources/parameters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
simulation:
dt: 0.05
T: 10.0
solver: fixed
blocks:
npz:
file_path: data.npz
key: y
repeat: 'False'
use_time: 'True'
npy:
file_path: data.npy
repeat: 'True'
csv:
file_path: data.csv
key: y
repeat: 'False'
use_time: false
logging:
- npz.outputs.out
- npy.outputs.out
- csv.outputs.out
plots: []
16 changes: 16 additions & 0 deletions examples/generate/sources/temp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import csv
import numpy as np

t = np.arange(0, 10, 0.1)
y = np.sin(t)
y = y.reshape(-1, 1)

np.savez('data.npz', time=t, y=y)

np.save('data.npy', y)

with open('data.csv', 'w', newline='') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(['time', 'y']) # Write header
for t_val, y_val in zip(t, y):
writer.writerow([t_val, y_val[0]]) # Write each row of data
2 changes: 2 additions & 0 deletions pySimBlocks/blocks/sources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
# ******************************************************************************

from pySimBlocks.blocks.sources.constant import Constant
from pySimBlocks.blocks.sources.file_source import FileSource
from pySimBlocks.blocks.sources.ramp import Ramp
from pySimBlocks.blocks.sources.step import Step
from pySimBlocks.blocks.sources.sinusoidal import Sinusoidal
from pySimBlocks.blocks.sources.white_noise import WhiteNoise

__all__ = [
"Constant",
"FileSource",
"Ramp",
"Step",
"Sinusoidal",
Expand Down
Loading