Skip to main content
Ctrl+K
Astropy
  • About
    • About Astropy
    • Code of Conduct
    • Acknowledging & Citing
    • History
  • Documentation
    • astropy
    • asdf-astropy
    • astropy-healpix
    • astroquery
    • ccdproc
    • photutils
    • regions
    • reproject
    • specreduce
    • specutils
  • Get Help
  • Contribute
  • Affiliated Packages
  • Team
  • GitHub
  • About ▾
    • About Astropy
    • Code of Conduct
    • Acknowledging & Citing
    • History
  • Documentation ▾
    • astropy
    • asdf-astropy
    • astropy-healpix
    • astroquery
    • ccdproc
    • photutils
    • regions
    • reproject
    • specreduce
    • specutils
  • Get Help
  • Contribute
  • Affiliated Packages
  • Team
  • GitHub
Logo image

Astropy v8.0.1

  • Getting Started
    • Installation
    • Importing astropy and Sub-packages
    • Tutorials
  • User Guide
    • Constants (astropy.constants)
      • Constant
      • EMConstant
    • Units and Quantities (astropy.units)
      • Quantity
      • Unit-Aware Type Annotations
      • Standard Units
      • Combining and Defining Units
      • Decomposing and Composing Units
      • Magnitudes and Other Logarithmic Units
      • Structured Units
      • String Representations of Units and Quantities
      • Equivalencies
      • Physical Types
      • Using Prior Versions of Constants
      • Low-Level Unit Conversion
      • Reference/API
        • add_enabled_aliases
        • add_enabled_equivalencies
        • add_enabled_units
        • allclose
        • beam_angular_area
        • brightness_temperature
        • def_physical_type
        • def_unit
        • dimensionless_angles
        • doppler_optical
        • doppler_radio
        • doppler_redshift
        • doppler_relativistic
        • get_current_unit_registry
        • get_physical_type
        • isclose
        • logarithmic
        • magnetic_flux_field
        • mass_energy
        • molar_mass_amu
        • parallax
        • pixel_scale
        • plate_scale
        • quantity_input
        • set_enabled_aliases
        • set_enabled_equivalencies
        • set_enabled_units
        • spectral
        • spectral_density
        • temperature
        • temperature_energy
        • thermodynamic_temperature
        • zero_point_flux
        • CompositeUnit
        • Decibel
        • DecibelUnit
        • Dex
        • DexUnit
        • Equivalency
        • FunctionQuantity
        • FunctionUnitBase
        • IrreducibleUnit
        • LogQuantity
        • LogUnit
        • MagUnit
        • Magnitude
        • NamedUnit
        • PhysicalType
        • PrefixUnit
        • Quantity
        • QuantityInfo
        • QuantityInfoBase
        • SpecificTypeQuantity
        • StructuredUnit
        • Unit
        • UnitBase
        • UnitConversionError
        • UnitParserWarning
        • UnitPrefix
        • UnitScaleError
        • UnitTypeError
        • UnitsError
        • UnitsWarning
        • UnrecognizedUnit
        • enable
        • enable
        • def_physical_type
        • get_physical_type
        • PhysicalType
        • get_format
        • CDS
        • FITS
        • OGIP
        • Base
        • Console
        • Generic
        • Latex
        • LatexInline
        • Unicode
        • VOUnit
    • N-Dimensional Datasets (astropy.nddata)
      • CCDData Class
      • Image Utilities
      • Utility Functions for Handling Bit Masks and Mask Arrays
      • Decorating Functions to Accept NDData Objects
      • NDData
      • Covariance
      • Mixins for Added Functionality
        • Slicing and Indexing NDData
        • NDData Arithmetic
        • I/O Mixin
      • Subclassing
      • Reference/API
        • add_array
        • bitfield_to_boolean_mask
        • block_reduce
        • block_replicate
        • extend_bit_flag_map
        • extract_array
        • fits_ccddata_reader
        • fits_ccddata_writer
        • interpret_bit_flags
        • overlap_slices
        • reshape_as_blocks
        • subpixel_indices
        • support_nddata
        • BitFlagNameMap
        • CCDData
        • Conf
        • Covariance
        • Cutout2D
        • FlagCollection
        • IncompatibleUncertaintiesException
        • InvalidBitFlag
        • InverseVariance
        • MissingDataAssociationException
        • NDArithmeticMixin
        • NDData
        • NDDataArray
        • NDDataBase
        • NDDataRef
        • NDIOMixin
        • NDSlicingMixin
        • NDUncertainty
        • NoOverlapError
        • PartialOverlapError
        • StdDevUncertainty
        • UnknownUncertainty
        • VarianceUncertainty
        • bitfield_to_boolean_mask
        • extend_bit_flag_map
        • interpret_bit_flags
        • BitFlagNameMap
        • InvalidBitFlag
        • add_array
        • extract_array
        • overlap_slices
        • subpixel_indices
        • Cutout2D
        • NoOverlapError
        • PartialOverlapError
    • Data Tables (astropy.table)
      • Constructing a Table
      • Accessing a Table
      • Modifying a Table
      • Table Operations
      • Table Indexing
      • Masking and Missing Values
      • Mixin Columns
      • Interfacing with DataFrames
      • Interfacing with the Pandas Package
      • Astropy Table and DataFrames
      • Table Implementation Details
      • Reference/API
        • dstack
        • hstack
        • join
        • join_distance
        • join_skycoord
        • represent_mixins_as_columns
        • setdiff
        • unique
        • vstack
        • BST
        • Column
        • ColumnGroups
        • ColumnInfo
        • Conf
        • JSViewer
        • MaskedColumn
        • NdarrayMixin
        • PprintIncludeExclude
        • QTable
        • Row
        • SCEngine
        • SerializedColumn
        • SortedArray
        • StringTruncateWarning
        • Table
        • TableAttribute
        • TableColumns
        • TableFormatter
        • TableGroups
        • TableMergeError
        • TableReplaceWarning
        • classic
        • ipydatagrid
    • Time and Dates (astropy.time)
      • Reference/API
        • update_leap_seconds
        • AstropyDatetimeLeapSecondWarning
        • Conf
        • OperandTypeError
        • ScaleValueError
        • Time
        • TimeBase
        • TimeBesselianEpoch
        • TimeBesselianEpochString
        • TimeCxcSec
        • TimeDatetime
        • TimeDatetime64
        • TimeDecimalYear
        • TimeDelta
        • TimeDeltaDatetime
        • TimeDeltaFormat
        • TimeDeltaJD
        • TimeDeltaMissingUnitWarning
        • TimeDeltaNumeric
        • TimeDeltaQuantityString
        • TimeDeltaSec
        • TimeEpochDate
        • TimeEpochDateString
        • TimeFITS
        • TimeFormat
        • TimeFromEpoch
        • TimeGPS
        • TimeGalexSec
        • TimeISO
        • TimeISOT
        • TimeInfo
        • TimeInfoBase
        • TimeJD
        • TimeJulianEpoch
        • TimeJulianEpochString
        • TimeMJD
        • TimeNumeric
        • TimePlotDate
        • TimeString
        • TimeUnique
        • TimeUnix
        • TimeUnixTai
        • TimeYMDHMS
        • TimeYearDayTime
        • TimezoneInfo
    • Time Series (astropy.timeseries)
      • Creating Time Series
      • Reading and Writing Time Series
      • Accessing Data in Time Series
      • Converting between Different Time Representations
      • Manipulation and Analysis of Time Series
      • Masking Values in Time Series
      • Interfacing with the Pandas Package
      • Lomb-Scargle Periodograms
      • Lomb-Scargle Periodograms for Multiband Data
      • Box Least Squares (BLS) Periodogram
      • Reference/API
        • aggregate_downsample
        • autocheck_required_columns
        • BasePeriodogram
        • BaseTimeSeries
        • BinnedTimeSeries
        • BoxLeastSquares
        • BoxLeastSquaresResults
        • LombScargle
        • LombScargleMultiband
        • TimeSeries
        • kepler_fits_reader
    • Astronomical Coordinate Systems (astropy.coordinates)
      • Working with Angles
      • Using the SkyCoord High-Level Class
      • Transforming between Systems
      • Solar System Ephemerides
      • Working with Earth Satellites Using Astropy Coordinates
      • Formatting Coordinate Strings
      • Separations, Offsets, Catalog Matching, and Related Functionality
      • Using and Designing Coordinate Representations
      • Using and Designing Coordinate Frames
      • Working with Velocities in Astropy Coordinates
      • Accounting for Space Motion
      • Using the SpectralCoord Class
      • Using the StokesCoord Class
      • Description of the Galactocentric Coordinate Frame
      • Usage Tips/Suggestions for Methods That Access Remote Resources
      • Common mistakes
      • Important Definitions
      • Fast In-Place Modification of Coordinates
      • Example Gallery
        • Transforming positions and velocities to and from a Galactocentric frame
        • Create a new coordinate frame class for Mars
        • Determining and plotting the altitude/azimuth of a celestial object
        • Create a new coordinate class (for the Sagittarius stream)
        • Convert a radial velocity to the Galactic Standard of Rest (GSR)
      • Reference/API
        • angular_separation
        • cartesian_to_spherical
        • concatenate
        • concatenate_representations
        • custom_stokes_symbol_mapping
        • get_body
        • get_body_barycentric
        • get_body_barycentric_posvel
        • get_constellation
        • get_icrs_coordinates
        • get_sun
        • golden_spiral_grid
        • is_rotation_or_reflection
        • make_transform_graph_docs
        • match_coordinates_3d
        • match_coordinates_sky
        • offset_by
        • position_angle
        • rotation_matrix
        • search_around_3d
        • search_around_sky
        • spherical_to_cartesian
        • uniform_spherical_random_surface
        • uniform_spherical_random_volume
        • AffineTransform
        • AltAz
        • Angle
        • Attribute
        • BarycentricMeanEcliptic
        • BarycentricTrueEcliptic
        • BaseAffineTransform
        • BaseBodycentricRepresentation
        • BaseCoordinateFrame
        • BaseDifferential
        • BaseEclipticFrame
        • BaseGeodeticRepresentation
        • BaseRADecFrame
        • BaseRepresentation
        • BaseRepresentationOrDifferential
        • BaseSphericalCosLatDifferential
        • BaseSphericalDifferential
        • BoundsError
        • CIRS
        • CartesianDifferential
        • CartesianRepresentation
        • CartesianRepresentationAttribute
        • CompositeTransform
        • ConvertError
        • CoordinateAttribute
        • CoordinateFrameInfo
        • CoordinateMatchResult
        • CoordinateSearchResult
        • CoordinateTransform
        • CustomBarycentricEcliptic
        • CylindricalDifferential
        • CylindricalRepresentation
        • DifferentialAttribute
        • Distance
        • DynamicMatrixTransform
        • EarthLocation
        • EarthLocationAttribute
        • FK4
        • FK4NoETerms
        • FK5
        • FunctionTransform
        • FunctionTransformWithFiniteDifference
        • GCRS
        • GRS80GeodeticRepresentation
        • Galactic
        • GalacticLSR
        • Galactocentric
        • GenericFrame
        • GeocentricMeanEcliptic
        • GeocentricTrueEcliptic
        • HADec
        • HCRS
        • HeliocentricEclipticIAU76
        • HeliocentricMeanEcliptic
        • HeliocentricTrueEcliptic
        • ICRS
        • ITRS
        • IllegalHourError
        • IllegalHourWarning
        • IllegalMinuteError
        • IllegalMinuteWarning
        • IllegalSecondError
        • IllegalSecondWarning
        • LSR
        • LSRD
        • LSRK
        • Latitude
        • Longitude
        • NonRotationTransformationError
        • NonRotationTransformationWarning
        • PhysicsSphericalDifferential
        • PhysicsSphericalRepresentation
        • PrecessedGeocentric
        • QuantityAttribute
        • RadialDifferential
        • RadialRepresentation
        • RangeError
        • RepresentationMapping
        • SkyCoord
        • SkyCoordInfo
        • SkyOffsetFrame
        • SpectralCoord
        • SpectralQuantity
        • SphericalCosLatDifferential
        • SphericalDifferential
        • SphericalRepresentation
        • StaticMatrixTransform
        • StokesCoord
        • StokesSymbol
        • Supergalactic
        • TEME
        • TETE
        • TimeAttribute
        • TransformGraph
        • UnitSphericalCosLatDifferential
        • UnitSphericalDifferential
        • UnitSphericalRepresentation
        • UnknownSiteException
        • WGS72GeodeticRepresentation
        • WGS84GeodeticRepresentation
        • galactocentric_frame_defaults
        • solar_system_ephemeris
    • World Coordinate System (astropy.wcs)
      • Shared Python Interface for World Coordinate Systems
      • Legacy Interface
      • Supported Projections
      • Example of Imaging WCS
      • Example of Cube WCS
      • Example of a Planetary WCS
      • Loading From a FITS File
      • Subsetting and Pixel Scales
      • Header-reading relaxation constants
      • astropy.wcs History
      • Validation and Bounds checking
      • Reference/API
        • find_all_wcs
        • get_include
        • validate
        • Auxprm
        • Celprm
        • DistortionLookupTable
        • FITSFixedWarning
        • InconsistentAxisTypesError
        • InvalidCoordinateError
        • InvalidPrjParametersError
        • InvalidSubimageSpecificationError
        • InvalidTabularParametersError
        • InvalidTransformError
        • NoConvergence
        • NoSolutionError
        • NoWcsKeywordsFoundError
        • NonseparableSubimageCoordinateSystemError
        • Prjprm
        • SingularMatrixError
        • Sip
        • Tabprm
        • WCS
        • WCSBase
        • WcsError
        • Wcsprm
        • Wtbarr
        • add_stokes_axis_to_wcs
        • celestial_frame_to_wcs
        • fit_wcs_from_points
        • is_proj_plane_distorted
        • local_partial_pixel_derivatives
        • non_celestial_pixel_scales
        • obsgeo_to_frame
        • pixel_to_pixel
        • pixel_to_skycoord
        • proj_plane_pixel_area
        • proj_plane_pixel_scales
        • skycoord_to_pixel
        • wcs_to_celestial_frame
        • custom_frame_to_wcs_mappings
        • custom_wcs_to_frame_mappings
        • deserialize_class
        • high_level_objects_to_values
        • sanitize_slices
        • validate_physical_types
        • values_to_high_level_objects
        • wcs_info_str
        • BaseHighLevelWCS
        • BaseLowLevelWCS
        • BaseWCSWrapper
        • HighLevelWCSMixin
        • HighLevelWCSWrapper
        • SlicedLowLevelWCS
    • Models and Fitting (astropy.modeling)
      • Models
      • Compound Models
      • Model Parameters
      • Fitting
      • Using Units with Models and Fitting
      • Performance Tips
      • Extending Models
      • Extending Fitters
      • Adding support for units to models
      • JointFitter
      • Parallel Fitting
      • 1D Models
      • 2D Models
      • Physical Models
      • Polynomial Models
      • Powerlaw Models
      • Spline Models
      • Fitting a line
      • Fitting with constraints
      • Fitting Model Sets
      • Reference/API
        • bind_bounding_box
        • bind_compound_bounding_box
        • compose_models_with_units
        • custom_model
        • fix_inputs
        • is_separable
        • separability_matrix
        • CompoundModel
        • Fittable1DModel
        • Fittable2DModel
        • FittableModel
        • InputParameterError
        • Model
        • ModelDefinitionError
        • Parameter
        • ParameterError
        • CompoundBoundingBox
        • ModelBoundingBox
        • Identity
        • Mapping
        • UnitsMapping
        • parallel_fit_dask
        • DogBoxLSQFitter
        • FitInfoArrayContainer
        • Fitter
        • FittingWithOutlierRemoval
        • JointFitter
        • LMLSQFitter
        • LevMarLSQFitter
        • LinearLSQFitter
        • ModelLinearityError
        • ModelsError
        • SLSQPLSQFitter
        • SimplexLSQFitter
        • TRFLSQFitter
        • SLSQP
        • Optimization
        • Simplex
        • leastsquare
        • leastsquare_1d
        • leastsquare_2d
        • leastsquare_3d
        • is_separable
        • separability_matrix
        • AiryDisk2D
        • ArcCosine1D
        • ArcSine1D
        • ArcTangent1D
        • Box1D
        • Box2D
        • Const1D
        • Const2D
        • Cosine1D
        • Disk2D
        • Ellipse2D
        • Exponential1D
        • Gaussian1D
        • Gaussian2D
        • GeneralSersic2D
        • KingProjectedAnalytic1D
        • Linear1D
        • Logarithmic1D
        • Lorentz1D
        • Lorentz2D
        • Moffat1D
        • Moffat2D
        • Multiply
        • Planar2D
        • RedshiftScaleFactor
        • RickerWavelet1D
        • RickerWavelet2D
        • Ring2D
        • Scale
        • Sersic1D
        • Sersic2D
        • Shift
        • Sine1D
        • Tangent1D
        • Trapezoid1D
        • TrapezoidDisk2D
        • Voigt1D
        • NFW
        • BlackBody
        • Drude1D
        • Plummer1D
        • BrokenPowerLaw1D
        • ExponentialCutoffPowerLaw1D
        • LogParabola1D
        • PowerLaw1D
        • Schechter1D
        • SmoothlyBrokenPowerLaw1D
        • SIP
        • Chebyshev1D
        • Chebyshev2D
        • Hermite1D
        • Hermite2D
        • InverseSIP
        • Legendre1D
        • Legendre2D
        • OrthoPolynomialBase
        • Polynomial1D
        • Polynomial2D
        • PolynomialModel
        • AffineTransformation2D
        • Conic
        • Cylindrical
        • HEALPix
        • Pix2SkyProjection
        • Projection
        • PseudoConic
        • PseudoCylindrical
        • QuadCube
        • Sky2PixProjection
        • Zenithal
        • Pix2Sky_ZenithalPerspective
        • Pix2Sky_AZP
        • Pix2Sky_SlantZenithalPerspective
        • Pix2Sky_SZP
        • Pix2Sky_Gnomonic
        • Pix2Sky_TAN
        • Pix2Sky_Stereographic
        • Pix2Sky_STG
        • Pix2Sky_SlantOrthographic
        • Pix2Sky_SIN
        • Pix2Sky_ZenithalEquidistant
        • Pix2Sky_ARC
        • Pix2Sky_ZenithalEqualArea
        • Pix2Sky_ZEA
        • Pix2Sky_Airy
        • Pix2Sky_AIR
        • Pix2Sky_CylindricalPerspective
        • Pix2Sky_CYP
        • Pix2Sky_CylindricalEqualArea
        • Pix2Sky_CEA
        • Pix2Sky_PlateCarree
        • Pix2Sky_CAR
        • Pix2Sky_Mercator
        • Pix2Sky_MER
        • Pix2Sky_SansonFlamsteed
        • Pix2Sky_SFL
        • Pix2Sky_Parabolic
        • Pix2Sky_PAR
        • Pix2Sky_Molleweide
        • Pix2Sky_MOL
        • Pix2Sky_HammerAitoff
        • Pix2Sky_AIT
        • Pix2Sky_ConicPerspective
        • Pix2Sky_COP
        • Pix2Sky_ConicEqualArea
        • Pix2Sky_COE
        • Pix2Sky_ConicEquidistant
        • Pix2Sky_COD
        • Pix2Sky_ConicOrthomorphic
        • Pix2Sky_COO
        • Pix2Sky_BonneEqualArea
        • Pix2Sky_BON
        • Pix2Sky_Polyconic
        • Pix2Sky_PCO
        • Pix2Sky_TangentialSphericalCube
        • Pix2Sky_TSC
        • Pix2Sky_COBEQuadSphericalCube
        • Pix2Sky_CSC
        • Pix2Sky_QuadSphericalCube
        • Pix2Sky_QSC
        • Pix2Sky_HEALPix
        • Pix2Sky_HPX
        • Pix2Sky_HEALPixPolar
        • Pix2Sky_XPH
        • Sky2Pix_ZenithalPerspective
        • Sky2Pix_AZP
        • Sky2Pix_SlantZenithalPerspective
        • Sky2Pix_SZP
        • Sky2Pix_Gnomonic
        • Sky2Pix_TAN
        • Sky2Pix_Stereographic
        • Sky2Pix_STG
        • Sky2Pix_SlantOrthographic
        • Sky2Pix_SIN
        • Sky2Pix_ZenithalEquidistant
        • Sky2Pix_ARC
        • Sky2Pix_ZenithalEqualArea
        • Sky2Pix_ZEA
        • Sky2Pix_Airy
        • Sky2Pix_AIR
        • Sky2Pix_CylindricalPerspective
        • Sky2Pix_CYP
        • Sky2Pix_CylindricalEqualArea
        • Sky2Pix_CEA
        • Sky2Pix_PlateCarree
        • Sky2Pix_CAR
        • Sky2Pix_Mercator
        • Sky2Pix_MER
        • Sky2Pix_SansonFlamsteed
        • Sky2Pix_SFL
        • Sky2Pix_Parabolic
        • Sky2Pix_PAR
        • Sky2Pix_Molleweide
        • Sky2Pix_MOL
        • Sky2Pix_HammerAitoff
        • Sky2Pix_AIT
        • Sky2Pix_ConicPerspective
        • Sky2Pix_COP
        • Sky2Pix_ConicEqualArea
        • Sky2Pix_COE
        • Sky2Pix_ConicEquidistant
        • Sky2Pix_COD
        • Sky2Pix_ConicOrthomorphic
        • Sky2Pix_COO
        • Sky2Pix_BonneEqualArea
        • Sky2Pix_BON
        • Sky2Pix_Polyconic
        • Sky2Pix_PCO
        • Sky2Pix_TangentialSphericalCube
        • Sky2Pix_TSC
        • Sky2Pix_COBEQuadSphericalCube
        • Sky2Pix_CSC
        • Sky2Pix_QuadSphericalCube
        • Sky2Pix_QSC
        • Sky2Pix_HEALPix
        • Sky2Pix_HPX
        • Sky2Pix_HEALPixPolar
        • Sky2Pix_XPH
        • EulerAngleRotation
        • RotateCelestial2Native
        • RotateNative2Celestial
        • Rotation2D
        • RotationSequence3D
        • SphericalRotationSequence
        • Spline1D
        • SplineExactKnotsFitter
        • SplineInterpolateFitter
        • SplineSmoothingFitter
        • SplineSplrepFitter
        • tabular_model
        • Tabular1D
        • Tabular2D
    • Uncertainties and Distributions (astropy.uncertainty)
      • normal
      • poisson
      • uniform
      • Distribution
    • Overview of Astropy File I/O
    • High-level Unified File I/O
      • Image Data
      • Table Data
        • Text (CSV, fixed-width, HTML, and specialized)
        • FITS
        • HDF5
        • Parquet
        • VO Tables
    • FITS File Handling (astropy.io.fits)
      • FITS Headers
      • Image Data
      • Table Data
      • Verification
      • Less Familiar Objects
      • Executable Scripts
      • Miscellaneous Features
      • Obtaining subsets from cloud-hosted FITS files
      • astropy.io.fits FAQ
      • Header Interface Transition Guide
      • astropy.io.fits History
      • Reference/API
        • File Handling and Convenience Functions
        • HDU Lists
        • Header Data Unit
        • Headers
        • Cards
        • Tables
        • Images
        • Differs
        • Verification Options
        • Tiled Compression
    • Text Tables (astropy.io.ascii)
      • Reading Tables
      • Writing Tables
      • ECSV Format
      • Fixed-Width Gallery
      • Fast ASCII I/O
      • Base Class Elements
      • Extension Reader Classes
      • Reference/API
        • convert_numpy
        • get_read_trace
        • get_reader
        • get_writer
        • read
        • set_guess
        • write
        • AASTex
        • AllType
        • BaseData
        • BaseHeader
        • BaseInputter
        • BaseOutputter
        • BaseReader
        • BaseSplitter
        • Basic
        • BasicData
        • BasicHeader
        • Cds
        • Column
        • CommentedHeader
        • Conf
        • ContinuationLinesInputter
        • Csv
        • Daophot
        • DefaultSplitter
        • Ecsv
        • FastBasic
        • FastCommentedHeader
        • FastCsv
        • FastNoHeader
        • FastRdb
        • FastTab
        • FixedWidth
        • FixedWidthData
        • FixedWidthHeader
        • FixedWidthNoHeader
        • FixedWidthSplitter
        • FixedWidthTwoLine
        • FloatType
        • HTML
        • InconsistentTableError
        • IntType
        • Ipac
        • Latex
        • Mesa
        • Mrt
        • NoHeader
        • NoType
        • NumType
        • ParameterError
        • QDP
        • RST
        • Rdb
        • SExtractor
        • StrType
        • Tab
        • TableOutputter
        • Tdat
        • WhitespaceSplitter
    • VOTable Handling (astropy.io.votable)
      • Table element
      • COOSYS element
      • Reading and writing VO model annotations (MIVOT)
      • Reference/API
        • from_table
        • is_votable
        • parse
        • parse_single_table
        • validate
        • writeto
        • Conf
        • CooSys
        • Element
        • Field
        • FieldRef
        • Group
        • Info
        • Link
        • MivotBlock
        • Param
        • ParamRef
        • Resource
        • TableElement
        • TimeSys
        • VOTableFile
        • Values
        • get_converter
        • table_column_to_votable_datatype
        • Converter
        • check_ucd
        • parse_ucd
        • coerce_range_list_param
        • convert_to_writable_filelike
        • make_validation_report
        • check_anyuri
        • check_id
        • check_mime_content_type
        • check_token
        • fix_id
        • validate_schema
        • add_data_origin_info
        • extract_data_origin
        • DataOrigin
        • DatasetOrigin
        • QueryOrigin
      • astropy.io.votable.exceptions
    • ECSV, HDF5, Parquet, PyArrow CSV, YAML (astropy.io.misc)
      • Reference/API
        • fnpickle
        • fnunpickle
        • read_ecsv
        • register_ecsv_table
        • write_ecsv
        • ColumnECSV
        • ECSVEngine
        • ECSVEngineIoAscii
        • ECSVEnginePandas
        • ECSVEnginePyArrow
        • ECSVHeader
        • read_table_hdf5
        • write_table_hdf5
        • convert_pa_table_to_astropy_table
        • read_csv
        • dump
        • load
        • load_all
        • AstropyDumper
        • AstropyLoader
    • Cosmological Calculations (astropy.cosmology)
      • Included Cosmology Realizations
        • available
        • WMAP1
        • WMAP3
        • WMAP5
        • WMAP7
        • WMAP9
        • Planck13
        • Planck15
        • Planck18
      • Units and Equivalencies
        • dimensionless_redshift
        • redshift_distance
        • redshift_hubble
        • redshift_temperature
        • with_H0
        • with_redshift
      • Cosmology I/O & Convert
        • Cosmology I/O Details
        • Built-in Cosmology To/From Formats
        • Custom Cosmology I/O formats
        • CosmologyFromFormat
        • CosmologyRead
        • CosmologyToFormat
        • CosmologyWrite
      • Traits
        • BaryonComponent
        • CriticalDensity
        • CurvatureComponent
        • DarkEnergyComponent
        • DarkMatterComponent
        • HubbleParameter
        • MatterComponent
        • NeutrinoComponent
        • PhotonComponent
        • ScaleFactor
        • TemperatureCMB
        • TotalComponent
      • For Developers
      • Reference/API
        • z_at_value
        • cosmology_equal
        • Cosmology
        • CosmologyError
        • FlatCosmologyMixin
        • FLRW
        • FlatFLRWMixin
        • LambdaCDM
        • FlatLambdaCDM
        • wCDM
        • FlatwCDM
        • w0waCDM
        • Flatw0waCDM
        • w0wzCDM
        • Flatw0wzCDM
        • wpwaCDM
        • FlatwpwaCDM
        • Parameter
        • default_cosmology
    • Convolution and Filtering (astropy.convolution)
      • Using the Convolution Functions
      • Convolution Kernels
      • Convolving with Unnormalized Kernels
      • Reference/API
        • convolve
        • convolve_fft
        • convolve_models
        • convolve_models_fft
        • discretize_model
        • interpolate_replace_nans
        • kernel_arithmetics
        • AiryDisk2DKernel
        • Box1DKernel
        • Box2DKernel
        • CustomKernel
        • Gaussian1DKernel
        • Gaussian2DKernel
        • Kernel
        • Kernel1D
        • Kernel2D
        • KernelArithmeticError
        • KernelError
        • KernelSizeError
        • Model1DKernel
        • Model2DKernel
        • Moffat2DKernel
        • RickerWavelet1DKernel
        • RickerWavelet2DKernel
        • Ring2DKernel
        • Tophat2DKernel
        • Trapezoid1DKernel
        • TrapezoidDisk2DKernel
    • IERS data access (astropy.utils.iers)
    • Data Visualization (astropy.visualization)
      • Plotting Astropy objects in Matplotlib
      • Making plots with world coordinates (WCSAxes)
        • Initializing axes with world coordinates
        • Plotting images and contours
        • Ticks, tick labels, and grid lines
        • Overplotting markers and artists
        • Overlaying coordinate systems
        • Slicing Multidimensional Data
        • Controlling Axes
        • Initializing WCSAxes with custom transforms
        • Using a custom frame
        • add_beam
        • add_scalebar
        • custom_ucd_coord_meta_mapping
        • Conf
        • CoordinateHelper
        • CoordinatesMap
        • Quadrangle
        • SphericalCircle
        • WCSAxes
        • WCSAxesSubplot
        • BaseFrame
        • EllipticalFrame
        • RectangularFrame
        • RectangularFrame1D
        • Spine
      • Image stretching and normalization
      • Choosing Histogram Bins
      • Creating color RGB images
      • Reference/API
        • hist
        • imshow_norm
        • imshow_simple_norm
        • make_lupton_rgb
        • make_rgb
        • quantity_support
        • simple_norm
        • time_support
        • AsinhStretch
        • AsymmetricPercentileInterval
        • BaseInterval
        • BaseStretch
        • BaseTransform
        • CompositeStretch
        • CompositeTransform
        • ContrastBiasStretch
        • HistEqStretch
        • ImageNormalize
        • LinearStretch
        • LogStretch
        • LuptonAsinhStretch
        • LuptonAsinhZscaleStretch
        • ManualInterval
        • MinMaxInterval
        • MplQuantityConverter
        • PercentileInterval
        • PowerDistStretch
        • PowerStretch
        • SimpleNorm
        • SinhStretch
        • SqrtStretch
        • SquaredStretch
        • SymmetricInterval
        • ZScaleInterval
        • imshow_norm
        • imshow_simple_norm
        • simple_norm
        • ImageNormalize
        • SimpleNorm
    • Astrostatistics Tools (astropy.stats)
      • Robust Statistical Estimators
        • sigma_clip
        • sigma_clipped_stats
        • SigmaClip
        • SigmaClippedStats
        • biweight_location
        • biweight_midcorrelation
        • biweight_midcovariance
        • biweight_midvariance
        • biweight_scale
      • Circular Statistics
        • circcorrcoef
        • circmean
        • circmoment
        • circstd
        • circvar
        • rayleightest
        • vonmisesmle
        • vtest
      • Ripley’s K Function Estimators
      • Reference/API
        • binned_binom_proportion
        • binom_conf_interval
        • bootstrap
        • cdf_from_intervals
        • fold_intervals
        • histogram_intervals
        • interval_overlap_length
        • kuiper
        • kuiper_false_positive_probability
        • kuiper_two
        • mad_std
        • median_absolute_deviation
        • poisson_conf_interval
        • signal_to_noise_oir_ccd
        • biweight_location
        • biweight_midcorrelation
        • biweight_midcovariance
        • biweight_midvariance
        • biweight_scale
        • sigma_clip
        • sigma_clipped_stats
        • jackknife_resampling
        • jackknife_stats
        • circcorrcoef
        • circmean
        • circmoment
        • circstd
        • circvar
        • rayleightest
        • vonmisesmle
        • vtest
        • bayesian_blocks
        • calculate_bin_edges
        • freedman_bin_width
        • histogram
        • knuth_bin_width
        • scott_bin_width
        • akaike_info_criterion
        • akaike_info_criterion_lsq
        • bayesian_info_criterion
        • bayesian_info_criterion_lsq
        • SigmaClip
        • SigmaClippedStats
        • Events
        • FitnessFunc
        • PointMeasures
        • RegularEvents
        • RipleysKEstimator
    • Masked Values and Quantities (astropy.utils.masked)
      • combine_masks
      • get_data_and_mask
      • MaskableShapedLikeNDArray
      • Masked
      • MaskedNDArray
      • bincount
      • broadcast_arrays
      • broadcast_to
      • choose
      • copyto
      • count_nonzero
      • full_like
      • insert
      • interp
      • lexsort
      • nanargmax
      • nanargmin
      • nancumprod
      • nancumsum
      • nanmax
      • nanmean
      • nanmedian
      • nanmin
      • nanpercentile
      • nanprod
      • nanquantile
      • nanstd
      • nansum
      • nanvar
      • ones_like
      • piecewise
      • place
      • put
      • select
      • zeros_like
    • SAMP (Simple Application Messaging Protocol) (astropy.samp)
      • Starting and Stopping a SAMP Hub Server
      • Sending and Receiving Tables and Images over SAMP
      • Communication between Integrated Clients Objects
      • Embedding a SAMP Hub in a GUI
      • Reference/API
        • safe_xmlrpc_loads
        • Conf
        • SAMPClient
        • SAMPClientError
        • SAMPHubError
        • SAMPHubProxy
        • SAMPHubServer
        • SAMPIntegratedClient
        • SAMPMsgReplierWrapper
        • SAMPProxyError
        • SAMPWarning
        • SAMPXXEServerProxy
        • WebProfileDialog
    • Configuration System (astropy.config)
      • Astropy’s Default Configuration File
      • Reference/API
        • create_config_file
        • generate_config
        • get_cache_dir
        • get_cache_dir_path
        • get_config
        • get_config_dir
        • get_config_dir_path
        • reload_config
        • temporary_cache_dir_path
        • temporary_config_dir_path
        • ConfigItem
        • ConfigNamespace
        • InvalidConfigurationItemWarning
        • set_temp_cache
        • set_temp_config
    • I/O Registry (astropy.io.registry)
      • Reference/API
        • delay_doc_updates
        • get_formats
        • get_reader
        • get_writer
        • identify_format
        • read
        • register_identifier
        • register_reader
        • register_writer
        • unregister_identifier
        • unregister_reader
        • unregister_writer
        • write
        • UnifiedIORegistry
        • UnifiedInputRegistry
        • UnifiedOutputRegistry
        • UnifiedReadWrite
        • UnifiedReadWriteMethod
        • IORegistryError
    • I/O Typing (astropy.io.typing)
      • ReadableFileLike
      • WriteableFileLike
    • Logging system
      • AstropyLogger
      • Conf
      • LoggingError
    • Python warnings system
    • Astropy Core Package Utilities (astropy.utils)
      • Downloadable Data Management (astropy.utils.data)
      • Reference/API
        • make_function_with_signature
        • HomogeneousList
        • color_print
        • human_file_size
        • human_time
        • isatty
        • print_code_line
        • terminal_size
        • ProgressBar
        • ProgressBarOrSpinner
        • Spinner
        • data_info_factory
        • dtype_info_name
        • BaseColumnInfo
        • DataInfo
        • MixinInfo
        • ParentDtypeInfo
        • deprecated
        • deprecated_attribute
        • deprecated_renamed_argument
        • format_doc
        • classproperty
        • lazyproperty
        • sharedmethod
        • diff_values
        • report_diff_values
        • where_not_allclose
        • AstropyBackwardsIncompatibleChangeWarning
        • AstropyDeprecationWarning
        • AstropyPendingDeprecationWarning
        • AstropyUserWarning
        • AstropyWarning
        • DuplicateRepresentationWarning
        • Conf
        • IERS
        • IERSDegradedAccuracyWarning
        • IERSRangeError
        • IERSStaleWarning
        • IERSWarning
        • IERS_A
        • IERS_Auto
        • IERS_B
        • LeapSeconds
        • earth_orientation_table
        • find_current_module
        • isinstancemethod
        • minversion
        • resolve_name
        • enable_merge_strategies
        • merge
        • common_dtype
        • MetaAttribute
        • MetaData
        • MergeNpConcatenate
        • MergePlus
        • MergeStrategy
        • MergeConflictError
        • MergeConflictWarning
        • dtype_bytes_or_chars
        • find_api_page
        • format_exception
        • indent
        • isiterable
        • online_help
        • silence
        • JsonCustomEncoder
        • NumpyRNGContext
        • lex
        • yacc
        • ThreadSafeParser
        • ScienceState
        • check_broadcast
        • simplify_basic_index
        • unbroadcast
        • IncompatibleShapeError
        • NDArrayShapeMethods
        • ShapedLikeNDArray
        • system_info
        • cache_contents
        • cache_total_size
        • check_download_cache
        • check_free_space_in_dir
        • clear_download_cache
        • compute_hash
        • download_file
        • download_files_in_parallel
        • export_download_cache
        • get_cached_urls
        • get_file_contents
        • get_free_space_in_dir
        • get_pkg_data_contents
        • get_pkg_data_filename
        • get_pkg_data_filenames
        • get_pkg_data_fileobj
        • get_pkg_data_fileobjs
        • get_pkg_data_path
        • get_readable_fileobj
        • import_download_cache
        • import_file_to_cache
        • is_url
        • is_url_in_cache
        • CacheDamaged
        • CacheMissingWarning
        • Conf
        • check_anyuri
        • check_id
        • check_mime_content_type
        • check_token
        • fix_id
        • get_xml_encoding
        • get_xml_iterator
        • xml_readlines
        • unescape_all
        • validate_schema
        • XMLWriter
    • Environment variables
    • Astropy Glossary
  • Contributing
  • Project Details
    • What’s New
      • What’s New in Astropy 8.0?
    • Full Changelog
    • LTS Backport Policy
    • Known Issues
    • Authors and Credits
    • Impact and Health
    • Licenses
  • User Guide
  • Astronomical Coordinate Systems (astropy.coordinates)
  • Separations, Offsets, Catalog Matching, and Related Functionality

