Skip to content

Commit eac2050

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/develop'
2 parents e8d0ad4 + 1f798c6 commit eac2050

31 files changed

+776
-139
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ us first, so we can expect your contributions and make sure they will be within
8686
scope.
8787

8888
If you need general support you can find us on [OpenPlanetary Slack](https://app.slack.com/client/T04CWPQL9/C04CWPQM5)
89+
(available to [OpenPlanetary members](https://www.openplanetary.org/join))
8990
or feel free to [email](mailto:[email protected]) the team.
9091

9192
---

docs/supported_datasets.md

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,12 @@ kernels in combination with JPL Horizons).
8686
- M3 L0, L1B, and L2 images and ancillary files
8787
(*note: L0 line prefix tables are not currently supported*)
8888
#### Clementine
89-
- Map-projected Basemap, HiRes, NIR, and UVVIS mosaics
90-
- These have been migrated to PDS4, pending archive approval.
89+
- Imaging Bundle (PDS4 at IMG)
90+
- EDRs (HiRes, LWIR, NIR, UVVIS and star trackers)
91+
- Map-projected Basemap, HiRes, NIR, and UVVIS mosaics
9192
- Gravity and topography derived products
9293
- LWIR RDRs
93-
- RSS bistatic radar RDRs
94+
- RSS bistatic radar RDRs (except a subset of image products; see 'Known Unsupported' below)
9495
- LIDAR data *note: This is a saved PDS data set, not a regular PDS archive,
9596
but it can be opened with `pdr`*
9697
#### Comet D/Shoemaker-Levy 9/Jupiter Impact Observing Campaign
@@ -109,7 +110,7 @@ kernels in combination with JPL Horizons).
109110
- Galileo Orbiter
110111
- NIMS tables
111112
- PPR EDRs
112-
- SSI REDRs (except line prefix tables)
113+
- SSI REDRs
113114
- UVS EDRs and RDRs
114115
#### Dawn
115116
- Framing Camera: EDRs, RDRs, mosaics, shape models, and most calibration images
@@ -129,6 +130,7 @@ kernels in combination with JPL Horizons).
129130
#### Deep Space 1
130131
- IDS RDRs
131132
- MICAS DEM, images, and matrices
133+
- MICAS EDRs and RDRs, and most PEPE EDRs (*note: these datasets are 'safed', use with caution*)
132134
#### EPOXI
133135
- HRI-IR raw and calibrated spectra
134136
- HRI-VIS raw and calibrated images
@@ -151,7 +153,7 @@ kernels in combination with JPL Horizons).
151153
- SSD: derived electron flux data
152154
- SSI:
153155
- Calibration images
154-
- REDRs (except line prefix tables)
156+
- REDRs
155157
- Ida/Gaspra specific data products at SBN
156158
- UV: UVS and EUV *note: They open correctly from their PDS4 labels, but the
157159
PDS3 labels are currently unsupported.*
@@ -230,9 +232,8 @@ kernels in combination with JPL Horizons).
230232
of the file in the incorrect letter case)
231233
- L2 and L3 GDR images/backplanes
232234
- L4 tables
233-
- LAMP
234-
- EDR and GDR
235-
- RDR (except acquisition list and pixel list tables)
235+
- LAMP EDR, RDR, and GDR (*note: The RDR calibrated histogram images are 4-D arrays,
236+
so `pdr`'s convenience display functions, e.g. `Data.show()`, won't work on them.*)
236237
- LEND EDR and RDR
237238
- LOLA RDR (*note: other LOLA datasets have been migrated to PDS4 and are
238239
notionally supported*)
@@ -255,9 +256,6 @@ kernels in combination with JPL Horizons).
255256
#### Magellan
256257
- FMAPs
257258
- Stereo-Derived Topography
258-
- C-BIDR images *note: `pdr` reads these correctly according to the
259-
specifications in the labels, but there are unaccounted-for offsets in the
260-
images.*
261259
- F-MIDR and C-MIDR
262260
- GxDR: GTDR, GEDR, GSDR, and GREDR
263261
- GVDR
@@ -585,6 +583,8 @@ kernels in combination with JPL Horizons).
585583
- Pancam color mosaics
586584
#### MSL
587585
- CheMin Film EDRs (have efm in filename)
586+
#### New Horizons
587+
- Pluto encounter derived data: ALICE stellar occultation data
588588
#### Phoenix
589589
- TEGA LED EDRs
590590
#### Rosetta
@@ -599,27 +599,26 @@ kernels in combination with JPL Horizons).
599599
## Known Unsupported Datasets
600600
#### Cassini
601601
- CIRS variable-length '.VAR' tables (support not planned)
602-
- ISS prefix tables (support planned)
602+
- ISS volume coiss_0011 v4.3 at the IMG JPL and ATM nodes (support not
603+
planned; v3.0 at IMG USGS is supported)
603604
- MAG error count housekeeping data
604605
- RPWS telemetry data
605606
- RSS ancillary products: TDF, TLM, PD1, PD2, TNF, EOP, ION, and TRO (support not planned)
606607
- VIMS EDR cubes (PDS3 labels; support not planned--open with PDS4 labels)
607608
- Huygens Probe DISR IR tables (support planned; low priority )
608609
#### Clementine
609-
- Imaging EDRs (basemap, HiRes, NIR, and UVVIS) (support not planned)
610-
- LWIR EDRs (support not planned)
611610
- RSS EDRs (support not planned)
612-
#### Comet D/Shoemaker-Levy 9/Jupiter Impact Observing Campaign
613-
- Galileo SSI REDR line-prefix tables (support planned)
611+
- RSS bistatic radar RDR images in the CL_2108 volume's 'sort' directory (support planned)
614612
#### Dawn
615613
- Framing camera: a handful of calibration images
616614
#### Deep Impact
617615
- Movies of 9P/Tempel 1 approach and encounter (support not planned; not an
618616
archive-compliant format)
617+
#### Deep Space 1
618+
- PEPE EDR binary housekeeping files (support not planned; 'safed' dataset)
619619
#### Galileo
620620
- MAG summary tables (other tables supported, support not planned)
621621
- NIMS Jupiter EDRs and cubes (support planned)
622-
- SSI REDR line-prefix tables (support planned)
623622
- PLS EDRs (support not planned)
624623
- PWS EDRs, binary REDRs, and REFDRs (support planned)
625624
#### Giotto
@@ -640,7 +639,6 @@ kernels in combination with JPL Horizons).
640639
- IRSN Halley v1.0 spectroscopy and filter response curve tables (support planned)
641640
- LSPN compressed images in the Halley V1.0 and Giacobini-Zinner datasets (support not planned)
642641
- SSN 2D spectral products with SPECTRAL_IMAGE_QUBE pointers (support planned)
643-
- SSN 2D spectral products with typos in their filenames (support not planned)
644642
- RSN UV visibility products (support planned)
645643
#### Juno
646644
- JADE Ion sensor housekeeping data prior to arrival at Jupiter (support not planned)
@@ -652,11 +650,12 @@ kernels in combination with JPL Horizons).
652650
- Level 0: sun pulse and merged telemetry (support planned; low priority)
653651
#### LRO
654652
- CRaTER EDR primary science data (support not planned)
655-
- LAMP RDR acquisition list and pixel list tables (support planned)
656-
- LAMP RDR calibrated histogram images read correctly, but they crash data.show() (support planned)
657653
- Mini-RF raw SAR products (support not planned)
658654
#### Magellan
659-
- C-BIDR ancillary tables (support not planned)
655+
- C-BIDR (support not planned)
656+
- *note: `pdr` reads the image products correctly according to the specifications
657+
in the labels, but there are offsets in the images due to underdefined header
658+
rows at the start of each data record.*
660659
- F-BIDR (support not planned)
661660
- ALT-EDR (support not planned)
662661
- ARCDR (support planned)
@@ -697,8 +696,8 @@ kernels in combination with JPL Horizons).
697696
PDS3-style files exists in the archive.*)
698697
#### MRO
699698
- RSS .tnf (support not planned)
699+
- RSS products in the 'ancillary' directory (support not planned)
700700
- MCS DDRs (support not planned)
701-
- HiRISE EDR line prefix tables (support planned)
702701
#### MSL
703702
- Malin Space Science Systems (MSSS) Camera EDRs: "Raw" (EDR) data from the
704703
Mars Science Laboratory's MSSS-produced cameras (Mastcam, MAHLI, and
@@ -711,8 +710,6 @@ kernels in combination with JPL Horizons).
711710
compressed in this way.
712711
- ChemCam LIBS EDR tables (support not planned)
713712
- RAD EDRs and RDRs (support planned)
714-
#### New Horizons
715-
- Pluto encounter derived data: ALICE stellar occultation data
716713
#### Pioneer Venus Orbiter
717714
- ORPA raw data (support not planned)
718715
- ORSE ODRs (support not planned)

