Metadata-Version: 2.1
Name: gladeparser
Version: 0.0.0
Summary: Parser for the GLADE+ catalog.
Author-email: Bernardo Veronese <bernardo.veronese@edu.ufes.br>
License: MIT License
        
        Copyright (c) 2024 Bernardo Porto Veronese
        
        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.
        
Project-URL: Homepage, https://github.com/binado/gladeparser
Keywords: gravitational waves,galaxy catalog,cosmology
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy <2.0
Requires-Dist: polars
Requires-Dist: pandas
Requires-Dist: tables
Requires-Dist: tqdm
Provides-Extra: ci
Requires-Dist: pytest ; extra == 'ci'
Provides-Extra: dev
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: ruff ; extra == 'dev'
Requires-Dist: pre-commit ; extra == 'dev'

# gladeparser

![tests](https://github.com/binado/gladeparser/actions/workflows/test.yml/badge.svg)

Parser for the [GLADE+ galaxy catalog](https://glade.elte.hu/).

## Usage

To read the catalog into a `pandas.DataFrame`:

```python
from gladeparser import to_pandas_df

filename = "path/to/catalog"
df = to_pandas_df(filename)
```

The preferred way of reading the catalog is using a `polars` backend, especially if you want to filter out the data:

```python
from gladeparser import to_polars_df
import polars as pl

# Grab objects from 2MASS catalog with redshifts corrected for peculiar velocity
filters = (
    pl.col("2MASS name").is_not_null(),
    pl.col("z_cmb").is_not_null(),
    pl.col("z_cmb") > 0,
    pl.col("z flag") == 1,
    pl.col("dist flag").is_in([1, 3])
)

# Selected columns
cols = ["ra", "dec", "z_cmb"]

filename = "path/to/catalog"
df = to_polars_df(filename, cols=cols, **filters)
```

### Parsing a subset of columns

```python
from gladeparser import to_pandas_df, get_columns

# Select the columns you want and return their names
# See more options in get_columns docstring
cols = get_columns('Localization', 'Distance', names=True)

filename = "path/to/catalog"
df = to_pandas_df(filename, cols=cols)
```

## Installation

Clone the repo and run

```bash
pip install .
```

## Testing

Make sure that you have `pytest` installed, or run

```bash
pip install .[dev]
```

Then run

```bash
pytest
```

## References

See the GLADE+ paper on [arXiv](https://arxiv.org/abs/2110.06184).