Separations, Offsets, Catalog Matching, and Related Functionality#

astropy.coordinates contains commonly-used tools for comparing or matching coordinate objects. Of particular importance are those for determining separations between coordinates and those for matching a coordinate (or coordinates) to a catalog. These are mainly implemented as methods on the coordinate objects.

In the examples below, we will assume that the following imports have already been executed:

>>> import astropy.units as u
>>> from astropy.coordinates import SkyCoord

Separations#

The on-sky separation can be computed with separation(), which computes the great-circle distance (not the small-angle approximation):

>>> c1 = SkyCoord('5h23m34.5s', '-69d45m22s', frame='icrs')
>>> c2 = SkyCoord('0h52m44.8s', '-72d49m43s', frame='fk5')
>>> sep = c1.separation(c2)
>>> sep
<Angle 20.74611448 deg>

The returned object is an Angle instance, so it is possible to access the angle in any of several equivalent angular units:

>>> sep.radian
np.float64(0.36208800460262563)
>>> sep.hour
np.float64(1.3830742984029318)
>>> sep.arcminute
np.float64(1244.7668685626384)
>>> sep.arcsecond
np.float64(74686.0121137583)

Also note that the two input coordinates were not in the same frame — one is automatically converted to match the other, ensuring that even though they are in different frames, the separation is determined consistently.

