{"id":26163839,"url":"https://github.com/xarray-contrib/xarray-simlab","last_synced_at":"2025-04-14T14:41:25.252Z","repository":{"id":53506120,"uuid":"93938479","full_name":"xarray-contrib/xarray-simlab","owner":"xarray-contrib","description":"Xarray extension and framework for computer model simulations","archived":false,"fork":false,"pushed_at":"2021-11-04T16:21:29.000Z","size":22464,"stargazers_count":74,"open_issues_count":29,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-28T03:32:42.108Z","etag":null,"topics":["modelling","python","simulation-framework","xarray"],"latest_commit_sha":null,"homepage":"http://xarray-simlab.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xarray-contrib.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-10T12:44:23.000Z","updated_at":"2025-02-15T01:59:26.000Z","dependencies_parsed_at":"2022-09-19T23:55:11.647Z","dependency_job_id":null,"html_url":"https://github.com/xarray-contrib/xarray-simlab","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xarray-contrib%2Fxarray-simlab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xarray-contrib%2Fxarray-simlab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xarray-contrib%2Fxarray-simlab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xarray-contrib%2Fxarray-simlab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xarray-contrib","download_url":"https://codeload.github.com/xarray-contrib/xarray-simlab/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248898464,"owners_count":21179781,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["modelling","python","simulation-framework","xarray"],"created_at":"2025-03-11T14:53:16.897Z","updated_at":"2025-04-14T14:41:25.221Z","avatar_url":"https://github.com/xarray-contrib.png","language":"Python","readme":"xarray-simlab: xarray extension for computer model simulations\n==============================================================\n\n|Build Status| |Coverage| |Doc Status| |Zenodo|\n\nxarray-simlab is a Python library that provides both a generic\nframework for building computational models in a modular fashion and a\nxarray_ extension for setting and running simulations using the\nxarray's ``Dataset`` structure. It is designed for fast, interactive\nand exploratory modeling.\n\nxarray-simlab is well integrated with other libraries of the PyData\necosystem such as `dask \u003chttps://docs.dask.org\u003e`_ and `zarr\n\u003chttps://zarr.readthedocs.io\u003e`_.\n\n.. _xarray: http://xarray.pydata.org\n.. |Build Status| image:: https://github.com/xarray-contrib/xarray-simlab/workflows/test/badge.svg?branch=master\n   :target: https://github.com/xarray-contrib/xarray-simlab/actions?workflow=test\n   :alt: Build Status\n.. |Coverage| image:: https://codecov.io/gh/xarray-contrib/xarray-simlab/branch/master/graphs/badge.svg?branch=master\n   :target: https://codecov.io/github/xarray-contrib/xarray-simlab?branch=master\n   :alt: Coverage Status\n.. |Doc Status| image:: http://readthedocs.org/projects/xarray-simlab/badge/?version=latest\n   :target: http://xarray-simlab.readthedocs.io/en/latest/?badge=latest\n   :alt: Documentation Status\n.. |Zenodo| image:: https://zenodo.org/badge/93938479.svg\n   :target: https://zenodo.org/badge/latestdoi/93938479\n   :alt: Citation\n\nIn a nutshell\n-------------\n\nThe Conway's Game of Life example shown below is adapted from this\n`blog post \u003chttps://jakevdp.github.io/blog/2013/08/07/conways-game-of-life/\u003e`_\nby Jake VanderPlas.\n\n1. Create new model components by writing compact Python classes,\n   i.e., very much like dataclasses_:\n\n.. code-block:: python\n\n    import numpy as np\n    import xsimlab as xs\n\n    @xs.process\n    class GameOfLife:\n        world = xs.variable(\n            dims=('x', 'y'), intent='inout', encoding={'fill_value': None}\n        )\n\n        def run_step(self):\n            nbrs_count = sum(\n                np.roll(np.roll(self.world, i, 0), j, 1)\n                for i in (-1, 0, 1) for j in (-1, 0, 1)\n                if (i != 0 or j != 0)\n            )\n            self._world_next = (nbrs_count == 3) | (self.world \u0026 (nbrs_count == 2))\n\n        def finalize_step(self):\n            self.world[:] = self._world_next\n\n\n    @xs.process\n    class Glider:\n        pos = xs.variable(dims='point_xy', description='glider position')\n        world = xs.foreign(GameOfLife, 'world', intent='out')\n\n        def initialize(self):\n            x, y = self.pos\n\n            kernel = [[1, 0, 0],\n                      [0, 1, 1],\n                      [1, 1, 0]]\n\n            self.world = np.zeros((10, 10), dtype=bool)\n            self.world[x:x+3, y:y+3] = kernel\n\n2. Create a new model just by providing a dictionary of model components:\n\n.. code-block:: python\n\n    model = xs.Model({'gol': GameOfLife,\n                      'init': Glider})\n\n3. Create an input ``xarray.Dataset``, run the model and get an output\n   ``xarray.Dataset``:\n\n.. code-block:: python\n\n    input_dataset = xs.create_setup(\n        model=model,\n        clocks={'step': np.arange(9)},\n        input_vars={'init__pos': ('point_xy', [4, 5])},\n        output_vars={'gol__world': 'step'}\n    )\n\n    output_dataset = input_dataset.xsimlab.run(model=model)\n\n.. code-block:: python\n\n    \u003e\u003e\u003e output_dataset\n    \u003cxarray.Dataset\u003e\n    Dimensions:     (point_xy: 2, step: 9, x: 10, y: 10)\n    Coordinates:\n      * step        (step) int64 0 1 2 3 4 5 6 7 8\n    Dimensions without coordinates: point_xy, x, y\n    Data variables:\n        init__pos   (point_xy) int64 4 5\n        gol__world  (step, x, y) bool False False False False ... False False False\n\n4. Perform model setup, pre-processing, run, post-processing and\n   visualization in a functional style, using method chaining:\n\n.. code-block:: python\n\n    import matplotlib.pyplot as plt\n\n    with model:\n        (input_dataset\n         .xsimlab.update_vars(\n             input_vars={'init__pos': ('point_xy', [2, 2])}\n         )\n         .xsimlab.run()\n         .gol__world.plot.imshow(\n             col='step', col_wrap=3, figsize=(5, 5),\n             xticks=[], yticks=[],\n             add_colorbar=False, cmap=plt.cm.binary)\n        )\n\n.. image:: doc/_static/gol.png\n   :width: 400px\n\n.. _dataclasses: https://docs.python.org/3/library/dataclasses.html\n\nDocumentation\n-------------\n\nDocumentation is hosted on ReadTheDocs:\nhttp://xarray-simlab.readthedocs.io\n\nLicense\n-------\n\n3-clause (\"Modified\" or \"New\") BSD license,\nsee `License file \u003chttps://github.com/xarray-contrib/xarray-simlab/blob/master/LICENSE\u003e`__.\n\nxarray-simlab uses short parts of the code of the xarray_, pandas_ and\ndask_ libraries. Their licenses are reproduced in the \"licenses\"\ndirectory.\n\n.. _pandas: http://pandas.pydata.org/\n\nAcknowledgment\n--------------\n\nThis project is supported by the `Earth Surface Process Modelling`_\ngroup of the GFZ Helmholtz Centre Potsdam.\n\n.. _`Earth Surface Process Modelling`: http://www.gfz-potsdam.de/en/section/earth-surface-process-modelling/\n\nCitation\n--------\n\nIf you use xarray-simlab in a scientific publication, we would\nappreciate a `citation`_.\n\n.. _`citation`: http://xarray-simlab.readthedocs.io/en/latest/citation.html\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxarray-contrib%2Fxarray-simlab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxarray-contrib%2Fxarray-simlab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxarray-contrib%2Fxarray-simlab/lists"}