tom-nonlocalizedevents


Nametom-nonlocalizedevents JSON
Version 0.8.1 PyPI version JSON
download
home_pagehttps://github.com/TOMToolkit/tom_nonlocalizedevents
SummaryReusable TOMToolkit app to support gravitational wave superevent and other nonlocalized event EM follow-up observations.
upload_time2024-06-05 22:24:59
maintainerNone
docs_urlNone
authorTOM Toolkit Project
requires_python<3.12,>=3.9
licenseGPL-3.0-only
keywords tomtoolkit astronomy astrophysics cosmology science
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![pypi](https://img.shields.io/pypi/v/tom-nonlocalizedevents.svg)](https://pypi.python.org/pypi/tom-nonlocalizedevents)
[![run-tests](https://github.com/TOMToolkit/tom_nonlocalizedevents/actions/workflows/run-tests.yml/badge.svg)](https://github.com/TOMToolkit/tom_nonlocalizedevents/actions/workflows/run-tests.yml)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/cbcf7ce565d8450f86fff863ef061ff9)](https://www.codacy.com/gh/TOMToolkit/tom_nonlocalizedevents/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=TOMToolkit/tom_nonlocalizedevents&amp;utm_campaign=Badge_Grade)
[![Coverage Status](https://coveralls.io/repos/github/TOMToolkit/tom_nonlocalizedevents/badge.svg?branch=main)](https://coveralls.io/github/TOMToolkit/tom_nonlocalizedevents?branch=main)

# GW Superevent (or GRB, Neutrino) EM follow-up

This reusable TOM Toolkit app provides support for gravitational wave (GW) superevent
and other non-localized event electromagnetic (EM) follow up observations.  

## Requirements

This TOM plugin requires the use of a postgresql 14+ database backend, since it leverages some postgres specific stuff for MOC volume map lookups.

## Installation

1. Install the package into your TOM environment:
    ```bash
    pip install tom-nonlocalizedevents
   ```

2. In your project `settings.py`, add `tom_nonlocalizedevents` and `webpack_loader` to your `INSTALLED_APPS` setting:

    ```python
    INSTALLED_APPS = [
        'webpack_loader',
        ...
        'tom_nonlocalizedevents',
    ]
    ```
    
    Also include the following Django-Webpack-Loader settings in your settings.py:

    ```python
    VUE_FRONTEND_DIR_TOM_NONLOCAL = os.path.join(STATIC_ROOT, 'tom_nonlocalizedevents/vue')
    WEBPACK_LOADER = {
        'TOM_NONLOCALIZEDEVENTS': {
            'CACHE': not DEBUG,
            'BUNDLE_DIR_NAME': 'tom_nonlocalizedevents/vue/',  # must end with slash
            'STATS_FILE': os.path.join(VUE_FRONTEND_DIR_TOM_NONLOCAL, 'webpack-stats.json'),
            'POLL_INTERVAL': 0.1,
            'TIMEOUT': None,
            'IGNORE': [r'.+\.hot-update.js', r'.+\.map']
        }
    }
    ```

    If `WEBPACK_LOADER` is already defined in your settings, then integrate these values in to it.

    Also add the following to your settings if they are not already there, setting whatever default values you need for your setup. These point to your deployed TOM toolkit instance, and to a hermes instance:
    ```python
    TOM_API_URL = os.getenv('TOM_API_URL', 'http://127.0.0.1:8000')
    HERMES_API_URL = os.getenv('HERMES_API_URL', 'https://hermes-dev.lco.global')

    ```

3. Include the tom_nonlocalizedevent URLconf in your project `urls.py`:
   ```python
   urlpatterns = [
        ...
        path('nonlocalizedevents/', include('tom_nonlocalizedevents.urls', namespace='nonlocalizedevents')),
   ]
   ```

4. Run ``python manage.py migrate`` to create the tom_nonlocalizedevents models.

5. Set environment variables below to configure different connections:

| Env variable | Description | Default |
| ------------ | ----------- | ------- |
| `SA_DB_CONNECTION_URL` | Location of your django postgres database used for sqlalchemy | by default, this uses Django `default` DB for the project |
| `POOL_SIZE` | The number of connections to keep open inside the connection pool. ([docs](https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.create_engine.params.pool_size)) | 5 |
| `MAX_OVERFLOW` | The number of connections to allow in connection pool “overflow”. ([docs](https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.create_engine.params.max_overflow)) | 10 |
| `CREDIBLE_REGION_PROBABILITIES` | JSON List of Credible Region probabilities to automatically check each candidate target for | `'[0.25, 0.5, 0.75, 0.9, 0.95]'` |
| `SAVE_TEST_ALERTS` | Boolean on if you want to save test nonlocalizedevents into your database (those with event_id beginning with 'M') | `true` |

See [Engine Configuration](https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.create_engine) for
details of SQLAlchemy Engine Configuration.

6. In your TOM project, make sure to run `python manage.py collectstatic` after installing this app, to collect its Vue pages into your `staticfiles` directory.

7. If you want to automatically ingest GW events into your TOM, you should also install the `tom_alertstreams` app into your TOM and configure it to use the tom_nonlocalizedevents handler to ingest GW events. The preferred way is to use the hop `igwn.gwalerts` topic and set it to the handler `tom_nonlocalizedevents.alertstream_handlers.igwn_event_handler.handle_igwn_message`. This format has the newest Ligo O4 fields. There is legacy support for the gcn classic over kafka plaintext formatted LVC alerts using the handler `tom_nonlocalizedevents.alertstream_handlers.gcn_event_handler.handle_message`. There is also a handler to handle retractions via the `handle_retraction` method in that package. For an example of what needs to be in your settings to configure `tom_alertstreams` for these streams, look [here](https://github.com/LCOGT/hermes/blob/dev/hermes_base/settings.py#L232)

## Development

When any changes are made to this library, the vue files will need to be build and bundled and committed into the repo so that they can be bundled and deployed with the django package. This means that after making any vue changes, you must run `npm run build` within the `tom_nonlocalizedevents_vue` directory once, which will install the built files into `tom_nonlocalizedevents/static/`, and then those built files will need to be committed into the repo. This allows django projects using this library to get those files when running `python manage.py collectstatic`.

## Running the tests

In order to run the tests, run the following in your virtualenv:

`python manage.py test`

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/TOMToolkit/tom_nonlocalizedevents",
    "name": "tom-nonlocalizedevents",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.12,>=3.9",
    "maintainer_email": null,
    "keywords": "tomtoolkit, astronomy, astrophysics, cosmology, science",
    "author": "TOM Toolkit Project",
    "author_email": "tomtoolkit@lco.global",
    "download_url": "https://files.pythonhosted.org/packages/32/92/b88c7d21541e8589a137945e5f1a07dd717b3ac8ba0752f6484e19d217d1/tom_nonlocalizedevents-0.8.1.tar.gz",
    "platform": null,
    "description": "[![pypi](https://img.shields.io/pypi/v/tom-nonlocalizedevents.svg)](https://pypi.python.org/pypi/tom-nonlocalizedevents)\n[![run-tests](https://github.com/TOMToolkit/tom_nonlocalizedevents/actions/workflows/run-tests.yml/badge.svg)](https://github.com/TOMToolkit/tom_nonlocalizedevents/actions/workflows/run-tests.yml)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/cbcf7ce565d8450f86fff863ef061ff9)](https://www.codacy.com/gh/TOMToolkit/tom_nonlocalizedevents/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=TOMToolkit/tom_nonlocalizedevents&amp;utm_campaign=Badge_Grade)\n[![Coverage Status](https://coveralls.io/repos/github/TOMToolkit/tom_nonlocalizedevents/badge.svg?branch=main)](https://coveralls.io/github/TOMToolkit/tom_nonlocalizedevents?branch=main)\n\n# GW Superevent (or GRB, Neutrino) EM follow-up\n\nThis reusable TOM Toolkit app provides support for gravitational wave (GW) superevent\nand other non-localized event electromagnetic (EM) follow up observations.  \n\n## Requirements\n\nThis TOM plugin requires the use of a postgresql 14+ database backend, since it leverages some postgres specific stuff for MOC volume map lookups.\n\n## Installation\n\n1. Install the package into your TOM environment:\n    ```bash\n    pip install tom-nonlocalizedevents\n   ```\n\n2. In your project `settings.py`, add `tom_nonlocalizedevents` and `webpack_loader` to your `INSTALLED_APPS` setting:\n\n    ```python\n    INSTALLED_APPS = [\n        'webpack_loader',\n        ...\n        'tom_nonlocalizedevents',\n    ]\n    ```\n    \n    Also include the following Django-Webpack-Loader settings in your settings.py:\n\n    ```python\n    VUE_FRONTEND_DIR_TOM_NONLOCAL = os.path.join(STATIC_ROOT, 'tom_nonlocalizedevents/vue')\n    WEBPACK_LOADER = {\n        'TOM_NONLOCALIZEDEVENTS': {\n            'CACHE': not DEBUG,\n            'BUNDLE_DIR_NAME': 'tom_nonlocalizedevents/vue/',  # must end with slash\n            'STATS_FILE': os.path.join(VUE_FRONTEND_DIR_TOM_NONLOCAL, 'webpack-stats.json'),\n            'POLL_INTERVAL': 0.1,\n            'TIMEOUT': None,\n            'IGNORE': [r'.+\\.hot-update.js', r'.+\\.map']\n        }\n    }\n    ```\n\n    If `WEBPACK_LOADER` is already defined in your settings, then integrate these values in to it.\n\n    Also add the following to your settings if they are not already there, setting whatever default values you need for your setup. These point to your deployed TOM toolkit instance, and to a hermes instance:\n    ```python\n    TOM_API_URL = os.getenv('TOM_API_URL', 'http://127.0.0.1:8000')\n    HERMES_API_URL = os.getenv('HERMES_API_URL', 'https://hermes-dev.lco.global')\n\n    ```\n\n3. Include the tom_nonlocalizedevent URLconf in your project `urls.py`:\n   ```python\n   urlpatterns = [\n        ...\n        path('nonlocalizedevents/', include('tom_nonlocalizedevents.urls', namespace='nonlocalizedevents')),\n   ]\n   ```\n\n4. Run ``python manage.py migrate`` to create the tom_nonlocalizedevents models.\n\n5. Set environment variables below to configure different connections:\n\n| Env variable | Description | Default |\n| ------------ | ----------- | ------- |\n| `SA_DB_CONNECTION_URL` | Location of your django postgres database used for sqlalchemy | by default, this uses Django `default` DB for the project |\n| `POOL_SIZE` | The number of connections to keep open inside the connection pool. ([docs](https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.create_engine.params.pool_size)) | 5 |\n| `MAX_OVERFLOW` | The number of connections to allow in connection pool \u201coverflow\u201d. ([docs](https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.create_engine.params.max_overflow)) | 10 |\n| `CREDIBLE_REGION_PROBABILITIES` | JSON List of Credible Region probabilities to automatically check each candidate target for | `'[0.25, 0.5, 0.75, 0.9, 0.95]'` |\n| `SAVE_TEST_ALERTS` | Boolean on if you want to save test nonlocalizedevents into your database (those with event_id beginning with 'M') | `true` |\n\nSee [Engine Configuration](https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.create_engine) for\ndetails of SQLAlchemy Engine Configuration.\n\n6. In your TOM project, make sure to run `python manage.py collectstatic` after installing this app, to collect its Vue pages into your `staticfiles` directory.\n\n7. If you want to automatically ingest GW events into your TOM, you should also install the `tom_alertstreams` app into your TOM and configure it to use the tom_nonlocalizedevents handler to ingest GW events. The preferred way is to use the hop `igwn.gwalerts` topic and set it to the handler `tom_nonlocalizedevents.alertstream_handlers.igwn_event_handler.handle_igwn_message`. This format has the newest Ligo O4 fields. There is legacy support for the gcn classic over kafka plaintext formatted LVC alerts using the handler `tom_nonlocalizedevents.alertstream_handlers.gcn_event_handler.handle_message`. There is also a handler to handle retractions via the `handle_retraction` method in that package. For an example of what needs to be in your settings to configure `tom_alertstreams` for these streams, look [here](https://github.com/LCOGT/hermes/blob/dev/hermes_base/settings.py#L232)\n\n## Development\n\nWhen any changes are made to this library, the vue files will need to be build and bundled and committed into the repo so that they can be bundled and deployed with the django package. This means that after making any vue changes, you must run `npm run build` within the `tom_nonlocalizedevents_vue` directory once, which will install the built files into `tom_nonlocalizedevents/static/`, and then those built files will need to be committed into the repo. This allows django projects using this library to get those files when running `python manage.py collectstatic`.\n\n## Running the tests\n\nIn order to run the tests, run the following in your virtualenv:\n\n`python manage.py test`\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-only",
    "summary": "Reusable TOMToolkit app to support gravitational wave superevent and other nonlocalized event EM follow-up observations.",
    "version": "0.8.1",
    "project_urls": {
        "Homepage": "https://github.com/TOMToolkit/tom_nonlocalizedevents",
        "Repository": "https://github.com/TOMToolkit/tom_nonlocalizedevents"
    },
    "split_keywords": [
        "tomtoolkit",
        " astronomy",
        " astrophysics",
        " cosmology",
        " science"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "38a2d5577bb8eb631144bc23385affbc0aa6b828e315421aafd17c5986c25fbc",
                "md5": "5f6dacbcd1f3a9bf485fda1cf082b7ea",
                "sha256": "48dfd16026449bf802e1a6b5d4485331a7ffaadd7b0f71331343a77e89342d51"
            },
            "downloads": -1,
            "filename": "tom_nonlocalizedevents-0.8.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5f6dacbcd1f3a9bf485fda1cf082b7ea",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.12,>=3.9",
            "size": 561426,
            "upload_time": "2024-06-05T22:24:57",
            "upload_time_iso_8601": "2024-06-05T22:24:57.363946Z",
            "url": "https://files.pythonhosted.org/packages/38/a2/d5577bb8eb631144bc23385affbc0aa6b828e315421aafd17c5986c25fbc/tom_nonlocalizedevents-0.8.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3292b88c7d21541e8589a137945e5f1a07dd717b3ac8ba0752f6484e19d217d1",
                "md5": "b03816785c913a0c9bda54290bce9548",
                "sha256": "84112516523bd8740ab8ddafdd3e4dbdb03b5256372553a53d8309dd11c30a3f"
            },
            "downloads": -1,
            "filename": "tom_nonlocalizedevents-0.8.1.tar.gz",
            "has_sig": false,
            "md5_digest": "b03816785c913a0c9bda54290bce9548",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.12,>=3.9",
            "size": 544728,
            "upload_time": "2024-06-05T22:24:59",
            "upload_time_iso_8601": "2024-06-05T22:24:59.994728Z",
            "url": "https://files.pythonhosted.org/packages/32/92/b88c7d21541e8589a137945e5f1a07dd717b3ac8ba0752f6484e19d217d1/tom_nonlocalizedevents-0.8.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-05 22:24:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "TOMToolkit",
    "github_project": "tom_nonlocalizedevents",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "tom-nonlocalizedevents"
}
        
Elapsed time: 0.95003s