In addition to the on-sky separation described above, separation_3d() will determine the 3D distance between two coordinates that have distance defined:

>>> c1 = SkyCoord('5h23m34.5s', '-69d45m22s', distance=70*u.kpc, frame='icrs')
>>> c2 = SkyCoord('0h52m44.8s', '-72d49m43s', distance=80*u.kpc, frame='icrs')
>>> sep = c1.separation_3d(c2)
>>> sep
<Distance 28.74398816 kpc>

Offsets#

Closely related to angular separations are offsets between coordinates. The key distinction for offsets is generally the concept of a “from” and “to” coordinate rather than the single scalar angular offset of a separation. coordinates contains conveniences to compute some of the common offsets encountered in astronomy.

The first piece of such functionality is the position_angle() method. This method computes the position angle between one SkyCoord instance and another (passed as the argument) following the astronomy convention (positive angles East of North):

>>> c1 = SkyCoord(1*u.deg, 1*u.deg, frame='icrs')
>>> c2 = SkyCoord(2*u.deg, 2*u.deg, frame='icrs')
>>> c1.position_angle(c2).to(u.deg)
<Angle 44.97818294 deg>

The combination of separation() and position_angle() thus give a set of directional offsets. To do the inverse operation — determining the new “destination” coordinate given a separation and position angle — the directional_offset_by() method is provided:

