inout package
Submodules
inout.classified_pcloud_writer module
- class inout.classified_pcloud_writer.ClassifiedPcloudWriter(**kwargs)
Bases:
Writer- Author:
Alberto M. Esmoris Pena
Class for writing classified point clouds (mostly to be used in pipelines).
See
Writer.- write(state, prefix=None, info=True)
Write the classified point cloud.
See
Writerandwriter.Writer.write().- Parameters:
state (
PipelineState) – The pipeline’s state that must contain the classified point cloud.
inout.geotiff_io module
- class inout.geotiff_io.GeoTiffIO
Bases:
object- Author:
Alberto M. Esmoris Pena
Class with util static methods for input/output operations related to GeoTiff files.
- static write(x, path, **kwargs)
Write the given data to a GeoTiff file.
- Parameters:
x (
PointCloudor tuple) – It can be either a point cloud or a tuple where the first element is the matrix of coordinates representing a point cloud and the second element is a raster-like grid of features representing the point cloud.path – Path where the GeoTiff file must be written.
kwargs – The key-word arguments governing the writing of the GeoTiff file.
- Returns:
Nothing, but a GeoTiff file is written to the given path.
- static write_pcloud(pcloud, path, **kwargs)
Write a point cloud as a GeoTiff file located at given path.
- Parameters:
pcloud – The point cloud to be written. It can be None, in which case the kwargs dictionary must contain an X element giving a matrix of coordinates and an F element giving the matrix of features.
path (str) – Path where the GeoTiff file must be written.
kwargs (dict) – The key-word arguments governing the GeoTiff specification and its writing.
- Returns:
Nothing
- static write_pcloud_as_geotiff(pcloud, path, **kwargs)
Assist the
geotiff_io.GeoTiffIO.write()method.- Returns:
Nothing, but writes the GeoTiff file.
- static write_grid_as_geotiff(X, Fgrid, path, **kwargs)
Assist the
geotiff_io.GeoTiffIO.write()method.- Parameters:
X – The matrix of coordinates representing a point cloud.
Fgrid – The raster-like grid of features representing a point cloud.
path – The path where the GeoTiff file must be written.
kwargs – The key-word arguments governing the writing of the GeoTiff file.
- Returns:
Nothing, but a GeoTiff file is written at given path.
- static build_fgrid_from_pcloud(Xgrid, X2D, F, width, height, xres, yres)
Build a grid of features from the given point cloud data.
- Parameters:
Xgrid – The grid of 2D coordinates.
X2D – The 2D coordinates matrix representing the point cloud.
F – The feature matrix representing the point cloud.
width – The number of cells along the x-axis.
height – The number of cells along the y-axis.
xres – The step size along the x-axis.
yres – The step size along the y-axis.
- Returns:
The grid of features corresponding to the grid of 2D coordinates and the given matrix of features.
- Return type:
np.ndarray
- static validate_geotiff_spec(crs, driver, xres, yres)
Validate whether the given GeoTiff specification is correct or not.
- Returns:
Nothing, but an Exception will be thrown if the specification is not valid.
- static generate_raster(X, xres, yres)
Generate a raster for the given point cloud considering the requested cell size.
- Parameters:
X – The matrix of coordinates representing the point cloud for which the raster must be generated.
xres – The cell size along the x-axis.
yres – The cell size along the y-axis.
- Returns:
The width, height, window, transform, xmin, xmax, ymin, and ymax values defining the generated raster.
inout.io_utils module
- class inout.io_utils.IOUtils
Bases:
object- Author:
Alberto M. Esmoris Pena
Class with util static methods for general input/output operations.
- static make_directory(dirpath, recursive=True, error_if_exists=False)
Create the given directory.
- Parameters:
dirpath (str) – The path of the directory to be created.
recursive (bool) – Whether to make parent directories recursively (True, default) or not (False).
error_if_exists – Whether to raise an exception if the directory already exists (True) or not (False, default).
- Returns:
Nothing at all, but the directory is created at the given path.
- static validate_path_to_file(path, msg='Cannot find file at given path:', accept_url=False)
Validate the given path points to an accessible file.
- Parameters:
path (str) – Path to a file that must be validated.
msg (str) – Message for the exception.
accept_url (bool) – If True, when the given path is a valid and accessible URL it will be accepted as a valid path. If False, URLs will not be accepted.
- Returns:
Nothing but an exception will be raised if the path is not valid.
- static validate_path_to_directory(path, msg='Given path does not point to an accessible directory:', try_to_make=True)
Validate the given path points to an accessible directory.
- Parameters:
path (str) – Path to a directory that must be validated.
msg (str) – Message for the exception.
try_to_make (bool) – Whether try to make the given directory (True) or just validate it exists (False).
- Returns:
Nothing but an exception will be raised if the path is not valid.
- static validate_url_to_file(url, msg='Given URL is not accessible:')
Validate the given URL can be accessed.
- Parameters:
url (str) – The URL to be checked.
msg (str) – Message for the exception.
- Returns:
Nothing but an exception will be raised if the URL is not accessible.
- static is_url(s)
Check whether the given string represents a URL.
- Parameters:
s – The string to be checked.
- Returns:
True if the given string represents a URL, false otherwise.
- static does_file_exist(path)
Check whether the given path represents a file that exists in the filesystem (True) or not (False).
- Parameters:
path – Path to the file whose existence must be checked.
- Returns:
True if the file at the given path exists (as a file), False otherwise.
- Return type:
bool
inout.json_io module
inout.model_io module
- class inout.model_io.ModelIO
Bases:
object- Author:
Alberto M. Esmoris Pena
Class with util static methods for input/output operations related to models.
- static read(path)
Read a model file.
- Parameters:
path (str) – Path to the model file.
- Returns:
Instance of Model (or corresponding derived class)
- Return type:
inout.model_writer module
- class inout.model_writer.ModelWriter(path=None)
Bases:
Writer- Author:
Alberto M. Esmoris Pena
Class for writing tasks/operations (mostly to be used in pipelines) related to models.
See
Writer.- static extract_writer_args(spec)
Extract the arguments to initialize/instantiate a ModelWriter from a key-word specification.
- Parameters:
spec – The key-word specification containing the arguments.
- Returns:
The arguments to initialize/instantiate a ModelWriter.
inout.pipeline_io module
- class inout.pipeline_io.PipelineIO
Bases:
object- Author:
Alberto M. Esmoris Pena
Class with util static methods for input/output operations related to pipelines.
- static read_predictive_pipeline(path, new_nn_path=None)
Read a predictive pipeline file.
- Parameters:
path (str) – Path to the pipeline file.
new_nn_path – Path to the serialized neural network when loading predictive pipelines with deep learning models. It can be None, in which case the nn_path attribute of the serialized
Architecturewill be considered.
- Returns:
- static write_predictive_pipeline(predictive_pipeline, path)
Write a predictive pipeline to a file.
- Parameters:
predictive_pipeline (
PredictivePipeline) – The predictive pipeline to be written.path (str) – Path where the pipeline file must be written.
- Returns:
Nothing.
inout.point_cloud_io module
- class inout.point_cloud_io.PointCloudIO
Bases:
object- Author:
Alberto M. Esmoris Pena
Class with util static methods for input/output operations related to point clouds.
- static read(path)
Read a LAS/LAZ point cloud.
- Parameters:
path – Path pointing to a LAS/LAZ point cloud.
- Returns:
The read point cloud.
- Return type:
- static read_path(path)
Read a LAS/LAZ point cloud file.
- Parameters:
path (str) – Path pointing to a LAS/LAZ point cloud file.
- Returns:
The read point cloud.
- Return type:
- static read_url(url, chunk_size=67108864)
Read a LAS/LAZ point cloud file from a given URL.
- Parameters:
url (str) – The URL corresponding to a LAS/LAZ point cloud.
chunk_size (float) – The chunk size for each reading operation on the input stream (in Bytes, def. 64 MiB).
- Returns:
- static write(pcloud, path)
Write a LAS/LAZ point cloud file.
- Parameters:
pcloud – The point cloud to be written.
path – Path where the LAS/LAZ file must be written.
- Returns:
Nothing
inout.predictions_writer module
- class inout.predictions_writer.PredictionsWriter(path=None)
Bases:
Writer- Author:
Alberto M. Esmoris Pena
Class for writing predictions (mostly to be used in pipelines).
See
Writer.- static extract_writer_args(spec)
Extract the arguments to initialize/instantiate a PredictionsWriter from a key-word specification.
- Parameters:
spec – The key-word specification containing the arguments.
- Returns:
The arguments to initialize/instantiate a PredictionsWriter.
- __init__(path=None)
Initialize/instantiate a PredictionsWriter.
See
Writerandwriter.Writer.__init__().
- write(preds, prefix=None, info=True)
Write the given predictions.
- Parameters:
preds (
np.ndarray) – The predictions to be written.prefix (str) – If None, the writing applies to path. If not None, the writing applies to prefix+path.
info (bool) – Whether to log an info message (True) or not (False).
inout.predictive_pipeline_writer module
- class inout.predictive_pipeline_writer.PredictivePipelineWriter(path=None, **kwargs)
Bases:
Writer- Author:
Alberto M. Esmoris Pena
Class for writing predictive pipelines.
See
PredictivePipeline.- static extract_writer_args(spec)
Extract the arguments to initialize/instantiate a PredictivePipelineWriter from a key-word specification.
- Parameters:
spec – The key-word specification containing the arguments.
- Returns:
The arguments to initialize/instantiate a PredictivePipelineWriter.
- __init__(path=None, **kwargs)
Initialize/instantiate a PredictivePipelineWriter.
See
Writerandwriter.Writer.__init__()
- write(pipeline, prefix=None, info=True)
Write the predictive version of the given pipeline.
- Parameters:
pipeline (
Pipeline) – Pipeline (must be transformable to a predictive pipeline).prefix (str) – If None, the writing applies to path. If not None, the writing applies to prefix+path.
info (bool) – Whether to log an info message (True) or not (False).
inout.writer module
- exception inout.writer.WriterException(message='')
Bases:
VL3DException- Author:
Alberto M. Esmoris Pena
Class for exceptions related to writing components. See
VL3DException- __init__(message='')
- class inout.writer.Writer(path=None)
Bases:
object- Author:
Alberto M. Esmoris Pena
Class for writing tasks/operations (mostly to be used in pipelines)
- Variables:
path (str) – The path to the output file for writing operations.
- static extract_writer_args(spec)
Extract the arguments to initialize/instantiate a Writer from a key-word specification.
- Parameters:
spec – The key-word specification containing the arguments.
- Returns:
The arguments to initialize/instantiate a Writer.
- __init__(path=None)
Initialize/instantiate a Writer
- Parameters:
path – The path itself. It might (or NOT) need a prefix. Any path that starts with “*” in the context of a Writer will need a prefix.
- write(pcloud, prefix=None, info=True)
Write the given point cloud.
- Parameters:
pcloud (
PointCloud) – The point cloud to be written.prefix (str) – If None, the writing applies to path. If not None, the writing applies to prefix+path. See
writer.Writer.prepare_path().info (bool) – Whether to log an info message (True) or not (False).
- prepare_path(prefix)
Merge the path with the prefix to obtain the actual path for the writing.
- Returns:
Prepared path.
- Return type:
str
- needs_prefix()
Check whether the Writer needs a prefix for write operations or not.
- Returns:
True if the Writer needs a prefix, False otherwise.
inout.writer_utils module
Module contents
- author:
Alberto M. Esmoris Pena
The I/O package contains the logic to read and write to any persistence and/or network layer of interest.