Skip to content

Commit

Permalink
pre-commit fix
Browse files Browse the repository at this point in the history
  • Loading branch information
daralynnrhode committed Aug 7, 2024
1 parent 6faa261 commit d19224c
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 16 deletions.
4 changes: 3 additions & 1 deletion imap_processing/cdf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ def met_to_j2000ns(
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]")
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

Expand Down
4 changes: 3 additions & 1 deletion imap_processing/codice/codice_l1a.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,9 @@ def process_codice_l1a(file_path: Path, data_version: str) -> xr.Dataset:
apid = CODICEAPID.COD_HI_SECT_SPECIES_COUNTS
table_id, plan_id, plan_step, view_id = (1, 0, 0, 6)

met0: np.timedelta64 = (np.datetime64("2024-04-29T00:00") - IMAP_EPOCH).astype("timedelta64[s]")
met0: np.timedelta64 = (np.datetime64("2024-04-29T00:00") - IMAP_EPOCH).astype(
"timedelta64[s]"
)
met0 = met0.astype(np.int64)
met = [met0, met0 + 1] # Using this to match the other data products
science_values = "" # Currently don't have simulated data for this
Expand Down
2 changes: 1 addition & 1 deletion imap_processing/glows/l1b/glows_l1b_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import dataclasses
import json
from dataclasses import InitVar, dataclass, field
from typing import Optional
from pathlib import Path
from typing import Optional

import numpy as np

Expand Down
4 changes: 2 additions & 2 deletions imap_processing/lo/l0/data_classes/science_direct_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ def _decompress_data(self) -> None:

# Case decoder indicates which parts of the data
# are transmitted for each case.
case_decoder = CASE_DECODER[(case_number, self.MODE[de_idx])] #type: ignore[index]
#Todo Mypy Error: Invalid index type "tuple[int, ndarray[Any, Any]]" for
case_decoder = CASE_DECODER[(case_number, self.MODE[de_idx])] # type: ignore[index]
# Todo Mypy Error: Invalid index type "tuple[int, ndarray[Any, Any]]" for
# "dict[tuple[int, int], TOFFields]"; expected type "tuple[int, int]"

# Check the case decoder to see if the TOF field was
Expand Down
6 changes: 3 additions & 3 deletions imap_processing/mag/l0/mag_l0_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ def __post_init__(self) -> None:
# Convert string output from space_packet_parser to numpy array of
# big-endian bytes
self.VECTORS = np.frombuffer(
int(self.VECTORS, 2).to_bytes(len(self.VECTORS) // 8, "big"), #type: ignore[arg-type]
#MYPY Error: Argument 1 to "int" has incompatible type
#"Union[ndarray[Any, Any], str]"; expected "Union[str, bytes, bytearray]"
int(self.VECTORS, 2).to_bytes(len(self.VECTORS) // 8, "big"), # type: ignore[arg-type]
# MYPY Error: Argument 1 to "int" has incompatible type
# "Union[ndarray[Any, Any], str]"; expected "Union[str, bytes, bytearray]"
dtype=np.dtype(">b"),
)

Expand Down
8 changes: 4 additions & 4 deletions imap_processing/swapi/l1/swapi_l1.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from imap_processing.utils import packet_file_to_datasets


def filter_good_data(full_sweep_sci: xr.Dataset) -> npt.NDArray:
def filter_good_data(full_sweep_sci: xr.Dataset) -> np.ndarray:
"""
Filter out bad data sweep indices.
Expand All @@ -30,7 +30,7 @@ def filter_good_data(full_sweep_sci: xr.Dataset) -> npt.NDArray:
Returns
-------
good_data_indices : np.ndarray
good_data_indices : numpy.ndarray
Good data sweep indices.
"""
# PLAN_ID for current sweep should all be one value and
Expand Down Expand Up @@ -71,7 +71,7 @@ def filter_good_data(full_sweep_sci: xr.Dataset) -> npt.NDArray:

def decompress_count(
count_data: np.ndarray, compression_flag: np.ndarray
) -> npt.NDArray:
) -> np.ndarray:
"""
Will decompress counts based on compression indicators.
Expand Down Expand Up @@ -121,7 +121,7 @@ def decompress_count(
return new_count


def find_sweep_starts(packets: xr.Dataset) -> npt.NDArray:
def find_sweep_starts(packets: xr.Dataset) -> np.ndarray:
"""
Find index of where new cycle started.
Expand Down
8 changes: 6 additions & 2 deletions imap_processing/swe/l1a/swe_science.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def swe_science(decom_data: list, data_version: str) -> xr.Dataset:
science_array = []
raw_science_array = []

metadata_arrays: np.ndarray =np.array(collections.defaultdict(list))
metadata_arrays: np.ndarray = np.array(collections.defaultdict(list))

# We know we can only have 8 bit numbers input, so iterate over all
# possibilities once up front
Expand Down Expand Up @@ -142,7 +142,11 @@ def swe_science(decom_data: list, data_version: str) -> xr.Dataset:
# Save data as np.int64 to be complaint with ISTP' FILLVAL
science_array.append(uncompress_data.astype(np.int64))
raw_science_array.append(raw_counts.astype(np.int64))
metadata_arrays = np.array(add_metadata_to_array(data_packet, dict(enumerate(metadata_arrays.flatten(), 1))))
metadata_arrays = np.array(
add_metadata_to_array(
data_packet, dict(enumerate(metadata_arrays.flatten(), 1))
)
)

# Load CDF attrs
cdf_attrs = ImapCdfAttributes()
Expand Down
2 changes: 1 addition & 1 deletion imap_processing/swe/utils/swe_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Various utility classes and functions to support SWE processing."""

from enum import IntEnum
import numpy as np

import space_packet_parser


Expand Down
1 change: 0 additions & 1 deletion tools/spice/spice_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import logging

import numpy as np
import numpy.typing as npt
import spiceypy as spice

Expand Down

0 comments on commit d19224c

Please sign in to comment.