spymicmac.asp#

spymicmac.asp is a collection of tools for interfacing with Ames Stereo Pipeline

initializing camera files#

spymicmac.asp.cam_from_footprint(fn_img, flavor, scan_res, fn_dem, north_up=True, footprints=None, mean_el=1000)[source]#

Generate a camera (.tsai) file from an image footprint.

Parameters:
  • fn_img (str) – the filename of the image to generate a camera for.

  • flavor (str) – what type of camera the image came from - currently either KH4 or KH9

  • scan_res (float) – the scanning resolution of the image

  • fn_dem (str | Path) – the filename of the reference DEM

  • north_up (bool) – whether the top of the image corresponds to North or not

  • footprints (GeoDataFrame) – a GeoDataFrame containing image footprints and an ID field with image names. If not provided, will attempt to download from USGS.

  • mean_el (float | int) – the mean surface elevation covered by the image. If None, uses DEM and footprint to calculate the value.

Returns:

spymicmac.asp.optical_bar_cam(fn_img, flavor, out_name, fprint=None, scan_res=7e-06, mean_el=1000)[source]#

Generate a sample ASP camera file for a KH-4 Optical Bar camera.

Parameters:
  • fn_img (str) – the filename of the image. Used to read the image size, and determine whether the image is from the aft or forward camera.

  • flavor (str) – what type of camera the image came from - currently either KH4 or KH9

  • out_name (str) – the filename to write the camera file to.

  • fprint (Polygon | None) – an optional image, footprint used to estimate the initial camera position

  • scan_res (float) – the image scanning resolution, in m per pixel (e.g., 7 microns -> 7.0e-6)

  • mean_el (float | int) – the mean elevation covered by the image

Return type:

None

bundle adjustment#

spymicmac.asp.bundle_adjust_from_gcp(fn_img, fn_cam, fn_out, fn_gcp)[source]#

Use an ASP GCP file to refine a camera position

Parameters:
  • fn_img (str) – the filename of the image to generate a camera for

  • fn_cam (str) – the camera filename to use for refinement

  • fn_out (str) – the output folder and prefix to write the updated camera to

  • fn_gcp (str) – the GCP filename

Return type:

None

miscellaneous#

spymicmac.asp.meas_to_asp_gcp(fn_gcp, fn_meas, imlist, outname=None, scale=1, singles=False)[source]#

Convert image measures stored in a micmac xml file to an ASP .gcp file format.

Parameters:
  • fn_gcp (str) – the filename of the shapefile with the GCP coordinates

  • fn_meas (str) – the filename of the xml file with the image measures

  • imlist (list) – the image(s) to write point locations for

  • outname (str) – the name of the output filename to create (default: {fn_meas}.gcp)

  • scale (int) – the factor by which to scale the image point locations (default: 1)

  • singles (bool) – write gcps present in only a single image (default: False)

Return type:

None