API reference
earthcarekit.read
File reading utilities.
Notes
This module depends on other internal modules:
- earthcarekit.constants
- earthcarekit.data
- earthcarekit.filter
- earthcarekit.geo
- earthcarekit.stats
- earthcarekit.typing
- earthcarekit.utils
- API reference
FileAgency
Bases: FileInfoEnum
- API reference
- API reference
Source code in earthcarekit/read/info/agency.py
from_input
classmethod
from_input(input: str | Dataset) -> FileAgency
Infers the EarthCARE product agency (i.e. ESA or JAXA) from a given file or dataset.
Source code in earthcarekit/read/info/agency.py
FileLatency
Bases: FileInfoEnum
- API reference
Source code in earthcarekit/read/info/latency.py
from_input
classmethod
from_input(input: str | Dataset) -> FileLatency
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/read/info/latency.py
FileType
Bases: FileInfoEnum
- API reference
Source code in earthcarekit/read/info/type.py
14 15 16 17 18 19 20 21 22 23 24 25 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 | |
from_input
classmethod
from_input(input: str | Dataset) -> FileType
Infers the EarthCARE product type from a given file or dataset.
Source code in earthcarekit/read/info/type.py
LazyDataset
dataclass
Warning
WARNING: EXPERIMENTAL CLASS
Interface and behaviour are subject to change in future version!
EarthCARE data container intended as a lightweight alternative to xarray.Dataset for faster variable access.
This class partially mimics the basic interface of xarray.Dataset, providing similar syntax for variable access
(e.g., ds["x"]) and related metadata (e.g., ds.dims, ds["x"].dims, ds["x"].values, ds["x"].long_name, or ds["x"].attrs["long_name"]).
Variables must be accessed at least once within a with block to be loaded.
Warning
Support by other earthcarekit tools is currently limited, but CurtainFigure should work.
Attributes:
| Name | Type | Description |
|---|---|---|
filepath |
str
|
Path to a EarthCARE data file in HDF5/NetCDF-4 format (.h5). |
trim_to_frame |
bool
|
Whether to trim the dataset to latitude frame bounds. Defaults to True. |
in_memory |
bool
|
If True, load dataset variables eagerly into memory.
Otherwise, variables are loaded lazily upon access.
If |
to_geoid |
bool
|
If True, converts variables representing height/altitude values from HAE (WGS84)
to AMSL (EGM96) using the |
vars |
str | Iterable[str] | None
|
Variable name or collection of names to load at initialization.
If None and |
origin |
Literal['native', 'derived'] | None
|
Product origin identifier.
Defaults to None. |
logger |
Logger
|
Logger instance used to diplay debug messages. Defaults to root logger. |
Example:
>>> with LazyDataset(fp) as ds:
>>> var = "mie_attenuated_backscatter"
>>> ds[var].attrs["long_name"] = "Co-polar part. bsc. coeff."
>>> cfig = eck.CurtainFigure()
>>> cfig.ecplot(ds, var)
>>> cfig.ecplot_temperature(ds)
>>> cfig.ecplot_elevation(ds)
Source code in earthcarekit/read/lazy/_dataset.py
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 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 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 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 | |
get
Retrieves a variables by name.
Variables are returned under the following conditions:
- If the variable is already loaded.
- If not loaded but a generator exists for the given
var, generates the variable first. - Otherwise, attempts to load the variable from the underlying dataset file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var
|
str
|
Name of the variable to retrieve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
LazyVariable |
LazyVariable
|
The requested variable. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If |
Source code in earthcarekit/read/lazy/_dataset.py
nadir_index
property
Index of the across-track nadir pixel or None if not applicable.
ProductInfo
dataclass
Class storing all info gathered from a EarthCARE product's file path.
Attributes:
| Name | Type | Description |
|---|---|---|
mission_id |
FileMissionID
|
Mission ID (ECA = EarthCARE). |
agency |
FileAgency
|
Agency that generated the file (E = ESA, J = JAXA). |
latency |
FileLatency
|
Latency indicator (X = not applicable, N = near real-time, O = offline). |
baseline |
str
|
Two-letter product/processor version string (e.g., "BA"). |
file_type |
FileType
|
Full product name (10 characters, e.g., "ATL_EBD_2A"). |
start_sensing_time |
Timestamp
|
Start-time of data collection (i.e., time of first available data in the product). |
start_processing_time |
Timestamp
|
Start-time of processing (i.e., time at which creation of the product started). |
orbit_number |
int
|
Number of the orbit. |
frame_id |
str
|
Single letter identifier between A and H, indication the orbit segment (A,B,H = night frames; D,E,F = day frames; C,G = polar day/night frames). |
orbit_and_frame |
str
|
Six-character string with leading zeros combining orbit number and frame ID. |
filename |
str
|
Full name of the product without file extension. |
filepath |
str
|
Local file path or empty string if not available. |
hdr_filepath |
str
|
Local header file path or empty string if not available. |
start_latitude |
float
|
Track start latitude [deg. N]. |
start_longitude |
float
|
Track start longitude [deg. E]. |
end_latitude |
float
|
Track end latitude [deg. N]. |
end_longitude |
float
|
Track end longitude [deg. E]. |
- API reference
Source code in earthcarekit/read/info/product_info.py
to_dataframe
add_depol_ratio
add_depol_ratio(
ds_anom: Dataset,
rolling_w: int = 20,
near_zero_tolerance: float = 2e-07,
smooth: bool = True,
skip_height_above_elevation: int = 300,
cpol_var: str = "mie_attenuated_backscatter",
xpol_var: str = "crosspolar_attenuated_backscatter",
elevation_var: str = ELEVATION_VAR,
height_var: str = HEIGHT_VAR,
height_dim: str = VERTICAL_DIM,
) -> Dataset
Compute depolarization ratio (DPOL = XPOL/CPOL) from attenuated backscatter signals.
This function derives the depol. 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 potential surface return.
Also, signals are smoothed (or "cleaned") with a rolling mean, and near-zero divisions are suppressed and set to NaN instead.
In the resulting dataset, the ratio curtain and a ratio profile calculated from mean profiles of the full dataset (e.g., 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
|
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 signals, and depol. ratio profile from mean profiles. |
Source code in earthcarekit/read/product/level1/atl_nom_1b.py
add_isccp_cloud_type
add_isccp_cloud_type(
ds: Dataset,
new_var: str = "isccp_cloud_type",
cot_var: str = "cloud_optical_thickness",
cth_var: str = "cloud_top_height",
along_track_dim: str = ALONG_TRACK_DIM,
across_track_dim: str = ACROSS_TRACK_DIM,
) -> Dataset
Adds a variable to the dataset containing ISCCP cloud types calculated from cloud optical thickness (COT) and cloud top height (CTH).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
A MSI_COP_2A dataset. |
required |
new_var
|
str
|
Name of the new ISCCP cloud type variable. Defaults to "isccp_cloud_type". |
'isccp_cloud_type'
|
cot_var
|
str
|
Name of the COT variable in |
'cloud_optical_thickness'
|
cth_var
|
str
|
Name of the CTH variable in |
'cloud_top_height'
|
along_track_dim
|
str
|
Name of the along-track dimension in |
ALONG_TRACK_DIM
|
across_track_dim
|
str
|
Name of the across-track dimension in |
ACROSS_TRACK_DIM
|
Returns:
| Type | Description |
|---|---|
Dataset
|
xr.Dataset: The input dataset with added ISCCP cloud type variable. |
References
- International Satellite Cloud Climatology Project (ISCCP). ISCCP Definition of Cloud Types. Retrieved September 25, 2025. https://isccp.giss.nasa.gov/cloudtypes.html
Source code in earthcarekit/read/product/level2a/msi_cop_2a.py
add_potential_temperature
add_potential_temperature(
ds: Dataset,
temperature_var: str = "temperature_kelvin",
pressure_var: str = "pressure",
new_var: str = "potential_temperature",
) -> Dataset
Computes potential temperature from temperature [K] and pressure [Pa] and adds it as a variable to the dataset (source: https://en.wikipedia.org/wiki/Potential_temperature, accessed: 2026-02-06).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Dataset (e.g., AUX_MET_1D) containing temperature [K] and pressure [Pa] data. |
required |
temperature_var
|
str
|
Input temperature variable name. Defaults to "temperature_kelvin". |
'temperature_kelvin'
|
pressure_var
|
str
|
Input pressure variable name. Defaults to "pressure". |
'pressure'
|
new_var
|
str
|
New variable name for potential temperature. Defaults to "potential_temperature". |
'potential_temperature'
|
Returns:
| Type | Description |
|---|---|
Dataset
|
xr.Dataset: Dataset with 2 new variables for potential temperature profiles added (kelvin and celsius). |
Source code in earthcarekit/read/product/auxiliary/aux_met_1d.py
add_scattering_ratio
add_scattering_ratio(
ds_anom: Dataset,
formula: Literal["x/c", "(c+x)/r", "(c+x+r)/r"],
rolling_w: int = 20,
near_zero_tolerance: float = 2e-07,
smooth: bool = True,
skip_height_above_elevation: int = 300,
cpol_var: str = "mie_attenuated_backscatter",
xpol_var: str = "crosspolar_attenuated_backscatter",
ray_var: str = "rayleigh_attenuated_backscatter",
elevation_var: str = ELEVATION_VAR,
height_var: str = HEIGHT_VAR,
height_dim: str = VERTICAL_DIM,
) -> Dataset
Compute scattering ratio from attenuated backscatter signals given a formula: "x/c", "(c+x)/r", or "(c+x+r)/r".
This function derives the scattering ratio from cross-polarized (XPOL), co-polarized (CPOL) and rayleigh (RAY) attenuated backscatter signals.
Signals below the surface are masked, by default with a vertical margin on 300 meters above elevation to remove potential surface return.
Also, signals are smoothed (or "cleaned") with a rolling mean, and near-zero divisions are suppressed and set to NaN instead.
In the resulting dataset, the ratio curtain and a ratio profile calculated from mean profiles of the full dataset (e.g., mean(XPOL)/mean(CPOL)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds_anom
|
Dataset
|
ATL_NOM_1B dataset containing the attenuated backscatter signals. |
required |
formula
|
Literal['x/c', '(c+x)/r', '(c+x+r)/r']
|
Formula used to calculate the scattering ratio. |
required |
rolling_w
|
int
|
Window size for rolling mean smoothing. Defaults to 20. |
20
|
near_zero_tolerance
|
float
|
Tolerance for masking near-zero denominators. Defaults to 2e-7. |
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
|
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'
|
ray_var
|
str
|
Input rayleigh variable name. Defaults to "rayleigh_attenuated_backscatter". |
'rayleigh_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: xr.Dataset: Dataset with added ratio curtain and ratio profile from mean profiles. |
Source code in earthcarekit/read/product/level1/atl_nom_1b.py
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 200 201 202 203 204 205 206 207 208 209 | |
get_product_info
get_product_info(
filepath: str, warn: bool = False, must_exist: bool = True, read_geo_from_hdr: bool = False
) -> ProductInfo
Gather all info contained in the EarthCARE product's file path.
Source code in earthcarekit/read/info/product_info.py
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 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
get_product_infos
get_product_infos(
filepaths: str | list[str] | NDArray | DataFrame | Dataset,
warn: bool = False,
must_exist: bool = True,
read_geo_from_hdr: bool = False,
) -> ProductDataFrame
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 |
Returns:
| Name | Type | Description |
|---|---|---|
ProductDataFrame |
ProductDataFrame
|
A dataframe containing extracted product information. |
Source code in earthcarekit/read/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/read/any.py
read_header_data
Opens the product header groups of a EarthCARE file as a xarray.Dataset.
Source code in earthcarekit/read/header.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/read/netcdf.py
read_polly
Reads manually processed PollyXT output text files as xarray.Dataset or returns an already open one.
Source code in earthcarekit/read/pollynet.py
read_product
read_product(
input: str | Dataset,
trim_to_frame: bool = True,
modify: bool = DEFAULT_READ_EC_PRODUCT_MODIFY,
header: bool = DEFAULT_READ_EC_PRODUCT_HEADER,
meta: bool = DEFAULT_READ_EC_PRODUCT_META,
ensure_nans: bool = DEFAULT_READ_EC_PRODUCT_ENSURE_NANS,
in_memory: bool = False,
to_geoid: bool = False,
origin: Literal["native", "derived"] | None = None,
try_lazy: bool = True,
**kwargs
) -> Dataset
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
|
ensure_nans
|
bool
|
If True, ensures that _FillValues are set to NaNs even if encoding of _FillValues or dtype is missing. Be aware, if True increases reading time. Defaults to True. |
DEFAULT_READ_EC_PRODUCT_ENSURE_NANS
|
in_memory
|
bool
|
If True, ensures the dataset is fully loaded into memory. Defaults to False. |
False
|
to_geoid
|
bool
|
If True, converts variables representing height/altitude values from HAE (WGS84) to
AMSL (EGM96) using the |
False
|
origin
|
Literal['native', 'derived'] | None
|
Product origin identifier.
Defaults to None. |
None
|
try_lazy
|
bool
|
If True, first attemps to read using |
True
|
Returns:
| Type | Description |
|---|---|
Dataset
|
xarray.Dataset: The resulting dataset. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If input is not a Dataset or string. |
- Getting started Supported EarthCARE products
Source code in earthcarekit/read/product/_generic.py
211 212 213 214 215 216 217 218 219 220 221 222 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 | |
read_products
read_products(
filepaths: Sequence[str] | NDArray[str_] | DataFrame,
zoom_at: float | None = None,
along_track_dim: str = ALONG_TRACK_DIM,
func: Callable | None = None,
func_inputs: Sequence[dict] | None = None,
max_num_files: int = 8,
coarsen: bool = True,
) -> Dataset
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/read/product/_concat.py
25 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 | |
read_science_data
read_science_data(
filepath: str, agency: Union[FileAgency, None] = None, ensure_nans: bool = False, **kwargs
) -> Dataset
Opens the science data of a EarthCARE file as a xarray.Dataset.
- Getting started Supported EarthCARE products
Source code in earthcarekit/read/science.py
rebin_msi_to_jsg
rebin_msi_to_jsg(
ds_msi: Dataset | str,
ds_xjsg: Dataset | str,
vars: list[str] | None = None,
k: int = 4,
eps: float = 1e-12,
lat_var: str = SWATH_LAT_VAR,
lon_var: str = SWATH_LON_VAR,
time_var: str = TIME_VAR,
along_track_dim: str = ALONG_TRACK_DIM,
across_track_dim: str = ACROSS_TRACK_DIM,
lat_var_xjsg: str = SWATH_LAT_VAR,
lon_var_xjsg: str = SWATH_LON_VAR,
time_var_xjsg: str = TIME_VAR,
along_track_dim_xjsg: str = ALONG_TRACK_DIM,
across_track_dim_xjsg: str = ACROSS_TRACK_DIM,
) -> Dataset
Rebins variables from an MSI product dataset onto the geo-spacial lat/lon grid given by the related AUX_JSG_1D dataset.
This function interpolates selected variables from ds_msi onto the JSG grid from ds_xjsg
using quick kd-tree nearest-neighbor search with scipy.spatial.cKDTree followed
by averaging the k-nearest points using inverse distance weighting. The resulting dataframe
matches the along- and across-track resolution of ds_xjsg.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds_msi
|
Dataset | str
|
The source MSI dataset (e.g., MSI_RGR_1C, MSI_COP_2A, ...). |
required |
ds_xjsg
|
Dataset | str
|
The target XJSG dataset. |
required |
vars
|
list[str] | None
|
List of variable names from |
None
|
k
|
int
|
Number of nearest geo-spacial 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
|
Returns:
| Type | Description |
|---|---|
Dataset
|
xr.Dataset: The MSI dataset with variables rebinned to the JSG grid. |
Source code in earthcarekit/read/product/_rebin_msi_to_jsg.py
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 | |
rebin_xmet_to_vertical_track
rebin_xmet_to_vertical_track(
ds_xmet: Dataset | str,
ds_vert: Dataset | str,
vars: list[str] | None = None,
k: int = 4,
eps: float = 1e-12,
lat_var: str = TRACK_LAT_VAR,
lon_var: str = TRACK_LON_VAR,
time_var: str = TIME_VAR,
height_var: str = HEIGHT_VAR,
along_track_dim: str = ALONG_TRACK_DIM,
height_dim: str = VERTICAL_DIM,
xmet_lat_var: str = "latitude",
xmet_lon_var: str = "longitude",
xmet_height_var: str = "geometrical_height",
xmet_height_dim: str = "height",
xmet_horizontal_grid_dim: str = "horizontal_grid",
) -> Dataset
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 | str
|
The source XMET dataset from which vertical curtain along track will be interpolated. |
required |
ds_vert
|
Dataset | str
|
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 |
- Tutorials Rebin X-MET along-track
Source code in earthcarekit/read/product/_rebin_xmet_to_vertical_track.py
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 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 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 | |
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/path.py
search_product
search_product(
root_dirpath: str | None = None,
config: str | ECKConfig | None = None,
file_type: str | Sequence[str] | None = None,
agency: str | Sequence[str] | None = None,
latency: str | Sequence[str] | None = None,
timestamp: TimestampLike | Sequence[TimestampLike] | None = None,
baseline: str | Sequence[str] | None = None,
orbit_and_frame: str | Sequence[str] | None = None,
orbit_number: int | str | Sequence[int | str] | None = None,
frame_id: str | Sequence[str] | None = None,
filename: str | Sequence[str] | None = None,
start_time: TimestampLike | None = None,
end_time: TimestampLike | None = None,
mode: Literal["exhaustive", "fast"] = "exhaustive",
read_geo_from_hdr: bool = False,
) -> ProductDataFrame
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
|
mode
|
Literal['exhaustive', 'fast']
|
Search strategy controlling completeness vs performance; the "exhaustive" mode
recursivly scans all files under the |
'exhaustive'
|
read_geo_from_hdr
|
bool
|
If True, reads start and end lat/lon from existing header files ( |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
resutls |
ProductDataFrame
|
Filtered table of matching product files as a |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If root directory does not exist. |
Source code in earthcarekit/read/product/_search.py
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 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | |