bilby.cython


Namebilby.cython JSON
Version 0.5.3 PyPI version JSON
download
home_pageNone
SummaryOptimized functionality for Bilby
upload_time2024-08-23 15:22:14
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![pipeline status](https://git.ligo.org/colm.talbot/bilby-cython/badges/main/pipeline.svg)](https://git.ligo.org/colm.talbot/bilby-cython/-/commits/main)
[![coverage report](https://git.ligo.org/colm.talbot/bilby-cython/badges/main/coverage.svg)](https://git.ligo.org/colm.talbot/bilby-cython/-/commits/main)
[![Latest Release](https://git.ligo.org/colm.talbot/bilby-cython/-/badges/release.svg)](https://git.ligo.org/colm.talbot/bilby-cython/-/releases)
[![Conda Forge](https://anaconda.org/conda-forge/bilby.cython/badges/version.svg)](https://anaconda.org/conda-forge/bilby.cython)
[![License](https://anaconda.org/conda-forge/bilby.cython/badges/license.svg)](https://anaconda.org/conda-forge/bilby.cython)

# bilby-cython

Optimized `cython` implementations of specific `Bilby` operations.

For very fast waveform models, computing the antenna response and time delays
uses a significant amount of run time, see, e.g., [this issue](https://git.ligo.org/lscsoft/bilby/-/issues/576).

This repo provides optimized `cython` implementations of the existing `Python`
functions.
Most of the speed up comes from leveraging the fact that these are operations
of 3-element vectors.

## Installation

`bilby.cython` is available through `conda-forge` and `pypi` and can be installed with either of the following

```console
$ conda install -c conda-forge bilby.cython
$ python -m pip install bilby.cython
```

There are prebuilt versions for many architectures/OSs, however, non-standard systems will require a version of `Cython` to build from the source with

## Usage

In order to use the functions implemented here you can import them from the
`bilby.cython package`
```python
from bilby_cython import geometry
geometry.get_polarization_tensor(ra=0.0, dec=0.0, time=0.0, psi=0.0, mode="plus")
```

## Ported functions

- `time_delay_geocentric`: calculating time delays between two interferometers
- `get_polarization_tensor`: calculation of polarization tensors
- `three_by_three_matrix_contraction`: rojecting polarization tensors against
   detector response tensors
- `calculate_arm`: calculate an interferometer arm vector
- `zenith_azimuth_to_theta_phi`: rotating the reference from from
   detector-based coordinates to celestial

## New functions

- `time_delay_from_geocenter`: calculate the time delay between an
   interferometer and the geocenter. This removes an array allocation that was
   slow for some reason.
- `get_polarization_tensor_multiple_modes`: compute multiple polarization
   tensors in a single function call. This reduces the overheads per call.

## Testing

`test/test_geometry.py` verifies that the new functions agree with the old
versions at sufficient precision.
The old code is deliberately copied from the current `Bilby` to enable testing
after `Bilby` switches to use this code.

## Timing

This is the output of `test/timing.py` when run on a 2020 M1 MacBook Pro.
The new functions are `5-40x` faster than the old versions.
These times are comparable with the lal` equivalents with greater flexibility.

```
Timing time delay calculation over 10000 trials.
Cython time: 2.366e-06
Numpy time: 1.026e-05
Timing polarization tensor calculation over 1000 trials.
Cython time: 2.470e-06
Numpy time: 4.247e-05
Timing two mode polarization tensor calculation over 1000 trials.
Cython time: 1.790e-06
Numpy time: 2.907e-05
Timing six mode polarization tensor calculation over 1000 trials.
Cython time: 1.250e-06
Numpy time: 4.111e-05
Timing antenna response calculation over 1000 trials.
Cython time: 4.269e-06
Numpy time: 4.709e-05
Timing frame conversion calculation over 1000 trials.
Cython time: 2.516e-06
Numpy time: 2.243e-05
```

Profiling the standard `Bilby` `fast_tutorial.py` example for a very fast
waveform model reduces the amount of time spent computing the antenna response
from 16% to 3% and computing time delays from 3% to 1%.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "bilby.cython",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Colm Talbot <colm.talbot@ligo.org>",
    "download_url": "https://files.pythonhosted.org/packages/4c/93/6877dd78b375f3e83c8209aecc18f18d1cd88269a8a5c2d3c7dd9ad4fc53/bilby_cython-0.5.3.tar.gz",
    "platform": null,
    "description": "[![pipeline status](https://git.ligo.org/colm.talbot/bilby-cython/badges/main/pipeline.svg)](https://git.ligo.org/colm.talbot/bilby-cython/-/commits/main)\n[![coverage report](https://git.ligo.org/colm.talbot/bilby-cython/badges/main/coverage.svg)](https://git.ligo.org/colm.talbot/bilby-cython/-/commits/main)\n[![Latest Release](https://git.ligo.org/colm.talbot/bilby-cython/-/badges/release.svg)](https://git.ligo.org/colm.talbot/bilby-cython/-/releases)\n[![Conda Forge](https://anaconda.org/conda-forge/bilby.cython/badges/version.svg)](https://anaconda.org/conda-forge/bilby.cython)\n[![License](https://anaconda.org/conda-forge/bilby.cython/badges/license.svg)](https://anaconda.org/conda-forge/bilby.cython)\n\n# bilby-cython\n\nOptimized `cython` implementations of specific `Bilby` operations.\n\nFor very fast waveform models, computing the antenna response and time delays\nuses a significant amount of run time, see, e.g., [this issue](https://git.ligo.org/lscsoft/bilby/-/issues/576).\n\nThis repo provides optimized `cython` implementations of the existing `Python`\nfunctions.\nMost of the speed up comes from leveraging the fact that these are operations\nof 3-element vectors.\n\n## Installation\n\n`bilby.cython` is available through `conda-forge` and `pypi` and can be installed with either of the following\n\n```console\n$ conda install -c conda-forge bilby.cython\n$ python -m pip install bilby.cython\n```\n\nThere are prebuilt versions for many architectures/OSs, however, non-standard systems will require a version of `Cython` to build from the source with\n\n## Usage\n\nIn order to use the functions implemented here you can import them from the\n`bilby.cython package`\n```python\nfrom bilby_cython import geometry\ngeometry.get_polarization_tensor(ra=0.0, dec=0.0, time=0.0, psi=0.0, mode=\"plus\")\n```\n\n## Ported functions\n\n- `time_delay_geocentric`: calculating time delays between two interferometers\n- `get_polarization_tensor`: calculation of polarization tensors\n- `three_by_three_matrix_contraction`: rojecting polarization tensors against\n   detector response tensors\n- `calculate_arm`: calculate an interferometer arm vector\n- `zenith_azimuth_to_theta_phi`: rotating the reference from from\n   detector-based coordinates to celestial\n\n## New functions\n\n- `time_delay_from_geocenter`: calculate the time delay between an\n   interferometer and the geocenter. This removes an array allocation that was\n   slow for some reason.\n- `get_polarization_tensor_multiple_modes`: compute multiple polarization\n   tensors in a single function call. This reduces the overheads per call.\n\n## Testing\n\n`test/test_geometry.py` verifies that the new functions agree with the old\nversions at sufficient precision.\nThe old code is deliberately copied from the current `Bilby` to enable testing\nafter `Bilby` switches to use this code.\n\n## Timing\n\nThis is the output of `test/timing.py` when run on a 2020 M1 MacBook Pro.\nThe new functions are `5-40x` faster than the old versions.\nThese times are comparable with the lal` equivalents with greater flexibility.\n\n```\nTiming time delay calculation over 10000 trials.\nCython time: 2.366e-06\nNumpy time: 1.026e-05\nTiming polarization tensor calculation over 1000 trials.\nCython time: 2.470e-06\nNumpy time: 4.247e-05\nTiming two mode polarization tensor calculation over 1000 trials.\nCython time: 1.790e-06\nNumpy time: 2.907e-05\nTiming six mode polarization tensor calculation over 1000 trials.\nCython time: 1.250e-06\nNumpy time: 4.111e-05\nTiming antenna response calculation over 1000 trials.\nCython time: 4.269e-06\nNumpy time: 4.709e-05\nTiming frame conversion calculation over 1000 trials.\nCython time: 2.516e-06\nNumpy time: 2.243e-05\n```\n\nProfiling the standard `Bilby` `fast_tutorial.py` example for a very fast\nwaveform model reduces the amount of time spent computing the antenna response\nfrom 16% to 3% and computing time delays from 3% to 1%.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Optimized functionality for Bilby",
    "version": "0.5.3",
    "project_urls": {
        "Homepage": "https://git.ligo.org/colm.talbot/bilby-cython"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8ee724a4d73fcee5e828b5819466ee8d5c7310119c3b08122a033ba6fe99d80e",
                "md5": "35e182e2a5138d544d77368a75dfc6d6",
                "sha256": "27a34164fbaf140f89e0e0e395c6ea3ae5e57209c07c7c717c4385fecb9dd398"
            },
            "downloads": -1,
            "filename": "bilby.cython-0.5.3-cp310-cp310-macosx_12_0_x86_64.whl",
            "has_sig": false,
            "md5_digest": "35e182e2a5138d544d77368a75dfc6d6",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.9",
            "size": 351950,
            "upload_time": "2024-08-23T15:21:59",
            "upload_time_iso_8601": "2024-08-23T15:21:59.038909Z",
            "url": "https://files.pythonhosted.org/packages/8e/e7/24a4d73fcee5e828b5819466ee8d5c7310119c3b08122a033ba6fe99d80e/bilby.cython-0.5.3-cp310-cp310-macosx_12_0_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0066aaf5ebb0467f0a3cd760aaefd5789a474785675717f7a9c18918d65556ec",
                "md5": "0b40753d20aa94974a82786ceb2fa1ba",
                "sha256": "0f72f2865d4a01cb241c400efe4764e85194fe43f362061778f291498f0538df"
            },
            "downloads": -1,
            "filename": "bilby.cython-0.5.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "0b40753d20aa94974a82786ceb2fa1ba",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.9",
            "size": 940117,
            "upload_time": "2024-08-23T15:22:01",
            "upload_time_iso_8601": "2024-08-23T15:22:01.082675Z",
            "url": "https://files.pythonhosted.org/packages/00/66/aaf5ebb0467f0a3cd760aaefd5789a474785675717f7a9c18918d65556ec/bilby.cython-0.5.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dec13799f4bd0e5a13375b621f21d12fd21e596d744b363e683f815afe593f1f",
                "md5": "410f7782875ac99fcadc46e6b36ceef5",
                "sha256": "813f2b53a55b0fbbc2a86ef9c025e3020eb086473663c110161e3b120728176d"
            },
            "downloads": -1,
            "filename": "bilby.cython-0.5.3-cp311-cp311-macosx_12_0_x86_64.whl",
            "has_sig": false,
            "md5_digest": "410f7782875ac99fcadc46e6b36ceef5",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.9",
            "size": 352052,
            "upload_time": "2024-08-23T15:22:03",
            "upload_time_iso_8601": "2024-08-23T15:22:03.209307Z",
            "url": "https://files.pythonhosted.org/packages/de/c1/3799f4bd0e5a13375b621f21d12fd21e596d744b363e683f815afe593f1f/bilby.cython-0.5.3-cp311-cp311-macosx_12_0_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e46a78511b5e08ed89f492297746e3f488159d90e2b89680777a3a37565916eb",
                "md5": "714cf5614bc2cee6efb0e071d8630439",
                "sha256": "4642cb38f2cea8129261e25fe4237e2c06982753ef3ce2611072e541b7ecf6fb"
            },
            "downloads": -1,
            "filename": "bilby.cython-0.5.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "714cf5614bc2cee6efb0e071d8630439",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.9",
            "size": 983911,
            "upload_time": "2024-08-23T15:22:05",
            "upload_time_iso_8601": "2024-08-23T15:22:05.699971Z",
            "url": "https://files.pythonhosted.org/packages/e4/6a/78511b5e08ed89f492297746e3f488159d90e2b89680777a3a37565916eb/bilby.cython-0.5.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8bc5ad5ca082b2610defc488679690df8137300c6bb396b24f783e3d74873fa4",
                "md5": "b3cd46c7e1d313bca6dc0b81a54f94ba",
                "sha256": "264ccd8ca1adabc794931ed6deb5082ad0ed4b52694be8158cb421a80a752bca"
            },
            "downloads": -1,
            "filename": "bilby.cython-0.5.3-cp312-cp312-macosx_12_0_x86_64.whl",
            "has_sig": false,
            "md5_digest": "b3cd46c7e1d313bca6dc0b81a54f94ba",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.9",
            "size": 351851,
            "upload_time": "2024-08-23T15:22:07",
            "upload_time_iso_8601": "2024-08-23T15:22:07.895094Z",
            "url": "https://files.pythonhosted.org/packages/8b/c5/ad5ca082b2610defc488679690df8137300c6bb396b24f783e3d74873fa4/bilby.cython-0.5.3-cp312-cp312-macosx_12_0_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1326f0b46d56d278665b484ec421dc571fb28bdd81635137d00e0edc2c8fddc9",
                "md5": "23ecd7c1c2ffbc8bea4b2914e47599fc",
                "sha256": "44e5e381c2861e26a4e1fd5c591ea0c3c9a0e2f0d8c78f28f8704abf2945cd8d"
            },
            "downloads": -1,
            "filename": "bilby.cython-0.5.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "23ecd7c1c2ffbc8bea4b2914e47599fc",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.9",
            "size": 1014120,
            "upload_time": "2024-08-23T15:22:09",
            "upload_time_iso_8601": "2024-08-23T15:22:09.942374Z",
            "url": "https://files.pythonhosted.org/packages/13/26/f0b46d56d278665b484ec421dc571fb28bdd81635137d00e0edc2c8fddc9/bilby.cython-0.5.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b26b04b2603b7dcb568b58b405a22a4968f34d3160ba1c88999ce6d7a978d4d4",
                "md5": "6b558265110ae88a7be502d3c47cc644",
                "sha256": "fe54b36fdbad53ce9bb0214c96f2f146ec5d963f2eb00aadb1e2df21215772c8"
            },
            "downloads": -1,
            "filename": "bilby.cython-0.5.3-cp39-cp39-macosx_12_0_x86_64.whl",
            "has_sig": false,
            "md5_digest": "6b558265110ae88a7be502d3c47cc644",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.9",
            "size": 352560,
            "upload_time": "2024-08-23T15:22:11",
            "upload_time_iso_8601": "2024-08-23T15:22:11.804946Z",
            "url": "https://files.pythonhosted.org/packages/b2/6b/04b2603b7dcb568b58b405a22a4968f34d3160ba1c88999ce6d7a978d4d4/bilby.cython-0.5.3-cp39-cp39-macosx_12_0_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4f23663c80a2b36627ac502838a24d0391bd0fd89ec45d1c8e13a6ae977762d9",
                "md5": "d449c5d3a17d3e821dcde68212840cab",
                "sha256": "54f48f2fc55c01a278c2ffcfcc0c9169792976d87425dbc891580751e5f00932"
            },
            "downloads": -1,
            "filename": "bilby.cython-0.5.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "d449c5d3a17d3e821dcde68212840cab",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.9",
            "size": 942157,
            "upload_time": "2024-08-23T15:22:13",
            "upload_time_iso_8601": "2024-08-23T15:22:13.343396Z",
            "url": "https://files.pythonhosted.org/packages/4f/23/663c80a2b36627ac502838a24d0391bd0fd89ec45d1c8e13a6ae977762d9/bilby.cython-0.5.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4c936877dd78b375f3e83c8209aecc18f18d1cd88269a8a5c2d3c7dd9ad4fc53",
                "md5": "4e6421d21f92dfaec84aa5365ce45628",
                "sha256": "44400b2abc6fa592b13d69f33460cb156d6edb48a783f5539ee0a21e1d0a3508"
            },
            "downloads": -1,
            "filename": "bilby_cython-0.5.3.tar.gz",
            "has_sig": false,
            "md5_digest": "4e6421d21f92dfaec84aa5365ce45628",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 238517,
            "upload_time": "2024-08-23T15:22:14",
            "upload_time_iso_8601": "2024-08-23T15:22:14.607785Z",
            "url": "https://files.pythonhosted.org/packages/4c/93/6877dd78b375f3e83c8209aecc18f18d1cd88269a8a5c2d3c7dd9ad4fc53/bilby_cython-0.5.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-23 15:22:14",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "bilby.cython"
}
        
Elapsed time: 0.54032s