Skip to content

Commit

Permalink
changes for greg
Browse files Browse the repository at this point in the history
  • Loading branch information
daralynnrhode committed Aug 8, 2024
1 parent 2e6a39b commit cdddef4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
15 changes: 6 additions & 9 deletions imap_processing/cdf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import logging
import re
from pathlib import Path
from typing import Optional

import imap_data_access
import numpy as np
Expand All @@ -25,8 +24,8 @@

def met_to_j2000ns(
met: np.typing.ArrayLike,
reference_epoch: Optional[np.datetime64] = IMAP_EPOCH,
) -> np.typing.ArrayLike:
reference_epoch: np.datetime64 = IMAP_EPOCH,
) -> np.typing.NDArray[np.int64]:
"""
Convert mission elapsed time (MET) to nanoseconds from J2000.
Expand Down Expand Up @@ -56,12 +55,10 @@ def met_to_j2000ns(
# to 32bit and overflow due to the nanosecond multiplication
time_array = (np.asarray(met, dtype=float) * 1e9).astype(np.int64)
# Calculate the time difference between our reference system and J2000
if isinstance(reference_epoch, np.datetime64):
place_holder: np.timedelta64 = (reference_epoch - J2000_EPOCH).astype(
"timedelta64[ns]"
)
j2000_offset: np.int64 = place_holder.astype(np.int64)
return j2000_offset + time_array
j2000_offset: np.typing.NDArray[np.datetime64] = (
reference_epoch - J2000_EPOCH
).astype("datetime64[ns]")
return j2000_offset.astype(np.int64) + time_array


def load_cdf(
Expand Down
6 changes: 2 additions & 4 deletions imap_processing/swapi/l1/swapi_l1.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ def find_sweep_starts(packets: xr.Dataset) -> npt.NDArray:
Array of indices of start cycle.
"""
if packets["epoch"].size < 12:
indices_start = np.array([], np.int64)
return indices_start
return np.array([], np.int64)

# calculate time difference between consecutive sweep
diff = packets["epoch"].data[1:] - packets["epoch"].data[:-1]
Expand Down Expand Up @@ -174,8 +173,7 @@ def find_sweep_starts(packets: xr.Dataset) -> npt.NDArray:
& ione[9:-1]
& ione[10:]
)
indices = np.where(valid)[0]
return indices
return np.where(valid)[0]


def get_indices_of_full_sweep(packets: xr.Dataset) -> npt.NDArray:
Expand Down

0 comments on commit cdddef4

Please sign in to comment.