>>> c1 = SkyCoord(1*u.deg, 1*u.deg, frame='icrs')
>>> position_angle = 45 * u.deg
>>> separation = 1.414 * u.deg
>>> c1.directional_offset_by(position_angle, separation)
<SkyCoord (ICRS): (ra, dec) in deg
    (2.0004075, 1.99964588)>

This technique is also useful for computing the midpoint (or indeed any point) between two coordinates in a way that accounts for spherical geometry (i.e., instead of averaging the RAs/Decs separately):

>>> coord1 = SkyCoord(0*u.deg, 0*u.deg, frame='icrs')
>>> coord2 = SkyCoord(1*u.deg, 1*u.deg, frame='icrs')
>>> pa = coord1.position_angle(coord2)
>>> sep = coord1.separation(coord2)
>>> coord1.directional_offset_by(pa, sep/2)
<SkyCoord (ICRS): (ra, dec) in deg
    (0.49996192, 0.50001904)>

There is also a spherical_offsets_to() method for computing angular offsets (e.g., small shifts like you might give a telescope operator to move from a bright star to a fainter target):

>>> bright_star = SkyCoord('8h50m59.75s', '+11d39m22.15s', frame='icrs')
>>> faint_galaxy = SkyCoord('8h50m47.92s', '+11d39m32.74s', frame='icrs')
>>> dra, ddec = bright_star.spherical_offsets_to(faint_galaxy)
>>> dra.to(u.arcsec)
<Angle -173.78873354 arcsec>
>>> ddec.to(u.arcsec)
<Angle 10.60510342 arcsec>

