cryoswath.l2 module#
Convert processed CryoSat L1b data to L2 point-elevation products.
- cryoswath.l2.from_id(track_idx, *, reprocess=True, save_or_return='both', cache_fullname=None, cores=None, **kwargs)[source]#
Processes CryoSat-2 L1b data into L2 data for specified tracks.
- Parameters:
track_idx (pd.DatetimeIndex | str) – A datetime index or identifier representing the tracks to process.
reprocess (bool | pd.Timestamp, optional) – Determines whether to reprocess existing data. If True, all data will be reprocessed. If False, existing cached data will be reused. If a timestamp is provided, only data older than the timestamp will be reprocessed. Default is True.
save_or_return (str, optional) – Specifies the output behavior. “save”: Saves the processed data to disk. “return”: Returns the processed data as GeoDataFrames. “both”: Saves the data and returns them. Default is “both”.
cache_fullname (str, optional) – Path to the cache file for storing processed data. If provided, data will be cached for rasterization with
cryoswath.l3.build_dataset().cores (int, optional) – Number of CPU cores to use for parallel processing. If not specified, the number of available cores will be detected automatically.
**kwargs – Additional keyword arguments passed to processing functions.
- Returns:
A tuple containing two GeoDataFrames with swath data and POCA data. If save_or_return is set to “save”, this function returns None.
- Return type:
tuple[gpd.GeoDataFrame]
Notes
If CRS is not provided, it will be determined per track.
To avoid issues with ESA FTP connection limits, consider downloading L1b data in advance or reducing the number of cores.
Cached data is managed per month. If reprocessing is disabled, months with cached data will be skipped.
Warning
Combining new and old data with different settings leads to inconsistent datasets.
- cryoswath.l2.from_processed_l1b(l1b_data=None, max_elev_diff=None, **gdf_kwargs)[source]#
Converts processed CryoSat-2 L1b data into a GeoDataFrame.
- Parameters:
l1b_data (xr.Dataset, optional) – The input L1b dataset to process. Defaults to None.
max_elev_diff (float, optional) – Maximum allowable elevation difference from reference. Rows exceeding this limit are excluded. Defaults to None.
**gdf_kwargs – Additional keyword arguments for GeoDataFrame creation, such as CRS.
- Returns:
A GeoDataFrame containing the processed L2 data with geometry points derived from either lat/lon or x/y coordinates.
- Return type:
gpd.GeoDataFrame
Notes
The CRS of the resulting GeoDataFrame is determined by the input dataset or overridden via gdf_kwargs.
- cryoswath.l2.grid(l2_data, spatial_res_meter, aggregation_function)[source]#
Aggregates L2 data into a spatial grid based on a specified resolution.
- Parameters:
l2_data (gpd.GeoDataFrame) – The input GeoDataFrame containing L2 data with geometry points.
spatial_res_meter (float) – The spatial resolution of the grid in meters.
aggregation_function (callable) – A function to aggregate data within each grid cell (e.g., np.mean).
- Returns:
A DataFrame containing aggregated data for each grid cell. The index includes the x and y coordinates of the grid cell and time.
- Return type:
pd.DataFrame
- cryoswath.l2.limit_filter(data, column, limit)[source]#
Filter rows where
abs(data[column])exceedslimit.- Parameters:
data (DataFrame)
column (str)
limit (float)
- Return type:
DataFrame
- cryoswath.l2.process_and_save(region_of_interest, start_datetime, end_datetime, *, buffer_region_by=10000, **kwargs)[source]#
Processes CryoSat-2 L1b data to L2 data for a specified region and time range.
This function identifies CryoSat-2 tracks within the region and time range, processes the corresponding L1b data into L2 data, and saves the results.
- Parameters:
region_of_interest (str | shapely.Polygon) – The region to process, specified as a RGI region id or a Shapely Polygon.
start_datetime (str | pd.Timestamp) – The start of the time range for processing.
end_datetime (str | pd.Timestamp) – The end of the time range for processing.
buffer_region_by (float, optional) – Buffer distance (in meters) to expand the region of interest. Default is 10,000 meters.
**kwargs – Additional keyword arguments passed to the from_id function.
- Returns:
Returns 0 upon successful processing and saving of L2 data.
- Return type:
int