<commit_before>.. _astropy-units:

**************************************
Units and Quantities (`astropy.units`)
**************************************

.. |quantity| replace:: :class:`~astropy.units.quantity.Quantity`

.. currentmodule:: astropy.units

Introduction
============

`astropy.units` handles defining and converting between physical
units, and performing arithmetic with physical quantities (numbers
with associated units).

Getting Started
===============

Most users of the `astropy.units` package will work with "quantities":
the combination of a value and a unit.  The easiest way to create a
|quantity| is to simply multiply or divide a value by one of the
built-in units.  It works with scalars, sequences and Numpy arrays::

    >>> from astropy import units as u
    >>> 42.0 * u.meter
    <Quantity 42.0 m>
    >>> [1., 2., 3.] * u.m
    <Quantity [ 1., 2., 3.] m>
    >>> import numpy as np
    >>> np.array([1., 2., 3.]) * u.m
    <Quantity [ 1., 2., 3.] m>

You can get the unit and value from a |quantity| using the unit and
value members::

    >>> q = 42.0 * u.meter
    >>> q.value
    42.0
    >>> q.unit
    Unit("m")<commit_msg>added unit examples & link to astropy.coordinates docs.<commit_after>.. _astropy-units:

**************************************
Units and Quantities (`astropy.units`)
**************************************

.. |quantity| replace:: :class:`~astropy.units.quantity.Quantity`

.. currentmodule:: astropy.units

Introduction
============

`astropy.units` handles defining, converting between, and performing arithmetic with physical quantities. Examples of physical quantities are meters, seconds, Hz, etc.

`astropy.units` does not know spherical geometry or sexidecimal: if you want to deal with celestial coordinates, see the `astropy.coordinates` package.  

Getting Started
===============

Most users of the `astropy.units` package will work with "quantities":
the combination of a value and a unit.  The easiest way to create a
|quantity| is to simply multiply or divide a value by one of the
built-in units.  It works with scalars, sequences and Numpy arrays::

    >>> from astropy import units as u
    >>> 42.0 * u.meter
    <Quantity 42.0 m>
    >>> [1., 2., 3.] * u.m
    <Quantity [ 1., 2., 3.] m>
    >>> import numpy as np
    >>> np.array([1., 2., 3.]) * u.m
    <Quantity [ 1., 2., 3.] m>

You can get the unit and value from a |quantity| using the unit and
value members::

    >>> q = 42.0 * u.meter
    >>> q.value
    42.0
    >>> q.unit
    Unit("m")
{'fraction_non_alphanumeric': 0.19493871095294582, 'fraction_numerical': 0.018979833926453145, 'mean_word_length': 3.525939177101968, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1315615', 'n_tokens_mistral': 796, 'n_tokens_neox': 716, 'n_words': 297}