The conceptual inverse of spherical_offsets_to() is also available as a method on any SkyCoord object: spherical_offsets_by(), which accepts two angular offsets (in longitude and latitude) and returns the coordinates at the offset location:

>>> target_star = SkyCoord(86.75309*u.deg, -31.5633*u.deg, frame='icrs')
>>> target_star.spherical_offsets_by(1.3*u.arcmin, -0.7*u.arcmin)
<SkyCoord (ICRS): (ra, dec) in deg
    (86.77852168, -31.57496415)>

“Sky Offset” Frames#

To extend the concept of spherical offsets, coordinates has a frame class SkyOffsetFrame which creates distinct frames that are centered on a specific point. These are known as “sky offset frames,” as they are a convenient way to create a frame centered on an arbitrary position on the sky suitable for computing positional offsets (e.g., for astrometry):

>>> from astropy.coordinates import SkyOffsetFrame, ICRS
>>> center = ICRS(10*u.deg, 45*u.deg)
>>> center.transform_to(SkyOffsetFrame(origin=center))
<SkyOffsetICRS Coordinate (rotation=0.0 deg, origin=<ICRS Coordinate: (ra, dec) in deg
    (10., 45.)>): (lon, lat) in deg
    (0., 0.)>
>>> target = ICRS(11*u.deg, 46*u.deg)
>>> target.transform_to(SkyOffsetFrame(origin=center))
<SkyOffsetICRS Coordinate (rotation=0.0 deg, origin=<ICRS Coordinate: (ra, dec) in deg
    (10., 45.)>): (lon, lat) in deg
    (0.69474685, 1.00428706)>

