Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/remove time dependency #312

Merged
merged 6 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
### Deprecated
### Removed
- Remove the time dependency when subsetting.
### Fixed
- Updated xarray enhancement get_indexers_from_nd function for SMAP_RSS_L2_SSS_V6.
- Fix minor bug in checking for empty indexers and same data bounds.
Expand Down
9 changes: 4 additions & 5 deletions podaac/subsetter/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,11 +560,7 @@ def compute_time_variable_name(dataset: xr.Dataset, lat_var: xr.Variable, total_
if var_name not in total_time_vars and 'time' in var_name_time.lower() and dataset[var_name].squeeze().dims[0] in lat_var.squeeze().dims:
return var_name

# OB.DAAC data does not have a time variable. Returning the following field of a composite time value to avoid exceptions.
if '__scan_line_attributes__day' in dataset.data_vars:
return '__scan_line_attributes__day'

raise ValueError('Unable to determine time variable')
return None


def compute_utc_name(dataset: xr.Dataset) -> Union[str, None]:
Expand Down Expand Up @@ -1296,6 +1292,9 @@ def subset(file_to_subset: str, bbox: np.ndarray, output_file: str,
time_var_names=time_var_names
)

if not time_var_names and (min_time or max_time):
raise ValueError('Could not determine time variable')

start_date = None
if hdf_type and (min_time or max_time):
dataset, start_date = tc.convert_to_datetime(dataset, time_var_names, hdf_type)
Expand Down
18 changes: 15 additions & 3 deletions podaac/subsetter/subset_harmony.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from tempfile import mkdtemp
import traceback
from typing import List, Union
import sys

import pystac
from pystac import Asset
Expand All @@ -41,9 +42,16 @@


class L2SSException(HarmonyException):
"""Base class for exceptions in the Harmony GDAL Adapter."""

"""L2SS Exception class for custom error messages to see in harmony api calls."""
def __init__(self, original_exception):
# Ensure we can extract traceback information
if original_exception.__traceback__ is None:
# Capture the current traceback if not already present
try:
raise original_exception
except type(original_exception):
original_exception.__traceback__ = sys.exc_info()[2]

# Extract the last traceback entry (most recent call) for the error location
tb = traceback.extract_tb(original_exception.__traceback__)[-1]

Expand All @@ -57,7 +65,11 @@ def __init__(self, original_exception):
readable_message = (f"Error in file '{filename}', line {lineno}, in function '{funcname}': "
f"{error_msg}")

super().__init__(readable_message, 'nasa/harmony-gdal-adapter')
# Call the parent class constructor with the formatted message and category
super().__init__(readable_message, 'podaac/l2-subsetter')

# Store the original exception for potential further investigation
self.original_exception = original_exception


def podaac_to_harmony_bbox(bbox: np.ndarray) -> Union[np.ndarray, float]:
Expand Down
Loading
Loading