plotastrodata 1.10.3__tar.gz → 1.11.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {plotastrodata-1.10.3/plotastrodata.egg-info → plotastrodata-1.11.1}/PKG-INFO +3 -13
- {plotastrodata-1.10.3 → plotastrodata-1.11.1}/README.md +2 -12
- {plotastrodata-1.10.3 → plotastrodata-1.11.1}/plotastrodata/__init__.py +1 -1
- plotastrodata-1.11.1/plotastrodata/_type_utils.py +104 -0
- plotastrodata-1.11.1/plotastrodata/_validation_utils.py +70 -0
- plotastrodata-1.11.1/plotastrodata/analysis_utils.py +1429 -0
- plotastrodata-1.11.1/plotastrodata/const_utils.py +129 -0
- plotastrodata-1.11.1/plotastrodata/coord_utils.py +250 -0
- plotastrodata-1.11.1/plotastrodata/ext_utils.py +88 -0
- {plotastrodata-1.10.3 → plotastrodata-1.11.1}/plotastrodata/fft_utils.py +221 -114
- {plotastrodata-1.10.3 → plotastrodata-1.11.1}/plotastrodata/fits_utils.py +190 -84
- {plotastrodata-1.10.3 → plotastrodata-1.11.1}/plotastrodata/fitting_utils.py +285 -118
- plotastrodata-1.11.1/plotastrodata/los_utils.py +169 -0
- {plotastrodata-1.10.3 → plotastrodata-1.11.1}/plotastrodata/matrix_utils.py +16 -9
- plotastrodata-1.11.1/plotastrodata/noise_utils.py +378 -0
- {plotastrodata-1.10.3 → plotastrodata-1.11.1}/plotastrodata/other_utils.py +77 -52
- plotastrodata-1.11.1/plotastrodata/plot_utils.py +2798 -0
- {plotastrodata-1.10.3 → plotastrodata-1.11.1/plotastrodata.egg-info}/PKG-INFO +3 -13
- {plotastrodata-1.10.3 → plotastrodata-1.11.1}/plotastrodata.egg-info/SOURCES.txt +2 -0
- plotastrodata-1.10.3/plotastrodata/analysis_utils.py +0 -938
- plotastrodata-1.10.3/plotastrodata/const_utils.py +0 -125
- plotastrodata-1.10.3/plotastrodata/coord_utils.py +0 -194
- plotastrodata-1.10.3/plotastrodata/ext_utils.py +0 -64
- plotastrodata-1.10.3/plotastrodata/los_utils.py +0 -107
- plotastrodata-1.10.3/plotastrodata/noise_utils.py +0 -245
- plotastrodata-1.10.3/plotastrodata/plot_utils.py +0 -1745
- {plotastrodata-1.10.3 → plotastrodata-1.11.1}/LICENSE +0 -0
- {plotastrodata-1.10.3 → plotastrodata-1.11.1}/MANIFEST.in +0 -0
- {plotastrodata-1.10.3 → plotastrodata-1.11.1}/plotastrodata.egg-info/dependency_links.txt +0 -0
- {plotastrodata-1.10.3 → plotastrodata-1.11.1}/plotastrodata.egg-info/not-zip-safe +0 -0
- {plotastrodata-1.10.3 → plotastrodata-1.11.1}/plotastrodata.egg-info/requires.txt +0 -0
- {plotastrodata-1.10.3 → plotastrodata-1.11.1}/plotastrodata.egg-info/top_level.txt +0 -0
- {plotastrodata-1.10.3 → plotastrodata-1.11.1}/setup.cfg +0 -0
- {plotastrodata-1.10.3 → plotastrodata-1.11.1}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: plotastrodata
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.11.1
|
|
4
4
|
Summary: plotastrodata is a tool for astronomers to create figures from FITS files and perform fundamental data analyses with ease.
|
|
5
5
|
Home-page: https://github.com/yusukeaso-astron/plotastrodata
|
|
6
6
|
Download-URL: https://github.com/yusukeaso-astron/plotastrodata
|
|
@@ -102,18 +102,8 @@ More examples and the complete API reference are available in the [online docume
|
|
|
102
102
|
|
|
103
103
|
## Conventions and Limitations
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
* By default, the R.A. axis increases toward the left (`xflip=True`), following the usual astronomical image convention. Use `xflip=False` to reverse this behavior.
|
|
108
|
-
* Velocity coordinates and `vsys` are in km/s, while `restfreq` is in Hz. A frequency axis read from FITS is converted to velocity relative to `vsys`.
|
|
109
|
-
* Sky positions may be given as coordinate strings, such as `'ICRS 01h23m45.6s 01d23m45.6s'`. Numeric positions supplied through `poslist`, such as `[0.2, 0.3]`, are relative plotting positions: 0 is the left or bottom edge and 1 is the right or top edge. They are not spatial offsets.
|
|
110
|
-
* Angles are in degrees unless an API explicitly states otherwise. Sky position angles are measured from north toward east. The polar-coordinate arrays `theta` and `phi` used by the line-of-sight utilities are in radians.
|
|
111
|
-
* A beam is represented by `[bmaj, bmin, bpa]`, where the first two values use the current spatial unit and `bpa` is in degrees. `Tb=True` converts data from Jy/beam to brightness temperature and requires a valid rest frequency and spatial-resolution metadata.
|
|
112
|
-
* `sigma` may be a numeric RMS value, a string selecting a noise-estimation method, or `None` to disable noise-dependent behavior. See the API documentation for the available estimation methods.
|
|
113
|
-
* Annotation methods accept a single value or a list of values. `include_chan` selects displayed channels by zero-based index; `None` applies the annotation to all channels.
|
|
114
|
-
* Position-velocity mode (`pv=True`) does not support regions, lines, arrows, or segment maps because its spatial and velocity axes use different units. Markers and text may still be placed using relative plotting positions.
|
|
115
|
-
* Constants in `const_utils` are plain numerical values in SI units, not `astropy.units.Quantity` objects.
|
|
116
|
-
|
|
105
|
+
See [Conventions and usage notes](docs/conventions.rst) for data formats, coordinate and angle conventions, runtime types, input validation, and usage limitations.
|
|
106
|
+
|
|
117
107
|
## Author
|
|
118
108
|
|
|
119
109
|
* Name: Yusuke Aso
|
|
@@ -73,18 +73,8 @@ More examples and the complete API reference are available in the [online docume
|
|
|
73
73
|
|
|
74
74
|
## Conventions and Limitations
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
* By default, the R.A. axis increases toward the left (`xflip=True`), following the usual astronomical image convention. Use `xflip=False` to reverse this behavior.
|
|
79
|
-
* Velocity coordinates and `vsys` are in km/s, while `restfreq` is in Hz. A frequency axis read from FITS is converted to velocity relative to `vsys`.
|
|
80
|
-
* Sky positions may be given as coordinate strings, such as `'ICRS 01h23m45.6s 01d23m45.6s'`. Numeric positions supplied through `poslist`, such as `[0.2, 0.3]`, are relative plotting positions: 0 is the left or bottom edge and 1 is the right or top edge. They are not spatial offsets.
|
|
81
|
-
* Angles are in degrees unless an API explicitly states otherwise. Sky position angles are measured from north toward east. The polar-coordinate arrays `theta` and `phi` used by the line-of-sight utilities are in radians.
|
|
82
|
-
* A beam is represented by `[bmaj, bmin, bpa]`, where the first two values use the current spatial unit and `bpa` is in degrees. `Tb=True` converts data from Jy/beam to brightness temperature and requires a valid rest frequency and spatial-resolution metadata.
|
|
83
|
-
* `sigma` may be a numeric RMS value, a string selecting a noise-estimation method, or `None` to disable noise-dependent behavior. See the API documentation for the available estimation methods.
|
|
84
|
-
* Annotation methods accept a single value or a list of values. `include_chan` selects displayed channels by zero-based index; `None` applies the annotation to all channels.
|
|
85
|
-
* Position-velocity mode (`pv=True`) does not support regions, lines, arrows, or segment maps because its spatial and velocity axes use different units. Markers and text may still be placed using relative plotting positions.
|
|
86
|
-
* Constants in `const_utils` are plain numerical values in SI units, not `astropy.units.Quantity` objects.
|
|
87
|
-
|
|
76
|
+
See [Conventions and usage notes](docs/conventions.rst) for data formats, coordinate and angle conventions, runtime types, input validation, and usage limitations.
|
|
77
|
+
|
|
88
78
|
## Author
|
|
89
79
|
|
|
90
80
|
* Name: Yusuke Aso
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""Annotated numeric types and output-boundary precision helpers.
|
|
2
|
+
|
|
3
|
+
Pydantic field coercion and preservation of computed output types are separate
|
|
4
|
+
from the noncoercing input checks in _validation_utils. A 0D array is not
|
|
5
|
+
implicitly a scalar: _normalize_float unwraps one only when the caller
|
|
6
|
+
explicitly requests scalar output.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from dataclasses import field
|
|
10
|
+
import numpy as np
|
|
11
|
+
from typing import Annotated, Any, Callable, Literal, overload
|
|
12
|
+
from pydantic import WrapValidator
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# Shared input types; validated settings are separate from uncoerced inputs.
|
|
16
|
+
RealScalar = float | np.floating | np.integer
|
|
17
|
+
RealSequence = list[RealScalar] | tuple[RealScalar, ...] | np.ndarray
|
|
18
|
+
PositionPair = tuple[RealScalar, RealScalar] | list[RealScalar] | np.ndarray
|
|
19
|
+
Position = str | PositionPair
|
|
20
|
+
Positions = Position | list[Position] | tuple[Position, ...]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _validate_float(value: Any, handler: Callable) -> float | np.longdouble:
|
|
24
|
+
"""Preserve extended precision before Pydantic coerces other values."""
|
|
25
|
+
return value if isinstance(value, np.longdouble) else handler(value)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
ValidatedFloat = Annotated[float | np.longdouble,
|
|
29
|
+
WrapValidator(_validate_float)]
|
|
30
|
+
|
|
31
|
+
# Raw analysis inputs retain their containers and scalar types.
|
|
32
|
+
BeamInput = np.ndarray | list[RealScalar | None] | tuple[RealScalar | None,
|
|
33
|
+
RealScalar | None,
|
|
34
|
+
RealScalar | None]
|
|
35
|
+
# Plotting converts inputs to lists and validates shape/completeness separately.
|
|
36
|
+
ValidatedBeamTriple = list[ValidatedFloat | None]
|
|
37
|
+
ValidatedBeams = ValidatedBeamTriple | list[ValidatedBeamTriple]
|
|
38
|
+
|
|
39
|
+
_FloatNormalizationInput = int | float | np.integer | np.floating | np.ndarray
|
|
40
|
+
_FloatNormalizationResult = int | float | np.integer | np.longdouble | np.ndarray
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@overload
|
|
44
|
+
def _normalize_float(value: _FloatNormalizationInput, *,
|
|
45
|
+
force_float: bool = False,
|
|
46
|
+
array_output: Literal[True]
|
|
47
|
+
) -> np.ndarray: ...
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@overload
|
|
51
|
+
def _normalize_float(value: np.ndarray, *,
|
|
52
|
+
force_float: bool = False,
|
|
53
|
+
array_output: None = None
|
|
54
|
+
) -> np.ndarray: ...
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@overload
|
|
58
|
+
def _normalize_float(value: float | np.floating, *,
|
|
59
|
+
force_float: bool = False,
|
|
60
|
+
array_output: Literal[False] | None = None
|
|
61
|
+
) -> float | np.longdouble: ...
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@overload
|
|
65
|
+
def _normalize_float(value: _FloatNormalizationInput, *,
|
|
66
|
+
force_float: bool = False,
|
|
67
|
+
array_output: bool | None = None
|
|
68
|
+
) -> _FloatNormalizationResult: ...
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _normalize_float(value: _FloatNormalizationInput, *,
|
|
72
|
+
force_float: bool = False,
|
|
73
|
+
array_output: bool | None = None
|
|
74
|
+
) -> _FloatNormalizationResult:
|
|
75
|
+
"""Normalize a real numerical result at its public output boundary.
|
|
76
|
+
|
|
77
|
+
By default, convert ordinary NumPy floating scalars to Python floats,
|
|
78
|
+
leaving integers and arrays unchanged. Extended-precision floating
|
|
79
|
+
scalars retain their precision.
|
|
80
|
+
|
|
81
|
+
force_float converts scalar integers to Python floats as well.
|
|
82
|
+
array_output=True preserves or restores array form via np.asarray;
|
|
83
|
+
False unwraps a zero-dimensional temporary before scalar normalization;
|
|
84
|
+
None preserves the result's existing scalar/array form. Arrays with
|
|
85
|
+
dimensions greater than zero always remain arrays. Array dtypes are
|
|
86
|
+
never changed by force_float, including for zero-dimensional arrays
|
|
87
|
+
retained with array_output=True or None.
|
|
88
|
+
"""
|
|
89
|
+
if array_output is True:
|
|
90
|
+
return np.asarray(value)
|
|
91
|
+
if isinstance(value, np.ndarray):
|
|
92
|
+
if array_output is not False or value.ndim != 0:
|
|
93
|
+
return value
|
|
94
|
+
value = value[()]
|
|
95
|
+
if isinstance(value, np.longdouble):
|
|
96
|
+
return value
|
|
97
|
+
if force_float or isinstance(value, np.floating):
|
|
98
|
+
return float(value)
|
|
99
|
+
return value
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def _internal_field() -> Any:
|
|
103
|
+
"""Create a fresh field for internal state populated after initialization."""
|
|
104
|
+
return field(init=False, default=None, repr=False, compare=False)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""Shared input validation without coercion or changes to numeric precision."""
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def _is_zero_dimensional_array(value: Any) -> bool:
|
|
8
|
+
"""Identify a NumPy 0D array without conversion or scalar extraction.
|
|
9
|
+
|
|
10
|
+
This shape predicate does not decide whether a caller accepts the value.
|
|
11
|
+
NumPy scalar objects are not arrays and return False.
|
|
12
|
+
"""
|
|
13
|
+
return isinstance(value, np.ndarray) and value.ndim == 0
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _is_uniform_spacing(steps: np.ndarray,
|
|
17
|
+
reference: int | float | np.integer | np.floating
|
|
18
|
+
) -> bool:
|
|
19
|
+
"""Compare intervals with a caller-selected reference (rtol=1e-5, atol=0).
|
|
20
|
+
|
|
21
|
+
Callers validate shape, finiteness, and allowed direction separately.
|
|
22
|
+
They choose the first interval or mean as appropriate for the operation.
|
|
23
|
+
No input arrays or intermediate scalar precision are changed.
|
|
24
|
+
"""
|
|
25
|
+
return bool(np.allclose(steps, reference, rtol=1e-5, atol=0))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _is_finite_real_scalar(value: Any) -> bool:
|
|
29
|
+
"""Accept finite Python/NumPy real numeric scalars without coercion.
|
|
30
|
+
|
|
31
|
+
Accept int, float, np.integer, and np.floating, excluding booleans.
|
|
32
|
+
Arrays (including 0D), complex values, strings, and other objects are
|
|
33
|
+
rejected. Return a Python bool and preserve extended floating precision.
|
|
34
|
+
"""
|
|
35
|
+
if (isinstance(value, bool)
|
|
36
|
+
or not isinstance(value, (int, float, np.integer, np.floating))):
|
|
37
|
+
return False
|
|
38
|
+
# Integers are finite; np.isfinite cannot handle arbitrary-size Python ints.
|
|
39
|
+
if isinstance(value, (int, np.integer)):
|
|
40
|
+
return True
|
|
41
|
+
return bool(np.isfinite(value))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _is_positive_real_scalar(value: Any) -> bool:
|
|
45
|
+
"""Require finite scalar form and strict positivity without coercion.
|
|
46
|
+
|
|
47
|
+
Return a Python bool; preserve the finite check's extended precision
|
|
48
|
+
and rejection of booleans, complex values, and arrays (including 0D).
|
|
49
|
+
"""
|
|
50
|
+
return _is_finite_real_scalar(value) and bool(value > 0)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _require_positive_real_scalar(value: Any, name: str) -> None:
|
|
54
|
+
"""Raise ValueError for invalid positive scalar input, without coercion."""
|
|
55
|
+
if not _is_positive_real_scalar(value):
|
|
56
|
+
raise ValueError(f'{name} must be a finite positive real scalar.')
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _require_integer(value: Any, name: str, minimum: int = 1) -> None:
|
|
60
|
+
"""Require a Python/NumPy integer at or above minimum, excluding booleans.
|
|
61
|
+
|
|
62
|
+
Floating values (even integral ones) and arrays (including 0D) are
|
|
63
|
+
rejected. Accepted values are left unchanged; normalization belongs at
|
|
64
|
+
public output boundaries.
|
|
65
|
+
"""
|
|
66
|
+
if (isinstance(value, (bool, np.bool_))
|
|
67
|
+
or not isinstance(value, (int, np.integer)) or value < minimum):
|
|
68
|
+
req01 = {0: 'a nonnegative integer', 1: 'a positive integer'}
|
|
69
|
+
requirement = req01.get(minimum, f'an integer of at least {minimum}')
|
|
70
|
+
raise ValueError(f'{name} must be {requirement}.')
|