Alternatively, the convenience method skyoffset_frame() lets you create a sky offset frame from an existing SkyCoord:

>>> center = SkyCoord(10*u.deg, 45*u.deg)
>>> aframe = center.skyoffset_frame()
>>> target.transform_to(aframe)
<SkyOffsetICRS Coordinate (rotation=0.0 deg, origin=<ICRS Coordinate: (ra, dec) in deg
    (10., 45.)>): (lon, lat) in deg
    (0.69474685, 1.00428706)>
>>> other = SkyCoord(9*u.deg, 44*u.deg, frame='fk5')
>>> other.transform_to(aframe)
<SkyCoord (SkyOffsetICRS: rotation=0.0 deg, origin=<ICRS Coordinate: (ra, dec) in deg
    (10., 45.)>): (lon, lat) in deg
    (-0.71943945, -0.99556216)>

Note

While sky offset frames appear to be all the same class, this not the case: the sky offset frame for each different type of frame for origin is actually a distinct class. E.g., SkyOffsetFrame(origin=ICRS(...)) yields an object of class SkyOffsetICRS, not SkyOffsetFrame. While this is not important for most uses of this class, it is important for things like type-checking, because something like SkyOffsetFrame(origin=ICRS(...)).__class__ is SkyOffsetFrame will not be True, as it would be for most classes.

