Unverified Commit e4173632 authored by acpaquette's avatar acpaquette Committed by GitHub
Browse files

CSM Camera Skymap (#5072)



* stuff

* idk

* working skypt on csm cam

* Initial tweeks to the CSM camera to get skymap to work with it

* Adds body rotation in csminit if it is present on the ISD

* Adds test to extract body rotation from isd if it exists

* Addressed feedback and did extra clean uip

* A bunch of msl related camera changes

* Removed left over print statements

* Updated csminit/CSMCamera pipeline to get the correct data

* Small doc fix in RaDecRange in Camera.cpp

* Cleaned up constant frame check in SpiceRotation

* Set camera based center longitude and allowed users to select mapping direction

* Updated the skymap docs

* Addressed PR feedback

* Moved git into its own environment

* Removed git submodule update in favor of jenkins doing it

* Fixed most test failures

* Fixed last failing test

* Clean up

* Fixed changes to comments in camera.cpp

* Added changelog entries

* Minor fixes and guards in CSMCamera

* Fixes in qview tools when working with sky target imagery

* Fixed spacing

* Removed body rotation extraction from ISDs

* Fixed failing test

* Updated cam camera tests

* Remove body rotation tests

* Added print statement

* Removed print statement

* Modified imageToRemoteImageLocus expected call

---------

Co-authored-by: default avatarKelvin Rodriguez <krodriguez@usgs.gov>
Co-authored-by: default avatarEC2 Default User <ec2-user@ip-10-12-67-80.us-west-2.compute.internal>
parent 12e0ec6d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -35,6 +35,11 @@ release.

## [Unreleased]

### Added

- CSMCamera can now read and use the body rotation from ALE produced ISDs [#5072](https://github.com/DOI-USGS/ISIS3/pull/5072)
- CSMSkyMap added to CSMCamera for use with local rover projections in ISIS [#5072](https://github.com/DOI-USGS/ISIS3/pull/5072)

### Fixed
- Fixed <i>noproj</i> bug where some temporary files were not deleted after call to cam2cam.  Issue: [#4813](https://github.com/USGS-Astrogeology/ISIS3/issues/4813)
- Fixed <i>noproj</i> bug where missing shapemodel-related keywords (RayTraceEngine, BulletParts, Tolerance) are dropped when the output label is created. This resulted in the Bullet collision detection engine not being used. Issue: [#5377](https://github.com/USGS-Astrogeology/ISIS3/issues/5377)
+20 −0
Original line number Diff line number Diff line
@@ -29,8 +29,10 @@ find files of those names at the top level of this repository. **/
#include "Pvl.h"
#include "PvlGroup.h"
#include "PvlKeyword.h"
#include "SpiceRotation.h"

using namespace std;
using json = nlohmann::json;

namespace Isis {

@@ -417,6 +419,24 @@ namespace Isis {
    blobLabel += PvlKeyword("PluginName", pluginName);
    cube->write(csmStateBlob);

    // Try to add naif keywords
    if (ui.WasEntered("ISD")) {
      QString isdFilePath = ui.GetFileName("ISD");
      std::ifstream isdFileStream(isdFilePath.toStdString());
      try {
        json isd = json::parse(isdFileStream);

        if (isd.contains("naif_keywords")) {
          json aleNaifKeywords = isd["naif_keywords"];
          PvlObject naifKeywords = PvlObject("NaifKeywords", aleNaifKeywords);
          *cube->label() += naifKeywords;
        }
      }
      catch (json::parse_error &e) {
        // continue if we hit a parse error
      }
    }

    try {
      CameraFactory::Create(*cube);
      p.WriteHistory(*cube);
+13 −1
Original line number Diff line number Diff line
@@ -88,7 +88,9 @@ void IsisMain() {
  userGrp.addKeyword(PvlKeyword("EquatorialRadius", toString(1.0)), Pvl::Replace);
  userGrp.addKeyword(PvlKeyword("PolarRadius", toString(1.0)), Pvl::Replace);
  userGrp.addKeyword(PvlKeyword("LatitudeType", "Planetocentric"), Pvl::Replace);
  if (!userGrp.hasKeyword("LongitudeDirection")) {
    userGrp.addKeyword(PvlKeyword("LongitudeDirection", "PositiveWest"), Pvl::Replace);
  }
  userGrp.addKeyword(PvlKeyword("LongitudeDomain", "360"), Pvl::Replace);
  if(userGrp.hasKeyword("PixelResolution")) {
    userGrp.deleteKeyword("PixelResolution");
@@ -102,6 +104,9 @@ void IsisMain() {
    userGrp.addKeyword(PvlKeyword("MaximumLongitude", toString(maxRa)), Pvl::Replace);
    userGrp.addKeyword(PvlKeyword("MinimumLatitude", toString(minDec)), Pvl::Replace);
    userGrp.addKeyword(PvlKeyword("MaximumLatitude", toString(maxDec)), Pvl::Replace);
    incam->SetImage(icube->sampleCount() / 2.0, icube->lineCount() / 2.0);
    double centerRa = incam->RightAscension();
    userGrp.addKeyword(PvlKeyword("CenterLongitude", toString(centerRa)), Pvl::Replace);
  }
  if(ui.GetString("DEFAULTSCALE") == "CAMERA") {
    double res = incam->RaDecResolution();
@@ -247,6 +252,13 @@ bool sky2map::Xform(double &inSample, double &inLine,
  if(p_incam->Sample() > p_inputSamples + 0.5) return false;
  if(p_incam->Line() > p_inputLines + 0.5) return false;

  p_incam->SetImage(p_incam->Sample(), p_incam->Line());
  
  // Check that the new line and sample projects close to the input Right Ascension 
  // and Declination
  if (abs(p_incam->RightAscension() - lon) > 0.1) return false;
  if (abs(p_incam->Declination() - lat) > 0.1) return false;

  // Everything is good
  inSample = p_incam->Sample();
  inLine = p_incam->Line();
+14 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
    MaximumLatitude        = Computed from the input camera cube or map file
    MinimumLongitude       = Computed from the input camera cube or map file
    MaximumLongitude       = Computed from the input camera cube or map file
    CenterLongitude        = Computed from the input camera cube at the center of the image

    ProjectionName         = Projection name in the map file
    Scale                  = Computed from the input camera cube or map file
@@ -48,6 +49,14 @@
    Finally, the user has the option to override the pixel resolution and the ground range (latitude/longitude).  These changes can be
    facilitied through the parameters SCALE, SRA, ERA, SDEC, and EDEC.
  </p>

  <p>
    In addition, skymap can be used to produce landed mosaics from rovers like MSL. This can be done using ALE to generate an ISD
    which can be attached to the cube via <def link="csminit">csminit</def>. The user would then have to update the LongitudeDirection 
    their map file to PositiveWest. This converts the projection from a right ascension/declination projection to an azimuth/elevation 
    projection. Once that is done, the user would run their ISIS cube through <def link="skymap">skymap</def> and see that the landed 
    rover data would project relative to other images in the same image sequence.
  </p>
  </description>

  <category>
@@ -101,6 +110,10 @@
      <change name="Debbie A. Cook" date="2012-12-10">
        Changed to use TProjection instead of Projection.  References #775
      </change>
      <change name="Adam Paquette" date="2023-05-01">
        Updated camera to properly calculate the center longitude. Also
        allowed users to select PositiveEast in there mapping file.
      </change>
 </history>

  <groups>
+8 −2
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

#include "Brick.h"
#include "Camera.h"
#include "CSMCamera.h"
#include "IException.h"
#include "iTime.h"

@@ -48,7 +49,12 @@ void IsisMain() {
  b.SetBasePosition(intSamp, intLine, 1);
  cube.read(b);
  
  double rot = cam->CelestialNorthClockAngle();
  double rot;
  if (cube.hasBlob("CSMState", "String")) {
    rot = ((CSMCamera*)cam)->CelestialNorthClockAngle();
  } else {
    rot = cam->CelestialNorthClockAngle();
  }

  // Create group with sky position
  PvlGroup sp("SkyPoint");
Loading