{
"info": {
"author": "Rok Cestnik",
"author_email": "rokcestn@uni-potsdam.de",
"bugtrack_url": null,
"classifiers": [],
"description": "OscillatorSnap\n==============\n\nMake a snapshot of an oscillator through its time series. \n\nOscillatorSnap uses \n`TensorFlow `_\nand\n`Keras `_\nand provides straightforward and non-technical high-level functions meant to appeal to non-experts of artificial neural networks. \nIt helps you train a recurrent neural network on oscillatory signals. \nAnd then from the trained network forecast the future state or probe the network for dynamical responses, e.g. estimate the phase response curve and maximal Lyapunov exponent. \n\n\n|\n\nCiting OscillatorSnap:\n.......................\nIf you use OscillatorSnap in your research, please cite our publication:\n\n\n| Rok Cestnik and Markus Abel, Inferring the dynamics of oscillatory systems using recurrent neural networks, Chaos (2019).\n\n\n+---------------------------------------------------------------------------------------------------+\n|| @article{cestnik_inferring_2019, |\n|| \tauthor = {R. Cestnik and M. Abel}, |\n|| \ttitle = {Inferring the dynamics of oscillatory systems using recurrent neural networks}, |\n|| \tyear = {2019}, |\n|| \tjournal = {Chaos}, |\n|| \tvolume = {X}, |\n|| \tpages = {X} |\n|| } |\n+---------------------------------------------------------------------------------------------------+\n\n\n|\n\nInstalling:\n......................\n\nInstall with: \n\n.. code:: bash\n\n\tsudo pip install oscillator_snap\n\nor download the repository and execute\n\n.. code:: bash\n\n\tsudo python setup.py install\n\nin its directory.\n\n\n|\n\nSimple example walkthrough: \n...........................\n\nMake sure to import oscillator_snap (it imports everything it needs):\n\n.. code:: python\n\n\tfrom oscillator_snap import *\n\n\nLet's suppose we have a timeseries s(t) in the format:\n\n.. code:: python\n\n\tdata = [[s(t_1), s(t_2), s(t_3),...], [p(t_1), p(t_2), p(t_3),...]]\n\nif one wants the signal to be generated with an ordinary differential equation this is done with:\n\n.. code:: python\n\n\tdata = generate_signal(derivatives, DATA_LENGTH, DATA_SAMPLING)\n\nthe, :code:`DATA_SAMPLING` is the ratio between the integration timestep and the timestep associated with :code:`data`, e.g. if the equation is integrated with :code:`dt = 0.01` and :code:`DATA_SAMPLING = 10` \nthen the :code:`data` is sampled with a timestep of :code:`0.1`. \n\n\nThere are some other parameters that need to be determined: \n\n.. code:: python \n\n\tPAST = 30 # determines the number of rolls of the RNN, how many historical values are considered for the one-step prediction\n\tNODES = 25 # number of nodes in each layer\n\tLEARNING_RATE = 0.01 \n\tBATCH_SIZE = 100 # how many training points are fed into the network at once\n\tEPOCHS = 10 # how many times is the data presented to the network during training\n\tVALIDATION_POINTS = 200 # how many data points are going to be separated for the validation set\n\nthe dimensions of the input and output also have to be specified, in this example:\n\n.. code:: python\n\n\tDIM_IN = 2\n\tDIM_OUT = 1\n\nThen the validation set is separated from the training data:\n\n.. code:: python\n\n\ttrain_data = [data[i][:-VALIDATION_POINTS] for i in range(len(data))]\n\tval_data = [data[i][-VALIDATION_POINTS] for i in range(len(data))]\n\nand then the data can be parsed:\n\n.. code:: python\n\n\tX, Y = parse_train_data(train_data, PAST, DIM_IN, DIM_OUT)\n\tX_val, Y_val = parse_train_data(val_data, PAST, DIM_OUT, DIM_OUT)\n\nA model needs to be created, it can be either freshly generated:\n\n.. code:: python\n\n\tmodel = generate_model(DIM_IN, DIM_OUT, PAST, NODES, LEARNING_RATE, cell=LSTM, n_hidden_layers=1)\n\nor loaded from previous use:\n\n.. code:: python\n\n\tmodel = load_model_dill()\n\n(see further down on how to save a model). \n\nThe model needs to be compiled:\n\n.. code:: python\n\n\tmodel = compile_model(model, LEARNING_RATE)\n\n\nand then it can be trained:\n\n.. code:: python\n\n\tmodel.fit(X, Y, batch_size=BATHC_SIZE, epochs=EPOCHS, validation_data=(X_val, Y_val))\n\nOnce the model is trained it can be used for signal forecasting:\n\n.. code:: python \n\n\tinp = [0 for i in range(PLOT_RANGE)] # input\n\tf_starter = forecast_starter(data, PAST, DIM_IN) # initial state, to start from a different state just change 'data'\n\tsignal_forecast = forecast(model, PAST, DIM_IN, f_starter, PLOT_RANGE, inp)\n\n\nestimating the natural period, phase response curve, the maximal Lyapunov exponent and the bifurcation diagram: \n\n.. code:: python\n\n\tperiod = period_measure(model, PAST, DIM_IN, f_starter, constant_input_offset=0, thr=0.0)\n\tlyapunov = lyapunov_measure(model, PAST, DIM_IN, f_starter, constant_input_offset=0)\n\tPRC = PRC_measure(model, PAST, DIM_IN, f_starter, constant_input_offset=0.0, thr=0.0, phase_repeats=20, stimulation=1.0)\n\tbif = bifurcation_diagram(model, PAST, DIM_IN, f_starter, ci_min=0.1, ci_max=2.0, dci=0.005, time_window=1000)\n\nand if the true dynamical equations are known, these quantities can be determined from equations as well for comparison:\n\n.. code:: python\n\n\tperiod_eq = oscillator_period(derivatives, inp=0, thr=0.0) # if the system is chaotic the average period can be computed: 'oscillator_average_period()'\n\tlyapunov_eq = oscillator_lyapunov(derivatives, inp=0)\n\tPRC_eq = oscillator_PRC(derivatives, inp=0, thr=0.0)\n\tbif_eq = oscillator_bifurcation(derivatives, inp_min=0.05, inp_max=2.0, d_inp=0.01, time_window=2000)\n\n\nThe model as well as any objects can be saved as:\n\n.. code:: python\n\n\tsave_model_dill(model)\n\tsave_object_dill(PRC, 'PRC')\n\tsave_object_dill(bif, 'bifurcation')\n\n\n\nTo plot the signal, phase response curve, bifurcation...:\n\n.. code:: python\n\n\tfrom matplotlib import pyplot\n\n\tpyplot.plot(signal_forecast[:PLOT_RANGE])\n\tpyplot.show()\n\n\tpyplot.plot(PRC[0], PRC[1])\n\tpyplot.show()\n\n\tpyplot.scatter(bif[0], bif[1], s=1.5)\n\tpyplot.show()\n\n\n\nOther examples are found in :code:`/oscillator_snap/examples/`.\n\n\n\n\n\n\n",
"description_content_type": "",
"docs_url": null,
"download_url": "",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "",
"keywords": "",
"license": "MIT",
"maintainer": "",
"maintainer_email": "",
"name": "oscillator-snap",
"package_url": "https://pypi.org/project/oscillator-snap/",
"platform": "",
"project_url": "https://pypi.org/project/oscillator-snap/",
"project_urls": null,
"release_url": "https://pypi.org/project/oscillator-snap/1.0/",
"requires_dist": [
"tensorflow",
"keras",
"numpy",
"scipy",
"h5py",
"dill"
],
"requires_python": "",
"summary": "Make a snapshot of an oscillator through its time series",
"version": "1.0"
},
"last_serial": 4966441,
"releases": {
"1.0": [
{
"comment_text": "",
"digests": {
"md5": "f7fa1821d98e705de7b256c26321bebd",
"sha256": "27b87af7125bed1a7b308a3eefafec3d761398024359f3e6d4a9270d417d8444"
},
"downloads": -1,
"filename": "oscillator_snap-1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f7fa1821d98e705de7b256c26321bebd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 13111,
"upload_time": "2019-03-21T03:36:07",
"url": "https://files.pythonhosted.org/packages/d3/47/920f30f0c3393132e38da5c1b04bf42073bbd894a22e25e51c0fce2c869e/oscillator_snap-1.0-py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "6dc629aaaa44a20be7027470974cc75d",
"sha256": "fce671ddf6a6e967f834641fc7bed6a7c8eb9d6dbd2a7bf9d18897405e71ae10"
},
"downloads": -1,
"filename": "oscillator_snap-1.0.tar.gz",
"has_sig": false,
"md5_digest": "6dc629aaaa44a20be7027470974cc75d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 13066,
"upload_time": "2019-03-21T03:36:09",
"url": "https://files.pythonhosted.org/packages/02/a2/9383b62a39d44a350b9ebb4abb184d2b7570015213153fc306aa2503e27b/oscillator_snap-1.0.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "f7fa1821d98e705de7b256c26321bebd",
"sha256": "27b87af7125bed1a7b308a3eefafec3d761398024359f3e6d4a9270d417d8444"
},
"downloads": -1,
"filename": "oscillator_snap-1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f7fa1821d98e705de7b256c26321bebd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 13111,
"upload_time": "2019-03-21T03:36:07",
"url": "https://files.pythonhosted.org/packages/d3/47/920f30f0c3393132e38da5c1b04bf42073bbd894a22e25e51c0fce2c869e/oscillator_snap-1.0-py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "6dc629aaaa44a20be7027470974cc75d",
"sha256": "fce671ddf6a6e967f834641fc7bed6a7c8eb9d6dbd2a7bf9d18897405e71ae10"
},
"downloads": -1,
"filename": "oscillator_snap-1.0.tar.gz",
"has_sig": false,
"md5_digest": "6dc629aaaa44a20be7027470974cc75d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 13066,
"upload_time": "2019-03-21T03:36:09",
"url": "https://files.pythonhosted.org/packages/02/a2/9383b62a39d44a350b9ebb4abb184d2b7570015213153fc306aa2503e27b/oscillator_snap-1.0.tar.gz"
}
]
}