asp_plot.icesat2_source#
ICESat-2 ATL06-SR altimetry source.
Owns the Earth/ICESat-2 side of asp_plot.altimetry.Altimetry:
requesting ATL06-SR points from SlideRule (with parquet caching), sampling
ESA WorldCover, temporal and outlier filtering, differencing against the ASP
DEM, and selecting the best track / best-worst 1 km segments used by the
profile plots and reproducibility (#121).
The class holds its own data (atl06sr_processing_levels /
atl06sr_processing_levels_filtered and the resolved request time range)
and reads the cross-cutting dem_fn / directory / aligned_dem_fn
from the coordinating Altimetry instance passed at construction.
Attributes#
Exceptions#
SlideRule could not be reached or did not return a result. |
Classes#
Request, cache, filter and difference ICESat-2 ATL06-SR points. |
Functions#
|
Class codes of one or several ESA WorldCover groups. |
Module Contents#
- exception asp_plot.icesat2_source.SlideRuleRequestError#
Bases:
RuntimeErrorSlideRule could not be reached or did not return a result.
Raised for every way an ICESat-2 request can fail on the SlideRule side: the client’s connection check at startup fails,
run()raises, orrun()returnsNone(#212, #214). The message names the request and says that it may succeed if repeated. A request that ran and found no points is not an error. A subclass ofRuntimeError, which was raised for aNoneresult before this class existed.
- class asp_plot.icesat2_source.Icesat2Source(alt, atl06sr_processing_levels=None, atl06sr_processing_levels_filtered=None)#
Bases:
asp_plot.altimetry_source.AltimetrySourceRequest, cache, filter and difference ICESat-2 ATL06-SR points.
- Parameters:
alt (Altimetry) – The coordinating
asp_plot.altimetry.Altimetryinstance. Cross-cutting paths (dem_fn,directory,aligned_dem_fn) are read from it so a single source of truth describes the DEM under analysis.atl06sr_processing_levels (dict, optional) – Pre-loaded ATL06-SR data for different processing levels.
atl06sr_processing_levels_filtered (dict, optional) – Pre-loaded filtered ATL06-SR data.
- atl06sr_to_dem_dh(n_sigma=3)#
Calculate height differences between ATL06-SR data and DEMs.
Interpolates DEM heights at ATL06-SR point locations and calculates the difference between ICESat-2 heights and DEM heights. If an aligned DEM is available, also calculates differences against it. Outliers beyond
n_sigma× standard deviation from the mean are removed by default (viafilter_outliers(), which first drops gross outliers more than 30 NMAD from the median).- Parameters:
n_sigma (float or None, optional) – Remove dh outliers beyond this many standard deviations from the mean. Default 3. Pass None to skip outlier filtering.
- Returns:
Adds columns to the filtered ATL06-SR data: - dem_height: Interpolated height from the original DEM - icesat_minus_dem: Height difference (ICESat-2 - DEM) - aligned_dem_height: Interpolated height from aligned DEM (if available) - icesat_minus_aligned_dem: Height difference with aligned DEM (if available)
- Return type:
None
Notes
This method performs bilinear interpolation of DEM values at ATL06-SR point locations using xarray and rioxarray. It handles coordinate system conversions automatically.
- filter_esa_worldcover(filter_out='water', retain_only=None)#
Filter ATL06-SR data based on ESA WorldCover land cover classes.
Filters the data points based on ESA WorldCover classification, either by removing specific land cover types or retaining only specific types.
- Parameters:
filter_out (str or list of str, optional) – Land cover group, or groups, to filter out, default is “water”. Options: “water”, “snow_ice”, “trees”, “low_vegetation”, “built_up” (
WORLDCOVER_GROUPS).["water", "trees"]is the stable-terrain choice when years separate the imagery from the ICESat-2 passes, since canopy height changes over that time.retain_only (str, list of str or None, optional) – If specified, retain only points matching this land cover group (or these groups), default is None. Same options as
filter_out.
- Returns:
Results are stored in the class attributes
- Return type:
None
Notes
This method uses the ESA WorldCover land cover classification (see
WORLDCOVER_NAMES), which was sampled when requesting the ATL06-SR data. A name that is not a group is reported and skipped; when no name is a group, nothing is filtered.
- filter_outliers(column='icesat_minus_dem', n_sigma=3)#
Remove dh outliers beyond n_sigma × standard deviation from the mean.
Gross outliers — more than
GROSS_OUTLIER_NMAD(30) normalized median absolute deviations from the median, e.g. a cloud-contaminated ICESat-2 pass — are dropped first, so that a large cluster of them cannot inflate the standard deviation and defeat the cut.
- generic_temporal_filter_atl06sr(select_years=None, select_months=None, select_days=None)#
Apply custom temporal filters to ATL06-SR data.
Filters the data based on specific years, months, or days, allowing for custom temporal filtering not covered by the predefined filters.
- Parameters:
- Returns:
Results are filtered in-place in the class attributes
- Return type:
None
Notes
This method modifies the existing filtered data rather than creating new entries with different keys. At least one of the filter parameters should be provided for the method to have any effect.
- get_altimetry_selections(key='all')#
Report the ICESat-2 selections a run made, for reproducibility (#121).
Bundles the request settings, the parquet cache locations (the exact points used), the auto-selected profile track, and the best/worst segment extents so they can be written to a figure-selections file and replayed on a later run.
- Parameters:
key (str, optional) – Processing level key, default is “all”.
- Returns:
{"request": {..}, "parquet_cache": {key: path}, "profile_track": {"rgt", "cycle", "spot"}, "segments": {"best": {..}, "worst": {..}}}. Keys are omitted when the corresponding selection is unavailable.- Return type:
- load_atl06sr_from_parquet(parquet_paths, h_sigma_quantile=1.0)#
Load ATL06-SR points directly from saved parquet caches.
Replays the exact points a prior run used (issue #121), bypassing the SlideRule request entirely so a re-processed scene compares against an identical ICESat-2 sample. Runs the same normalization + quality filter as a fresh request via
_ingest_atl06sr.- Parameters:
- Returns:
True if at least one parquet was loaded, False otherwise.
- Return type:
- predefined_temporal_filter_atl06sr(date=None)#
Apply predefined temporal filters to ATL06-SR data.
Creates multiple temporally filtered versions of the ATL06-SR data based on a reference date, including: - 15-day window around the date - 45-day window around the date - 91-day window around the date - Seasonal filter (same season as the reference date)
- Parameters:
date (datetime or None, optional) – Reference date for filtering. If None, extracts date from stereopair metadata, default is None
- Returns:
Results are stored in the class attributes with new keys indicating the temporal filter applied
- Return type:
None
Notes
This method is particularly useful for DEM validation and alignment, as it provides multiple temporal windows to analyze the stability of the terrain and to identify optimal temporal windows for alignment.
- request_atl06sr_multi_processing(processing_levels=['all', 'ground', 'canopy', 'top_of_canopy'], res=20, len=40, ats=20, cnt=10, maxi=6, h_sigma_quantile=1.0, save_to_parquet=False, filename='atl06sr', region=None, time_range='all', scene_date=None, time_buffer_days=365, t0=None, t1=None, geoloc_corr=None)#
Request ICESat-2 ATL06-SR data for multiple processing levels.
Downloads ATL06-SR data from the SlideRule API for specified processing levels (surface types), with options to filter and save the results. Each processing level targets different surface types like ground, canopy, etc.
- Parameters:
processing_levels (list, optional) – List of processing levels to request, default is [“all”, “ground”, “canopy”, “top_of_canopy”]
res (int, optional) – ATL06-SR segment resolution in meters, default is 20
len (int, optional) – ATL06-SR segment length in meters, default is 40
ats (int, optional) – Along-track sigma, default is 20
cnt (int, optional) – Minimum number of photons for segment, default is 10
maxi (int, optional) – Maximum iterations for surface fit, default is 6
h_sigma_quantile (float, optional) – Quantile for filtering by h_sigma, default is 1.0
save_to_parquet (bool, optional) – Whether to save results to parquet files, default is False
filename (str, optional) – Base filename for saved data, default is “atl06sr”
region (list or None, optional) – Region bounds as [minx, miny, maxx, maxy] in lat/lon, default is None (derived from DEM)
time_range (str, optional) –
"all"(default) requests all ICESat-2 data from mission start to present."buffered"activates time filtering via the cascade:t0/t1>scene_date±time_buffer_days> XML metadata ±time_buffer_days> fall back to all.scene_date (str or datetime-like, optional) – Scene acquisition date, used when
time_range="buffered". If None, auto-detected from stereopair XML metadata.time_buffer_days (int, optional) – Days before/after scene_date defining the time window, default is 365
t0 (str or datetime-like, optional) – Explicit start date (e.g. “2020-01-01”), used when
time_range="buffered". Overridesscene_date.t1 (str or datetime-like, optional) – Explicit end date (e.g. “2024-12-31”). Defaults to present if only
t0is provided.geoloc_corr (str or None, optional) – ATL03 geolocation correction for SlideRule to apply to the photons before the fit, default is None (no correction).
"conus"applies one north/east/up shift per granule and beam, covering the continental US. Photons on a beam with no correction entry are dropped, so the corrected request returns fewer points, and none outside the continental US. The setting is part of the request recorded in the parquet cache, so a corrected and an uncorrected request do not reuse each other’s cache.
- Returns:
Results are stored in the class attributes
- Return type:
None
- Raises:
ValueError – If
geoloc_corris not None or one ofGEOLOC_CORRECTIONS.SlideRuleRequestError – If a level is not cached and SlideRule cannot be reached, the request fails, or it returns nothing.
Notes
This method makes SlideRule API calls which require internet connectivity. It also samples ESA WorldCover data for land cover classification of the ICESat-2 data points. The method includes filtering to improve data quality by removing points with high uncertainty and from early mission cycles.
- sample_esa_worldcover()#
Sample ESA WorldCover 10m values into every filtered processing level that doesn’t already have them.
Normally not needed when data is requested via
request_atl06sr_multi_processing, which samples WorldCover automatically before caching. Use this when working with manually-loaded data.
- sample_slope(slope_dem=None, scale=SLOPE_SCALE_M)#
Sample terrain slope into every filtered processing level.
Adds a
slope_degcolumn (SLOPE_COLUMN) fromasp_plot.terrain.slope_at_points(), and records the DEM and scale used inslope_dem_fnandslope_scale.- Parameters:
slope_dem (str, optional) – DEM to take slope from, such as the reference DEM of the stereo run. Default None: the DEM being validated. A DEM independent of the one validated is the better choice, since the validated DEM’s own errors raise its slope where they are large.
scale (float or None, optional) – Length scale of the slope in meters, default
asp_plot.terrain.SLOPE_SCALE_M(30 m, about one ATL06-SR segment). A finer DEM is averaged to it first, so a 1 m DSM gives terrain slope and not the slope of roofs and canopy edges. None uses the DEM’s own resolution.
- to_csv_for_pc_align(key='ground', filename_prefix='atl06sr_for_pc_align')#
Export ATL06-SR data to CSV format for use with pc_align.
Creates a CSV file from the filtered ATL06-SR data that is formatted for use with the ASP pc_align tool, containing longitude, latitude, and height above datum.
- Parameters:
- Returns:
Path to the created CSV file
- Return type:
Notes
The ASP pc_align tool requires input data in a specific format. This method converts the ATL06-SR GeoDataFrame to the required CSV format with columns for longitude, latitude, and height.
- atl06sr_processing_levels#
- atl06sr_processing_levels_filtered#
- slope_dem_fn = None#
- slope_scale = None#
- asp_plot.icesat2_source.worldcover_group_values(groups)#
Class codes of one or several ESA WorldCover groups.
- asp_plot.icesat2_source.GEOLOC_CORRECTIONS = ('conus',)#
- asp_plot.icesat2_source.ICESAT2_BLOCK_COLUMNS = ('rgt', 'cycle', 'spot')#
- asp_plot.icesat2_source.ICESAT2_MISSION_START#
- asp_plot.icesat2_source.MAX_GRANULES_LISTED = 10000#
- asp_plot.icesat2_source.MAX_GRANULES_PER_REQUEST = 250#
- asp_plot.icesat2_source.WORLDCOVER_GROUPS#
- asp_plot.icesat2_source.logger#