当前位置: 首页>>代码示例>>Python>>正文


Python Vizier.query_object方法代码示例

本文整理汇总了Python中astroquery.vizier.Vizier.query_object方法的典型用法代码示例。如果您正苦于以下问题:Python Vizier.query_object方法的具体用法?Python Vizier.query_object怎么用?Python Vizier.query_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在astroquery.vizier.Vizier的用法示例。


在下文中一共展示了Vizier.query_object方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_hip

# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_object [as 别名]
def get_hip(name):
    """
    Given a star's Bayer designation, queries
    VizieR and attempts to locate a Hipparcos
    star ID at the location.

    Returns an integer HIP ID if found, or None otherwise

    Maintains a .hip_cache_stars file to speed up lookups;
    you can delete the .hip_cache_stars file to perform
    fresh lookups.
    """
    # Search the Hipparcos catalog, and only return results that include
    # a HIP (Hipparcos) column, sorting the results by magnitude.  The
    # top result is almost certainly the star we want.
    v = Vizier(catalog='I/239/hip_main', columns=["HIP", "+Vmag"])

    try:
        result = v.query_object(name)
    except EOFError:
        # if we get no results we might get an EOFError
        return None
    try:
        table = result['I/239/hip_main']
    except TypeError:
        # A TypeError means that the results didn't include anything from
        # the I/239/hip_main catalog.  The "in" operator doesn't seem to
        # work with Table objects.
        return None
    else:
        return table['HIP'][0]
开发者ID:Stellarium,项目名称:stellarium,代码行数:33,代码来源:generate_star_names.py

示例2: get_galaxy_s4g_one_component_info

# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_object [as 别名]
def get_galaxy_s4g_one_component_info(name):

    """
    This function ...
    :param name:
    :return:
    """

    # The Vizier querying object
    vizier = Vizier()
    vizier.ROW_LIMIT = -1

    # Get the "galaxies" table
    result = vizier.query_object(name, catalog=["J/ApJS/219/4/galaxies"])

    # No results?
    if len(result) == 0: return None, None, None, None, None, None

    # Get table
    table = result[0]

    # PA: [0.2/180] Outer isophote position angle
    # e_PA: [0/63] Standard deviation in PA
    # Ell:  [0.008/1] Outer isophote ellipticity
    # e_Ell: [0/0.3] Standard deviation in Ell

    # PA1: Elliptical isophote position angle in deg
    # n: Sersic index
    # Re: effective radius in arcsec

    # Tmag: total magnitude

    s4g_name = table["Name"][0]

    pa = Angle(table["PA"][0] - 90., "deg")
    pa_error = Angle(table["e_PA"][0], "deg")

    ellipticity = table["Ell"][0]
    ellipticity_error = table["e_Ell"][0]

    n = table["n"][0]

    re = table["Re"][0] * u("arcsec")

    mag = table["Tmag"][0]

    # Return the results
    return s4g_name, pa, ellipticity, n, re, mag
开发者ID:SKIRT,项目名称:PTS,代码行数:50,代码来源:catalogs.py

示例3: query_catalog_for_object

# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_object [as 别名]
def query_catalog_for_object(identifier, catalog=duncan1991):
    """
    Parameters
    ----------
    identifier : str

    catalog : str (optional)

    Returns
    -------

    """
    query = Vizier.query_object(identifier, catalog=catalog)

    if len(query) > 0:
        return query[0][0]
    else:
        return dict(Smean=np.nan, Smin=np.nan, Smax=np.nan)
开发者ID:bmorris3,项目名称:freckles,代码行数:20,代码来源:catalog.py

示例4: create_vizier_metafile

# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_object [as 别名]
def create_vizier_metafile():
    result = Vizier.query_object("sirius")

    text_file = open("D:\\Programming\\Astronomy\\VizierMeta.txt", "w")
    text_file.truncate()

    for table in result:
        #print table.colnames
        text_file.write('(' + table.meta['name'] + ') ' + table.meta['description'] + '\n')

        for col in table.colnames:
            text_file.write('\t' + col + '\n')

        text_file.write('\n')
        text_file.write('\n')
        #print table.colnames
        #print table.meta['description']

    text_file.close()
开发者ID:Civa,项目名称:Zenith,代码行数:21,代码来源:vizier.py

示例5: get_s4g_properties

# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_object [as 别名]
    def get_s4g_properties(self):

        """
        This function ...
        :return:
        """

        # Inform the user
        log.info("Querying the S4G catalog ...")

        # The Vizier querying object
        vizier = Vizier(columns=['Name', 'RAJ2000', 'DEJ2000', 'amaj', 'ell', 'Dmean', "e_Dmean", "PA"])
        vizier.ROW_LIMIT = -1

        # Get parameters from S4G catalog
        result = vizier.query_object(self.galaxy_name, catalog=["J/PASP/122/1397/s4g"])
        table = result[0]

        # Galaxy name for S4G catalog
        self.properties.name = table["Name"][0]

        # Galaxy center from decomposition (?)
        ra_center = table["RAJ2000"][0]
        dec_center = table["DEJ2000"][0]
        center = SkyCoordinate(ra=ra_center, dec=dec_center, unit="deg", frame='fk5')
        self.properties.center = center

        # Center position
        #self.properties.center = SkyCoordinate(ra=self.info["RA"][0], dec=self.info["DEC"][0], unit="deg") # center position from DustPedia

        # Distance
        self.properties.distance = table["Dmean"][0] * u("Mpc")
        self.properties.distance_error = table["e_Dmean"][0] * u("Mpc")

        # Major axis, ellipticity, position angle
        self.properties.major_arcsec = table["amaj"][0] * u("arcsec")
        self.properties.major = (self.properties.distance * self.properties.major_arcsec).to("pc", equivalencies=dimensionless_angles())

        # Ellipticity
        self.properties.ellipticity = table["ell"][0]
        self.properties.position_angle = Angle(table["PA"][0] + 90.0, u("deg"))
开发者ID:SKIRT,项目名称:PTS,代码行数:43,代码来源:properties.py

示例6: query

# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_object [as 别名]
def query():
    result = Vizier.query_object("Betelgeuse", catalog=["V/137D/XHIP", "V/85A/catalog"])
    #result = Vizier.query_object("sirius", catalog="J/A+A/501/949/table")

    text_file = open("D:\\Programming\\Astronomy\\VizierTest.txt", "w")
    text_file.truncate()

    for table in result:
        text_file.write('\n')
        text_file.write('\n')
        text_file.write('(' + table.meta['name'] + ') ' + table.meta['description'] + '\n')
        text_file.write('\n')
        text_file.write('\n')
        for row in table:
            for col in table.colnames:
                text_file.write(col + '\t' + str(row[col]) + '\n')
                text_file.write('\n')
                #print row[col]

            #print row

    text_file.close()
开发者ID:Civa,项目名称:Zenith,代码行数:24,代码来源:vizier.py

示例7: SEDFetcher

# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_object [as 别名]

#.........这里部分代码省略.........
        # - "D25FUV": Observed D25 ellipse FUV band AB magnitude [mag]
        # - "e_D25FUV": Uncertainty in D25FUV [mag]
        # - "D25NUV": Observed D25 ellipse NUV band AB magnitude [mag]
        # - "e_D25NUV": Uncertainty in D25NUV [mag]
        # - "AFUV": Foreground FUV extinction [mag]
        # - "ANUV": Foreground NUV extinction [mag]
        # - "asyFUV": Observed asymptotic FUV (120-177nm) AB magnitude [mag]
        # - "e_asyFUV": Uncertainty in asyFUV [mag]
        # - "asyNUV": Observed asymptotic NUV (177-300nm) AB magnitude [mag]
        # - "e_asyNUV": Uncertainty in asyNUV [mag]
        # - "logFUV": Log of the FUV (120-177nm) luminosity [W]
        # - "logNUV": Log of the NUV (177-300nm) luminosity [W]
        # - "Umag": Johnson U band integrated magnitude [mag] Note (1): In the Vega scale. Published as part of the RC3 catalog, Cat. VII/155)
        # - "e_Umag": Uncertainty in Umag [mag]
        # - "Bmag": Johnson B band integrated magnitude [mag]
        # - "e_Bmag": Uncertainty in Bmag [mag]
        # - "Vmag": Johnson V band integrated magnitude [mag]
        # - "e_Vmag": Uncertainty in Vmag [mag]
        # - "Jmag": 2MASS J band total magnitude [mag]
        # - "e_Jmag": Uncertainty in Jmag [mag]
        # - "Hmag": 2MASS H band total magnitude [mag]
        # - "e_Hmag": Uncertainty in Hmag [mag]
        # - "Kmag": 2MASS K band total magnitude [mag]
        # - "e_Kmag": Uncertainty in Kmag [mag]
        # - "F12um": IRAS 12 micron flux density [Jy]
        # - "e_F12um": Uncertainty in F12um [Jy]
        # - "F25um": IRAS 25 micron flux density [Jy]
        # - "e_F25um": Uncertainty in F25um [Jy]
        # - "F60um": IRAS 60 micron flux density [Jy]
        # - "e_F60um": Uncertainty in F60um [Jy]
        # - "F100um": IRAS 100 micron flux density [Jy]
        # - "e_F100um": Uncertainty in F100um [Jy]

        result = self.vizier.query_object(self.galaxy_name, catalog="J/ApJS/173/185/galex")
        # Result is a list of tables, we only have one table with one entry

        # Create an SED
        sed = ObservedSED()

        # All AB magnitudes

        # FUV --

        if not result[0]["asyFUV"].mask[0]:

            fuv_mag = result[0]["asyFUV"][0]
            fuv_mag_error = result[0][0]["e_asyFUV"]
            fuv_mag_lower = fuv_mag - fuv_mag_error
            fuv_mag_upper = fuv_mag + fuv_mag_error

            # flux
            fuv = unitconversion.ab_to_jansky(fuv_mag)
            fuv_lower = unitconversion.ab_to_jansky(fuv_mag_upper)
            fuv_upper = unitconversion.ab_to_jansky(fuv_mag_lower)
            fuv_error = ErrorBar(fuv_lower, fuv_upper, at=fuv)
            sed.add_entry(self.filters["FUV"], fuv, fuv_error)

        # NUV --

        if not result[0]["asyNUV"].mask[0]:

            nuv_mag = result[0][0]["asyNUV"]
            nuv_mag_error = result[0][0]["e_asyNUV"]
            nuv_mag_lower = nuv_mag - nuv_mag_error
            nuv_mag_upper = nuv_mag + nuv_mag_error
开发者ID:Stargrazer82301,项目名称:CAAPR,代码行数:69,代码来源:sedfetching.py

示例8: vizier_query

# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_object [as 别名]
def vizier_query(obj, params=True, method='both', coordinate=False):
    """Give mean/median values of some parameters for an object.
    This script use VizieR for looking up the object.

    :obj: The object to query (e.g. HD20010).
    :parama: Extra parameters to look for (default is Teff, logg, __Fe_H_).
    :method: Print median, main or both

    :returns: A dictionary with the parameters
    """

    with warnings.catch_warnings():
        warnings.simplefilter('ignore')
        cat = Vizier.query_object(obj)

    if coordinate:
        for c in cat:
            try:
                ra = c['RAJ2000'][0]
                dec = c['DEJ2000'][0]
            except KeyError:
                ra = 0
            if ra != 0:
                break
        print('\n\n%s %s %s' % (obj, ra, dec))
    else:
        print('\n\nObject: %s' % obj)

    parameters = {'Teff': [], 'logg': [], '__Fe_H_': []}
    if params:
        params=['Teff', 'logg', '__Fe_H_']
        for param in params:
            parameters[param] = []

        for ci in cat:
            for column in parameters.keys():
                try:
                    parameters[column].append(ci[column].quantity)
                except (TypeError, KeyError):
                    pass

        for key in parameters.keys():
            pi = parameters[key]
            parameters[key] = _q2a(pi)
            if len(parameters[key]):
                mean = round(np.nanmean(parameters[key]), 2)
                median = round(np.nanmedian(parameters[key]), 2)
            else:
                mean = 'Not available'
                median = 'Not available'

            if key.startswith('__'):
                key = '[Fe/H]'
            if method == 'mean':
                print('\n%s:\tMean value: %s' % (key, mean))
            elif method == 'median':
                print('\n%s\tMedian value: %s' % (key, median))
            else:
                print('\n%s:\tMean value: %s' % (key, mean))
                print('%s:\tMedian value: %s' % (key, median))

    return parameters, cat
开发者ID:DanielAndreasen,项目名称:astro_scripts,代码行数:64,代码来源:vizier_query.py

示例9: get_galaxy_info

# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_object [as 别名]
def get_galaxy_info(name, position):

    """
    This function ...
    :param name:
    :param position:
    :return:
    """

    # Obtain more information about this galaxy
    try:

        ned_result = Ned.query_object(name)
        ned_entry = ned_result[0]

        # Get a more common name for this galaxy (sometimes, the name obtained from NED is one starting with 2MASX .., use the PGC name in this case)
        if ned_entry["Object Name"].startswith("2MASX "): gal_name = name
        else: gal_name = ned_entry["Object Name"]

        # Get the redshift
        gal_redshift = ned_entry["Redshift"]
        if isinstance(gal_redshift, np.ma.core.MaskedConstant): gal_redshift = None

        # Get the type (G=galaxy, HII ...)
        gal_type = ned_entry["Type"]
        if isinstance(gal_type, np.ma.core.MaskedConstant): gal_type = None

    except astroquery.exceptions.RemoteServiceError:

        # Set attributes
        gal_name = name
        gal_redshift = None
        gal_type = None

    except astroquery.exceptions.TimeoutError:

        # Set attributes
        gal_name = name
        gal_redshift = None
        gal_type = None

    except:

        # Set attributes
        gal_name = name
        gal_redshift = None
        gal_type = None

    # Create a new Vizier object and set the row limit to -1 (unlimited)
    viz = Vizier(keywords=["galaxies", "optical"])
    viz.ROW_LIMIT = -1

    # Query Vizier and obtain the resulting table
    result = viz.query_object(name.replace(" ", ""), catalog=["VII/237"])

    # Not found ... TODO: fix this ... this object was in the first query output
    if len(result) == 0: return name, position, None, None, [], None, None, None, None, None, None

    table = result[0]

    # Get the correct entry (sometimes, for example for mergers, querying with the name of one galaxy gives two hits! We have to obtain the right one each time!)
    if len(table) == 0: raise ValueError("The galaxy could not be found under this name")
    elif len(table) == 1: entry = table[0]
    else:

        entry = None

        # Some rows don't have names, if no match is found based on the name just take the row that has other names defined
        rows_with_names = []
        for row in table:
            if row["ANames"]: rows_with_names.append(row)

        # If only one row remains, take that one for the galaxy we are looking for
        if len(rows_with_names) == 1: entry = rows_with_names[0]

        # Else, loop over the rows where names are defined and look for a match
        else:
            for row in rows_with_names:

                names = row["ANames"]

                if name.replace(" ", "") in names or gal_name.replace(" ", "") in names:

                    entry = row
                    break

        # If no matches are found, look for the table entry for which the coordinate matches the given position (if any)
        if entry is None and position is not None:
            for row in table:
                if np.isclose(row["_RAJ2000"], position.ra.value) and np.isclose(row["_DEJ2000"], position.dec.value):
                    entry = row
                    break

    # Note: another temporary fix
    if entry is None: return name, position, None, None, [], None, None, None, None, None, None

    # Get the right ascension and the declination
    position = SkyCoordinate(ra=entry["_RAJ2000"], dec=entry["_DEJ2000"], unit="deg", frame="fk5")

    # Get the names given to this galaxy
#.........这里部分代码省略.........
开发者ID:Stargrazer82301,项目名称:CAAPR,代码行数:103,代码来源:catalogs.py

示例10: GalaxyDecomposer

# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_object [as 别名]

