repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
astropy | astropy/cosmology/_src/tests/io/test_model.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import inspect
import random
import numpy as np
import pytest
from astropy.cosmology import Cosmology, w0wzCDM
from astropy.cosmology._src.io.builtin.model import (
_CosmologyModel,
from_model,
to_model,
)
from astropy.cosmology._src.tests.h... | 183 | 6,652 |
astropy | astropy/cosmology/_src/tests/io/base.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import pytest
import astropy.units as u
from astropy.cosmology import Cosmology, Parameter, realizations
from astropy.cosmology import units as cu
from astropy.cosmology._src.core import _COSMOLOGY_CLASSES, dataclass_decorator
from astropy.cosmology.real... | 216 | 7,617 |
astropy | astropy/cosmology/_src/tests/io/test_html.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import pytest
import astropy.units as u
from astropy.cosmology._src.io.builtin.html import (
_FORMAT_TABLE,
read_html_table,
write_html_table,
)
from astropy.table import QTable, Table, vstack
from astropy.utils.compat.optional_deps import HA... | 262 | 10,019 |
astropy | astropy/cosmology/_src/tests/parameter/test_descriptors.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Testing :mod:`astropy.cosmology._src.parameter.descriptor`."""
from types import MappingProxyType
from typing import ClassVar
import pytest
from astropy.cosmology import Cosmology, Parameter
from astropy.cosmology._src.parameter import ParametersAtt... | 130 | 5,075 |
astropy | astropy/cosmology/_src/tests/parameter/test_parameter.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Testing :mod:`astropy.cosmology._src.parameter`."""
from collections.abc import Callable
import numpy as np
import pytest
import astropy.units as u
from astropy.cosmology import Cosmology, Parameter
from astropy.cosmology._src.core import _COSMOLOGY... | 448 | 15,772 |
astropy | astropy/cosmology/_src/tests/parameter/test_utils.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from astropy.cosmology._src.parameter import Parameter, all_parameters
def test_all_parameters():
"""Test :func:`astropy.cosmology._src.utils.all_parameters`."""
class ClassA:
a = 1
b = 2
got = all_parameters(ClassA)
a... | 27 | 643 |
astropy | astropy/cosmology/_src/traits/scale_factor.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Scale factor.
This is private API. See `~astropy.cosmology.traits` for public API.
"""
__all__ = ("ScaleFactor",)
from numpy.typing import ArrayLike
import astropy.units as u
from astropy.cosmology._src.utils import aszarr
class ScaleFactor:
... | 58 | 1,635 |
astropy | astropy/cosmology/_src/traits/baryons.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Baryon component."""
__all__ = ("BaryonComponent",)
from collections.abc import Callable
from typing import Any
import numpy as np
from numpy.typing import ArrayLike, NDArray
from astropy.cosmology._src.typing import FArray
from astropy.cosmology._s... | 48 | 1,356 |
astropy | astropy/cosmology/_src/traits/photoncomponent.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Photon component."""
__all__ = ("PhotonComponent",)
from collections.abc import Callable
from typing import Any
import numpy as np
from numpy.typing import ArrayLike, NDArray
from astropy.cosmology._src.typing import FArray
from astropy.cosmology._s... | 47 | 1,338 |
astropy | astropy/cosmology/_src/traits/darkmatter.py | .py | """Trait for dark matter component of cosmology."""
__all__ = ("DarkMatterComponent",)
from collections.abc import Callable
from typing import Any
import numpy as np
from numpy.typing import ArrayLike, NDArray
from astropy.cosmology._src.typing import FArray
from astropy.cosmology._src.utils import aszarr
from astr... | 51 | 1,463 |
astropy | astropy/cosmology/_src/traits/totalcomponent.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
__all__ = ("TotalComponent",)
from abc import abstractmethod
import numpy as np
from numpy.typing import ArrayLike
from astropy.cosmology._src.typing import FArray
from astropy.units import Quantity
class TotalComponent:
"""The cosmology has attr... | 43 | 1,201 |
astropy | astropy/cosmology/_src/traits/neutrino.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
r"""Neutrino component trait.
This is private API. See `~astropy.cosmology.traits` for public API.
"""
__all__ = ["NeutrinoComponent"]
from abc import abstractmethod
from collections.abc import Callable
from functools import cached_property
from typing ... | 259 | 8,494 |
astropy | astropy/cosmology/_src/traits/matter.py | .py | """Matter component."""
import numpy as np
from numpy.typing import ArrayLike
from astropy.cosmology._src.typing import FArray
from astropy.cosmology._src.utils import aszarr
from astropy.units import Quantity
__all__ = ("MatterComponent",)
class MatterComponent:
"""The cosmology has attributes and methods for... | 46 | 1,285 |
astropy | astropy/cosmology/_src/traits/curvature.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Global Curvature.
This is private API. See `~astropy.cosmology.traits` for public API.
"""
__all__ = ("CurvatureComponent",)
import abc
import numpy as np
from numpy.typing import ArrayLike, NDArray
from astropy.cosmology._src.utils import aszarr
... | 91 | 2,448 |
astropy | astropy/cosmology/_src/traits/rhocrit.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Critical density component."""
__all__ = ("CriticalDensity",)
from collections.abc import Callable
from typing import Any
from numpy.typing import ArrayLike, NDArray
from astropy.units import Quantity
class CriticalDensity:
"""The object has a... | 42 | 1,130 |
astropy | astropy/cosmology/_src/traits/hubble.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Hubble parameter trait.
This is private API. See `~astropy.cosmology.traits` for public API.
"""
__all__ = ("HubbleParameter",)
from collections.abc import Callable
from functools import cached_property
from typing import Any
import numpy as np
from... | 61 | 1,607 |
astropy | astropy/cosmology/_src/traits/tcmb.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""CMB Temperature.
This is private API. See `~astropy.cosmology.traits` for public API.
"""
__all__ = ("TemperatureCMB",)
from numpy.typing import ArrayLike
from astropy.cosmology._src.utils import aszarr
from astropy.units import Quantity
class T... | 60 | 1,523 |
astropy | astropy/cosmology/_src/traits/darkenergy.py | .py | __all__ = ("DarkEnergyComponent",)
from abc import abstractmethod
from math import exp, log
import numpy as np
from numpy.typing import ArrayLike
from astropy.cosmology._src.scipy_compat import quad
from astropy.cosmology._src.typing import FArray
from astropy.cosmology._src.utils import aszarr
from astropy.units im... | 154 | 5,274 |
astropy | astropy/cosmology/_src/flrw/wpwazpcdm.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
__all__ = ("FlatwpwaCDM", "wpwaCDM")
from numpy import exp
from numpy.typing import ArrayLike
from astropy.cosmology import units as cu
from astropy.cosmology._src.core import dataclass_decorator
from astropy.cosmology._src.parameter import Parameter
fr... | 352 | 12,902 |
astropy | astropy/cosmology/_src/flrw/w0wzcdm.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
__all__ = ("Flatw0wzCDM", "w0wzCDM")
from numpy import exp
from numpy.typing import ArrayLike
from astropy.cosmology._src.core import dataclass_decorator
from astropy.cosmology._src.parameter import Parameter
from astropy.cosmology._src.typing import FA... | 298 | 10,322 |
astropy | astropy/cosmology/_src/flrw/w0cdm.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
__all__ = ("FlatwCDM", "wCDM")
import numpy as np
from numpy import sqrt
from numpy.typing import ArrayLike
from astropy.cosmology._src.core import dataclass_decorator
from astropy.cosmology._src.parameter import Parameter
from astropy.cosmology._src.ty... | 395 | 13,358 |
astropy | astropy/cosmology/_src/flrw/lambdacdm.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
__all__ = ("FlatLambdaCDM", "LambdaCDM")
from math import acos, cos, inf, sin, sqrt
from numbers import Number
import numpy as np
from numpy import log
from numpy.typing import ArrayLike, NDArray
# isort: split
from astropy.cosmology._src.core import d... | 772 | 27,780 |
astropy | astropy/cosmology/_src/flrw/w0wacdm.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
__all__ = ("Flatw0waCDM", "w0waCDM")
from numpy import exp
from numpy.typing import ArrayLike
from astropy.cosmology._src.core import dataclass_decorator
from astropy.cosmology._src.parameter import Parameter
from astropy.cosmology._src.typing import FA... | 316 | 11,277 |
astropy | astropy/cosmology/_src/flrw/base.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
__all__ = ("FLRW", "FlatFLRWMixin")
import inspect
import warnings
from dataclasses import field
from functools import cached_property
from inspect import signature
from math import floor, pi, sqrt
from typing import Any, Final, NamedTuple, TypeVar, over... | 1,339 | 46,056 |
astropy | astropy/cosmology/_src/io/__init__.py | .py | """Astropy Cosmology IO. **NOT public API**.
The public API is provided by :mod:`astropy.cosmology.io`.
"""
# Licensed under a 3-clause BSD style license - see LICENSE.rst
| 6 | 173 |
astropy | astropy/cosmology/_src/io/connect.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
__all__ = (
# classes
"CosmologyFromFormat",
"CosmologyRead",
"CosmologyToFormat",
"CosmologyWrite",
)
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, Literal, TypeVar, overload
from astropy.cosmology._src.... | 370 | 12,683 |
astropy | astropy/cosmology/_src/io/builtin/table.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""|Cosmology| <-> |Table| I/O, using |Cosmology.to_format| and |Cosmology.from_format|.
This module provides functions to transform a |Cosmology| object to and from a |Table|
object. The functions are registered with ``convert_registry`` under the format... | 485 | 21,314 |
astropy | astropy/cosmology/_src/io/builtin/utils.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
from astropy.modeling import Parameter as ModelParameter
from astropy.table import Column
def convert_parameter_to_column(parameter, value, meta=None):
"""Convert a |Cosmology| Parameter to a Table |Column|.
Parameters
-... | 71 | 1,791 |
astropy | astropy/cosmology/_src/io/builtin/row.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""|Cosmology| <-> |Row| I/O, using |Cosmology.to_format| and |Cosmology.from_format|.
A `~astropy.cosmology.Cosmology` as a `~astropy.table.Row` will have
the cosmology's name and parameters as columns.
>>> from astropy.cosmology import Planck18
... | 284 | 12,086 |
astropy | astropy/cosmology/_src/io/builtin/model.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""|Cosmology| <-> Model I/O, using |Cosmology.to_format| and |Cosmology.from_format|.
This module provides functions to transform a |Cosmology| object to and from a
:class:`~astropy.modeling.Model`. The functions are registered with ``convert_registry``
... | 300 | 10,627 |
astropy | astropy/cosmology/_src/io/builtin/mapping.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""|Cosmology| <-> Mapping I/O, using |Cosmology.to_format| and |Cosmology.from_format|.
This module provides functions to transform a |Cosmology| instance to a mapping
(`dict`-like) object and vice versa, from a mapping object back to a |Cosmology|
insta... | 433 | 19,488 |
astropy | astropy/cosmology/_src/io/builtin/__init__.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Read/Write/Interchange methods for `astropy.cosmology`.
**NOT public API**.
"""
# Import to register with the I/O machinery
from . import cosmology, ecsv, html, latex, mapping, model, mrt, row, table, yaml
| 9 | 275 |
astropy | astropy/cosmology/_src/io/builtin/ecsv.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""|Cosmology| <-> ECSV I/O, using |Cosmology.read| and |Cosmology.write|.
This module provides functions to write/read a |Cosmology| object to/from an ECSV file.
The functions are registered with ``readwrite_registry`` under the format name
"ascii.ecsv".... | 514 | 18,517 |
astropy | astropy/cosmology/_src/io/builtin/html.py | .py | r"""|Cosmology| <-> html I/O, using |Cosmology.read| and |Cosmology.write|.
We assume the following setup:
>>> from pathlib import Path
>>> from tempfile import TemporaryDirectory
>>> temp_dir = TemporaryDirectory()
Writing a cosmology to a html file will produce a table with the cosmology's type,
name, ... | 372 | 12,394 |
astropy | astropy/cosmology/_src/io/builtin/mrt.py | .py | r"""|Cosmology| <-> MRT I/O, using |Cosmology.read| and |Cosmology.write|.
We assume the following setup:
>>> from pathlib import Path
>>> from tempfile import TemporaryDirectory
>>> temp_dir = TemporaryDirectory()
Writing a cosmology to a mrt file will produce a table with the cosmology's type,
name, an... | 325 | 12,789 |
astropy | astropy/cosmology/_src/io/builtin/latex.py | .py | r"""|Cosmology| <-> LaTeX I/O, using |Cosmology.read| and |Cosmology.write|.
We assume the following setup:
>>> from pathlib import Path
>>> from tempfile import TemporaryDirectory
>>> temp_dir = TemporaryDirectory()
Writing a cosmology to a LaTeX file will produce a table with the cosmology's type,
name... | 215 | 7,357 |
astropy | astropy/cosmology/_src/io/builtin/yaml.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
r"""|Cosmology| <-> YAML I/O, using |Cosmology.to_format| and |Cosmology.from_format|.
This module provides functions to transform a |Cosmology| object to and from a `yaml
<https://yaml.org>`_ representation. The functions are registered with
``convert_re... | 266 | 9,482 |
astropy | astropy/cosmology/_src/io/builtin/cosmology.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""|Cosmology| I/O, using |Cosmology.to_format| and |Cosmology.from_format|.
This module provides functions to transform a |Cosmology| object to and from another
|Cosmology| object. The functions are registered with ``convert_registry`` under the
format n... | 120 | 3,698 |
astropy | astropy/cosmology/_src/parameter/descriptors.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
__all__: list[str] = ["ParametersAttribute"]
from dataclasses import dataclass, field
from types import MappingProxyType
from typing import TYPE_CHECKING, Any, NoReturn, Union
if TYPE_CHECKING:
import astropy.cosmology
@dataclass(frozen=True, slot... | 70 | 2,489 |
astropy | astropy/cosmology/_src/parameter/utils.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
__all__ = ("all_parameters",)
import functools
import operator
from dataclasses import Field
from typing import TypeGuard
from .core import Parameter
def is_parameter_or_field(obj: object, /) -> TypeGuard[Parameter | Field[Parameter]]:
"""Return i... | 34 | 1,062 |
astropy | astropy/cosmology/_src/parameter/converter.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
__all__ = (
"validate_non_negative",
"validate_to_float",
"validate_to_scalar",
"validate_with_unit",
)
from collections.abc import Callable
from typing import TYPE_CHECKING, Any
from numpy.typing import NDArray
import astropy.units as ... | 123 | 3,379 |
astropy | astropy/cosmology/_src/parameter/core.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
__all__ = ("MISSING", "Parameter")
import copy
from collections.abc import Sequence
from dataclasses import KW_ONLY, dataclass, field, fields, is_dataclass, replace
from enum import Enum, auto
from typing import TYPE_CHECKING, Any, Union
import astropy.... | 305 | 11,317 |
astropy | astropy/cosmology/tests/test_scalar_inv_efuncs.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Tests for the scalar_inv_efuncs Cython extension in astropy.cosmology."""
from numpy.testing import assert_allclose
from astropy.cosmology._src.flrw.scalar_inv_efuncs import (
flcdm_inv_efunc_nomnu,
flcdm_inv_efunc_norel,
fwcdm_inv_efunc_n... | 129 | 4,313 |
astropy | astropy/timeseries/binned.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from copy import deepcopy
import numpy as np
from astropy import units as u
from astropy.table import QTable, Table, groups
from astropy.time import Time, TimeDelta
from astropy.timeseries.core import BaseTimeSeries, autocheck_required_columns
from astr... | 411 | 16,645 |
astropy | astropy/timeseries/__init__.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This subpackage contains classes and functions for work with time series.
"""
from astropy.timeseries import io
from astropy.timeseries.binned import *
from astropy.timeseries.core import *
from astropy.timeseries.downsample import *
from astropy.tim... | 13 | 391 |
astropy | astropy/timeseries/sampled.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from copy import deepcopy
import numpy as np
from astropy import units as u
from astropy.table import QTable, Table, groups
from astropy.time import Time, TimeDelta
from astropy.timeseries.core import BaseTimeSeries, autocheck_required_columns
from astr... | 435 | 16,664 |
astropy | astropy/timeseries/downsample.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import warnings
from itertools import pairwise
import numpy as np
from astropy import units as u
from astropy.time import Time, TimeDelta
from astropy.timeseries.binned import BinnedTimeSeries
from astropy.timeseries.sampled import TimeSeries
from astro... | 314 | 12,872 |
astropy | astropy/timeseries/core.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from contextlib import contextmanager
from functools import wraps
from types import FunctionType
from astropy.table import QTable
__all__ = ["BaseTimeSeries", "autocheck_required_columns"]
COLUMN_RELATED_METHODS = [
"add_column",
"add_columns",... | 104 | 3,526 |
astropy | astropy/timeseries/periodograms/base.py | .py | import abc
import numpy as np
from astropy.timeseries.binned import BinnedTimeSeries
from astropy.timeseries.sampled import TimeSeries
__all__ = ["BasePeriodogram"]
class BasePeriodogram:
@abc.abstractmethod
def __init__(self, t, y, dy=None):
pass
@classmethod
def from_timeseries(
... | 62 | 1,966 |
astropy | astropy/timeseries/periodograms/lombscargle_multiband/core.py | .py | """Main Lomb-Scargle Multiband Implementation"""
import numpy as np
from astropy import units as u
from astropy.time import Time, TimeDelta
from astropy.timeseries.binned import BinnedTimeSeries
from astropy.timeseries.periodograms.lombscargle import LombScargle
from astropy.timeseries.sampled import TimeSeries
from... | 706 | 26,317 |
astropy | astropy/timeseries/periodograms/lombscargle_multiband/tests/test_lombscargle_multiband.py | .py | import numpy as np
import pytest
from numpy.testing import assert_allclose
from astropy import units as u
from astropy.table import MaskedColumn
from astropy.tests.helper import assert_quantity_allclose
from astropy.time import Time, TimeDelta
from astropy.timeseries import TimeSeries
from astropy.timeseries.periodogr... | 635 | 19,947 |
astropy | astropy/timeseries/periodograms/lombscargle_multiband/implementations/main.py | .py | """
Main Lomb-Scargle Multiband Implementation
The ``lombscarglemultiband`` function here is essentially a switch
statement for the various implementations available in this submodule
"""
__all__ = ["available_methods", "lombscargle_multiband"]
from .mbfast_impl import lombscargle_mbfast
from .mbflex_impl import lom... | 74 | 1,826 |
astropy | astropy/timeseries/periodograms/lombscargle_multiband/implementations/mle.py | .py | import numpy as np
__all__ = ["construct_regularization", "design_matrix", "periodic_fit"]
def design_matrix(t, bands, frequency, dy=None, nterms_base=1, nterms_band=1):
t = np.asarray(t)
omega = np.asarray(2 * np.pi * frequency)
unique_bands = np.unique(bands)
# Construct X - design matrix of the s... | 177 | 5,178 |
astropy | astropy/timeseries/periodograms/lombscargle_multiband/implementations/mbfast_impl.py | .py | import numpy as np
from astropy.timeseries.periodograms.lombscargle.implementations import lombscargle
__all__ = ["lombscargle_mbfast"]
def lombscargle_mbfast(
t,
y,
bands,
dy=None,
frequency=None,
sb_method="auto",
assume_regular_frequency=False,
normalization="standard",
fit_me... | 66 | 1,842 |
astropy | astropy/timeseries/periodograms/lombscargle_multiband/implementations/mbflex_impl.py | .py | import numpy as np
__all__ = ["lombscargle_mbflex"]
def lombscargle_mbflex(
t,
y,
bands,
frequency,
dy=None,
nterms_base=1,
nterms_band=1,
reg_base=None,
reg_band=1e-6,
regularize_by_trace=True,
center_data=True,
):
if (nterms_base == 0) and (nterms_band == 0):
... | 128 | 3,867 |
astropy | astropy/timeseries/periodograms/lombscargle/_testing.py | .py | import numpy as np
def assert_not_strictly_equal(
a, b, err="Output arrays are the same - dispatch test has failed"
):
"""
Asserts that passed arguments are not bitwise equal.
Failure means that arrays can be considered to be a copy of each other.
Parameters
----------
a : array-like
... | 23 | 565 |
astropy | astropy/timeseries/periodograms/lombscargle/utils.py | .py | import numpy as np
NORMALIZATIONS = ["standard", "psd", "model", "log"]
def compute_chi2_ref(y, dy=None, center_data=True, fit_mean=True):
"""Compute the reference chi-square for a particular dataset.
Note: this is not valid center_data=False and fit_mean=False.
Parameters
----------
y : array-... | 105 | 3,082 |
astropy | astropy/timeseries/periodograms/lombscargle/setup_package.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import os
from numpy import get_include as get_numpy_include
from setuptools import Extension
ROOT = os.path.relpath(os.path.dirname(__file__))
def get_extensions():
ext = Extension(
"astropy.timeseries.periodograms.lombscargle.implementat... | 18 | 482 |
astropy | astropy/timeseries/periodograms/lombscargle/__init__.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
lombscargle
===========
AstroPy-compatible implementation of the Lomb-Scargle periodogram.
"""
from .core import LombScargle
| 10 | 195 |
astropy | astropy/timeseries/periodograms/lombscargle/_statistics.py | .py | """
Utilities for computing periodogram statistics.
This is an internal module; users should access this functionality via the
``false_alarm_probability`` and ``false_alarm_level`` methods of the
``astropy.timeseries.LombScargle`` API.
"""
from functools import wraps
import numpy as np
from astropy import units as ... | 506 | 16,195 |
astropy | astropy/timeseries/periodograms/lombscargle/core.py | .py | """Main Lomb-Scargle Implementation."""
import numpy as np
from astropy import units
from astropy import units as u
from astropy.time import Time, TimeDelta
from astropy.timeseries.periodograms.base import BasePeriodogram
from . import _statistics
from .implementations import available_methods, lombscargle
from .imp... | 767 | 28,267 |
astropy | astropy/timeseries/periodograms/lombscargle/tests/test_lombscargle.py | .py | import numpy as np
import pytest
from numpy.testing import assert_allclose
from astropy import units as u
from astropy.tests.helper import assert_quantity_allclose
from astropy.time import Time, TimeDelta
from astropy.timeseries.periodograms.lombscargle import LombScargle
from astropy.timeseries.periodograms.lombscarg... | 562 | 17,895 |
astropy | astropy/timeseries/periodograms/lombscargle/tests/test_statistics.py | .py | import numpy as np
import pytest
from numpy.testing import assert_allclose
import astropy.units as u
from astropy.timeseries.periodograms.lombscargle import LombScargle
from astropy.timeseries.periodograms.lombscargle._statistics import (
METHODS,
fap_single,
inv_fap_single,
)
from astropy.timeseries.perio... | 208 | 7,135 |
astropy | astropy/timeseries/periodograms/lombscargle/tests/test_utils.py | .py | import numpy as np
import pytest
from numpy.testing import assert_allclose
from astropy.timeseries.periodograms.lombscargle.core import LombScargle
from astropy.timeseries.periodograms.lombscargle.utils import (
compute_chi2_ref,
convert_normalization,
)
NORMALIZATIONS = ["standard", "model", "log", "psd"]
... | 46 | 1,372 |
astropy | astropy/timeseries/periodograms/lombscargle/implementations/main.py | .py | """
Main Lomb-Scargle Implementation.
The ``lombscargle`` function here is essentially a sophisticated switch
statement for the various implementations available in this submodule
"""
__all__ = ["available_methods", "lombscargle"]
import numpy as np
from astropy.utils.compat.optional_deps import HAS_SCIPY
from .ch... | 241 | 8,170 |
astropy | astropy/timeseries/periodograms/lombscargle/implementations/utils.py | .py | from math import factorial
import numpy as np
def bitceil(N):
"""
Find the bit (i.e., power of 2) immediately greater than or equal to N.
Note: this works for numbers up to 2 ** 64.
Roughly equivalent to int(2 ** np.ceil(np.log2(N))).
"""
return 1 << int(N - 1).bit_length()
def next_fast_le... | 500 | 14,393 |
astropy | astropy/timeseries/periodograms/lombscargle/implementations/chi2_impl.py | .py | import numpy as np
from .mle import design_matrix
def lombscargle_chi2(
t,
y,
dy,
frequency,
normalization="standard",
fit_mean=True,
center_data=True,
nterms=1,
):
"""Lomb-Scargle Periodogram.
This implements a chi-squared-based periodogram, which is relatively slow
but ... | 94 | 2,891 |
astropy | astropy/timeseries/periodograms/lombscargle/implementations/fastchi2_impl.py | .py | from itertools import chain
import numpy as np
from .utils import trig_sum
def lombscargle_fastchi2(
t,
y,
dy,
f0,
df,
Nf,
normalization="standard",
fit_mean=True,
center_data=True,
nterms=1,
use_fft=True,
trig_sum_kwds=None,
*,
algorithm="lra",
):
"""Lomb... | 161 | 5,528 |
astropy | astropy/timeseries/periodograms/lombscargle/implementations/mle.py | .py | import numpy as np
def design_matrix(t, frequency, dy=None, bias=True, nterms=1):
"""Compute the Lomb-Scargle design matrix at the given frequency.
This is the matrix X such that the periodic model at the given frequency
can be expressed :math:`\\hat{y} = X \\theta`.
Parameters
----------
t ... | 106 | 3,175 |
astropy | astropy/timeseries/periodograms/lombscargle/implementations/slow_impl.py | .py | import numpy as np
def lombscargle_slow(
t, y, dy, frequency, normalization="standard", fit_mean=True, center_data=True
):
"""Lomb-Scargle Periodogram.
This is a pure-python implementation of the original Lomb-Scargle formalism
(e.g. [1]_, [2]_), with the addition of the floating mean (e.g. [3]_)
... | 120 | 3,721 |
astropy | astropy/timeseries/periodograms/lombscargle/implementations/fast_impl.py | .py | import numpy as np
from .utils import trig_sum
def lombscargle_fast(
t,
y,
dy,
f0,
df,
Nf,
center_data=True,
fit_mean=True,
normalization="standard",
use_fft=True,
trig_sum_kwds=None,
*,
algorithm="lra",
):
"""Fast Lomb-Scargle Periodogram.
This implements... | 158 | 5,661 |
astropy | astropy/timeseries/periodograms/lombscargle/implementations/scipy_impl.py | .py | import numpy as np
from astropy.utils.compat.optional_deps import HAS_SCIPY
def lombscargle_scipy(t, y, frequency, normalization="standard", center_data=True):
"""Lomb-Scargle Periodogram.
This is a wrapper of ``scipy.signal.lombscargle`` for computation of the
Lomb-Scargle periodogram. This is a relati... | 73 | 2,440 |
astropy | astropy/timeseries/periodograms/lombscargle/implementations/tests/test_mle.py | .py | import numpy as np
import pytest
from numpy.testing import assert_allclose
from astropy.timeseries.periodograms.lombscargle.implementations.mle import (
design_matrix,
periodic_fit,
)
@pytest.fixture
def t():
rand = np.random.default_rng(42)
return 10 * rand.random(10)
@pytest.mark.parametrize("fre... | 66 | 2,007 |
astropy | astropy/timeseries/periodograms/lombscargle/implementations/tests/test_utils.py | .py | import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_equal
from astropy.timeseries.periodograms.lombscargle._testing import (
assert_not_strictly_equal,
)
from astropy.timeseries.periodograms.lombscargle.implementations.utils import (
bitceil,
extirpolate,
jn,
trig_sum... | 122 | 3,378 |
astropy | astropy/timeseries/periodograms/bls/methods.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
__all__ = ["bls_fast", "bls_slow"]
from functools import partial
import numpy as np
from ._impl import bls_impl
def bls_slow(t, y, ivar, period, duration, oversample, use_likelihood):
"""Compute the periodogram using a brute force reference metho... | 151 | 5,316 |
astropy | astropy/timeseries/periodograms/bls/setup_package.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import os
from numpy import get_include as get_numpy_include
from setuptools import Extension
BLS_ROOT = os.path.relpath(os.path.dirname(__file__))
def get_extensions():
ext = Extension(
"astropy.timeseries.periodograms.bls._impl",
... | 21 | 503 |
astropy | astropy/timeseries/periodograms/bls/__init__.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Box Least Squares Algorithms.
Box Least Squares
=================
AstroPy-compatible reference implementation of the transit periorogram used
to discover transiting exoplanets.
"""
__all__ = ["BoxLeastSquares", "BoxLeastSquaresResults"]
from .core... | 16 | 368 |
astropy | astropy/timeseries/periodograms/bls/core.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
__all__ = ["BoxLeastSquares", "BoxLeastSquaresResults"]
import numpy as np
from astropy import units
from astropy import units as u
from astropy.time import Time, TimeDelta
from astropy.timeseries.periodograms.base import BasePeriodogram
from astropy.ti... | 878 | 34,147 |
astropy | astropy/timeseries/periodograms/bls/tests/test_bls.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_equal
from astropy import units as u
from astropy.tests.helper import assert_quantity_allclose
from astropy.time import Time, TimeDelta
from astropy.timeseries.periodogram... | 513 | 17,516 |
astropy | astropy/timeseries/tests/test_sampled.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from datetime import datetime
import pytest
from numpy.testing import assert_allclose, assert_equal
from astropy import units as u
from astropy.table import Column, Table
from astropy.tests.helper import assert_quantity_allclose
from astropy.time import... | 520 | 17,843 |
astropy | astropy/timeseries/tests/test_downsample.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import sys
import warnings
import numpy as np
import pytest
from numpy.testing import assert_equal
from astropy import units as u
from astropy.table import MaskedColumn
from astropy.time import Time
from astropy.timeseries.downsample import (
aggreg... | 437 | 15,535 |
astropy | astropy/timeseries/tests/test_binned.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import pytest
from numpy.testing import assert_allclose, assert_equal
from astropy import units as u
from astropy.tests.helper import assert_quantity_allclose
from astropy.time import Time, TimeDelta
from astropy.timeseries.binned import BinnedTimeSeries... | 499 | 13,562 |
astropy | astropy/timeseries/tests/test_common.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import pytest
from numpy.testing import assert_equal
from astropy import units as u
from astropy.table import QTable, Table, join, vstack
from astropy.time import Time
from astropy.timeseries.binned import BinnedTimeSeries
from astropy.timeseries.sampled... | 101 | 3,288 |
astropy | astropy/timeseries/io/kepler.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import warnings
import numpy as np
from astropy.io import fits, registry
from astropy.table import MaskedColumn, Table
from astropy.time import Time, TimeDelta
from astropy.timeseries.sampled import TimeSeries
__all__ = ["kepler_fits_reader"]
def kepl... | 116 | 3,829 |
astropy | astropy/timeseries/io/tests/test_kepler.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from unittest import mock
import pytest
from astropy.io.fits import BinTableHDU, HDUList, Header, PrimaryHDU
from astropy.timeseries.io.kepler import kepler_fits_reader
from astropy.units import UnitsWarning
from astropy.utils.data import get_pkg_data_f... | 158 | 5,649 |
astropy | astropy/visualization/transform.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
__all__ = ["BaseTransform", "CompositeTransform"]
class BaseTransform:
"""
A transformation object.
This is used to construct transformations such as scaling, stretching, and
so on.
"""
def __add__(self, other):
return... | 42 | 1,083 |
astropy | astropy/visualization/stretch.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Classes that deal with stretching, i.e. mapping a range of [0:1] values onto
another set of [0:1] values with a transformation.
"""
import numpy as np
from .transform import BaseTransform, CompositeTransform
__all__ = [
"AsinhStretch",
"Bas... | 992 | 29,206 |
astropy | astropy/visualization/hist.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from astropy.stats.histogram import calculate_bin_edges
__all__ = ["hist"]
def hist(x, bins=10, ax=None, max_bins=1e5, **kwargs):
"""Enhanced histogram function.
This is a histogram function that enables the use of more sophisticated
algor... | 76 | 2,409 |
astropy | astropy/visualization/lupton_rgb.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Combine 3 images to produce a properly-scaled RGB image following
Lupton et al. (2004).
The three images must be aligned and have the same pixel scale and size.
For details, see : https://ui.adsabs.harvard.edu/abs/2004PASP..116..133L
"""
import nump... | 759 | 25,129 |
astropy | astropy/visualization/interval.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Classes that deal with computing intervals from arrays of values based on
various criteria.
"""
import abc
import numpy as np
from astropy.utils.masked import get_data_and_mask
from .transform import BaseTransform
__all__ = [
"AsymmetricPerce... | 380 | 11,601 |
astropy | astropy/visualization/mpl_style.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This module contains dictionaries that can be used to set a matplotlib
# plotting style. It is no longer documented/recommended as of Astropy v3.0
# but is kept here for backward-compatibility.
__all__ = ["astropy_mpl_style", "astropy_mpl_style_1"]
# ... | 79 | 2,122 |
astropy | astropy/visualization/basic_rgb.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Combine 3 images to produce properly-scaled RGB images with arbitrary scaling.
The three images must be aligned and have the same pixel scale and size.
"""
import numpy as np
from astropy.visualization.interval import ManualInterval
from astropy.vis... | 218 | 7,277 |
astropy | astropy/visualization/time.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from datetime import datetime
import numpy as np
from astropy import units as u
from astropy.time import Time
__all__ = ["time_support"]
__doctest_requires__ = {"time_support": ["matplotlib"]}
UNSUPPORTED_FORMATS = ("datetime", "datetime64")
YMDHMS_F... | 248 | 9,546 |
astropy | astropy/visualization/units.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from contextlib import ContextDecorator
import numpy as np
from astropy import units as u
from astropy.utils.compat.optional_deps import HAS_MATPLOTLIB
__all__ = ["MplQuantityConverter", "quantity_support"]
__doctest_skip__ = ["quantity_support"]
_de... | 161 | 5,706 |
astropy | astropy/visualization/mpl_normalize.py | .py | """
Normalization class for Matplotlib that can be used to produce
colorbars.
"""
import inspect
import numpy as np
from numpy import ma
from astropy.utils.compat.optional_deps import HAS_MATPLOTLIB
from astropy.utils.decorators import future_keyword_only
from .interval import (
AsymmetricPercentileInterval,
... | 738 | 23,969 |
astropy | astropy/visualization/wcsaxes/wcsapi.py | .py | # Functions/classes for WCSAxes related to APE14 WCSes
from __future__ import annotations
from contextlib import contextmanager
import numpy as np
from astropy import units as u
from astropy.coordinates import ICRS, BaseCoordinateFrame, SkyCoord
from astropy.wcs import WCS
from astropy.wcs.wcsapi import SlicedLowLev... | 460 | 15,476 |
astropy | astropy/visualization/wcsaxes/coordinate_helpers.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This file defines the classes used to represent a 'coordinate', which includes
axes, ticks, tick labels, and grid lines.
"""
import warnings
import numpy as np
from matplotlib import rcParams
from matplotlib.patches import PathPatch
from matplotlib.... | 1,628 | 59,943 |
astropy | astropy/visualization/wcsaxes/coordinates_map.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from collections import OrderedDict
from textwrap import indent
from .coordinate_helpers import CoordinateHelper
from .coordinate_range import find_coordinate_range
from .frame import RectangularFrame, RectangularFrame1D
class CoordinatesMap:
"""
... | 200 | 7,643 |
astropy | astropy/visualization/wcsaxes/utils.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
import numpy as np
from astropy import units as u
from astropy.coordinates import BaseCoordinateFrame, UnitSphericalRepresentation
__all__ = [
"select_step_degree",
"select_step_hour",
"select_step_scalar",
"transform_contour_set_inplace"... | 168 | 5,762 |
astropy | astropy/visualization/wcsaxes/formatter_locator.py | .py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This file defines the AngleFormatterLocator class which is a class that
# provides both a method for a formatter and one for a locator, for a given
# label spacing. The advantage of keeping the two connected is that we need to
# make sure that the form... | 661 | 22,148 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.