diff --git a/CrocoDash/raw_data_access/datasets/glorys.py b/CrocoDash/raw_data_access/datasets/glorys.py index 719693ee..ace5ed10 100644 --- a/CrocoDash/raw_data_access/datasets/glorys.py +++ b/CrocoDash/raw_data_access/datasets/glorys.py @@ -12,6 +12,7 @@ import pandas as pd from .utils import convert_lons_to_180_range from CrocoDash.raw_data_access.base import * +from mom6_forge.utils import longitude_slicer class GLORYS(ForcingProduct): @@ -75,9 +76,6 @@ def get_glorys_data_from_rda( ds_in_files = [] date_strings = [date.strftime("%Y%m%d") for date in dates] - # Adjust lat lon inputs to make sure they are in the correct range of -180 to 180 - lon_min, lon_max = convert_lons_to_180_range(lon_min, lon_max) - for date in date_strings: pattern = os.path.join(ds_in_path, "**", f"*_{date}_*.nc") ds_in_files.extend(glob.glob(pattern, recursive=True)) @@ -87,30 +85,11 @@ def get_glorys_data_from_rda( ds_in_files, decode_times=False, engine="h5netcdf", parallel=True )[variables] - if lon_min * lon_max > 0: - dataset = ds.sel( - latitude=slice(lat_min - 1, lat_max + 1), - longitude=slice(lon_min - 1, lon_max + 1), - ) - else: - dataset = xr.concat( - [ - ds.sel( - latitude=slice(lat_min - 1, lat_max + 1), - **{"longitude": slice(lon_min - 1, 360)}, - ), - ds.sel( - latitude=slice(lat_min - 1, lat_max + 1), - **{"longitude": slice(-180, lon_max + 1)}, - ), - ], - dim="longitude", - ) - - # convert longitude from degree west to degree east - dataset["longitude"] = (360 - dataset["longitude"]) % 360 - dataset = dataset.sortby("longitude") + buf = 1.0 # buffer in degrees to ensure we have enough data for interpolation at the boundaries + dataset = longitude_slicer( + ds, [lon_min - buf, lon_max + buf], longitude_coords="longitude" + ) dataset.to_netcdf(path) return path diff --git a/CrocoDash/visualCaseGen b/CrocoDash/visualCaseGen index e71f479a..0ac0cac3 160000 --- a/CrocoDash/visualCaseGen +++ b/CrocoDash/visualCaseGen @@ -1 +1 @@ -Subproject commit e71f479a9827bdf5c94c458c46f5928251085aeb +Subproject commit 0ac0cac38bd4e29a7f7e77dac18f034d2f4aa5bf