docs/version_history.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,48 @@
11
# Version History
2+
## [1.4.0] - 2025-03-13
3+
### Added
4+
5+
#### Features
6+
- Support for line prefix tables
7+
- Useful messages for missing files in debug mode
8+
9+
#### Dataset Support
10+
- additional LRO LAMP RDR table/image pointers
11+
- raw images of 9P/TEMPEL 1 from the Keck Observatory
12+
- Deep Space 1 safed MICAS and PEPE datasets
13+
- Lunar Prospector ancillary ascii tables
14+
- VG1/VG2 safed MAG solar wind and POS cruise phase tables
15+
- safed Stardust datasets from the mission's early cruise phase
16+
- New Horizons Pluto encounter ALICE stellar occultation data (updated from
17+
'known unsupported' to 'notionally supported')
18+
- MGS RSS USO tables
19+
- PVO ORPA and ORSE misc ancillary tables
20+
- JUNO Waves EDR housekeeping tables
21+
- Earth-based ring occultation (EBROCC_0001) ancillary data
22+
- Voyager ring profiles ancillary data
23+
- ground-based MAHL images
24+
- CRISM ancillary tables
25+
- Clementine BSR RDR sorted/aggregated tables (CL_2108)
26+
- Line prefix tables
27+
- Galileo SSI REDR
28+
- Cassini ISS
29+
- HiRISE EDR
30+
31+
### Changed
32+
33+
34+
### Fixed
35+
- numpy >= 2.0 no longer automatically upcasts integer dtypes in cases like
36+
`np.int16(0) + 1000000`. In some unusual cases, this can cause an
37+
`OverflowError` when applying scaling factors / offsets (MOLA MEGDRs formed
38+
the motivating example). `Data.get_scaled()` will now catch these errors and
39+
automatically typecast arrays in response.
40+
- glitch reading headers from PDS4-labeled FITS files without unique local
41+
references for said headers
42+
43+
### Removed
44+
45+
246