This same frame is also useful as a tool for defining frames that are relative to a specific, known object useful for hierarchical physical systems like galaxy groups. For example, objects around M31 are sometimes shown in a coordinate frame aligned with standard ICRA RA/Dec, but on M31:

>>> m31 = SkyCoord(10.6847083*u.deg, 41.26875*u.deg, frame='icrs')
>>> ngc147 = SkyCoord(8.3005*u.deg, 48.5087389*u.deg, frame='icrs')
>>> ngc147_inm31 = ngc147.transform_to(m31.skyoffset_frame())
>>> xi, eta = ngc147_inm31.lon, ngc147_inm31.lat
>>> xi
<Longitude -1.59206948 deg>
>>> eta
<Latitude 7.26183757 deg>

Note

Currently, distance information in the origin of a SkyOffsetFrame is not used to compute any part of the transform. The origin is only used for on-sky rotation. This may change in the future, however.

Matching Catalogs#

coordinates leverages the coordinate framework to make it possible to find the closest coordinates in a catalog to a desired set of other coordinates. For example, assuming ra1/dec1 and ra2/dec2 are NumPy arrays loaded from some file:

>>> c = SkyCoord(ra=ra1*u.degree, dec=dec1*u.degree)
>>> catalog = SkyCoord(ra=ra2*u.degree, dec=dec2*u.degree)
>>> idx, d2d, d3d = c.match_to_catalog_sky(catalog)

