Skip to content

Commit d3ece42

Browse files
Merge pull request #472 from nyx-space/deps/hifitime-4.1.2
Deps/hifitime 4.1.2
2 parents 7156bda + ffb4730 commit d3ece42

File tree

3 files changed

+109
-30
lines changed

3 files changed

+109
-30
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ resolver = "2"
33
members = ["anise", "anise-cli", "anise-gui", "anise-py", "anise/fuzz"]
44

55
[workspace.package]
6-
version = "0.6.4"
6+
version = "0.6.5"
77
edition = "2021"
88
authors = ["Christopher Rabotin <christopher.rabotin@gmail.com>"]
99
description = "ANISE provides a toolkit and files for Attitude, Navigation, Instrument, Spacecraft, and Ephemeris data. It's a modern replacement of NAIF SPICE file."
@@ -26,7 +26,7 @@ exclude = [
2626
]
2727

2828
[workspace.dependencies]
29-
hifitime = "4.1.1"
29+
hifitime = "4.1.2"
3030
memmap2 = "0.9.4"
3131
crc32fast = "1.4.2"
3232
der = { version = "0.7.8", features = ["derive", "alloc", "real"] }
@@ -46,7 +46,7 @@ numpy = "0.25"
4646
ndarray = ">= 0.15, < 0.17"
4747
rayon = "1.10.0"
4848

49-
anise = { version = "0.6.4", path = "anise", default-features = false }
49+
anise = { version = "0.6.5", path = "anise", default-features = false }
5050

5151
[profile.bench]
5252
debug = true

anise-py/anise/__init__.pyi

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import typing
22

3-
4-
from anise.astro import AzElRange, Frame, Occultation, Orbit
5-
from anise.time import Epoch, TimeScale, TimeSeries
6-
from anise.rotation import DCM
7-
83
@typing.final
94
class Aberration:
105
"""Represents the aberration correction options in ANISE.
@@ -274,7 +269,7 @@ Obs. -- Target
274269
def sun_angle_deg_from_frame(self, target: Frame, observer: Frame, epoch: Epoch) -> float:
275270
"""Convenience function that calls `sun_angle_deg` with the provided frames instead of the ephemeris ID."""
276271

277-
def transform(self, target_frame: Orbit, observer_frame: Frame, epoch: Epoch, ab_corr: Aberration=None) -> Orbit:
272+
def transform(self, target_frame: Frame, observer_frame: Frame, epoch: Epoch, ab_corr: Aberration=None) -> Orbit:
278273
"""Returns the Cartesian state needed to transform the `from_frame` to the `to_frame`.
279274
280275
# SPICE Compatibility
@@ -288,7 +283,7 @@ will return exactly the same data as the spkerz SPICE call.
288283
# Note
289284
The units will be those of the underlying ephemeris data (typically km and km/s)"""
290285

291-
def transform_many(self, target_frame: Orbit, observer_frame: Frame, time_series: TimeSeries, ab_corr: Aberration=None) -> typing.List[Orbit]:
286+
def transform_many(self, target_frame: Frame, observer_frame: Frame, time_series: TimeSeries, ab_corr: Aberration=None) -> typing.List[Orbit]:
292287
"""Returns a chronologically sorted list of the Cartesian states that transform the `from_frame` to the `to_frame` for each epoch of the time series, computed in parallel under the hood.
293288
Note: if any transformation fails, the error will be printed to the stderr.
294289
@@ -304,7 +299,7 @@ Refer to [transform_to] for details."""
304299
def transform_to(self, state: Orbit, observer_frame: Frame, ab_corr: Aberration=None) -> Orbit:
305300
"""Returns the provided state as seen from the observer frame, given the aberration."""
306301

307-
def translate(self, target_frame: Orbit, observer_frame: Frame, epoch: Epoch, ab_corr: Aberration=None) -> Orbit:
302+
def translate(self, target_frame: Frame, observer_frame: Frame, epoch: Epoch, ab_corr: Aberration=None) -> Orbit:
308303
"""Returns the Cartesian state of the target frame as seen from the observer frame at the provided epoch, and optionally given the aberration correction.
309304
310305
# SPICE Compatibility
@@ -321,7 +316,7 @@ This function only performs the translation and no rotation whatsoever. Use the
321316
# Note
322317
This function performs a recursion of no more than twice the [MAX_TREE_DEPTH]."""
323318

324-
def translate_geometric(self, target_frame: Orbit, observer_frame: Frame, epoch: Epoch) -> Orbit:
319+
def translate_geometric(self, target_frame: Frame, observer_frame: Frame, epoch: Epoch) -> Orbit:
325320
"""Returns the geometric position vector, velocity vector, and acceleration vector needed to translate the `from_frame` to the `to_frame`, where the distance is in km, the velocity in km/s, and the acceleration in km/s^2."""
326321

327322
def translate_to(self, state: Orbit, observer_frame: Frame, ab_corr: Aberration=None) -> Orbit:
@@ -458,4 +453,6 @@ This function modified `self` and changes the URI to be the path to the download
458453
"""Return repr(self)."""
459454

460455
def __str__(self) -> str:
461-
"""Return str(self)."""
456+
"""Return str(self)."""
457+
458+
def exec_gui():...

anise-py/anise/time.pyi

Lines changed: 99 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ As such, the largest negative duration that can be represented sets the centurie
1616
1717
(Python documentation hints)"""
1818

