# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['visnet1d']

package_data = \
{'': ['*']}

install_requires = \
['dash>=2.3.1,<3.0.0',
 'numpy>=1.22.3,<2.0.0',
 'pandas>=1.4.2,<2.0.0',
 'pillow>=9.4.0,<10.0.0',
 'plotly>=5.7.0,<6.0.0']

setup_kwargs = {
    'name': 'visnet1d',
    'version': '0.1.4',
    'description': 'A visualation tool for 1D networks',
    'long_description': '# VisNet1D\n\nA simple visualisation tool for 1D networks. \n\n![An image of visnet1d](visnet1d.png)\n\n## Installation\n\n### Use in your project\n\nPython Package Index (PIP):\n```\npip install visnet1d\n```\n\nPoetry:\n```\npoetry add visnet1d\n```\n\n### Use the development version\n\nGit:\n```\ngit clone git@gitlab.com:abdrysdale/visnet1d.git\nnix-shell\npoetry install\npoetry shell\n```\n\nInstallation instructions for `nix` can be obtained from [here](https://nixos.org/download.html).\nIf you don\'t have and don\'t want to install nix, it is sufficient to just install poetry and skip the `nix-shell` command.\nPoetry installation instructions can be obtained from [here](https://python-poetry.org/).\n\n### Just want to run the examples?\n\nIf you just want to run one of the examples, such as the vessel network example:\n```\npip install visnet1d\ngit clone git@gitlab.com:abdrysdale/visnet1d.git\ncd visnet1d\n```\n\nThe run the desired example script with:\n```\npython examples/vessel_network.py\n```\nNaturally replacing `vessel_network.py` with any of the other examples.\nNext, go to `http://127.0.0.1:8050` in your browser and start exploring!\n\n\n## Usage\n\nVisNet1D is intended to be used to visualise signals across a 1-dimensional network at potentially multiple locations.\nIt can either be used to explore an output of an other function, viewing signal(s) at different locations and comparing the results or it can be used to visualise the change in a function output due to a change in inputs.\n\nAn example usage is shown below:\n\nFirst import the library:\n```python\nimport visnet1d\n```\n\n\nNow we define a simple function that takes a spatial argument along with other keyword arguments.\nThis function returns y as a function of t at some spatial point x.\nIt must return two vectors to be compatible with the default plotting function.\nBut don\'t worry! You can define your own plotting functions - we\'ll get to that later.\n```python\ndef foobar(x, tmax=1, a=2, b=3):\n    t = np.linspace(0, tmax, 100)\n    y = a * np.sin(x + 2 * np.pi * t / b)\n    return y, t\n```\n\nHere we define a list for the function input arguments.\nThese are used to display the inputs on the web-page and pass the results to the function `foobar`.\n```python\ninput_dict_list = [\n    {\n        "name" : "Amplitude",   # Name to be displayed on the web app.\n        "id" : "a",             # Internal id and keyword argument for the function (foobar).\n        "value" : 1,            # Initial value.\n        "type" : "number",      # Used by Dash to determine the input type.\n    },\n    {\n        "name" : "Period",\n        "id" : "b",\n        "value" : 2,\n        "type" : "number",\n    },\n    {\n        "name" : "Maximum t",\n        "id" : "tmax",\n        "value": 1,\n        "type" : "number",\n    },\n]\n```\nThe allowed types that dash input accepts can be found [here](https://dash.plotly.com/dash-core-components/input).\n\nNext we need to define the boundaries that separate locations.\nTo illustrate this, let\'s consider two vessels connected in series:\n```python\nboundaries = {     # Locations can be selected from a drop-down menu\n        "Vessel 1" : [0, np.pi],          # [Start, End]\n        "Vessel 2" : [np.pi, 3 * np.pi],  \n}\n```\n\nNow we create a site object and run the site.\n```python\nsite = visnet1d.Site(\n        foobar,             # Function to plot.\n        boundaries,         # Locations to select.\n        input_dict_list,    # List of function inputs (each input has it\'s own dictionary).\n        xlab="Time (s)",    # X-axis label\n        ylab="Response",    # Y-axis label\n        title="My title",   # Title\n)\n\n# Runs the server with the default arguments - same as site.run()\nsite.run(host="127.0.0.1", port="8050", debug=False)\n```\nGo to `127.0.0.1:8050` on your web browser view the webapp.\n\n### Custom plots\n\nCustom plot functions can be utilised using the `plot` keyword argument for the visnet1d.Site class.\nE.g.\n\n```python\nsite = visnet.Site(\n    my_function,\n    my_boundaries,\n    my_input_dictionary_list,\n    plot=my_custom_plot_function, # <- This is how you pass your custom plot function.\n)\n```\n\nA few things to note about writing custom plotting functions:\n\n- The function must take the Site object as the **only** input argument.\n- The function must return a plotly figure.\n\nA few notable attributes of the Site class:\n\n- `site.function_kwargs` : Is a list of dictionaries of the inputs defined by the `input_dict_list` argument.\n    These are the values that you can change in the inputs section in the webapp.\n- `site.boundaries` : The boundaries defined by the `boundaries` argument.\n- `site.loc_slider_vals` : A dictionary of all of the slider positions for all of the previously selected locations.\n    The dictionary is of the format `location` : `value`. Where location is the location key used in the `boundaries` argument and `value` is the value of the slider.\n- `site.loc_keys` : A list of the locations currently selected. Where each location is the key used in the `boundaries argument.`\n- `site.x` : The current position of the active slider.\n\n### Exploring a static output\n\nBy default, VisNet1D evaluates the function each time an input is changed.\nFor a very expensive function this isn\'t ideal.\nMoreover, there might be use case whereby the outputs of very complicated network have been produced by some other expensive function and you just wish to use VisNet1D to explore the output.\n\nHere\'s how you\'d do something like that:\n```python\nmy_outputs = visnet1d.get_static_function(out_mat, t, axis=0)\n```\nFirst use the inbuilt function `get_static_function()` to handle static outputs.\nThis function needs to be passed the 2D output matrix and the value for the x-axis.\nThe output matrix might be something like a signal as a function of space and time.\n\nMoreover, as the outputs are static there are no function inputs so we can do away with the `input_dict_list` argument.\nThis is done like so:\n```python\nsite = visnet.Site(\n    my_outputs,\n    my_boundaries,\n    input_dict_list=None,\n)\n```\n\n### Customising plots\n\nBy default all the plots are editable and you can pass the x axis label, y axis label and title into the site object with the following:\n```python\nsite = visnet.Site(\n    my_function,\n    my_boundaries,\n    my_input_dictionary_list,\n    xlab=my_x_label,\n    ylab=my_y_label,\n    title=my_title,\n)\n```\n\nMoreover, the width of the graph itself can be controlled by using:\n```python\nsite = visnet.Site(\n    my_function,\n    my_boundaries,\n    my_input_dictionary_list,\n    gwidth=80, # This sets the width of the graph to be 80% of the screen width.\n)\n\n```\n\nIt is also possible to display an optional image underneath the input section to aid network visualisation:\n```python\nsite = visnet.Site(\n    my_function,\n    my_boundaries,\n    my_input_dictionary_list,\n    image=\'path/to/my/image.png\'    # Any Pillow supported image format can be used\n    iheight=80,                     # Adjusts the image height to be 80% of the screen height.\n)\n```\n\n## Examples\n\nFor full examples see the [examples/](examples/) directory.\n\n## Contributing\n\n- For contributing guidelines see [CONTRIBUTING](CONTRIBUTING.md).\n',
    'author': 'Alex',
    'author_email': 'adrysdale@protonmail.com',
    'maintainer': 'None',
    'maintainer_email': 'None',
    'url': 'https://gitlab.com/abdrysdale/visnet1d',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.10,<4.0',
}


setup(**setup_kwargs)
