API reference
earthcarekit.read
Reading utilities for EarthCARE product data.
FileAgency
Bases: FileInfoEnum
Source code in earthcarekit/utils/read/product/file_info/agency.py
from_input
classmethod
Infers the EarthCARE product agency (i.e. ESA or JAXA) from a given file or dataset.
Source code in earthcarekit/utils/read/product/file_info/agency.py
FileLatency
Bases: FileInfoEnum
Source code in earthcarekit/utils/read/product/file_info/latency.py
from_input
classmethod
Infers the EarthCARE product latency indicator (i.e. N for Near-real time, O for Offline, X for not applicable) from a given name, file or dataset.
Source code in earthcarekit/utils/read/product/file_info/latency.py
FileType
Bases: FileInfoEnum
Source code in earthcarekit/utils/read/product/file_info/type.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
from_input
classmethod
Infers the EarthCARE product type from a given file or dataset.
Source code in earthcarekit/utils/read/product/file_info/type.py
ProductInfo
dataclass
Class storing all info gathered from a EarthCARE product's file path.
Source code in earthcarekit/utils/read/product/file_info/product_info.py
add_depol_ratio
add_depol_ratio(
ds_anom,
rolling_w=20,
near_zero_tolerance=2e-07,
smooth=True,
skip_height_above_elevation=300,
depol_ratio_var="depol_ratio",
cpol_cleaned_var="cpol_cleaned_for_depol_calculation",
xpol_cleaned_var="xpol_cleaned_for_depol_calculation",
depol_ratio_from_means_var="depol_ratio_from_means",
cpol_var="mie_attenuated_backscatter",
xpol_var="crosspolar_attenuated_backscatter",
elevation_var=ELEVATION_VAR,
height_var=HEIGHT_VAR,
height_dim=VERTICAL_DIM,
)
Compute depolarization ratio (DPOL = XPOL/CPOL) from attenuated backscatter signals.
This function derives the depolarization ratio from cross-polarized (XPOL) and
co-polarized (CPOL) attenuated backscatter signals. Signals below the surface
are masked, by default with a vertical margin on 300 meters above elevation to remove
potencial surface retrun. Also, signals are smoothed (or "cleaned") with a rolling mean,
and near-zero divisions are suppressed. Cleaned CPOL and XPOL signals are stored alongside DPOL,
and a secondary single depol. profile calculated from mean profiles is added (i.e., mean(XPOL)/mean(CPOL)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds_anom
|
Dataset
|
ATL_NOM_1B dataset containing cross- and co-polar attenuated backscatter. |
required |
rolling_w
|
int
|
Window size for rolling mean smoothing. Defaults to 20. |
20
|
near_zero_tolerance
|
float
|
Tolerance for masking near-zero |
2e-07
|
smooth
|
bool
|
Whether to apply rolling mean smoothing. Defaults to True. |
True
|
skip_height_above_elevation
|
int
|
Vertical margin above surface elevation to mask in meters. Defaults to 300. |
300
|
depol_ratio_var
|
str
|
Name for depol. ratio variable. Defaults to "depol_ratio". |
'depol_ratio'
|
cpol_cleaned_var
|
str
|
Name for cleaned co-polar variable. Defaults to "cpol_cleaned_for_depol_calculation". |
'cpol_cleaned_for_depol_calculation'
|
xpol_cleaned_var
|
str
|
Name for cleaned cross-polar variable. Defaults to "xpol_cleaned_for_depol_calculation". |
'xpol_cleaned_for_depol_calculation'
|
depol_ratio_from_means_var
|
str
|
Name for ratio from mean profiles. Defaults to "depol_ratio_from_means". |
'depol_ratio_from_means'
|
cpol_var
|
str
|
Input co-polar variable name. Defaults to "mie_attenuated_backscatter". |
'mie_attenuated_backscatter'
|
xpol_var
|
str
|
Input cross-polar variable name. Defaults to "crosspolar_attenuated_backscatter". |
'crosspolar_attenuated_backscatter'
|
elevation_var
|
str
|
Elevation variable name. Defaults to ELEVATION_VAR. |
ELEVATION_VAR
|
height_var
|
str
|
Height variable name. Defaults to HEIGHT_VAR. |
HEIGHT_VAR
|
height_dim
|
str
|
Height dimension name. Defaults to VERTICAL_DIM. |
VERTICAL_DIM
|
Returns:
| Type | Description |
|---|---|
Dataset
|
xr.Dataset: Dataset with added depol. ratio, cleaned |
Source code in earthcarekit/utils/read/product/level1/atl_nom_1b.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
get_product_info
Gather all info contained in the EarthCARE product's file path.
Source code in earthcarekit/utils/read/product/file_info/product_info.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
get_product_infos
Extracts product metadata from EarthCARE product file paths (e.g. file_type, orbit_number, frame_id, baseline, ...).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepaths
|
str | list[str] | NDArray | DataFrame | Dataset
|
Input sources for EarthCARE product files. Can be one of
- |
required |
**kwargs
|
Additional arguments passed to |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
ProductDataFrame |
ProductDataFrame
|
A dataframe containing extracted product information. |
Source code in earthcarekit/utils/read/product/file_info/product_info.py
read_any
Reads various input types and returns an xarray.Dataset.
This function can read
- EarthCARE product files (
.h5) - NetCDF files (
.nc) - Manually processed PollyXT output files (
.txt)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
str | Dataset
|
File path or existing Dataset. |
required |
**kwargs
|
Additional keyword arguments for specific readers. |
{}
|
Returns:
| Type | Description |
|---|---|
Dataset
|
xr.Dataset: Opened dataset. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the file type is not supported. |
TypeError
|
If the input type is invalid. |
Source code in earthcarekit/utils/read/_read_any.py
read_header_data
Opens the product header groups of a EarthCARE file as a xarray.Dataset.
Source code in earthcarekit/utils/read/product/header_group.py
read_nc
Returns an xarray.Dataset from a Dataset or NetCDF file path, optionally loaded into memory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
Dataset or str
|
Path to a NetCDF file. If a already opened |
required |
modify
|
bool
|
If True, default modifications to the opened dataset will be applied (e.g., converting heights in Polly data from height a.g.l. to height above mean sea level). |
True
|
in_memory
|
bool
|
If True, ensures the dataset is fully loaded into memory. Defaults to False. |
False
|
**kwargs
|
Key-word arguments passed to |
{}
|
Returns:
| Type | Description |
|---|---|
Dataset
|
xarray.Dataset: The resulting dataset. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If input is not a Dataset or string. |
Source code in earthcarekit/utils/read/_read_nc.py
read_polly
Reads manually processed PollyXT output text files as xarray.Dataset or returns an already open one.
Source code in earthcarekit/utils/read/_read_polly.py
read_product
read_product(
input,
trim_to_frame=True,
modify=DEFAULT_READ_EC_PRODUCT_MODIFY,
header=DEFAULT_READ_EC_PRODUCT_HEADER,
meta=DEFAULT_READ_EC_PRODUCT_META,
in_memory=False,
**kwargs
)
Returns an xarray.Dataset from a Dataset or EarthCARE file path, optionally loaded into memory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
str or Dataset
|
Path to a EarthCARE file. If a |
required |
trim_to_frame
|
bool
|
Whether to trim the dataset to latitude frame bounds. Defaults to True. |
True
|
modify
|
bool
|
If True, default modifications to the opened dataset will be applied (e.g., renaming dimension corresponding to height to "vertical"). Defaults to True. |
DEFAULT_READ_EC_PRODUCT_MODIFY
|
header
|
bool
|
If True, all header data will be included in the dataframe. Defaults to False. |
DEFAULT_READ_EC_PRODUCT_HEADER
|
meta
|
bool
|
If True, select meta data from header (like orbit number and frame ID) will be included in the dataframe. Defaults to True. |
DEFAULT_READ_EC_PRODUCT_META
|
in_memory
|
bool
|
If True, ensures the dataset is fully loaded into memory. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
Dataset
|
xarray.Dataset: The resulting dataset. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If input is not a Dataset or string. |
Source code in earthcarekit/utils/read/product/_generic.py
read_products
read_products(
filepaths,
zoom_at=None,
along_track_dim=ALONG_TRACK_DIM,
func=None,
func_inputs=None,
max_num_files=8,
coarsen=True,
)
Read and concatenate a sequence of EarthCARE frames into a single xarray Dataset.
By default, the dataset is coarsened according to the number of input frames (e.g.,
combining 3 products averages every 3 profiles, so the along-track dimension remains
comparable to a single product). Optionally applies a processing function to each
frame and zooms in on a specific region (defined by zoom_at) without coarsening.
Coarsening can also be turned of but might case memory issues.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepaths
|
Sequence[str] or DataFrame
|
EarthCARE product file paths as a list or a DataFrame with metadata
including |
required |
zoom_at
|
float
|
If set, selects only a zoomed-in portion of the frames around this fractional index. Defaults to None. |
None
|
along_track_dim
|
str
|
Name of the dimension to concatenate along. Defaults to ALONG_TRACK_DIM. |
ALONG_TRACK_DIM
|
func
|
Callable
|
Function to apply to each frame after loading. Defaults to None. |
None
|
func_inputs
|
Sequence[dict]
|
Optional per-frame arguments to pass to |
None
|
max_num_files
|
int
|
Max. number of files that are allowed to be loaded at once.
A |
8
|
coarsen
|
bool
|
If Ture, read data sets are coarened depending on the number given of files. Only aplicable when not zooming. Defaults to Ture. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
Dataset |
Dataset
|
Concatenated dataset with all frames along |
Source code in earthcarekit/utils/read/product/_concat.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
read_science_data
Opens the science data of a EarthCARE file as a xarray.Dataset.
Source code in earthcarekit/utils/read/product/science_group.py
rebin_xmet_to_vertical_track
rebin_xmet_to_vertical_track(
ds_xmet,
ds_vert,
vars=None,
k=4,
eps=1e-12,
lat_var=TRACK_LAT_VAR,
lon_var=TRACK_LON_VAR,
time_var=TIME_VAR,
height_var=HEIGHT_VAR,
along_track_dim=ALONG_TRACK_DIM,
height_dim=VERTICAL_DIM,
xmet_lat_var="latitude",
xmet_lon_var="longitude",
xmet_height_var="geometrical_height",
xmet_height_dim="height",
xmet_horizontal_grid_dim="horizontal_grid",
)
Rebins variables from an AUX_MET_1D (XMET) dataset onto the vertical curtain track of given by another dataset (e.g. ATL_EBD_2A).
This function interpolates selected variables from ds_xmet onto a EarthCARE
vertical track given in ds_vert, using quick horizontal kd-tree nearest-neighbor search with scipy.spatial.cKDTree followed
by averaging the k-nearest vertical XMET profiles using inverse distance weighting. The resulting
profiles are then interpolated in the vertical to match the height resolution of ds_vert.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds_xmet
|
Dataset
|
The source XMET dataset from which vertical curtain along track will be interpolated. |
required |
ds_vert
|
Dataset
|
The target dataset containing the vertical curtain track. |
required |
vars
|
list[str] | None
|
List of variable names from |
None
|
k
|
int
|
Number of nearest horizontal neighbors to include in the kd-tree search. Defaults to 4. |
4
|
eps
|
float
|
Numerical threshold to avoid division by zero in distance calculations during the kd-tree search. Defaults to 1e-12. |
1e-12
|
lat_var
|
str
|
Name of the latitude variable in |
TRACK_LAT_VAR
|
lon_var
|
str
|
Name of the longitude variable in |
TRACK_LON_VAR
|
time_var
|
str
|
Name of the time variable in |
TIME_VAR
|
height_var
|
str
|
Name of the height variable in |
HEIGHT_VAR
|
along_track_dim
|
str
|
Name of the along-track dimension in |
ALONG_TRACK_DIM
|
height_dim
|
str
|
Name of the vertical or height dimension in |
VERTICAL_DIM
|
xmet_lat_var
|
str
|
Name of the latitude variable in |
'latitude'
|
xmet_lon_var
|
str
|
Name of the longitude variable in |
'longitude'
|
xmet_height_var
|
str
|
Name of the height variable in |
'geometrical_height'
|
xmet_height_dim
|
str
|
Name of the vertical dimension in |
'height'
|
xmet_horizontal_grid_dim
|
str
|
Name of the horizontal grid dimension in |
'horizontal_grid'
|
Returns:
| Type | Description |
|---|---|
Dataset
|
xr.Dataset: A new dataset containing the selected XMET variables interpolated to the grid of the
vertical curtain given in |
Raises:
| Type | Description |
|---|---|
KeyError
|
If any specified variable or coordinate name is not found in |
Source code in earthcarekit/utils/read/product/auxiliary/aux_met_1d.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
search_files_by_regex
Recursively searches for files in a directory that match a given regex pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root_dirpath
|
str
|
The root directory to start the search from. |
required |
regex_pattern
|
str
|
A regular expression pattern to match file names against. |
required |
Return
list[str]: A list of absolute file paths that point to files with matching names.
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the root directory does not exist. |
error
|
If the given pattern is not a valid regular expression. |
Source code in earthcarekit/utils/read/search.py
search_product
search_product(
root_dirpath=None,
config=None,
file_type=None,
agency=None,
latency=None,
timestamp=None,
baseline=None,
orbit_and_frame=None,
orbit_number=None,
frame_id=None,
filename=None,
start_time=None,
end_time=None,
)
Searches for EarthCARE product files matching given metadata filters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root_dirpath
|
str
|
Root directory to search. Defaults to directory given in a configuration file. |
None
|
config
|
str | ECKConfig | None
|
Path to a |
None
|
file_type
|
str | Sequence[str]
|
Product file type(s) to match. |
None
|
agency
|
str | Sequence[str]
|
Producing agency or agencies (e.g. "ESA" or "JAXA"). |
None
|
latency
|
str | Sequence[str]
|
Data latency level(s). |
None
|
timestamp
|
TimestampLike | Sequence
|
Timestamp(s) included in the product's time coverage. |
None
|
baseline
|
str | Sequence[str]
|
Baseline version(s). |
None
|
orbit_and_frame
|
str | Sequence[str]
|
Orbit and frame identifiers. |
None
|
orbit_number
|
int, str, | Sequence
|
Orbit number(s). |
None
|
frame_id
|
str | Sequence[str]
|
Frame identifier(s). |
None
|
filename
|
str | Sequence[str]
|
Specific filename(s) or regular expression patterns to match. |
None
|
start_time
|
TimestampLike
|
First timestamp included in the product's time coverage. |
None
|
end_time
|
TimestampLike
|
Last timestamp included in the product's time coverage. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
ProductDataFrame |
ProductDataFrame
|
Filtered list of matching product files as a |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If root directory does not exist. |
Source code in earthcarekit/utils/read/product/_search.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | |