{ "info": { "author": "Noam Benelli and Alex Liberzon", "author_email": "alex.liberzon@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7" ], "description": "[![DOI](https://www.zenodo.org/badge/116568819.svg)](https://www.zenodo.org/badge/latestdoi/116568819)\n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/alexliberzonlab/mothpy/master?filepath=notebooks%2Fmothpy_getting_started.ipynb)\n\n# MothPy\n\nThe `mothpy` package is a NumPy based implementation of moth-inspired navigation strategies that uses\n`pompy` library to create the puff, wind and concentration models. See `pompy/Readme.md`\nfor details\n\n## What is this repository for?\n\nThis Python package allows simulation moth-like navigators in dynamic 2D odour\nconcentration fields spread in turbulent flows\n\nLiberzon, Harrington, Daniel, Gurka, Harari and Zilman *\"Moth-inspired navigation algorithm in a turbulent odor plume from a pulsating source\"* proposed a novel navigator principle using properties of a turbulent patchy plume, https://journals.plos.org/plosone/article/comments?id=10.1371/journal.pone.0198422 \n\nIn order to compare this moth-inspired navigator with other navigator types available in the literature, e.g. by Carde and co-workers, we use `pompy` https://github.com/InsectRobotics/pompy and add these moth-inspiried navigators to its simulation fields. We try to create mean wind with meandering and turbulence and vary odor release parameters to test various navigators' statistics, e.g. success rate, flight time, etc. \n\n\n## Installation and requirements\n\n Python 2.7\n Numpy\n Scipy\n Matplotlib\n pompy*\n\nNote: we use an older version of `pompy`, included in the repository. In the future, we would be able to update to a newer version of `pompy` and implement it as a submodule. \n\n## Example usage\n\n```python\n\npython compare_navigators_in_different_wind_conditions.py\n\n```\n\n![Demo flight](img/Demonstration_of_different_navigation_strategies.png)\n\n## How to create figures from the paper\n\n### Set up the navigators (optional)\n\nThe file Casting_competition initiates the navigators to compete in the simulation. Four loops initiate four equal sized groups of navigators, their properties can be changed within these loops - navigation and casting strategies, location, and so on. \nFor more information about navigators check out the models file.\n\n### Set up the wind and plume conditions (optional)\n\nThe file Compare_navigtors... initiates the main loop. For each iteration a new plume and wind model are initiated for the simulation to occur in. The function generate_job dictates the terms of the simulation in terms of wind and plume partameteres. In order to set the simulation enter the required parameters as input for generate_job. For example:\n\n```python\n\nfor i in range(4):\n job_file_name = 'job'+ str(i)+ '.json'\n data_file_name = 'data'+ str(i)+ '.json'\n generate_job(char_time = 3.5, amplitude =0.1, job_file = job_file_name,\n t_max =15, puff_release_rate = 100,\n puff_spread_rate = 0.0001*(1+i),\n dt = 0.01, num_it = 1)\n```\n\nThe only value that changes is the puff spread rate, varying from 0.0001 to 0.0004.\nMake sure that only one variable of the simulation changes with each iteration. Multivaribale changes will create problems later on.\n\n#### Run `comapare_navigators.py`\n\nWhen the file is run the wind and plume paramters that have been set are saved into \"job\" files, one JSON file for each iteration (job0.JSON, job1.JSON...).\n\nThe trajectories of the navigators are saved as \"data\" files, (data0.JSON, data1.JSON), on which the later analyses will be made. \nNotice the following line\n\n```python\n save_plot(job_file_name, data_file_name, title, navigator_titles)\n```\n\nWould save an image per each navigation attempt in the default settings, and that means 800 images. Better if you comment it out `#`. That could supply useful input in some cases.\n\n#### Run `line_graphs.py`\n\nThe file line_graphs plots bar graphs of the four different simulations. It read from the Data and Job files, so those could be replaced and There is no need to set up anything for this file, just run it. The output should look like this:\n\n![Success Percentage vs Puff Spread Rate](img/spVSpsr.png)\n![Average Navigation Time vs Puff Spread Rate](img/spVSpsr.png)\n\n## How to manage and design navigators\n\n### initiating a navigator\n\nLet us look at this example from the casting_competition file:\n\n```python\n navigator1 = models.moth_modular(sim_region, cd['x_start'], cd['y_start'], cd['nav_type'] , cd['cast_type'], cd['wait_type'])\n```\n\nThe navigator is initiated with it is initial `x` and `y` coordinates and the modes of *navigating, casting and waiting*.\n\n### Wait, cast and navigation types\n\nA navigator is an object of the `moth_modular` class. It has an attribute to define each movement type, `wait_type, cast_type, nav_type`.\n\nThe attribute itself can be an integer or a string, it doesn't matter, but it should correlate to a signifier inside of the corresponding function. For example, let's look at the casting function\n\n```python\ndef cast(self,wind_vel_at_pos):\n if self.state != 'cast' :\n #if this is the beginging of a new casting phase\n self.change_direction()\n if self.cast_type == 0:\n self.u=0\n self.v=0\n if self.cast_type == 1:\n self.calculate_wind_angle(wind_vel_at_pos)\n self.u = -self.speed*np.cos(self.gamma+self.wind_angle)\n self.v = self.speed*np.sin(self.gamma+self.wind_angle)\n if self.cast_type == 2:\n #define different betas for different casting patterns\n self.cast2(wind_vel_at_pos)\n```\n\nThe function, like all movement functions, takes as input the parameters of the navigator and the wind velocity at the position (as calculated by the wind model).\nThe first conditional changes the direction of casting from the previous direction. This has nothing to with the cast type. \nThe second, third and fourth conditionals are dependent on the cast type, and use it as an indicator as to how to move. Note that the function can call upon other functions. The stracture of the `wait` and `navigate` are very similar - The function sets the velocity `(u,v)` of the navigator. The actual time step is performed in the update function.\n\n#### Defining new movement types\n\nIn order to create a new waiting, casting or navigation, first enter the models file. For example, let's say we would like to design a new waiting mode. First, we sould define a condition within the waiting function.\n\n```python\ndef wait(self, wind_vel_at_pos):\n if wait_type == 'example wait type':\n```\n\nNow, if the navigator was initiated to so its wait type attribute is 'example wait type' the wait function will be directed into the actions we define under that conditional. Secondly, define the changes in you would like to be made to the velocity of the navigator:\n\n```python\ndef wait(self, wind_vel_at_pos):\n if wait_type == 'example wait type':\n u *= 1.1\n v *= 1.1\n```\n\nThe same approach should be applied to any of the movement functions. After we defined the new condition, we can use it when initiating a new navigator:\n\n```python\n navigator1 = models.moth_modular(sim_region, cd['x_start'], cd['y_start'], cd['nav_type'], cd['cast_type'], 'example wait type')\n```\n\n\n## How to cite this work\n\nPlease use the DOI in the suggested form: \n\nBenneli, N. and Liberzon, A. \"MothPy - a moth-inspired navigator flying in a plume-odor simulation fields\" [![DOI](https://www.zenodo.org/badge/116568819.svg)](https://www.zenodo.org/badge/latestdoi/116568819)\n\n\n## Run the Getting Starting test online: \n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/alexliberzonlab/mothpy/master?filepath=notebooks%2Fmothpy_getting_started.ipynb)\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/alexliberzonlab/mothpy", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "mothpy", "package_url": "https://pypi.org/project/mothpy/", "platform": "", "project_url": "https://pypi.org/project/mothpy/", "project_urls": { "Homepage": "https://github.com/alexliberzonlab/mothpy" }, "release_url": "https://pypi.org/project/mothpy/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "MothPy allows simulation moth-like navigators in dynamic 2D odour concentration fields spread in turbulent flows", "version": "0.0.1" }, "last_serial": 5629054, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "f491677d23141b767426abc19ef6a481", "sha256": "dadbe8df18cb16c4ae9d892835183697d8ce3cb0746f1f16b4b88bac6b44a748" }, "downloads": -1, "filename": "mothpy-0.0.1-py2-none-any.whl", "has_sig": false, "md5_digest": "f491677d23141b767426abc19ef6a481", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 49704, "upload_time": "2019-08-03T20:02:54", "url": "https://files.pythonhosted.org/packages/0b/ad/d5af77a786b65ff91f3936b560247459337247ceb6b3ddc067fec1c1e944/mothpy-0.0.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c16c8e4e4c487552686e92a3ba0b1d0f", "sha256": "3cf71e75842b1b2b1d8422c894e395ac4638a73291b9e2520ead7ffa5425a4fc" }, "downloads": -1, "filename": "mothpy-0.0.1.tar.gz", "has_sig": false, "md5_digest": "c16c8e4e4c487552686e92a3ba0b1d0f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 40173, "upload_time": "2019-08-03T20:02:57", "url": "https://files.pythonhosted.org/packages/f3/b7/f783a64f5dd6e03454738b80b172ea50e1067773aceac1d9256efa8e4c60/mothpy-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f491677d23141b767426abc19ef6a481", "sha256": "dadbe8df18cb16c4ae9d892835183697d8ce3cb0746f1f16b4b88bac6b44a748" }, "downloads": -1, "filename": "mothpy-0.0.1-py2-none-any.whl", "has_sig": false, "md5_digest": "f491677d23141b767426abc19ef6a481", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 49704, "upload_time": "2019-08-03T20:02:54", "url": "https://files.pythonhosted.org/packages/0b/ad/d5af77a786b65ff91f3936b560247459337247ceb6b3ddc067fec1c1e944/mothpy-0.0.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c16c8e4e4c487552686e92a3ba0b1d0f", "sha256": "3cf71e75842b1b2b1d8422c894e395ac4638a73291b9e2520ead7ffa5425a4fc" }, "downloads": -1, "filename": "mothpy-0.0.1.tar.gz", "has_sig": false, "md5_digest": "c16c8e4e4c487552686e92a3ba0b1d0f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 40173, "upload_time": "2019-08-03T20:02:57", "url": "https://files.pythonhosted.org/packages/f3/b7/f783a64f5dd6e03454738b80b172ea50e1067773aceac1d9256efa8e4c60/mothpy-0.0.1.tar.gz" } ] }