Skip to content

Commit

Permalink
CSM Camera Skymap (#5072)
Browse files Browse the repository at this point in the history
* 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: Kelvin Rodriguez <[email protected]>
Co-authored-by: EC2 Default User <[email protected]>
  • Loading branch information
3 people authored Feb 9, 2024
1 parent 12e0ec6 commit e417363
Show file tree
Hide file tree
Showing 24 changed files with 621 additions and 230 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 20 additions & 0 deletions isis/src/base/apps/csminit/csminit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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);
Expand Down
14 changes: 13 additions & 1 deletion isis/src/base/apps/skymap/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
userGrp.addKeyword(PvlKeyword("LongitudeDirection", "PositiveWest"), 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");
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
15 changes: 14 additions & 1 deletion isis/src/base/apps/skymap/skymap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
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
Scale = Computed from the input camera cube or map file
EndGroup
</pre>

Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
10 changes: 8 additions & 2 deletions isis/src/base/apps/skypt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

Expand Down Expand Up @@ -47,8 +48,13 @@ void IsisMain() {
int intLine = (int)(line + 0.5);
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");
Expand Down
Loading

0 comments on commit e417363

Please sign in to comment.