gaiaspec.getGaia¶
Retrieve and calibrate Gaia XP spectra as CALSPEC-style standards.
gaiaspec.getGaia ¶
Retrieve and calibrate Gaia XP spectra as CALSPEC-style standards.
Front-end of gaiaspec. Loads the bundled Gaia source / spectra tables, resolves
a star to its Gaia DR3 source id (via Simbad or the CALSPEC matching table),
calibrates the Gaia XP coefficients into flux-vs-wavelength spectra (via
gaiaxpy), optionally applies the empirical flux correction from
:mod:gaiaspec.spectrum_correction, and exposes it in the CALSPEC dictionary
format. The :class:Gaia class wraps a single standard star.
Gaia ¶
A single Gaia standard star and its calibrated XP spectrum.
Resolves label to a Gaia DR3 source id, copies the matching source-table
columns onto the instance as attributes, and lazily exposes the calibrated
(optionally flux-corrected) spectrum.
Source code in gaiaspec/getGaia.py
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | |
get_spectrum_numpy ¶
get_spectrum_numpy(flux_correction=None, correction_threshold=0.8)
Return the star's calibrated spectrum in CALSPEC dictionary format.
Uses the bundled XP coefficients if the star is in the local table, otherwise downloads it from the Gaia archive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flux_correction
|
str
|
Correction variant (None disables). |
None
|
correction_threshold
|
float
|
Minimum correlation to apply. |
0.8
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
|
Source code in gaiaspec/getGaia.py
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | |
plot_spectrum ¶
plot_spectrum(xscale='log', yscale='log')
Plot the star's calibrated flux vs wavelength with error bars.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xscale
|
str
|
Matplotlib x-axis scale. |
'log'
|
yscale
|
str
|
Matplotlib y-axis scale. |
'log'
|
Source code in gaiaspec/getGaia.py
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | |
get_gaia_sources ¶
get_gaia_sources()
Load the bundled Gaia source catalog.
Returns:
| Type | Description |
|---|---|
|
pandas.DataFrame: The |
Source code in gaiaspec/getGaia.py
45 46 47 48 49 50 51 52 53 54 | |
get_gaia_spectra ¶
get_gaia_spectra()
Load the bundled Gaia XP spectra table (uncalibrated coefficients).
Returns:
| Type | Description |
|---|---|
|
pandas.DataFrame: The |
Source code in gaiaspec/getGaia.py
57 58 59 60 61 62 63 64 65 66 | |
get_gaia_spectra_calibrated ¶
get_gaia_spectra_calibrated(flux_correction=None, correction_threshold=0.8)
Calibrate every bundled Gaia XP spectrum into CALSPEC-format flux.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flux_correction
|
str
|
Empirical correction variant to apply
(e.g. |
None
|
correction_threshold
|
float
|
Minimum correlation for the correction to be applied. |
0.8
|
Returns:
| Type | Description |
|---|---|
|
list[dict]: One CALSPEC-format spectrum dict per source. |
Source code in gaiaspec/getGaia.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
get_gaia_calspec_matching ¶
get_gaia_calspec_matching()
Load the bundled CALSPEC <-> Gaia name matching table.
Returns:
| Type | Description |
|---|---|
|
pandas.DataFrame: The |
|
|
|
Source code in gaiaspec/getGaia.py
101 102 103 104 105 106 107 108 109 110 111 | |
get_gaia_name_from_calspec ¶
get_gaia_name_from_calspec(star_label)
Resolve a CALSPEC star label to its Gaia DR3 name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
star_label
|
str
|
CALSPEC star label / key. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
The matching |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the star is not matched to exactly one Gaia entry. |
Source code in gaiaspec/getGaia.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
get_gaia_from_query_id ¶
get_gaia_from_query_id(source_id, output_path='.cache/gaiaxpy', truncation=False)
Retrieve Gaia spectrum data for one specified source ID. It can obtain the data from a CSV file located at the given 'path' or by calibrating the data with the specified 'wavelength_sampling'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_id
|
int
|
A source ID for which Gaia spectrum data is requested. |
required |
wavelength_sampling
|
float
|
The desired wavelength sampling for the spectrums. |
required |
path
|
str
|
The path to a CSV file containing Gaia spectra data. Default is None. |
required |
Returns:
| Type | Description |
|---|---|
|
pd.DataFrame: A DataFrame containing the Gaia spectrums data for the specified source IDs. |
Source code in gaiaspec/getGaia.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
download_spectrum_from_id ¶
download_spectrum_from_id(source_id, truncation=False)
Download and calibrate a single Gaia XP spectrum from the Gaia archive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_id
|
int
|
Gaia DR3 source id. |
required |
truncation
|
bool
|
Apply gaiaxpy basis truncation. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
|
|
|
and the wavelength sampling. |
Source code in gaiaspec/getGaia.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
convert_gaia_spectrum_to_calspec_format ¶
convert_gaia_spectrum_to_calspec_format(wavelength, gaia_flux, gaia_flux_error, flux_correction=None, correction_threshold=0.8)
Wrap a calibrated Gaia spectrum in the CALSPEC dictionary format.
Attaches astropy units, and optionally multiplies the flux and errors by the
empirical correction from :mod:gaiaspec.spectrum_correction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wavelength
|
ndarray
|
Wavelength grid (nm). |
required |
gaia_flux
|
ndarray
|
Flux (W m^-2 nm^-1). |
required |
gaia_flux_error
|
ndarray
|
Statistical flux error. |
required |
flux_correction
|
str
|
Correction variant (None disables it). |
None
|
correction_threshold
|
float
|
Minimum correlation to apply it. |
0.8
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
|
Source code in gaiaspec/getGaia.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
get_gaia_name_from_star_name ¶
get_gaia_name_from_star_name(label, debug=False)
Examples¶
id = get_gaia_name_from_star_name("HD111980") id 3510294882898890880
Source code in gaiaspec/getGaia.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | |
is_gaiaspec ¶
is_gaiaspec(label, debug=False)
Whether a star is present in the bundled Gaia source catalog.
Resolves the label to a Gaia DR3 id (via Simbad) if needed, then checks the bundled source table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str | int
|
Star name or Gaia source id. |
required |
debug
|
bool
|
Print resolution diagnostics. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
True if the star is in the bundled catalog. |
Source code in gaiaspec/getGaia.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | |
is_gaia_full ¶
is_gaia_full(label, debug=False)
Whether a Gaia XP spectrum can be retrieved for a star.
Resolves the label to a Gaia DR3 id and tries to fetch its spectrum from the archive/cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str | int
|
Star name or Gaia source id. |
required |
debug
|
bool
|
Print resolution diagnostics. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
True if a spectrum is available. |
Source code in gaiaspec/getGaia.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | |