plotastrodata 1.10.2__tar.gz → 1.11.0__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.
Files changed (33) hide show
  1. {plotastrodata-1.10.2/plotastrodata.egg-info → plotastrodata-1.11.0}/PKG-INFO +3 -13
  2. {plotastrodata-1.10.2 → plotastrodata-1.11.0}/README.md +2 -12
  3. {plotastrodata-1.10.2 → plotastrodata-1.11.0}/plotastrodata/__init__.py +1 -1
  4. plotastrodata-1.11.0/plotastrodata/_type_utils.py +100 -0
  5. plotastrodata-1.11.0/plotastrodata/analysis_utils.py +1381 -0
  6. plotastrodata-1.11.0/plotastrodata/const_utils.py +129 -0
  7. plotastrodata-1.11.0/plotastrodata/coord_utils.py +249 -0
  8. plotastrodata-1.11.0/plotastrodata/ext_utils.py +88 -0
  9. {plotastrodata-1.10.2 → plotastrodata-1.11.0}/plotastrodata/fft_utils.py +220 -114
  10. {plotastrodata-1.10.2 → plotastrodata-1.11.0}/plotastrodata/fits_utils.py +153 -68
  11. {plotastrodata-1.10.2 → plotastrodata-1.11.0}/plotastrodata/fitting_utils.py +250 -98
  12. plotastrodata-1.11.0/plotastrodata/los_utils.py +169 -0
  13. {plotastrodata-1.10.2 → plotastrodata-1.11.0}/plotastrodata/matrix_utils.py +16 -9
  14. plotastrodata-1.11.0/plotastrodata/noise_utils.py +369 -0
  15. {plotastrodata-1.10.2 → plotastrodata-1.11.0}/plotastrodata/other_utils.py +74 -52
  16. plotastrodata-1.11.0/plotastrodata/plot_utils.py +2673 -0
  17. {plotastrodata-1.10.2 → plotastrodata-1.11.0/plotastrodata.egg-info}/PKG-INFO +3 -13
  18. {plotastrodata-1.10.2 → plotastrodata-1.11.0}/plotastrodata.egg-info/SOURCES.txt +1 -0
  19. plotastrodata-1.10.2/plotastrodata/analysis_utils.py +0 -938
  20. plotastrodata-1.10.2/plotastrodata/const_utils.py +0 -125
  21. plotastrodata-1.10.2/plotastrodata/coord_utils.py +0 -194
  22. plotastrodata-1.10.2/plotastrodata/ext_utils.py +0 -64
  23. plotastrodata-1.10.2/plotastrodata/los_utils.py +0 -107
  24. plotastrodata-1.10.2/plotastrodata/noise_utils.py +0 -245
  25. plotastrodata-1.10.2/plotastrodata/plot_utils.py +0 -1736
  26. {plotastrodata-1.10.2 → plotastrodata-1.11.0}/LICENSE +0 -0
  27. {plotastrodata-1.10.2 → plotastrodata-1.11.0}/MANIFEST.in +0 -0
  28. {plotastrodata-1.10.2 → plotastrodata-1.11.0}/plotastrodata.egg-info/dependency_links.txt +0 -0
  29. {plotastrodata-1.10.2 → plotastrodata-1.11.0}/plotastrodata.egg-info/not-zip-safe +0 -0
  30. {plotastrodata-1.10.2 → plotastrodata-1.11.0}/plotastrodata.egg-info/requires.txt +0 -0
  31. {plotastrodata-1.10.2 → plotastrodata-1.11.0}/plotastrodata.egg-info/top_level.txt +0 -0
  32. {plotastrodata-1.10.2 → plotastrodata-1.11.0}/setup.cfg +0 -0
  33. {plotastrodata-1.10.2 → plotastrodata-1.11.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotastrodata
3
- Version: 1.10.2
3
+ Version: 1.11.0
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
- * Array axes are ordered as `(y, x)` for a 2D image, `(v, y, x)` for a spectral cube, and `(v, x)` for a position-velocity diagram. With NumPy-array input, supply matching one-dimensional coordinate arrays; a spectral cube requires `v` to construct channel maps. FITS input obtains these coordinates from its header.
106
- * Spatial coordinates are offsets from `center`. They are expressed in arcseconds when `dist=1`. When `dist` is set to the source distance in parsecs, spatial offsets and beam sizes are expressed in au.
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, and supported usage.
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
- * Array axes are ordered as `(y, x)` for a 2D image, `(v, y, x)` for a spectral cube, and `(v, x)` for a position-velocity diagram. With NumPy-array input, supply matching one-dimensional coordinate arrays; a spectral cube requires `v` to construct channel maps. FITS input obtains these coordinates from its header.
77
- * Spatial coordinates are offsets from `center`. They are expressed in arcseconds when `dist=1`. When `dist` is set to the source distance in parsecs, spatial offsets and beam sizes are expressed in au.
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, and supported usage.
77
+
88
78
  ## Author
89
79
 
90
80
  * Name: Yusuke Aso
@@ -1,4 +1,4 @@
1
1
  import warnings
2
2
 
3
3
  warnings.simplefilter('ignore', FutureWarning)
4
- __version__ = '1.10.2'
4
+ __version__ = '1.11.0'
@@ -0,0 +1,100 @@
1
+ """Internal helpers for preserving numeric output precision."""
2
+
3
+ from dataclasses import field
4
+ import numpy as np
5
+ from typing import Annotated, Any, Callable, Literal, overload
6
+ from pydantic import WrapValidator
7
+
8
+
9
+ # Shared input types; validated settings are separate from uncoerced inputs.
10
+ RealScalar = float | np.floating | np.integer
11
+ RealSequence = list[RealScalar] | tuple[RealScalar, ...] | np.ndarray
12
+ PositionPair = tuple[RealScalar, RealScalar] | list[RealScalar] | np.ndarray
13
+ Position = str | PositionPair
14
+ Positions = Position | list[Position] | tuple[Position, ...]
15
+
16
+
17
+ def _validate_float(value: Any, handler: Callable) -> float | np.longdouble:
18
+ """Preserve extended precision before Pydantic coerces other values."""
19
+ return value if isinstance(value, np.longdouble) else handler(value)
20
+
21
+
22
+ ValidatedFloat = Annotated[float | np.longdouble,
23
+ WrapValidator(_validate_float)]
24
+
25
+ # Raw analysis inputs retain their containers and scalar types.
26
+ BeamInput = np.ndarray | list[RealScalar | None] | tuple[RealScalar | None,
27
+ RealScalar | None,
28
+ RealScalar | None]
29
+ # Plotting converts inputs to lists and validates shape/completeness separately.
30
+ ValidatedBeamTriple = list[ValidatedFloat | None]
31
+ ValidatedBeams = ValidatedBeamTriple | list[ValidatedBeamTriple]
32
+
33
+
34
+
35
+ _FloatNormalizationInput = int | float | np.integer | np.floating | np.ndarray
36
+ _FloatNormalizationResult = int | float | np.integer | np.longdouble | np.ndarray
37
+
38
+
39
+ @overload
40
+ def _normalize_float(value: _FloatNormalizationInput, *,
41
+ force_float: bool = False,
42
+ array_output: Literal[True]
43
+ ) -> np.ndarray: ...
44
+
45
+
46
+ @overload
47
+ def _normalize_float(value: np.ndarray, *,
48
+ force_float: bool = False,
49
+ array_output: None = None
50
+ ) -> np.ndarray: ...
51
+
52
+
53
+ @overload
54
+ def _normalize_float(value: float | np.floating, *,
55
+ force_float: bool = False,
56
+ array_output: Literal[False] | None = None
57
+ ) -> float | np.longdouble: ...
58
+
59
+
60
+ @overload
61
+ def _normalize_float(value: _FloatNormalizationInput, *,
62
+ force_float: bool = False,
63
+ array_output: bool | None = None
64
+ ) -> _FloatNormalizationResult: ...
65
+
66
+
67
+ def _normalize_float(value: _FloatNormalizationInput, *,
68
+ force_float: bool = False,
69
+ array_output: bool | None = None
70
+ ) -> _FloatNormalizationResult:
71
+ """Normalize a real numerical result at its public output boundary.
72
+
73
+ By default, convert ordinary NumPy floating scalars to Python floats,
74
+ leaving integers and arrays unchanged. Extended-precision floating
75
+ scalars retain their precision.
76
+
77
+ force_float converts scalar integers to Python floats as well.
78
+ array_output=True preserves or restores array form via np.asarray;
79
+ False unwraps a zero-dimensional temporary before scalar normalization;
80
+ None preserves the result's existing scalar/array form. Arrays with
81
+ dimensions greater than zero always remain arrays. Array dtypes are
82
+ never changed by force_float, including for zero-dimensional arrays
83
+ retained with array_output=True or None.
84
+ """
85
+ if array_output is True:
86
+ return np.asarray(value)
87
+ if isinstance(value, np.ndarray):
88
+ if array_output is not False or value.ndim != 0:
89
+ return value
90
+ value = value[()]
91
+ if isinstance(value, np.longdouble):
92
+ return value
93
+ if force_float or isinstance(value, np.floating):
94
+ return float(value)
95
+ return value
96
+
97
+
98
+ def _internal_field() -> Any:
99
+ """Create a fresh field for internal state populated after initialization."""
100
+ return field(init=False, default=None, repr=False, compare=False)