cryoswath.l1b module
cryoswath.l1b module
It mainly contains the L1bData class, that allows to process ESA CryoSat-2 SARIn L1b data to point elevation estimate (L2 data).
- cryoswath.l1b.append_exclude_mask(cs_l1b_ds: Dataset) Dataset[source]
Adds mask indicating samples below threshold.
Waveform samples that don’t fulfill power and/or coherence requirements are flagged. The thresholds have to be included in the provided dataset. By default, they are assigned on creation.
- Parameters:
cs_l1b_ds (l1b_data) – Input data.
- Returns:
Data including mask.
- Return type:
l1b_data
- cryoswath.l1b.append_poca_and_swath_idxs(cs_l1b_ds: Dataset) Dataset[source]
Adds indices for estimated POCA and begin of swath.
- Parameters:
cs_l1b_ds (l1b_data) – Input data.
- Returns:
Data including mask.
- Return type:
l1b_data
- cryoswath.l1b.build_flag_mask(cs_l1b_flag: DataArray, flag_val_list: list) DataArray[source]
Function returns a waveform mask based on flag values.
This function can handle two types of flags: those that take the form of a checklist with multiple allowed ticks, and those that indicate one of more possible selections.
It is designed for CryoSat-2 SARIn L1b Baseline D or E data and relies on an attribute “flag_masks” or “flag_values”. For CRISTAL or if the attributes change, this function needs an update.
- Parameters:
cs_l1b_flag (xr.DataArray) – L1bData flag variable.
flag_val_list (list, optional) – List of flag values to mask.
- Returns:
Mask that is True where flag matched provided list.
- Return type:
xr.DataArray
- cryoswath.l1b.download_wrapper(region_of_interest: str | Polygon = None, start_datetime: str | Timestamp = '2010', end_datetime: str | Timestamp = '2035', *, buffer_region_by: float = None, track_idx: DatetimeIndex | str = None, stop_event: Event = None, n_threads: int = 8) int[source]
Download ESA’s L1b product.
- Parameters:
region_of_interest (str | shapely.Polygon, optional) – Provide a RGI identifier or lon/lat polygon to subset downloaded data. Defaults to None.
start_datetime (str | pd.Timestamp, optional) – Defaults to “2010”.
end_datetime (str | pd.Timestamp, optional) – Defaults to “2035”.
buffer_region_by (float, optional) – Use a buffer in meter around provided region (also RGI identifier). Defaults to None.
track_idx (pd.DatetimeIndex | str, optional) – Download only tracks at known times. Defaults to None.
stop_event (Event, optional) – Define when to terminate threads. Defaults to None.
n_threads (int, optional) – Number of download threads. Defaults to 8.
- Returns:
0 on success, 1 on graceful exit after error, and 2 on being aborted.
- Return type:
int
- cryoswath.l1b.drop_waveform(cs_l1b_ds, time_20_ku_mask)[source]
Use mask along time dim to drop waveforms.
- Parameters:
time_20_ku_mask (1-dim bool) – Mask: drop where True.
- Returns:
Input dataset without marked waveforms.
- Return type:
xr.Dataset or DataArray
- cryoswath.l1b.get_rgi_o2(ds) str[source]
Finds RGIv7 o2 region that contains the track’s central lat, lon.
- Returns:
RGI v7 long_code
- Return type:
str
- cryoswath.l1b.noise_val(vec: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]) float[source]
calculate average noise values for waveform
- Parameters:
vec (ArrayLike) – First few (well more than 30) samples of power waveform.
- Returns:
Noise power
- Return type:
float
- cryoswath.l1b.read_esa_l1b(l1b_filename: str, *, waveform_selection: int | Timestamp | list[int | Timestamp] | slice = None, drop_waveforms_by_flag: dict[str, list] = {'flag_mcd_20_ku': ['block_degraded', 'blank_block', 'datation_degraded', 'orbit_prop_error', 'echo_saturated', 'other_echo_error', 'sarin_rx1_error', 'sarin_rx2_error', 'window_delay_error', 'agc_error', 'trk_echo_error', 'echo_rx1_error', 'echo_rx2_error', 'npm_error', 'power_scale_error']}, mask_coherence_gt1: bool = True, drop_outside: float = 30000, coherence_threshold: float = 0.6, power_threshold: tuple = ('snr', 10), smooth_phase_difference: bool = True, use_original_noise_estimates: bool = False, dem_file_name_or_path: str = None) None[source]
Loads ESA SARIn L1b and does initial processing
- Args to init:
l1b_filename (str): File to read data from.
- waveform_selection (int | pd.Timestamp | list[int |
pd.Timestamp] | slice, optional): Waveforms to retrieve data from. If none provided, retrieve all data. Defaults to None.
- drop_waveforms_by_flag (dict[str, list], optional):
Exclude waveform based on flags. Defaults to {“flag_mcd_20_ku”, [ ‘block_degraded’, ‘blank_block’, ‘datation_degraded’, ‘orbit_prop_error’, ‘echo_saturated’, ‘other_echo_error’, ‘sarin_rx1_error’, ‘sarin_rx2_error’, ‘window_delay_error’, ‘agc_error’, ‘trk_echo_error’, ‘echo_rx1_error’, ‘echo_rx2_error’, ‘npm_error’, ‘power_scale_error’]}.
mask_coherence_gt1 (bool, optional): Defaults to True.
- drop_outside (float, optional): Exclude waveforms where nadir is
a chosen distance in meters outside of any RGI glacier. If None, no waveforms are excluded. Defaults to 30_000.
- coherence_threshold (float, optional): Exclude waveform samples
with a lower coherence. This choice also affects the grouping, start sample for swath processing per waveform, and the POCA retrieval. Defaults to 0.6.
- power_threshold (tuple, optional): Similar to the coherence
threshold, but does not affect swath start or POCA retrieval. Defaults to (“snr”, 10).