I've been making high-res Natural Color images for the eastern Caribbean based on some code provided by @aschueth is Discussion #60 , and even my laptop with 32 GB memory was struggling handling all the full disk data files, particularly at the plotting stage. I had lots of memory based exceptions. I'm offering up a sketch of some subsetting code I wrote which I think will be a good starting point for a new function or method. This should address Discussion #130.
An issue I encountered along the way was the loss of projection/transform information in the .RGB.imshow object with the subsetting so that's thrown in with the function below.
from goes2go.tools import lat_lon_to_scan_angles
def subset_goes_by_latlon(ds: GOES, lon_min: float, lon_max: float, lat_min: float, lat_max: float) -> GOES:
"""
Subset a GOES ABI dataset by latitude/longitude bounds.
Works for full-disk (CMIPF), CONUS (CMIPC), and mesoscale (CMIPM) products.
"""
import
## Get projection info from the dataset
proj_info = ds.goes_imager_projection
# Convert each corner of the lat/lon bounding box to scan angles
x_min, y_min = lat_lon_to_scan_angles(lat_min, lon_min, proj_info)
x_max, y_max = lat_lon_to_scan_angles(lat_max, lon_max, proj_info)
# Ensure bounds are in correct order (important if input is flipped)
x0, x1 = sorted([x_min, x_max])
y0, y1 = sorted([y_min, y_max])
# Subset using .where with drop=True
subset = ds.where(
(ds['x'] >= x0) & (ds['x'] <= x1) &
(ds['y'] >= y0) & (ds['y'] <= y1),
drop=True
)
# rebuild imshow transform
subset.rgb.imshow_kwargs['transform'] = ds.FOV.crs
return subset
I'll note that I'm working with a novice level of understanding of GOES2GO, xarray, and the resulting data structures, otherwise I'd write some code and make a PR.
I've been making high-res Natural Color images for the eastern Caribbean based on some code provided by @aschueth is Discussion #60 , and even my laptop with 32 GB memory was struggling handling all the full disk data files, particularly at the plotting stage. I had lots of memory based exceptions. I'm offering up a sketch of some subsetting code I wrote which I think will be a good starting point for a new function or method. This should address Discussion #130.
An issue I encountered along the way was the loss of projection/transform information in the
.RGB.imshowobject with the subsetting so that's thrown in with the function below.I'll note that I'm working with a novice level of understanding of GOES2GO, xarray, and the resulting data structures, otherwise I'd write some code and make a PR.