19-
def __init__(self, string_repr: str) -> Duration:
19+
def __init__(self, string_repr: str) -> None:
2020
"""Defines generally usable durations for nanosecond precision valid for 32,768 centuries in either direction, and only on 80 bits / 10 octets.
2121
2222
**Important conventions:**
@@ -89,7 +89,7 @@ assert_eq!(two_hours_three_min.ceil(1.seconds()), two_hours_three_min + 1.second
8989
assert_eq!(two_hours_three_min.ceil(1.hours() + 5.minutes()), 2.hours() + 10.minutes());
9090
```"""
9191

92-
def decompose(self) -> typing.Tuple:
92+
def decompose(self) -> tuple:
9393
"""Decomposes a Duration in its sign, days, hours, minutes, seconds, ms, us, ns"""
9494

9595
def floor(self, duration: Duration) -> Duration:
@@ -172,7 +172,7 @@ assert_eq!(two_hours_three_min.round(1.hours() + 5.minutes()), 2.hours() + 10.mi
172172
+ 1 if the number is positive
173173
+ -1 if the number is negative"""
174174

175-
def to_parts(self) -> typing.Tuple:
175+
def to_parts(self) -> tuple:
176176
"""Returns the centuries and nanoseconds of this duration
177177
NOTE: These items are not public to prevent incorrect durations from being created by modifying the values of the structure directly."""
178178

@@ -277,7 +277,7 @@ Refer to the appropriate functions for initializing this Epoch from different ti
277277
duration: Duration
278278
time_scale: TimeScale
279279

280-
def __init__(self, string_repr: str) -> Epoch:
280+
def __init__(self, string_repr: str) -> None:
281281
"""Defines a nanosecond-precision Epoch.
282282
283283
Refer to the appropriate functions for initializing this Epoch from different time scales or representations.
@@ -303,6 +303,16 @@ assert_eq!(
303303
e.ceil(3.minutes()),
304304
Epoch::from_gregorian_tai_hms(2022, 10, 3, 17, 45, 0)
305305
);
306+
```"""
307+
308+
def day_of_month(self) -> int:
309+
"""Returns the number of days since the start of the Gregorian month in the current time scale.
310+
311+
# Example
312+
```
313+
use hifitime::Epoch;
314+
let dt = Epoch::from_gregorian_tai_at_midnight(2025, 7, 3);
315+
assert_eq!(dt.day_of_month(), 3);
306316
```"""
307317

308318
def day_of_year(self) -> float:
@@ -974,6 +984,9 @@ NOTE: This function will return an error if the centuries past GPST time are not
974984
def to_gpst_seconds(self) -> float:
975985
"""Returns seconds past GPS Time Epoch, defined as UTC midnight of January 5th to 6th 1980 (cf. <https://gssc.esa.int/navipedia/index.php/Time_References_in_GNSS#GPS_Time_.28GPST.29>)."""
976986

987+
def to_gregorian(self, time_scale: TimeScale=None) -> tuple:
988+
"""Converts the Epoch to the Gregorian parts in the (optionally) provided time scale as (year, month, day, hour, minute, second)."""
989+
977990
def to_gst_days(self) -> float:
978991
"""Returns days past GST (Galileo) Time Epoch,
979992
starting on August 21st 1999 Midnight UT
@@ -1088,7 +1101,7 @@ NOTE: This function will return an error if the centuries past QZSST time are no
10881101
def to_tai_duration(self) -> Duration:
10891102
"""Returns this time in a Duration past J1900 counted in TAI"""
10901103

1091-
def to_tai_parts(self) -> typing.Tuple:
1104+
def to_tai_parts(self) -> tuple:
10921105
"""Returns the TAI parts of this duration"""
10931106

10941107
def to_tai_seconds(self) -> float:
@@ -1119,7 +1132,7 @@ past J2000, one cannot solve the revert the operation analytically. Instead, we
11191132
def to_tdb_seconds(self) -> float:
11201133
"""Returns the Dynamic Barycentric Time (TDB) (higher fidelity SPICE ephemeris time) whose epoch is 2000 JAN 01 noon TAI (cf. <https://gssc.esa.int/navipedia/index.php/Transformations_between_Time_Systems#TDT_-_TDB.2C_TCB>)"""
11211134

1122-
def to_time_of_week(self) -> typing.Tuple[int]:
1135+
def to_time_of_week(self) -> tuple:
11231136
"""Converts this epoch into the time of week, represented as a rolling week counter into that time scale
11241137
and the number of nanoseconds elapsed in current week (since closest Sunday midnight).
11251138
This is usually how GNSS receivers describe a timestamp."""
@@ -1186,10 +1199,70 @@ Several time scales do _not_ have a reference day that's on a Monday, e.g. BDT."
11861199
def weekday_utc(self) -> Weekday:
11871200
"""Returns weekday in UTC timescale"""
11881201

1202+
def with_hms(self, hours: int, minutes: int, seconds: int) -> Epoch:
1203+
"""Returns a copy of self where the time is set to the provided hours, minutes, seconds
1204+
Invalid number of hours, minutes, and seconds will overflow into their higher unit.
1205+
Warning: this does _not_ set the subdivisions of second to zero."""
1206+
1207+
def with_hms_from(self, other: Epoch) -> Epoch:
1208+
"""Returns a copy of self where the hours, minutes, seconds is set to the time of the provided epoch but the
1209+
sub-second parts are kept from the current epoch.
1210+
1211+
```
1212+
use hifitime::prelude::*;
1213+
1214+
let epoch = Epoch::from_gregorian_utc(2022, 12, 01, 10, 11, 12, 13);
1215+
let other_utc = Epoch::from_gregorian_utc(2024, 12, 01, 20, 21, 22, 23);
1216+
let other = other_utc.to_time_scale(TimeScale::TDB);
1217+
1218+
assert_eq!(
1219+
epoch.with_hms_from(other),
1220+
Epoch::from_gregorian_utc(2022, 12, 01, 20, 21, 22, 13)
1221+
);
1222+
```"""
1223+
1224+
def with_hms_strict(self, hours: int, minutes: int, seconds: int) -> Epoch:
1225+
"""Returns a copy of self where the time is set to the provided hours, minutes, seconds
1226+
Invalid number of hours, minutes, and seconds will overflow into their higher unit.
1227+
Warning: this will set the subdivisions of seconds to zero."""
1228+
1229+
def with_hms_strict_from(self, other: Epoch) -> Epoch:
1230+
"""Returns a copy of self where the time is set to the time of the other epoch but the subseconds are set to zero.
1231+
1232+
```
1233+
use hifitime::prelude::*;
1234+
1235+
let epoch = Epoch::from_gregorian_utc(2022, 12, 01, 10, 11, 12, 13);
1236+
let other_utc = Epoch::from_gregorian_utc(2024, 12, 01, 20, 21, 22, 23);
1237+
let other = other_utc.to_time_scale(TimeScale::TDB);
1238+
1239+
assert_eq!(
1240+
epoch.with_hms_strict_from(other),
1241+
Epoch::from_gregorian_utc(2022, 12, 01, 20, 21, 22, 0)
1242+
);
1243+
```"""
1244+
1245+
def with_time_from(self, other: Epoch) -> Epoch:
1246+
"""Returns a copy of self where all of the time components (hours, minutes, seconds, and sub-seconds) are set to the time of the provided epoch.
1247+
1248+
```
1249+
use hifitime::prelude::*;
1250+
1251+
let epoch = Epoch::from_gregorian_utc(2022, 12, 01, 10, 11, 12, 13);
1252+
let other_utc = Epoch::from_gregorian_utc(2024, 12, 01, 20, 21, 22, 23);
1253+
// If the other Epoch is in another time scale, it does not matter, it will be converted to the correct time scale.
1254+
let other = other_utc.to_time_scale(TimeScale::TDB);
1255+
1256+
assert_eq!(
1257+
epoch.with_time_from(other),
1258+
Epoch::from_gregorian_utc(2022, 12, 01, 20, 21, 22, 23)
1259+
);
1260+
```"""
1261+
11891262
def year(self) -> int:
11901263
"""Returns the number of Gregorian years of this epoch in the current time scale."""
11911264

1192-
def year_days_of_year(self) -> typing.Tuple:
1265+
def year_days_of_year(self) -> tuple:
11931266
"""Returns the year and the days in the year so far (days of year)."""
11941267

11951268
def __add__():
@@ -1268,34 +1341,43 @@ set self.__traceback__ to tb and return self."""
12681341

12691342
@typing.final
12701343
class LatestLeapSeconds:
1271-
"""List of leap seconds from <https://www.ietf.org/timezones/data/leap-seconds.list>.
1344+
"""List of leap seconds from <https://data.iana.org/time-zones/data/leap-seconds.list>.
12721345
This list corresponds the number of seconds in TAI to the UTC offset and to whether it was an announced leap second or not.
12731346
The unannoucned leap seconds come from dat.c in the SOFA library."""
12741347

12751348
def __init__(self) -> None:
1276-
"""List of leap seconds from <https://www.ietf.org/timezones/data/leap-seconds.list>.
1349+
"""List of leap seconds from <https://data.iana.org/time-zones/data/leap-seconds.list>.
12771350
This list corresponds the number of seconds in TAI to the UTC offset and to whether it was an announced leap second or not.
12781351
The unannoucned leap seconds come from dat.c in the SOFA library."""
12791352

1353+
def is_up_to_date(self) -> bool:
1354+
"""Downloads the latest leap second list from IANA, and returns whether the embedded leap seconds are still up to date
1355+
1356+
```
1357+
use hifitime::leap_seconds::LatestLeapSeconds;
1358+
1359+
assert!(LatestLeapSeconds::default().is_up_to_date().unwrap(), "Hifitime needs to update its leap seconds list!");
1360+
```"""
1361+
12801362
def __repr__(self) -> str:
12811363
"""Return repr(self)."""
12821364

12831365
@typing.final
12841366
class LeapSecondsFile:
1285-
"""A leap second provider that uses an IERS formatted leap seconds file.
1367+
"""A leap second provider that uses an IERS formatted leap seconds file."""
12861368

1287-
(Python documentation hints)"""
1288-
1289-
def __init__(self, path: str) -> LeapSecondsFile:
1290-
"""A leap second provider that uses an IERS formatted leap seconds file.
1291-
1292-
(Python documentation hints)"""
1369+
def __init__(self, path: str) -> None:
1370+
"""A leap second provider that uses an IERS formatted leap seconds file."""
12931371

12941372
def __repr__(self) -> str:
12951373
"""Return repr(self)."""
12961374

12971375
@typing.final
12981376
class MonthName:
1377+
"""Defines Month names, can be initialized either from its variant or its integer (1 for January)."""
1378+
1379+
def __init__(self, month: int) -> None:
1380+
"""Defines Month names, can be initialized either from its variant or its integer (1 for January)."""
12991381

13001382
def __eq__(self, value: typing.Any) -> bool:
13011383
"""Return self==value."""
@@ -1463,7 +1545,7 @@ class TimeSeries:
14631545
14641546
(Python documentation hints)"""
14651547

1466-
def __init__(self, start: Epoch, end: Epoch, step: Duration, inclusive: bool) -> TimeSeries:
1548+
def __init__(self, start: Epoch, end: Epoch, step: Duration, inclusive: bool) -> None:
14671549
"""An iterator of a sequence of evenly spaced Epochs.
14681550
14691551
(Python documentation hints)"""

0 commit comments

Comments
 (0)