#.........这里部分代码省略.........
        self.get_general_parameters()

        # Get the decomposition parameters
        #self.get_p4() currently (writing on 31 of march 2016) there is a problem with the effective radius values
        # (at least for M81) on Vizier as well as in the PDF version of table 7 (S4G models homepage).

        # Parse the S4G table 8 to get the decomposition parameters
        self.get_parameters_from_table()

        #self.parameters.bulge.n = 2.62
        #self.parameters.bulge.PA = Angle(-31.9 + 90., "deg")
        #self.parameters.bulge.q = 0.71
        #value = 46.2 * Unit("arcsec")
        #self.parameters.bulge.Re = (self.parameters.distance * value).to("pc", equivalencies=dimensionless_angles())

        #value = 155.4 * Unit("arcsec")
        #self.parameters.disk.hr = (self.parameters.distance * value).to("pc", equivalencies=dimensionless_angles())
        #self.parameters.disk.q = 0.52
        #self.parameters.disk.PA = Angle(-28.3 + 90., "deg")

    # -----------------------------------------------------------------

    def get_general_parameters(self):

        """
        This function ...
        :return:
        """

        # Inform the user
        log.info("Querying the S4G catalog ...")

        # Get parameters from S4G catalog
        result = self.vizier.query_object(self.galaxy_name, catalog=["J/PASP/122/1397/s4g"])
        table = result[0]

        # Galaxy name for S4G catalog
        self.parameters.galaxy_name = table["Name"][0]

        # Galaxy center from decomposition (?)
        ra_center = table["_RAJ2000"][0]
        dec_center = table["_DEJ2000"][0]
        center = SkyCoordinate(ra=ra_center, dec=dec_center, unit="deg", frame='fk5')
        self.parameters.center = center

        # Distance
        self.parameters.distance = table["Dmean"][0] * Unit("Mpc")
        self.parameters.distance_error = table["e_Dmean"][0] * Unit("Mpc")

        # Major axis, ellipticity, position angle
        self.parameters.major_arcsec = table["amaj"][0] * Unit("arcsec")
        self.parameters.major = (self.parameters.distance * self.parameters.major_arcsec).to("pc", equivalencies=dimensionless_angles())

        # Ellipticity
        self.parameters.ellipticity = table["ell"][0]
        self.parameters.position_angle = Angle(table["PA"][0] + 90.0, Unit("deg"))

        # Magnitudes
        asymptotic_ab_magnitude_i1 = table["__3.6_"][0]
        asymptotic_ab_magnitude_i2 = table["__4.5_"][0]
        asymptotic_ab_magnitude_i1_error = table["e__3.6_"][0]
        asymptotic_ab_magnitude_i2_error = table["e__4.5_"][0]

        self.parameters.i1_mag = asymptotic_ab_magnitude_i1
        self.parameters.i1_mag_error = asymptotic_ab_magnitude_i1_error
        self.parameters.i2_mag = asymptotic_ab_magnitude_i2
开发者ID:Stargrazer82301,项目名称:CAAPR,代码行数:70,代码来源:decomposition.py

示例11: enumerate

# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_object [as 别名]
E1DecRange = []
# Loop through each Landolt star and retrieve the USNO-B1 data for that object.
for iStar, star in enumerate(landoltStars):
    # Parse the star's name in SimbadName
    simbadName = star['SimbadName'].decode('utf-8')

    # Parse this star's pointing
    RA, Dec  = star['_RAJ2000'], star['_DEJ2000']

    # Skip over Landolt stars more than 10 degrees from the equator.
    if np.abs(Dec) > 20.0:
        print('Star {0} is far from the equator... skipping'.format(simbadName))
        continue

    # Query the USNO-B1.0 data for this object
    USNOB = Vizier.query_object(simbadName,
        radius = 5.0*u.arcsec, catalog='USNO-B1')

    if len(USNOB) > 0:
        # Some match was found, so grab that 'catalog'
        USNOB = USNOB[0]
    else:
        print('Star {0} not matched in USNO-B1.0... skipping'.format(simbadName))
        continue

    # If there is more than one object returned,
    if len(USNOB) > 1:
        # Then find the object closest to the query point and just use that.
        matchInd = np.where(USNOB['_r'].data == USNOB['_r'].data.min())
        USNOB    = USNOB[matchInd]

    # Test if we know where this data came from
开发者ID:jmontgom10,项目名称:USNO-B_transformations,代码行数:34,代码来源:01_downloadCatalogs.py

示例12: S4G

# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_object [as 别名]

