|
42 | 42 | _APY_GE_31,
|
43 | 43 | _APY_LOADED,
|
44 | 44 | _APY_UNITS,
|
| 45 | + _AQ_GT_47, |
45 | 46 | _ASTROQUERY_LOADED,
|
46 | 47 | _NUMEXPR_LOADED,
|
47 | 48 | )
|
@@ -7471,35 +7472,66 @@ def _from_name_oneobject(name, obs):
|
7471 | 7472 | # Make sure to make an HTTPS request so this code works in the browser
|
7472 | 7473 | simbad.SIMBAD_URL = simbad.SIMBAD_URL.replace("http://", "https://")
|
7473 | 7474 | simbad.add_votable_fields(
|
7474 |
| - "ra(d)", "dec(d)", "pmra", "pmdec", "rv_value", "plx", "distance" |
| 7475 | + "ra" if _AQ_GT_47 else "ra(d)", |
| 7476 | + "dec" if _AQ_GT_47 else "dec(d)", |
| 7477 | + "pmra", |
| 7478 | + "pmdec", |
| 7479 | + "rvz_radvel" if _AQ_GT_47 else "rv_value", |
7475 | 7480 | )
|
7476 |
| - simbad.remove_votable_fields("main_id", "coordinates") |
| 7481 | + if not _AQ_GT_47: |
| 7482 | + simbad.add_votable_fields("plx", "distance") |
7477 | 7483 | # query SIMBAD for the named object
|
7478 | 7484 | try:
|
7479 | 7485 | simbad_table = simbad.query_object(name)
|
7480 | 7486 | except OSError: # pragma: no cover
|
7481 | 7487 | raise OSError("failed to connect to SIMBAD")
|
7482 | 7488 | if not simbad_table:
|
7483 | 7489 | raise ValueError(f"failed to find {name} in SIMBAD")
|
7484 |
| - # check that the necessary coordinates have been found |
7485 |
| - missing = simbad_table.mask |
7486 |
| - if any(missing["RA_d", "DEC_d", "PMRA", "PMDEC", "RV_VALUE"][0]) or all( |
7487 |
| - missing["PLX_VALUE", "Distance_distance"][0] |
7488 |
| - ): |
7489 |
| - raise ValueError( |
7490 |
| - "failed to find some coordinates for {} in " "SIMBAD".format(name) |
7491 |
| - ) |
7492 |
| - ra, dec, pmra, pmdec, vlos = simbad_table[ |
7493 |
| - "RA_d", "DEC_d", "PMRA", "PMDEC", "RV_VALUE" |
7494 |
| - ][0] |
7495 |
| - # get a distance value |
7496 |
| - if not missing["PLX_VALUE"][0]: |
7497 |
| - dist = 1.0 / simbad_table["PLX_VALUE"][0] |
| 7490 | + if _AQ_GT_47: |
| 7491 | + # check that the necessary coordinates have been found |
| 7492 | + missing = simbad_table.mask |
| 7493 | + if any(missing["ra", "dec", "pmra", "pmdec", "rvz_radvel"][0]): |
| 7494 | + raise ValueError( |
| 7495 | + "failed to find some coordinates for {} in " "SIMBAD".format(name) |
| 7496 | + ) |
| 7497 | + ra, dec, pmra, pmdec, vlos = simbad_table[ |
| 7498 | + "ra", "dec", "pmra", "pmdec", "rvz_radvel" |
| 7499 | + ][0] |
| 7500 | + # get a distance value |
| 7501 | + simbad.add_votable_fields("plx_value") |
| 7502 | + simbad_table = simbad.query_object(name) |
| 7503 | + if not simbad_table or ( |
| 7504 | + hasattr(simbad_table["plx_value"][0], "mask") |
| 7505 | + and simbad_table["plx_value"][0].mask |
| 7506 | + ): # No parallax, try to find a distance |
| 7507 | + simbad.add_votable_fields("mesdistance") |
| 7508 | + simbad_table = simbad.query_object(name) |
| 7509 | + if not simbad_table: |
| 7510 | + raise ValueError(f"Failed to find a distance for {name} in SIMBAD") |
| 7511 | + dist = simbad_table["mesdistance.dist"][0] |
| 7512 | + else: |
| 7513 | + dist = 1.0 / simbad_table["plx_value"][0] |
7498 | 7514 | else:
|
7499 |
| - dist_str = ( |
7500 |
| - str(simbad_table["Distance_distance"][0]) + simbad_table["Distance_unit"][0] |
7501 |
| - ) |
7502 |
| - dist = units.Quantity(dist_str).to(units.kpc).value |
| 7515 | + # check that the necessary coordinates have been found |
| 7516 | + missing = simbad_table.mask |
| 7517 | + if any(missing["RA_d", "DEC_d", "PMRA", "PMDEC", "RV_VALUE"][0]) or all( |
| 7518 | + missing["PLX_VALUE", "Distance_distance"][0] |
| 7519 | + ): |
| 7520 | + raise ValueError( |
| 7521 | + "failed to find some coordinates for {} in " "SIMBAD".format(name) |
| 7522 | + ) |
| 7523 | + ra, dec, pmra, pmdec, vlos = simbad_table[ |
| 7524 | + "RA_d", "DEC_d", "PMRA", "PMDEC", "RV_VALUE" |
| 7525 | + ][0] |
| 7526 | + # get a distance value |
| 7527 | + if not missing["PLX_VALUE"][0]: |
| 7528 | + dist = 1.0 / simbad_table["PLX_VALUE"][0] |
| 7529 | + else: |
| 7530 | + dist_str = ( |
| 7531 | + str(simbad_table["Distance_distance"][0]) |
| 7532 | + + simbad_table["Distance_unit"][0] |
| 7533 | + ) |
| 7534 | + dist = units.Quantity(dist_str).to(units.kpc).value |
7503 | 7535 | return [ra, dec, dist, pmra, pmdec, vlos]
|
7504 | 7536 |
|
7505 | 7537 |
|
|
0 commit comments