The distances returned d3d are 3-dimensional distances. Unless both source (c) and catalog (catalog) coordinates have associated distances, this quantity assumes that all sources are at a distance of 1 (dimensionless).

You can also find the nearest 3D matches, different from the on-sky separation shown above only when the coordinates were initialized with a distance:

>>> c = SkyCoord(ra=ra1*u.degree, dec=dec1*u.degree, distance=distance1*u.kpc)
>>> catalog = SkyCoord(ra=ra2*u.degree, dec=dec2*u.degree, distance=distance2*u.kpc)
>>> idx, d2d, d3d = c.match_to_catalog_3d(catalog)

Now idx are indices into catalog that are the closest objects to each of the coordinates in c, d2d are the on-sky distances between them, and d3d are the 3-dimensional distances. Because coordinate objects support indexing, idx enables easy access to the matched set of coordinates in the catalog:

>>> d3d
<Quantity [1335.55538257] kpc>
>>> matches = catalog[idx]
>>> matches.separation_3d(c)
<Distance [1335.55538257] kpc>
>>> dra, ddec = c.spherical_offsets_to(matches)

This functionality can also be accessed from the match_coordinates_sky() and match_coordinates_3d() functions. These will work on either SkyCoord objects or the lower-level frame classes:

>>> from astropy.coordinates import match_coordinates_sky
>>> idx, d2d, d3d = match_coordinates_sky(c, catalog)
>>> idx, d2d, d3d = match_coordinates_sky(c.frame, catalog.frame)

It is possible to impose a separation constraint (e.g., the maximum separation to be considered a match) by creating a boolean mask with d2d or d3d. For example:

>>> max_sep = 1.0 * u.arcsec
>>> idx, d2d, d3d = c.match_to_catalog_3d(catalog)
>>> sep_constraint = d2d < max_sep
>>> c_matches = c[sep_constraint]
>>> catalog_matches = catalog[idx[sep_constraint]]

Now, c_matches and catalog_matches are the matched sources in c and catalog, respectively, which are separated by less than 1 arcsecond.

Searching around Coordinates#

Closely related functionality can be used to search for all coordinates within a certain distance (either 3D distance or on-sky) of another set of coordinates. The search_around_* methods (and functions) provide this functionality, with an interface very similar to match_coordinates_*:

>>> import numpy as np
>>> idxc, idxcatalog, d2d, d3d = catalog.search_around_sky(c, 1*u.deg)
>>> np.all(d2d < 1*u.deg)
np.True_
>>> idxc, idxcatalog, d2d, d3d = catalog.search_around_3d(c, 1*u.kpc)
>>> np.all(d3d < 1*u.kpc)
np.True_

The key difference for these methods is that there can be multiple (or no) matches in catalog around any locations in c. Hence, indices into both c and catalog are returned instead of just indices into catalog. These can then be indexed back into the two SkyCoord objects, or, for that matter, any array with the same order:

>>> np.all(c[idxc].separation(catalog[idxcatalog]) == d2d)
np.True_
>>> np.all(c[idxc].separation_3d(catalog[idxcatalog]) == d3d)
np.True_
>>> print(catalog_objectnames[idxcatalog])
['NGC 1234' 'NGC 4567' ...]

Note, though, that this dual-indexing means that search_around_* does not work well if one of the coordinates is a scalar, because the returned index would not make sense for a scalar:

>>> scalarc = SkyCoord(ra=1*u.deg, dec=2*u.deg, distance=distance1*u.kpc)
>>> idxscalarc, idxcatalog, d2d, d3d = catalog.search_around_sky(scalarc, 1*u.deg)
ValueError: One of the inputs to search_around_sky is a scalar.

As a result (and because the search_around_* algorithm is inefficient in the scalar case), the best approach for this scenario is to instead use the separation* methods:

>>> d2d = scalarc.separation(catalog)
>>> catalogmsk = d2d < 1*u.deg
>>> d3d = scalarc.separation_3d(catalog)
>>> catalog3dmsk = d3d < 1*u.kpc

The resulting catalogmsk or catalog3dmsk variables are boolean arrays rather than arrays of indices, but in practice they usually can be used in the same way as idxcatalog from the above examples. If you definitely do need indices instead of boolean masks, you can do:

>>> idxcatalog = np.where(catalogmsk)[0]
>>> idxcatalog3d = np.where(catalog3dmsk)[0]

previous

Formatting Coordinate Strings

next

Using and Designing Coordinate Representations

On this page
  • Separations
  • Offsets
    • “Sky Offset” Frames
  • Matching Catalogs
  • Searching around Coordinates
Edit

© Copyright 2011–2026, The Astropy Developers.

Code of Conduct

Updated on 30 Sep 2026 , built with Sphinx 8.2.3