#.........这里部分代码省略.........
        # b_to_a = 1. - self.properties.ellipticity
        #
        # # Calculate the inclination
        # inclination_deg = 90. - math.degrees(math.acos(b_to_a))
        # inclination = Angle(inclination_deg, "deg")
        #
        # # Check the inclination
        # if self.inclination is not None:
        #     difference = abs(self.inclination - inclination)
        #     rel_difference = difference / self.inclination
        #     if rel_difference > 0.1:
        #         log.warning("The inclination angle calculated based on the decomposition differs by " + str(rel_difference*100) + "% from the specified inclination")
        #
        # # Set the incliantion
        # self.properties.inclination = inclination

    # -----------------------------------------------------------------

    def get_s4g_properties(self):

        """
        This function ...
        :return:
        """

        # Inform the user
        log.info("Querying the S4G catalog ...")

        # The Vizier querying object, specifying the necessary columns for this class
        self.vizier = Vizier(columns=['Name', 'RAJ2000', 'DEJ2000', 'Dmean', 'e_Dmean', 'amaj', 'ell', '[3.6]', '[4.5]', 'e_[3.6]', 'e_[4.5]', 'PA'])
        self.vizier.ROW_LIMIT = -1

        # Get parameters from S4G catalog
        result = self.vizier.query_object(self.config.galaxy_name, catalog=["J/PASP/122/1397/s4g"])
        table = result[0]

        # Galaxy name for S4G catalog
        self.properties.name = table["Name"][0]
        # Galaxy center from decomposition (?)
        ra_center = table["RAJ2000"][0]
        dec_center = table["DEJ2000"][0]
        center = SkyCoordinate(ra=ra_center, dec=dec_center, unit="deg", frame='fk5')
        self.properties.center = center

        # Center position
        #self.properties.center = SkyCoordinate(ra=self.info["RA"][0], dec=self.info["DEC"][0], unit="deg") # center position from DustPedia
        
        # Distance
        self.properties.distance = table["Dmean"][0] * u("Mpc")
        self.properties.distance_error = table["e_Dmean"][0] * u("Mpc")

        # Major axis, ellipticity, position angle
        self.properties.major_arcsec = table["amaj"][0] * u("arcsec")
        self.properties.major = (self.properties.distance * self.properties.major_arcsec).to("pc", equivalencies=dimensionless_angles())

        # Ellipticity
        self.properties.ellipticity = table["ell"][0]
        self.properties.position_angle = Angle(table["PA"][0] + 90.0, u("deg"))

        # Magnitudes
        asymptotic_ab_magnitude_i1 = table["__3.6_"][0]
        asymptotic_ab_magnitude_i2 = table["__4.5_"][0]
        asymptotic_ab_magnitude_i1_error = table["e__3.6_"][0]
        asymptotic_ab_magnitude_i2_error = table["e__4.5_"][0]

        #self.properties.i1_mag = asymptotic_ab_magnitude_i1
开发者ID:SKIRT,项目名称:PTS,代码行数:70,代码来源:s4g.py

示例13: vizier_query

# 需要导入模块: from astroquery.vizier import Vizier [as 别名]
# 或者: from astroquery.vizier.Vizier import query_object [as 别名]
def vizier_query(object, params=None, method="both", coordinate=False):
    """Give mean/median values of some parameters for an object.
    This script use VizieR for looking up the object.

    :object: The object to query (e.g. HD20010).
    :parama: Extra parameters to look for (default is Teff, logg, __Fe_H_).
    :method: Print median, main or both

    :returns: A dictionary with the parameters

    """

    methods = ("median", "mean", "both")
    if method not in methods:
        raise ValueError("method must be one of:", methods)

    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        cat = Vizier.query_object(object)

    if coordinate:
        for c in cat:
            try:
                ra = c["RAJ2000"][0]
                dec = c["DEJ2000"][0]
            except KeyError:
                ra = 0
                pass
            if ra != 0:
                break
        print("%s %s %s" % (object, ra, dec))
    else:
        print("Object: %s" % object)

    parameters = {"Teff": [], "logg": [], "__Fe_H_": []}
    if params:
        params = ["Teff", "logg", "__Fe_H_"]
        for param in params:
            parameters[param] = []

        for ci in cat:
            for column in parameters.keys():
                try:
                    parameters[column].append(ci[column].quantity)
                except (TypeError, KeyError):
                    pass

        for key in parameters.keys():
            pi = parameters[key]
            parameters[key] = _q2a(pi)
            if len(parameters[key]):
                mean = round(np.nanmean(parameters[key]), 2)
                median = round(np.nanmedian(parameters[key]), 2)
            else:
                mean = "Not available"
                median = "Not available"

            if key.startswith("__"):
                key = "[Fe/H]"
            if method == "mean":
                print("\n%s:\tMean value: %s" % (key, mean))
            elif method == "median":
                print("\n%s\tMedian value: %s" % (key, median))
            else:
                print("\n%s:\tMean value: %s" % (key, mean))
                print("%s:\tMedian value: %s" % (key, median))

    return parameters, cat
开发者ID:jason-neal,项目名称:astro_scripts,代码行数:70,代码来源:vizier_query.py


注:本文中的astroquery.vizier.Vizier.query_object方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。