Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • 698042a
  • /
  • notebooks
  • /
  • simulators
  • /
  • simulators.ipynb
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:2942d91caf0abbe59d9bb94339930e1e808ec4e1
directory badge Iframe embedding
swh:1:dir:3b4becb9805f5d7f3655fb7047f85f35d2277fa1

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
simulators.ipynb
{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "__Simulators__\n",
        "\n",
        "These scripts simulate the 1D Gaussian datasets used to demonstrate model-fitting."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "%matplotlib inline\n",
        "from pyprojroot import here\n",
        "workspace_path = str(here())\n",
        "%cd $workspace_path\n",
        "print(f\"Working Directory has been set to `{workspace_path}`\")\n",
        "\n",
        "import util\n",
        "from os import path\n",
        "\n",
        "import autofit as af"
      ],
      "outputs": [],
      "execution_count": null
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "__Gaussian x1__"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "dataset_path = path.join(\"dataset\", \"example_1d\", \"gaussian_x1\")\n",
        "gaussian = af.ex.Gaussian(centre=50.0, normalization=25.0, sigma=10.0)\n",
        "util.simulate_dataset_1d_via_gaussian_from(gaussian=gaussian, dataset_path=dataset_path)"
      ],
      "outputs": [],
      "execution_count": null
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "__Gaussian x1 (0)__"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "dataset_path = path.join(\"dataset\", \"example_1d\", \"gaussian_x1_0\")\n",
        "gaussian = af.ex.Gaussian(centre=50.0, normalization=25.0, sigma=1.0)\n",
        "util.simulate_dataset_1d_via_gaussian_from(gaussian=gaussian, dataset_path=dataset_path)"
      ],
      "outputs": [],
      "execution_count": null
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "__Gaussian x1 (1)__"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "gaussian = af.ex.Gaussian(centre=50.0, normalization=25.0, sigma=5.0)\n",
        "dataset_path = path.join(\"dataset\", \"example_1d\", \"gaussian_x1_1\")\n",
        "util.simulate_dataset_1d_via_gaussian_from(gaussian=gaussian, dataset_path=dataset_path)"
      ],
      "outputs": [],
      "execution_count": null
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "__Gaussian x1 (2)__"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "gaussian = af.ex.Gaussian(centre=50.0, normalization=25.0, sigma=10.0)\n",
        "dataset_path = path.join(\"dataset\", \"example_1d\", \"gaussian_x1_2\")\n",
        "util.simulate_dataset_1d_via_gaussian_from(gaussian=gaussian, dataset_path=dataset_path)"
      ],
      "outputs": [],
      "execution_count": null
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "__Gaussian x1 (Identical 0)__"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "dataset_path = path.join(\"dataset\", \"example_1d\", \"gaussian_x1_identical_0\")\n",
        "gaussian = af.ex.Gaussian(centre=50.0, normalization=25.0, sigma=10.0)\n",
        "util.simulate_dataset_1d_via_gaussian_from(gaussian=gaussian, dataset_path=dataset_path)"
      ],
      "outputs": [],
      "execution_count": null
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "__Gaussian x1 (Identical 1)__"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "dataset_path = path.join(\"dataset\", \"example_1d\", \"gaussian_x1_identical_1\")\n",
        "gaussian = af.ex.Gaussian(centre=50.0, normalization=25.0, sigma=10.0)\n",
        "util.simulate_dataset_1d_via_gaussian_from(gaussian=gaussian, dataset_path=dataset_path)"
      ],
      "outputs": [],
      "execution_count": null
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "__Gaussian x1 (Identical 2)__"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "dataset_path = path.join(\"dataset\", \"example_1d\", \"gaussian_x1_identical_2\")\n",
        "gaussian = af.ex.Gaussian(centre=50.0, normalization=25.0, sigma=10.0)\n",
        "util.simulate_dataset_1d_via_gaussian_from(gaussian=gaussian, dataset_path=dataset_path)"
      ],
      "outputs": [],
      "execution_count": null
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "__Gaussian x1 + Exponential x1__"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "gaussian = af.ex.Gaussian(centre=50.0, normalization=25.0, sigma=10.0)\n",
        "exponential = af.ex.Exponential(centre=50.0, normalization=40.0, rate=0.05)\n",
        "dataset_path = path.join(\"dataset\", \"example_1d\", \"gaussian_x1__exponential_x1\")\n",
        "util.simulate_dataset_1d_via_profile_1d_list_from(\n",
        "    profile_1d_list=[gaussian, exponential], dataset_path=dataset_path\n",
        ")"
      ],
      "outputs": [],
      "execution_count": null
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "__Gaussian x2 + Exponential x1__"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "gaussian_0 = af.ex.Gaussian(centre=50.0, normalization=25.0, sigma=10.0)\n",
        "gaussian_1 = af.ex.Gaussian(centre=20.0, normalization=30.0, sigma=5.0)\n",
        "exponential = af.ex.Exponential(centre=70.0, normalization=40.0, rate=0.005)\n",
        "dataset_path = path.join(\"dataset\", \"example_1d\", \"gaussian_x2__exponential_x1\")\n",
        "util.simulate_dataset_1d_via_profile_1d_list_from(\n",
        "    profile_1d_list=[gaussian_0, gaussian_1, exponential], dataset_path=dataset_path\n",
        ")"
      ],
      "outputs": [],
      "execution_count": null
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "__Gaussian x2__"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "gaussian_0 = af.ex.Gaussian(centre=50.0, normalization=20.0, sigma=1.0)\n",
        "gaussian_1 = af.ex.Gaussian(centre=50.0, normalization=40.0, sigma=5.0)\n",
        "dataset_path = path.join(\"dataset\", \"example_1d\", \"gaussian_x2\")\n",
        "util.simulate_dataset_1d_via_profile_1d_list_from(\n",
        "    profile_1d_list=[gaussian_0, gaussian_1], dataset_path=dataset_path\n",
        ")"
      ],
      "outputs": [],
      "execution_count": null
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "__Gaussian x3__"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "gaussian_0 = af.ex.Gaussian(centre=50.0, normalization=20.0, sigma=1.0)\n",
        "gaussian_1 = af.ex.Gaussian(centre=50.0, normalization=40.0, sigma=5.0)\n",
        "gaussian_2 = af.ex.Gaussian(centre=50.0, normalization=60.0, sigma=10.0)\n",
        "dataset_path = path.join(\"dataset\", \"example_1d\", \"gaussian_x3\")\n",
        "util.simulate_dataset_1d_via_profile_1d_list_from(\n",
        "    profile_1d_list=[gaussian_0, gaussian_1, gaussian_2], dataset_path=dataset_path\n",
        ")"
      ],
      "outputs": [],
      "execution_count": null
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "__Gaussian x1 unconvolved__"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "dataset_path = path.join(\"dataset\", \"example_1d\", \"gaussian_x1_unconvolved\")\n",
        "gaussian = af.ex.Gaussian(centre=50.0, normalization=25.0, sigma=3.0)\n",
        "util.simulate_dataset_1d_via_gaussian_from(gaussian=gaussian, dataset_path=dataset_path)"
      ],
      "outputs": [],
      "execution_count": null
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "__Gaussian x1 convolved__"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "dataset_path = path.join(\"dataset\", \"example_1d\", \"gaussian_x1_convolved\")\n",
        "gaussian = af.ex.Gaussian(centre=50.0, normalization=25.0, sigma=3.0)\n",
        "util.simulate_data_1d_with_kernel_via_gaussian_from(\n",
        "    gaussian=gaussian, dataset_path=dataset_path\n",
        ")"
      ],
      "outputs": [],
      "execution_count": null
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "__Gaussian x1 with feature__"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "dataset_path = path.join(\"dataset\", \"example_1d\", \"gaussian_x1_with_feature\")\n",
        "gaussian = af.ex.Gaussian(centre=50.0, normalization=25.0, sigma=10.0)\n",
        "gaussian_feature = af.ex.Gaussian(centre=70.0, normalization=0.3, sigma=0.5)\n",
        "util.simulate_dataset_1d_via_profile_1d_list_from(\n",
        "    profile_1d_list=[gaussian, gaussian_feature], dataset_path=dataset_path\n",
        ")"
      ],
      "outputs": [],
      "execution_count": null
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "__Gaussian x2 split__"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "dataset_path = path.join(\"dataset\", \"example_1d\", \"gaussian_x2_split\")\n",
        "gaussian_0 = af.ex.Gaussian(centre=25.0, normalization=50.0, sigma=12.5)\n",
        "gaussian_1 = af.ex.Gaussian(centre=75.0, normalization=50.0, sigma=12.5)\n",
        "util.simulate_dataset_1d_via_profile_1d_list_from(\n",
        "    profile_1d_list=[gaussian_0, gaussian_1], dataset_path=dataset_path\n",
        ")\n"
      ],
      "outputs": [],
      "execution_count": null
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "__Gaussian x1 time__"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "dataset_path = path.join(\"dataset\", \"example_1d\", \"gaussian_x1_variable\", \"sigma_0\")\n",
        "gaussian = af.ex.Gaussian(centre=50.0, normalization=50.0, sigma=30.0)\n",
        "util.simulate_dataset_1d_via_gaussian_from(gaussian=gaussian, dataset_path=dataset_path)\n",
        "\n",
        "dataset_path = path.join(\"dataset\", \"example_1d\", \"gaussian_x1_variable\", \"sigma_1\")\n",
        "gaussian = af.ex.Gaussian(centre=50.0, normalization=50.0, sigma=20.0)\n",
        "util.simulate_dataset_1d_via_gaussian_from(gaussian=gaussian, dataset_path=dataset_path)\n",
        "\n",
        "dataset_path = path.join(\"dataset\", \"example_1d\", \"gaussian_x1_variable\", \"sigma_2\")\n",
        "gaussian = af.ex.Gaussian(centre=50.0, normalization=50.0, sigma=10.0)\n",
        "util.simulate_dataset_1d_via_gaussian_from(gaussian=gaussian, dataset_path=dataset_path)\n",
        "# %%\n",
        "'''\n",
        "Finish.\n",
        "'''"
      ],
      "outputs": [],
      "execution_count": null
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [],
      "outputs": [],
      "execution_count": null
    }
  ],
  "metadata": {
    "anaconda-cloud": {},
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.6.1"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 4
}

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API