347
## [1.3.0] - 2024-10-18
448
### Added

pdr/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
if TYPE_CHECKING:
99
from pathlib import Path
1010

11-
__version__ = "1.3.0"
11+
__version__ = "1.4.0"
1212

1313
pkg_dir = _osp.abspath(_osp.dirname(__file__))
1414

pdr/_scaling.py

Lines changed: 74 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
from numbers import Number
2-
from typing import Optional, Sequence
1+
import warnings
2+
from functools import wraps
3+
from itertools import product
4+
from numbers import Integral, Number, Real
5+
from typing import Optional, Sequence, Union
36

47
import numpy as np
58

@@ -59,6 +62,73 @@ def mask_specials(obj, specials):
5962
return obj
6063

6164

65+
def fit_to_scale(
66+
arr: np.ndarray,
67+
scale: Union[Integral, Real],
68+
offset: Union[Integral, Real]
69+
) -> np.ndarray:
70+
"""
71+
Return a version of `arr` cast to the minimum dtype that will hold its
72+
range of values after multiplying by `offset` and adding `scale`.
73+
74+
Supports:
75+
76+
float32, float64, uint8, int8, uint16, int16, uint32, int32, uint64, int64.
77+
"""
78+
if arr.dtype.char not in 'bBhHiIlLqQnNpPf':
79+
raise TypeError(f"This function does not support {arr.dtype.name}")
80+
if arr.dtype.char in 'fd' or int(scale + offset) != scale + offset:
81+
bases, widths, infofunc = ('f',), (4, 8), np.finfo
82+
else:
83+
bases, widths, infofunc = ('u', 'i'), (1, 2, 4, 8), np.iinfo
84+
amin, amax = map(int, (arr.min(), arr.max()))
85+
smin, smax = amin * scale + offset, amax * scale + offset
86+
for base, width in product(bases, widths):
87+
candidate = np.dtype(f'{base}{width}')
88+
cinfo = infofunc(candidate)
89+
if smin >= cinfo.min and smax <= cinfo.max:
90+
return arr.astype(candidate)
91+
raise TypeError("Unable to find a suitable data type for scaling.")
92+
93+
94+
def overflow_wrap(array_func):
95+
@wraps(array_func)
96+
def with_upcasting(arr, scale, offset, *args, **kwargs):
97+
with warnings.catch_warnings():
98+
warnings.filterwarnings("error", message=".*overflow enc.*")
99+
try:
100+
return array_func(arr, scale, offset, *args, **kwargs)
101+
except (OverflowError, RuntimeWarning):
102+
arr = fit_to_scale(arr, scale, offset)
103+
return array_func(arr, scale, offset, *args, **kwargs)
104+
105+
return with_upcasting
106+
107+
108+
def _copy_scale(obj, offset, scale):
109+
try:
110+
# TODO: we should also be doing this per-plane scaling in inplace case
111+
if len(obj) == len(scale) == len(offset) > 1:
112+
planes = [
113+
obj[ix] * scale[ix] + offset[ix] for ix in range(len(scale))
114+
]
115+
stacked = np.rollaxis(np.ma.dstack(planes), 2)
116+
return stacked
117+
except TypeError:
118+
pass # len() is not usable on a float object
119+
return obj * scale + offset
120+
121+
122+
def _inplace_scale(obj, offset, scale):
123+
if len(obj) == len(scale) == len(offset) > 1:
124+
for ix, _ in enumerate(scale):
125+
obj[ix] = obj[ix] * scale[ix] + offset[ix]
126+
else:
127+
obj *= scale
128+
obj += offset
129+
return obj
130+
131+
62132
def scale_array(
63133
meta: PDRLike,
64134
obj: np.ndarray,
@@ -86,28 +156,13 @@ def scale_array(
86156
# we're casting to float, we can't
87157
# TODO: detect rollover cases, etc.
88158
if inplace is True and not casting_to_float(obj, scale, offset):
89-
if len(obj) == len(scale) == len(offset) > 1:
90-
for ix, _ in enumerate(scale):
91-
obj[ix] = obj[ix] * scale[ix] + offset[ix]
92-
else:
93-
obj *= scale
94-
obj += offset
95-
return obj
159+
return overflow_wrap(_inplace_scale)(obj, offset, scale)
96160
# if we're casting to float, permit specification of dtype
97161
# prior to operation (float64 is numpy's default and often excessive)
98162
if casting_to_float(obj, scale, offset):
99163
if float_dtype is not None:
100164
obj = obj.astype(float_dtype)
101-
try:
102-
if len(obj) == len(scale) == len(offset) > 1:
103-
planes = [
104-
obj[ix] * scale[ix] + offset[ix] for ix in range(len(scale))
105-
]
106-
stacked = np.rollaxis(np.ma.dstack(planes), 2)
107-
return stacked
108-
except TypeError:
109-
pass # len() is not usable on a float object
110-
return obj * scale + offset
165+
return overflow_wrap(_copy_scale)(obj, offset, scale)
111166

112167

113168
# TODO: shake this out much more vigorously

pdr/formats/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import pdr.formats.ihw as ihw
1919
import pdr.formats.iue as iue
2020
import pdr.formats.juno as juno
21+
import pdr.formats.lp as lp
2122
import pdr.formats.lroc as lroc
2223
import pdr.formats.lro as lro
2324
import pdr.formats.mariner as mariner
@@ -31,6 +32,7 @@
3132
import pdr.formats.msl_ccam as msl_ccam
3233
import pdr.formats.msl_places as msl_places
3334
import pdr.formats.msl_rems as msl_rems
35+
import pdr.formats.msx as msx
3436
import pdr.formats.nh as nh
3537
import pdr.formats.odyssey as odyssey
3638
import pdr.formats.phoenix as phoenix

0 commit comments

Comments
 (0)