ASTROMER


NameASTROMER JSON
Version 0.1.7 PyPI version JSON
download
home_page
SummaryCreates light curves embeddings using ASTROMER
upload_time2023-08-10 03:47:24
maintainer
docs_urlNone
author
requires_python<3.11,>=3.7
licenseMIT License Copyright (c) [2022] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords astromer astronomy deep learning embbedings light curves photometry transformers
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ASTROMER Python library 🔭

ASTROMER is a transformer based model pretrained on millions of light curves. ASTROMER can be finetuned on specific datasets to create useful representations that can improve the performance of novel deep learning models.

❗ This version of ASTROMER can only works on single band light curves.

🔥 [See the official repo here](https://github.com/astromer-science/main-code)

## Install
```
pip install ASTROMER
```

## How to use it
Currently, there are 2 pre-trained models: `macho` and `atlas`.
To load weights use:
```
from ASTROMER.models import SingleBandEncoder

model = SingleBandEncoder()
model = model.from_pretraining('macho')
```
It will automatically download the weights from [this public github repository](https://github.com/astromer-science/weights.git) and load them into the `SingleBandEncoder` instance.

Assuming you have a list of vary-lenght (numpy) light curves.
```
import numpy as np

samples_collection = [ np.array([[5200, 0.3, 0.2],
                                 [5300, 0.5, 0.1],
                                 [5400, 0.2, 0.3]]),

                       np.array([[4200, 0.3, 0.1],
                                 [4300, 0.6, 0.3]]) ]

```
Light curves are `Lx3` matrices with time, magnitude, and magnitude std.
To encode samples use:
```
attention_vectors = model.encode(samples_collection,
                                 oids_list=['1', '2'],
                                 batch_size=1,
                                 concatenate=True)
```
where
- `samples_collection` is a list of numpy array light curves
- `oids_list` is a list with the light curves ids (needed to concatenate 200-len windows)
- `batch_size` specify the number of samples per forward pass
-  when `concatenate=True` ASTROMER concatenates every 200-lenght windows belonging the same object id. The output when `concatenate=True` is a list of vary-length attention vectors.

## Finetuning or training from scratch
`ASTROMER` can be easly trained by using the `fit`. It include

```
from ASTROMER import SingleBandEncoder

model = SingleBandEncoder(num_layers= 2,
                          d_model   = 256,
                          num_heads = 4,
                          dff       = 128,
                          base      = 1000,
                          dropout   = 0.1,
                          maxlen    = 200)
model.from_pretrained('macho')
```
where,
- `num_layers`: Number of self-attention blocks
- `d_model`: Self-attention block dimension (must be divisible by `num_heads`)
- `num_heads`: Number of heads within the self-attention block
- `dff`: Number of neurons for the fully-connected layer applied after the attention blocks
- `base`: Positional encoder base (see formula)
- `dropout`: Dropout applied to output of the fully-connected layer
- `maxlen`: Maximum length to process in the encoder
Notice you can ignore `model.from_pretrained('macho')` for clean training.
```
mode.fit(train_data,
         validation_data,
         epochs=2,
         patience=20,
         lr=1e-3,
         project_path='./my_folder',
         verbose=0)
```
where,
- `train_data`: Training data already formatted as tf.data
- `validation_data`: Validation data already formatted as tf.data
- `epochs`: Number of epochs for training
- `patience`: Early stopping patience
- `lr`: Learning rate
- `project_path`: Path for saving weights and training logs
- `verbose`: (0) Display information during training (1) don't

`train_data` and `validation_data` should be loaded using `load_numpy` or `pretraining_records` functions. Both functions are in the `ASTROMER.preprocessing` module.

For large datasets is recommended to use Tensorflow Records ([see this tutorial to execute our data pipeline](https://github.com/astromer-science/main-code/blob/main/presentation/notebooks/create_records.ipynb))

## Resources
- [ASTROMER Tutorials](https://www.stellardnn.org/astromer/)

## Contributing to ASTROMER 🤝
If you train your model from scratch, you can share your pre-trained weights by submitting a Pull Request on [the weights repository](https://github.com/astromer-science/weights)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "ASTROMER",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "<3.11,>=3.7",
    "maintainer_email": "",
    "keywords": "ASTROMER,astronomy,deep learning,embbedings,light curves,photometry,transformers",
    "author": "",
    "author_email": "Cristobal Donoso-Oliva <cridonoso@inf.udec.cl>",
    "download_url": "https://files.pythonhosted.org/packages/50/5a/01036ebf2f90a031a6810c706ecf036d0672af34445de518a702360b0634/astromer-0.1.7.tar.gz",
    "platform": null,
    "description": "# ASTROMER Python library \ud83d\udd2d\n\nASTROMER is a transformer based model pretrained on millions of light curves. ASTROMER can be finetuned on specific datasets to create useful representations that can improve the performance of novel deep learning models.\n\n\u2757 This version of ASTROMER can only works on single band light curves.\n\n\ud83d\udd25 [See the official repo here](https://github.com/astromer-science/main-code)\n\n## Install\n```\npip install ASTROMER\n```\n\n## How to use it\nCurrently, there are 2 pre-trained models: `macho` and `atlas`.\nTo load weights use:\n```\nfrom ASTROMER.models import SingleBandEncoder\n\nmodel = SingleBandEncoder()\nmodel = model.from_pretraining('macho')\n```\nIt will automatically download the weights from [this public github repository](https://github.com/astromer-science/weights.git) and load them into the `SingleBandEncoder` instance.\n\nAssuming you have a list of vary-lenght (numpy) light curves.\n```\nimport numpy as np\n\nsamples_collection = [ np.array([[5200, 0.3, 0.2],\n                                 [5300, 0.5, 0.1],\n                                 [5400, 0.2, 0.3]]),\n\n                       np.array([[4200, 0.3, 0.1],\n                                 [4300, 0.6, 0.3]]) ]\n\n```\nLight curves are `Lx3` matrices with time, magnitude, and magnitude std.\nTo encode samples use:\n```\nattention_vectors = model.encode(samples_collection,\n                                 oids_list=['1', '2'],\n                                 batch_size=1,\n                                 concatenate=True)\n```\nwhere\n- `samples_collection` is a list of numpy array light curves\n- `oids_list` is a list with the light curves ids (needed to concatenate 200-len windows)\n- `batch_size` specify the number of samples per forward pass\n-  when `concatenate=True` ASTROMER concatenates every 200-lenght windows belonging the same object id. The output when `concatenate=True` is a list of vary-length attention vectors.\n\n## Finetuning or training from scratch\n`ASTROMER` can be easly trained by using the `fit`. It include\n\n```\nfrom ASTROMER import SingleBandEncoder\n\nmodel = SingleBandEncoder(num_layers= 2,\n                          d_model   = 256,\n                          num_heads = 4,\n                          dff       = 128,\n                          base      = 1000,\n                          dropout   = 0.1,\n                          maxlen    = 200)\nmodel.from_pretrained('macho')\n```\nwhere,\n- `num_layers`: Number of self-attention blocks\n- `d_model`: Self-attention block dimension (must be divisible by `num_heads`)\n- `num_heads`: Number of heads within the self-attention block\n- `dff`: Number of neurons for the fully-connected layer applied after the attention blocks\n- `base`: Positional encoder base (see formula)\n- `dropout`: Dropout applied to output of the fully-connected layer\n- `maxlen`: Maximum length to process in the encoder\nNotice you can ignore `model.from_pretrained('macho')` for clean training.\n```\nmode.fit(train_data,\n         validation_data,\n         epochs=2,\n         patience=20,\n         lr=1e-3,\n         project_path='./my_folder',\n         verbose=0)\n```\nwhere,\n- `train_data`: Training data already formatted as tf.data\n- `validation_data`: Validation data already formatted as tf.data\n- `epochs`: Number of epochs for training\n- `patience`: Early stopping patience\n- `lr`: Learning rate\n- `project_path`: Path for saving weights and training logs\n- `verbose`: (0) Display information during training (1) don't\n\n`train_data` and `validation_data` should be loaded using `load_numpy` or `pretraining_records` functions. Both functions are in the `ASTROMER.preprocessing` module.\n\nFor large datasets is recommended to use Tensorflow Records ([see this tutorial to execute our data pipeline](https://github.com/astromer-science/main-code/blob/main/presentation/notebooks/create_records.ipynb))\n\n## Resources\n- [ASTROMER Tutorials](https://www.stellardnn.org/astromer/)\n\n## Contributing to ASTROMER \ud83e\udd1d\nIf you train your model from scratch, you can share your pre-trained weights by submitting a Pull Request on [the weights repository](https://github.com/astromer-science/weights)\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) [2022]  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Creates light curves embeddings using ASTROMER",
    "version": "0.1.7",
    "project_urls": {
        "Homepage": "https://github.com/astromer-science/python-library"
    },
    "split_keywords": [
        "astromer",
        "astronomy",
        "deep learning",
        "embbedings",
        "light curves",
        "photometry",
        "transformers"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fe351455b4989a74f0e28a748e7318f62523d9e0be0249f6f23ff55c9272b217",
                "md5": "198488060c9d77b02dacd884b2a2eae7",
                "sha256": "c181ab6a1dc221ded5a702e5729a55b427bcd5dc6a9689ee5922c7cf163d8fb6"
            },
            "downloads": -1,
            "filename": "astromer-0.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "198488060c9d77b02dacd884b2a2eae7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.11,>=3.7",
            "size": 28097,
            "upload_time": "2023-08-10T03:46:54",
            "upload_time_iso_8601": "2023-08-10T03:46:54.444439Z",
            "url": "https://files.pythonhosted.org/packages/fe/35/1455b4989a74f0e28a748e7318f62523d9e0be0249f6f23ff55c9272b217/astromer-0.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "505a01036ebf2f90a031a6810c706ecf036d0672af34445de518a702360b0634",
                "md5": "d50c5015a61e0a01df77e7c2ed37ee78",
                "sha256": "339eb2117009be53b6c0886be625f785f7259a296852c813f749937cf6320c00"
            },
            "downloads": -1,
            "filename": "astromer-0.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "d50c5015a61e0a01df77e7c2ed37ee78",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.11,>=3.7",
            "size": 2982692,
            "upload_time": "2023-08-10T03:47:24",
            "upload_time_iso_8601": "2023-08-10T03:47:24.434726Z",
            "url": "https://files.pythonhosted.org/packages/50/5a/01036ebf2f90a031a6810c706ecf036d0672af34445de518a702360b0634/astromer-0.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-10 03:47:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "astromer-science",
    "github_project": "python-library",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "astromer"
}
        
Elapsed time: 0.10464s