@classmethod
def from_paths(
cls,
*,
header_paths: Sequence[str | Path],
image_paths: Sequence[str | Path] | None = None,
):
if image_paths is not None and len(header_paths) != len(image_paths):
raise InvalidInputError(
{
"header_paths_length": len(header_paths),
"image_paths_length": len(image_paths),
},
"The length of hdr_paths and img_path must be equal.",
)
if image_paths is None:
spectral_images = [
SpectralImage.envi_open(header_path=hdr_path)
for hdr_path in track(
header_paths, description="Loading spectral images..."
)
]
else:
spectral_images = [
SpectralImage.envi_open(header_path=hdr_path, image_path=img_path)
for hdr_path, img_path in track(
zip(header_paths, image_paths),
description="Loading spectral images...",
)
]
logger.info("Spectral images loaded into memory.")
return cls(spectral_images)