pycontrails.datalib.leo_utils

Tools for working with Sentinel-2 and Landsat data.

pycontrails.datalib.leo_utils.estimate_scan_time(ephemeris_df, utm_crs, x, y)

Estimate the scan time for the given x, y pixels.

Project the x, y coordinates (in UTM coordinate system) onto the ephemeris track and interpolate the time.

Parameters:
  • ephemeris_df (pandas.DataFrame) – DataFrame containing the ephemeris data with columns: - ‘EPHEMERIS_ECEF_X’: ECEF X coordinates (meters) - ‘EPHEMERIS_ECEF_Y’: ECEF Y coordinates (meters) - ‘EPHEMERIS_ECEF_Z’: ECEF Z coordinates (meters) - ‘EPHEMERIS_TIME’: Timestamps (as datetime64[ns])

  • utm_crs (pyproj.CRS) – The UTM coordinate reference system used for projection.

  • x (npt.NDArray[np.floating]) – The x coordinates of the points to estimate the scan time for. Should be in the correct UTM coordinate system.

  • y (npt.NDArray[np.floating]) – The y coordinates of the points to estimate the scan time for. Should be in the correct UTM coordinate system.

Returns:

npt.NDArray[np.datetime64] – The estimated scan times as numpy datetime64[ns] array. Points for which x or y are nan will have NaT as the corresponding output value.

pycontrails.datalib.leo_utils.scan_angle_correction(ds, x, y, z, *, maxiter=5, tol=10.0, full_output=False)

Apply the scan angle correction to the given x, y, z coordinates.

Parameters:
  • ds (xarray.Dataset) – The dataset containing the viewing azimuth angle (VAA) and viewing zenith angle (VZA) arrays. The units for both are degrees.

  • x (npt.NDArray[np.floating]) – The x coordinates of the points to correct. Should be in the correct UTM coordinate system

  • y (npt.NDArray[np.floating]) – The y coordinates of the points to correct. Should be in the correct UTM coordinate system.

  • z (npt.NDArray[np.floating]) – The z coordinates (altitude in meters) of the points to correct.

  • maxiter (int, optional) – Maximum number of iterations to perform. Default is 5.

  • tol (float, optional) – Tolerance for convergence in meters. Default is 10.0.

  • full_output (bool, optional) – If True, return an additional boolean array indicating which points successfully converged. Default is False.

Returns:

tuple[npt.NDArray[np.floating], npt.NDArray[np.floating]] – The corrected x and y coordinates as numpy arrays in the UTM coordinate system. Points that are not contained in the non-nan region of the image will contain nan values in the output arrays.