pyegcdb 0.1.0a1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyegcdb-0.1.0a1/LICENSE +14 -0
- pyegcdb-0.1.0a1/PKG-INFO +100 -0
- pyegcdb-0.1.0a1/README.md +81 -0
- pyegcdb-0.1.0a1/pyproject.toml +30 -0
- pyegcdb-0.1.0a1/setup.cfg +4 -0
- pyegcdb-0.1.0a1/src/pyegcdb/__init__.py +1 -0
- pyegcdb-0.1.0a1/src/pyegcdb/core.py +212 -0
- pyegcdb-0.1.0a1/src/pyegcdb.egg-info/PKG-INFO +100 -0
- pyegcdb-0.1.0a1/src/pyegcdb.egg-info/SOURCES.txt +10 -0
- pyegcdb-0.1.0a1/src/pyegcdb.egg-info/dependency_links.txt +1 -0
- pyegcdb-0.1.0a1/src/pyegcdb.egg-info/requires.txt +3 -0
- pyegcdb-0.1.0a1/src/pyegcdb.egg-info/top_level.txt +1 -0
pyegcdb-0.1.0a1/LICENSE
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Copyright (C) 2026 Dóra Tarczay-Nehéz
|
|
2
|
+
|
|
3
|
+
This program is free software: you can redistribute it and/or modify
|
|
4
|
+
it under the terms of the GNU General Public License as published by
|
|
5
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
(at your option) any later version.
|
|
7
|
+
|
|
8
|
+
This program is distributed in the hope that it will be useful,
|
|
9
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
GNU General Public License for more details.
|
|
12
|
+
|
|
13
|
+
You should have received a copy of the GNU General Public License
|
|
14
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
pyegcdb-0.1.0a1/PKG-INFO
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyegcdb
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: Python client for the Extragalactic Cepheid Database of the Konkoly Observatory
|
|
5
|
+
Author-email: Dóra Tarczay-Nehéz <tarczaynehez.dora@csfk.org>
|
|
6
|
+
License: GNU GPLv3
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: requests>=2.28.0
|
|
16
|
+
Requires-Dist: pandas>=1.5.0
|
|
17
|
+
Requires-Dist: astropy>=5.0.0
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# pyegcdb
|
|
21
|
+
|
|
22
|
+
`pyegcdb` is the official Python client for the **Konkoly Cepheid Database**. It provides astronomers and researchers with a seamless interface to query light curves and stellar catalog data directly within a Python environment.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
You can install the package directly from PyPI:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install pyegcdb
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
To begin using the library, initialize the client and fetch data by the star's name:
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from pyegcdb import KonkolyCepheids
|
|
39
|
+
|
|
40
|
+
# 1. Initialize the client
|
|
41
|
+
db = KonkolyCepheids()
|
|
42
|
+
|
|
43
|
+
# 2. Fetch light curve data for a specific star
|
|
44
|
+
star_name = "OGLE LMC-SC1 14252"
|
|
45
|
+
lc_df = db.load_datapoints(identifier=star_name, bands=['B'])
|
|
46
|
+
|
|
47
|
+
# 3. Preview the results
|
|
48
|
+
if not lc_df.empty:
|
|
49
|
+
print(lc_df.head())
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## Key Features
|
|
57
|
+
|
|
58
|
+
* **Light Curve Retrieval:** Easily download raw photometric time-series data for specific Cepheids.
|
|
59
|
+
* **Catalog Querying:** Perform advanced searches based on galaxy, variable type, or perform a Cone Search (RA/Dec).
|
|
60
|
+
* **Smart Filtering:** Built-in deduplication logic that prioritizes the most recent publication data.
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
## Citation
|
|
64
|
+
If you use `pyegcdb` in your research, please cite our relevant work:
|
|
65
|
+
|
|
66
|
+
```bibtex
|
|
67
|
+
@INPROCEEDINGS{2020svos.conf..115T,
|
|
68
|
+
author = {{Tarczay-Neh{\'e}z}, D. and {Szabados}, L. and {Dencs}, Z.},
|
|
69
|
+
title = "{Cepheids Near and Far}",
|
|
70
|
+
keywords = {Stars: variables: Cepheids, Astronomical databases: miscellaneous, Galaxies: statistics, Stars: statistics, Galaxy: stellar content, (Cosmology:) distance scale},
|
|
71
|
+
booktitle = {Stars and their Variability Observed from Space},
|
|
72
|
+
year = 2020,
|
|
73
|
+
editor = {{Neiner}, C. and {Weiss}, W.~W. and {Baade}, D. and {Griffin}, R.~E. and {Lovekin}, C.~C. and {Moffat}, A.~F.~J.},
|
|
74
|
+
month = jan,
|
|
75
|
+
pages = {115-118},
|
|
76
|
+
adsurl = {https://ui.adsabs.harvard.edu/abs/2020svos.conf..115T},
|
|
77
|
+
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@INPROCEEDINGS{2022eas..conf..420T,
|
|
83
|
+
author = {{Tarczay-Neh{\'e}z}, D{\'o}ra and {Dencs}, Zolt{\'a}n and {Szabados}, L{\'a}szl{\'o} and {Moln{\'a}r}, L{\'a}szl{\'o}},
|
|
84
|
+
title = "{Extragalactic Cepheid Database}",
|
|
85
|
+
booktitle = {EAS2022, European Astronomical Society Annual Meeting},
|
|
86
|
+
year = 2022,
|
|
87
|
+
month = jul,
|
|
88
|
+
eid = {420},
|
|
89
|
+
pages = {420},
|
|
90
|
+
adsurl = {https://ui.adsabs.harvard.edu/abs/2022eas..conf..420T},
|
|
91
|
+
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
This software is released under the [GNU GPLv3] license.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# pyegcdb
|
|
2
|
+
|
|
3
|
+
`pyegcdb` is the official Python client for the **Konkoly Cepheid Database**. It provides astronomers and researchers with a seamless interface to query light curves and stellar catalog data directly within a Python environment.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
You can install the package directly from PyPI:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install pyegcdb
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
To begin using the library, initialize the client and fetch data by the star's name:
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
from pyegcdb import KonkolyCepheids
|
|
20
|
+
|
|
21
|
+
# 1. Initialize the client
|
|
22
|
+
db = KonkolyCepheids()
|
|
23
|
+
|
|
24
|
+
# 2. Fetch light curve data for a specific star
|
|
25
|
+
star_name = "OGLE LMC-SC1 14252"
|
|
26
|
+
lc_df = db.load_datapoints(identifier=star_name, bands=['B'])
|
|
27
|
+
|
|
28
|
+
# 3. Preview the results
|
|
29
|
+
if not lc_df.empty:
|
|
30
|
+
print(lc_df.head())
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## Key Features
|
|
38
|
+
|
|
39
|
+
* **Light Curve Retrieval:** Easily download raw photometric time-series data for specific Cepheids.
|
|
40
|
+
* **Catalog Querying:** Perform advanced searches based on galaxy, variable type, or perform a Cone Search (RA/Dec).
|
|
41
|
+
* **Smart Filtering:** Built-in deduplication logic that prioritizes the most recent publication data.
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## Citation
|
|
45
|
+
If you use `pyegcdb` in your research, please cite our relevant work:
|
|
46
|
+
|
|
47
|
+
```bibtex
|
|
48
|
+
@INPROCEEDINGS{2020svos.conf..115T,
|
|
49
|
+
author = {{Tarczay-Neh{\'e}z}, D. and {Szabados}, L. and {Dencs}, Z.},
|
|
50
|
+
title = "{Cepheids Near and Far}",
|
|
51
|
+
keywords = {Stars: variables: Cepheids, Astronomical databases: miscellaneous, Galaxies: statistics, Stars: statistics, Galaxy: stellar content, (Cosmology:) distance scale},
|
|
52
|
+
booktitle = {Stars and their Variability Observed from Space},
|
|
53
|
+
year = 2020,
|
|
54
|
+
editor = {{Neiner}, C. and {Weiss}, W.~W. and {Baade}, D. and {Griffin}, R.~E. and {Lovekin}, C.~C. and {Moffat}, A.~F.~J.},
|
|
55
|
+
month = jan,
|
|
56
|
+
pages = {115-118},
|
|
57
|
+
adsurl = {https://ui.adsabs.harvard.edu/abs/2020svos.conf..115T},
|
|
58
|
+
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@INPROCEEDINGS{2022eas..conf..420T,
|
|
64
|
+
author = {{Tarczay-Neh{\'e}z}, D{\'o}ra and {Dencs}, Zolt{\'a}n and {Szabados}, L{\'a}szl{\'o} and {Moln{\'a}r}, L{\'a}szl{\'o}},
|
|
65
|
+
title = "{Extragalactic Cepheid Database}",
|
|
66
|
+
booktitle = {EAS2022, European Astronomical Society Annual Meeting},
|
|
67
|
+
year = 2022,
|
|
68
|
+
month = jul,
|
|
69
|
+
eid = {420},
|
|
70
|
+
pages = {420},
|
|
71
|
+
adsurl = {https://ui.adsabs.harvard.edu/abs/2022eas..conf..420T},
|
|
72
|
+
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
## License
|
|
81
|
+
This software is released under the [GNU GPLv3] license.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pyegcdb"
|
|
7
|
+
version = "0.1.0a1"
|
|
8
|
+
description = "Python client for the Extragalactic Cepheid Database of the Konkoly Observatory"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [
|
|
11
|
+
{ name = "Dóra Tarczay-Nehéz", email = "tarczaynehez.dora@csfk.org" }
|
|
12
|
+
]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
"Intended Audience :: Science/Research",
|
|
18
|
+
"Topic :: Scientific/Engineering :: Astronomy"
|
|
19
|
+
]
|
|
20
|
+
requires-python = ">=3.8"
|
|
21
|
+
dependencies = [
|
|
22
|
+
"requests>=2.28.0",
|
|
23
|
+
"pandas>=1.5.0",
|
|
24
|
+
"astropy>=5.0.0" # For astronomical things
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
license = {text = "GNU GPLv3"}
|
|
28
|
+
|
|
29
|
+
[tool.setuptools.packages.find]
|
|
30
|
+
where = ["src"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .core import KonkolyCepheids
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import urllib.parse
|
|
4
|
+
|
|
5
|
+
class KonkolyCepheids:
|
|
6
|
+
def __init__(self, base_url="https://cepheids.konkoly.hu/api/v1"):
|
|
7
|
+
self.base_url = base_url
|
|
8
|
+
self._band_map = {
|
|
9
|
+
1: 'magU', 2: 'magB', 3: 'magV', 4: 'magR', 5: 'magI', 6: 'magJ', 7: 'magH', 8: 'magK',
|
|
10
|
+
9: 'magu', 10: 'magg', 11: 'magr', 12: 'magi', 13: 'magz', 14: 'magG',
|
|
11
|
+
46: 'magW1', 47: 'magW2', 48: 'magW3', 49: 'magW4'
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
def ping(self) -> bool:
|
|
15
|
+
url = f"{self.base_url}/ping"
|
|
16
|
+
try:
|
|
17
|
+
response = requests.get(url, timeout=5)
|
|
18
|
+
return response.status_code == 200
|
|
19
|
+
except requests.exceptions.RequestException:
|
|
20
|
+
return False
|
|
21
|
+
|
|
22
|
+
def query(self,
|
|
23
|
+
galaxy: str = None,
|
|
24
|
+
var_type: int = None,
|
|
25
|
+
ra: str or float = None,
|
|
26
|
+
dec: str or float = None,
|
|
27
|
+
radius: float or int = 5,
|
|
28
|
+
bands: str or list = 'all',
|
|
29
|
+
include_period: bool = True) -> pd.DataFrame:
|
|
30
|
+
"""
|
|
31
|
+
Queries the database with support for galaxy, type, and Cone Search (RA/Dec).
|
|
32
|
+
Filters out database-level duplicates by keeping the newest publication data.
|
|
33
|
+
"""
|
|
34
|
+
url = f"{self.base_url}/cepheids"
|
|
35
|
+
|
|
36
|
+
params = {
|
|
37
|
+
'include_period': str(include_period).lower()
|
|
38
|
+
}
|
|
39
|
+
if galaxy:
|
|
40
|
+
params['galaxy'] = galaxy
|
|
41
|
+
if var_type:
|
|
42
|
+
params['type'] = var_type
|
|
43
|
+
|
|
44
|
+
if ra is not None and dec is not None:
|
|
45
|
+
params['ra'] = str(ra)
|
|
46
|
+
params['dec'] = str(dec)
|
|
47
|
+
params['radius'] = float(radius)
|
|
48
|
+
|
|
49
|
+
if isinstance(bands, list):
|
|
50
|
+
params['bands'] = ",".join(bands)
|
|
51
|
+
else:
|
|
52
|
+
params['bands'] = bands
|
|
53
|
+
|
|
54
|
+
try:
|
|
55
|
+
response = requests.get(url, params=params, timeout=15)
|
|
56
|
+
if response.status_code != 200:
|
|
57
|
+
print(f"❌ Server error: {response.status_code}")
|
|
58
|
+
return pd.DataFrame()
|
|
59
|
+
|
|
60
|
+
json_data = response.json()
|
|
61
|
+
if json_data.get('status') != 'success' or json_data.get('count', 0) == 0:
|
|
62
|
+
print("⚠ No records found matching the criteria.")
|
|
63
|
+
return pd.DataFrame()
|
|
64
|
+
|
|
65
|
+
raw_data = json_data['data']
|
|
66
|
+
flattened_records = []
|
|
67
|
+
|
|
68
|
+
for item in raw_data:
|
|
69
|
+
# Kinyerjük a pozíciókat, hogy meghatározzuk a legfrissebbet (legnagyobb art_id)
|
|
70
|
+
positions = item.get('positions', [])
|
|
71
|
+
base2 = [p for p in positions if p.get('base') == 2]
|
|
72
|
+
|
|
73
|
+
latest_pos = None
|
|
74
|
+
latest_art_id = -1
|
|
75
|
+
|
|
76
|
+
if base2:
|
|
77
|
+
# Megkeressük a legfrissebb pozíció rekordot az art_id alapján
|
|
78
|
+
latest_pos = sorted(base2, key=lambda x: x.get('art_id', 0) or 0, reverse=True)[0]
|
|
79
|
+
latest_art_id = latest_pos.get('art_id', 0) or 0
|
|
80
|
+
|
|
81
|
+
record = {
|
|
82
|
+
'id': item.get('id'),
|
|
83
|
+
'name': item.get('name'),
|
|
84
|
+
'galaxy': item.get('galaxy', {}).get('gen_short_name', 'Unknown'),
|
|
85
|
+
'type': item.get('types', [{}])[0].get('type') if item.get('types') else None,
|
|
86
|
+
'latest_art_id': latest_art_id # Ezt használjuk majd a drop_duplicates-nél
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if 'distance_arcsec' in item:
|
|
90
|
+
record['distance_arcsec'] = float(item['distance_arcsec'])
|
|
91
|
+
|
|
92
|
+
if include_period:
|
|
93
|
+
periods = item.get('periods', [])
|
|
94
|
+
record['period'] = float(periods[0].get('value')) if periods and periods[0].get('value') else None
|
|
95
|
+
|
|
96
|
+
if latest_pos:
|
|
97
|
+
record['ra'] = latest_pos.get('ra')
|
|
98
|
+
record['dec'] = latest_pos.get('dec')
|
|
99
|
+
else:
|
|
100
|
+
record['ra'] = record['dec'] = None
|
|
101
|
+
|
|
102
|
+
if isinstance(bands, list):
|
|
103
|
+
for b in bands:
|
|
104
|
+
record[f'mag{b}'] = None
|
|
105
|
+
else:
|
|
106
|
+
for b_name in self._band_map.values():
|
|
107
|
+
record[b_name] = None
|
|
108
|
+
|
|
109
|
+
for mag_obj in item.get('magnitudes', []):
|
|
110
|
+
b_id = mag_obj.get('band_type_id')
|
|
111
|
+
b_col_name = self._band_map.get(b_id)
|
|
112
|
+
if b_col_name:
|
|
113
|
+
record[b_col_name] = float(mag_obj.get('value')) if mag_obj.get('value') else None
|
|
114
|
+
|
|
115
|
+
flattened_records.append(record)
|
|
116
|
+
|
|
117
|
+
df = pd.DataFrame(flattened_records)
|
|
118
|
+
|
|
119
|
+
# --- DUPLIKÁCIÓK TISZTÍTÁSA CIKK-FRISSESSÉG ALAPJÁN ---
|
|
120
|
+
if not df.empty:
|
|
121
|
+
# Először a legfrissebb cikkek szerint csökkenőbe rendezünk
|
|
122
|
+
df = df.sort_values('latest_art_id', ascending=False)
|
|
123
|
+
|
|
124
|
+
# Csillag ID alapján eldobjuk a duplikátumokat, így a legfrissebb (első) marad meg
|
|
125
|
+
df = df.drop_duplicates(subset=['id'], keep='first')
|
|
126
|
+
|
|
127
|
+
# Ha volt Cone Search, akkor esztétikailag visszaállíthatjuk a távolság szerinti sorrendet
|
|
128
|
+
if 'distance_arcsec' in df.columns:
|
|
129
|
+
df = df.sort_values('distance_arcsec')
|
|
130
|
+
|
|
131
|
+
# Takarítás: a segéd oszlopot elrejtjük a kutató elől
|
|
132
|
+
df = df.drop(columns=['latest_art_id']).reset_index(drop=True)
|
|
133
|
+
|
|
134
|
+
print(f"✓ Successfully fetched and cleaned {len(df)} unique records (based on latest publication).")
|
|
135
|
+
return df
|
|
136
|
+
|
|
137
|
+
except requests.exceptions.RequestException as e:
|
|
138
|
+
print(f"❌ Network error: {e}")
|
|
139
|
+
return pd.DataFrame()
|
|
140
|
+
|
|
141
|
+
def load_datapoints(self, identifier: int or str, bands: str or list = 'all') -> pd.DataFrame:
|
|
142
|
+
"""
|
|
143
|
+
Fetches the raw photometric time-series (light curve) for a specific Cepheid.
|
|
144
|
+
"""
|
|
145
|
+
safe_identifier = urllib.parse.quote(str(identifier))
|
|
146
|
+
url = f"{self.base_url}/cepheids/{safe_identifier}/lightcurve"
|
|
147
|
+
|
|
148
|
+
params = {}
|
|
149
|
+
if isinstance(bands, list):
|
|
150
|
+
params['bands'] = ",".join(bands)
|
|
151
|
+
else:
|
|
152
|
+
params['bands'] = bands
|
|
153
|
+
|
|
154
|
+
local_band_map = {
|
|
155
|
+
1: 'U', 2: 'B', 3: 'V', 4: 'R', 5: 'I', 6: 'J', 7: 'H', 8: 'K',
|
|
156
|
+
9: 'u', 10: 'g', 11: 'r', 12: 'i', 13: 'z', 14: 'G',
|
|
157
|
+
46: 'W1', 47: 'W2', 48: 'W3', 49: 'W4'
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
try:
|
|
161
|
+
response = requests.get(url, params=params, timeout=15)
|
|
162
|
+
|
|
163
|
+
#DEBUG: Ha 500-as hiba van, írjuk ki, mit mondott a szerver
|
|
164
|
+
if response.status_code == 500:
|
|
165
|
+
print(f"❌ Server error 500! Szerver válasza: {response.text[:500]}")
|
|
166
|
+
return pd.DataFrame()
|
|
167
|
+
elif response.status_code != 200:
|
|
168
|
+
print(f"❌ Server error: {response.status_code}")
|
|
169
|
+
return pd.DataFrame()
|
|
170
|
+
|
|
171
|
+
json_data = response.json()
|
|
172
|
+
if json_data.get('status') != 'success':
|
|
173
|
+
print(f"❌ Database error: {json_data.get('message', 'Unknown error')}")
|
|
174
|
+
return pd.DataFrame()
|
|
175
|
+
|
|
176
|
+
server_ceph_id = json_data.get('ceph_id')
|
|
177
|
+
server_star_name = json_data.get('name')
|
|
178
|
+
print(f"🎯 Star resolved: Found '{server_star_name}' (Internal EGCDb ID: {server_ceph_id})")
|
|
179
|
+
|
|
180
|
+
raw_points = json_data['data']
|
|
181
|
+
total_points = json_data.get('count', 0)
|
|
182
|
+
|
|
183
|
+
if total_points == 0:
|
|
184
|
+
print(f"⚠ Warning: No points found matching the criteria.")
|
|
185
|
+
return pd.DataFrame()
|
|
186
|
+
|
|
187
|
+
print(f"📥 Downloading and parsing {total_points} photometric datapoints...")
|
|
188
|
+
|
|
189
|
+
flattened_points = []
|
|
190
|
+
for pt in raw_points:
|
|
191
|
+
b_id = pt.get('ceph_mag_conn_id')
|
|
192
|
+
b_name = local_band_map.get(b_id, f"ID_{b_id}")
|
|
193
|
+
|
|
194
|
+
jd_val = pt.get('time_jd') if pt.get('time_jd') is not None else pt.get('HJD_epoch')
|
|
195
|
+
|
|
196
|
+
flattened_points.append({
|
|
197
|
+
'jd': float(jd_val) if jd_val is not None else None,
|
|
198
|
+
'magnitude': float(pt['data']) if pt.get('data') is not None else None,
|
|
199
|
+
'error': float(pt['mag_err']) if pt.get('mag_err') is not None else None,
|
|
200
|
+
'band': b_name
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
df = pd.DataFrame(flattened_points)
|
|
204
|
+
if not df.empty and 'jd' in df.columns:
|
|
205
|
+
df = df.sort_values('jd').reset_index(drop=True)
|
|
206
|
+
|
|
207
|
+
print(f"✓ Light curve loaded successfully into DataFrame.")
|
|
208
|
+
return df
|
|
209
|
+
|
|
210
|
+
except requests.exceptions.RequestException as e:
|
|
211
|
+
print(f"❌ Network error while fetching light curve: {e}")
|
|
212
|
+
return pd.DataFrame()
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyegcdb
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: Python client for the Extragalactic Cepheid Database of the Konkoly Observatory
|
|
5
|
+
Author-email: Dóra Tarczay-Nehéz <tarczaynehez.dora@csfk.org>
|
|
6
|
+
License: GNU GPLv3
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: requests>=2.28.0
|
|
16
|
+
Requires-Dist: pandas>=1.5.0
|
|
17
|
+
Requires-Dist: astropy>=5.0.0
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# pyegcdb
|
|
21
|
+
|
|
22
|
+
`pyegcdb` is the official Python client for the **Konkoly Cepheid Database**. It provides astronomers and researchers with a seamless interface to query light curves and stellar catalog data directly within a Python environment.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
You can install the package directly from PyPI:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install pyegcdb
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
To begin using the library, initialize the client and fetch data by the star's name:
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from pyegcdb import KonkolyCepheids
|
|
39
|
+
|
|
40
|
+
# 1. Initialize the client
|
|
41
|
+
db = KonkolyCepheids()
|
|
42
|
+
|
|
43
|
+
# 2. Fetch light curve data for a specific star
|
|
44
|
+
star_name = "OGLE LMC-SC1 14252"
|
|
45
|
+
lc_df = db.load_datapoints(identifier=star_name, bands=['B'])
|
|
46
|
+
|
|
47
|
+
# 3. Preview the results
|
|
48
|
+
if not lc_df.empty:
|
|
49
|
+
print(lc_df.head())
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## Key Features
|
|
57
|
+
|
|
58
|
+
* **Light Curve Retrieval:** Easily download raw photometric time-series data for specific Cepheids.
|
|
59
|
+
* **Catalog Querying:** Perform advanced searches based on galaxy, variable type, or perform a Cone Search (RA/Dec).
|
|
60
|
+
* **Smart Filtering:** Built-in deduplication logic that prioritizes the most recent publication data.
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
## Citation
|
|
64
|
+
If you use `pyegcdb` in your research, please cite our relevant work:
|
|
65
|
+
|
|
66
|
+
```bibtex
|
|
67
|
+
@INPROCEEDINGS{2020svos.conf..115T,
|
|
68
|
+
author = {{Tarczay-Neh{\'e}z}, D. and {Szabados}, L. and {Dencs}, Z.},
|
|
69
|
+
title = "{Cepheids Near and Far}",
|
|
70
|
+
keywords = {Stars: variables: Cepheids, Astronomical databases: miscellaneous, Galaxies: statistics, Stars: statistics, Galaxy: stellar content, (Cosmology:) distance scale},
|
|
71
|
+
booktitle = {Stars and their Variability Observed from Space},
|
|
72
|
+
year = 2020,
|
|
73
|
+
editor = {{Neiner}, C. and {Weiss}, W.~W. and {Baade}, D. and {Griffin}, R.~E. and {Lovekin}, C.~C. and {Moffat}, A.~F.~J.},
|
|
74
|
+
month = jan,
|
|
75
|
+
pages = {115-118},
|
|
76
|
+
adsurl = {https://ui.adsabs.harvard.edu/abs/2020svos.conf..115T},
|
|
77
|
+
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@INPROCEEDINGS{2022eas..conf..420T,
|
|
83
|
+
author = {{Tarczay-Neh{\'e}z}, D{\'o}ra and {Dencs}, Zolt{\'a}n and {Szabados}, L{\'a}szl{\'o} and {Moln{\'a}r}, L{\'a}szl{\'o}},
|
|
84
|
+
title = "{Extragalactic Cepheid Database}",
|
|
85
|
+
booktitle = {EAS2022, European Astronomical Society Annual Meeting},
|
|
86
|
+
year = 2022,
|
|
87
|
+
month = jul,
|
|
88
|
+
eid = {420},
|
|
89
|
+
pages = {420},
|
|
90
|
+
adsurl = {https://ui.adsabs.harvard.edu/abs/2022eas..conf..420T},
|
|
91
|
+
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
This software is released under the [GNU GPLv3] license.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/pyegcdb/__init__.py
|
|
5
|
+
src/pyegcdb/core.py
|
|
6
|
+
src/pyegcdb.egg-info/PKG-INFO
|
|
7
|
+
src/pyegcdb.egg-info/SOURCES.txt
|
|
8
|
+
src/pyegcdb.egg-info/dependency_links.txt
|
|
9
|
+
src/pyegcdb.egg-info/requires.txt
|
|
10
|
+
src/pyegcdb.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pyegcdb
|