asp_plot.csm_analysis
=====================

.. py:module:: asp_plot.csm_analysis

.. autoapi-nested-parse::

   Camera-model analysis: turn original/optimized camera pairs into the
   position- and orientation-difference GeoDataFrame consumed by the plotting
   layer (``csm_camera.py``).

   This module owns the asp_plot-specific analysis (``get_orbit_plot_gdf``,
   ``reproject_ecef``, ``poly_fit``) and builds on the ASP-mirrored readers in
   ``csm_io.py``.



Functions
---------

.. autoapisummary::

   asp_plot.csm_analysis.get_orbit_plot_gdf
   asp_plot.csm_analysis.poly_fit
   asp_plot.csm_analysis.reproject_ecef


Module Contents
---------------

.. py:function:: get_orbit_plot_gdf(original_camera, optimized_camera, map_crs=None, trim=True)

   Create a GeoDataFrame containing camera positions and orientation differences.

   :param original_camera: Path to the original camera file
   :type original_camera: str
   :param optimized_camera: Path to the optimized camera file
   :type optimized_camera: str
   :param map_crs: EPSG code for the target coordinate system, default is None (keep ECEF)
   :type map_crs: int or None, optional
   :param trim: Whether to trim data to only the first and last image lines for linescan
                cameras, default is True
   :type trim: bool, optional

   :returns: A GeoDataFrame containing camera positions and orientation data with
             columns for position differences, angle differences, and original values
   :rtype: geopandas.GeoDataFrame

   .. rubric:: Notes

   This function compares the original and optimized camera models and
   calculates the differences in position and orientation. For linescan
   cameras, it optionally trims the data to only include samples corresponding
   to the actual image lines.


.. py:function:: poly_fit(X, Y)

   Fit a linear polynomial to data and return the fitted values.

   :param X: Independent variable values
   :type X: array-like
   :param Y: Dependent variable values
   :type Y: array-like

   :returns: Fitted Y values from a degree 1 polynomial fit
   :rtype: numpy.ndarray


.. py:function:: reproject_ecef(positions, to_epsg=4326)

   Reproject ECEF coordinates to a specified EPSG coordinate system.

   :param positions: A 2D array of ECEF coordinates, where each row represents a point
   :type positions: numpy.ndarray
   :param to_epsg: The EPSG code of the target coordinate system, default is 4326 (WGS84)
   :type to_epsg: int, optional

   :returns: A 2D array of reprojected coordinates in the target EPSG coordinate system
   :rtype: numpy.ndarray

   .. rubric:: Notes

   ECEF (Earth-Centered, Earth-Fixed) coordinates are a 3D Cartesian coordinate
   system with the origin at the center of the Earth. This function converts
   those coordinates to a different coordinate system specified by an EPSG code.


