Skip to content

Add support for Chandrayaan2TMC #5767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions isis/appdata/import/PDS4/Chandrayaan2TMC2.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ Object = IsisCube
SunAzimuth = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_sun_azimuth._text }} <degrees>
SunElevation = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_sun_elevation._text }} <degrees>
SolarIncidence = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_solar_incidence._text }} <degrees>
Projection = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_projection }}
Area = {{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_area }}
Projection = "{{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_projection }}"
Area = "{{ Product_Observational.Observation_Area.Mission_Area.isda_Product_Parameters.isda_area }}"
End_Group
{% endif %}

Expand Down
1 change: 1 addition & 0 deletions isis/appdata/translations/MissionName2DataDir.trn
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Group = MissionName
Translation = (Chandrayaan1, "CHANDRAYAAN-1 ORBITER")
Translation = (Chandrayaan1, CHANDRAYAAN1_ORBITER)
Translation = (Chandrayaan1, CHANDRAYAAN-1)
Translation = (Chandrayaan2, Chandrayaan-2)
Translation = (Clementine1, CLEMENTINE_1)
Translation = (Clementine1, "CLEMENTINE 1")
Translation = (Clipper, "CLIPPER")
Expand Down
21 changes: 10 additions & 11 deletions isis/src/base/objs/SpiceRotation/SpiceRotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2486,10 +2486,9 @@ namespace Isis {
"Full cache size does NOT match cache size in LoadTimeCache -- should never happen";
throw IException(IException::Programmer, msg, _FILEINFO_);
}

SpiceDouble timeSclkdp[p_fullCacheSize];
SpiceDouble quats[p_fullCacheSize][4];
double avvs[p_fullCacheSize][3]; // Angular velocity vector
std::vector<SpiceDouble> timeSclkdp(p_fullCacheSize);
std::vector<SpiceDouble> quats(p_fullCacheSize * 4);
std::vector<double> avvs(p_fullCacheSize * 3);

// We will treat et as the sclock time and avoid converting back and forth
std::vector<ale::Rotation> fullRotationCache = m_orientation->getRotations();
Expand All @@ -2501,23 +2500,23 @@ namespace Isis {
rotationMatrix[3], rotationMatrix[4], rotationMatrix[5],
rotationMatrix[6], rotationMatrix[7], rotationMatrix[8]
};
m2q_c(CJ, quats[r]);
m2q_c(CJ, &quats[r * 4]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why multiply the index?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the old code quats was a 2d array, here we changed it to a 1d vector so we have to jump over four elements each time to read the quaternion. I think this largely had to do with 2d vectors not being contiguious

if (p_hasAngularVelocity) {
ale::Vec3d angularVelocity = angularVelocities[r];
vequ_c((SpiceDouble *) &angularVelocity.x, avvs[r]);
vequ_c((SpiceDouble *) &angularVelocity.x, &avvs[r*3]);
}
}

double cubeStarts = timeSclkdp[0]; //,timsSclkdp[ckBlob.Records()-1] };
double cubeStarts = timeSclkdp[0]; //,timsSclkdp[ckBlob.Records()-1] ;
double radTol = 0.000000017453; //.000001 degrees Make this instrument dependent TODO
SpiceInt avflag = 1; // Don't use angular velocity for now
SpiceInt nints = 1; // Always make an observation a single interpolation interval
double dparr[p_fullCacheSize]; // Double precision work array
SpiceInt intarr[p_fullCacheSize]; // Integer work array
SpiceInt sizOut = p_fullCacheSize; // Size of downsized cache

ck3sdn(radTol, avflag, (int *) &sizOut, timeSclkdp, (doublereal *) quats,
(SpiceDouble *) avvs, nints, &cubeStarts, dparr, (int *) intarr);
ck3sdn(radTol, avflag, (int *) &sizOut, &timeSclkdp[0], (doublereal *) &quats[0],
(SpiceDouble *) &avvs[0], nints, &cubeStarts, dparr, (int *) intarr);

// Clear full cache and load with downsized version
p_cacheTime.clear();
Expand All @@ -2538,9 +2537,9 @@ namespace Isis {
et = timeSclkdp[r];
p_cacheTime.push_back(et);
std::vector<double> CJ(9);
q2m_c(quats[r], (SpiceDouble( *)[3]) &CJ[0]);
q2m_c(&quats[r*4], (SpiceDouble(*)[3]) &CJ[0]);
rotationCache.push_back(CJ);
vequ_c(avvs[r], (SpiceDouble *) &av[0]);
vequ_c(&avvs[r*3], (SpiceDouble *) &av[0]);
avCache.push_back(av);
}

Expand Down
2 changes: 1 addition & 1 deletion isis/src/base/objs/SpiceRotation/SpiceRotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ namespace Isis {
int p_axis1; //!< Axis of rotation for angle 1 of rotation
int p_axis2; //!< Axis of rotation for angle 2 of rotation
int p_axis3; //!< Axis of rotation for angle 3 of rotation
ale::Orientations *m_orientation; //! Cached orientation information
ale::Orientations *m_orientation = nullptr; //! Cached orientation information

private:
// method
Expand Down
1 change: 1 addition & 0 deletions isis/src/chandrayaan2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(ISISROOT)/make/isismake.cat
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this used for anything other than cat tests?

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Group = CHANDRAYAAN-2/TMC-2
Version = 1
Library = Chandrayaan2TmcCamera
Routine = Chandrayaan2TmcCameraPlugin
EndGroup

Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/** This is free and unencumbered software released into the public domain.

The authors of ISIS do not claim copyright on the contents of this file.
For more details about the LICENSE terms and the AUTHORS, you will
find files of those names at the top level of this repository. **/

/* SPDX-License-Identifier: CC0-1.0 */

#include "Chandrayaan2TmcCamera.h"

#include <QString>

#include "Affine.h"
#include "CameraDistortionMap.h"
#include "CameraFocalPlaneMap.h"
#include "IException.h"
#include "iTime.h"
#include "IString.h"
#include "LineScanCameraDetectorMap.h"
#include "LineScanCameraGroundMap.h"
#include "LineScanCameraSkyMap.h"
#include "NaifStatus.h"

using namespace std;
namespace Isis {
/**
* Constructs a Chandrayaan 2 TMC Camera object using the image labels.
*
*/
Chandrayaan2TmcCamera::Chandrayaan2TmcCamera(Cube &cube) : LineScanCamera(cube) {
m_instrumentNameLong = "Terrain Mapping Camera-2";
m_instrumentNameShort = "TMC-2";
m_spacecraftNameLong = "Chandrayaan 2";
m_spacecraftNameShort = "Chan2";

NaifStatus::CheckErrors();
// Set up the camera info from ik/iak kernels
SetFocalLength();
//Chandrayaan2 iak uses INS-152???_PIXEL_SIZE instead of PIXEL_PITCH
QString ikernKey = "INS" + toString(naifIkCode()) + "_PIXEL_SIZE";
// Pixel size is specified in meters, we need it in mm
SetPixelPitch(getDouble(ikernKey)*1000);

// Get the start time from labels
Pvl &lab = *cube.label();
PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
QString stime = (QString)inst["StartTime"];
SpiceDouble etStart=0;
etStart = iTime(stime).Et();

double csum = 1;
if (inst.hasKeyword("SpatialSumming")){
csum = inst["SpatialSumming"];
}
double lineRate = (double) inst["LineExposureDuration"] / 1000;

// Setup detector map
LineScanCameraDetectorMap *detectorMap =
new LineScanCameraDetectorMap(this, etStart, lineRate);
detectorMap->SetDetectorSampleSumming(csum);

// Setup focal plane map
CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());

// Retrieve boresight location from instrument kernel (IK) (addendum?)
QString centerKey = "INS" + toString((int)naifIkCode()) + "_CENTER";
double sampleCenter = getDouble(centerKey, 0);
double lineCenter = getDouble(centerKey, 1);

focalMap->SetDetectorOrigin(sampleCenter, lineCenter);
focalMap->SetDetectorOffset(0.0, 0.0);

// @TODO set no distortion? No values in IK
// Setup distortion map
CameraDistortionMap *distMap = new CameraDistortionMap(this);
distMap->SetDistortion(naifIkCode());

// Setup the ground and sky map
new LineScanCameraGroundMap(this);
new LineScanCameraSkyMap(this);


// Set proper end frame
int tmcFrame(0);
if (naifIkCode() == -152210) {
// Frame DAWN_VIR_VIS : DAWN_VIR_VIS_ZERO
tmcFrame = -152220;
}
else if (naifIkCode() == -152211) { // (channelId == "IR)
// Frame DAWN_VIR_IR : DAWN_VIR_IR_ZERO
tmcFrame = -152221;
}
else if (naifIkCode() == -152212) {
tmcFrame = -152222;
}
else {
QString msg = "Unknown frame code [" + toString(naifIkCode()) + "] for Chandrayaan2 TMC Camera.";
throw IException(IException::Programmer, msg, _FILEINFO_);
}

instrumentRotation()->SetFrame(tmcFrame);

LoadCache();
NaifStatus::CheckErrors();
}
}


/**
* This is the function that is called in order to instantiate an Chandrayaan2TmcCamera object.
*
* @param cube The input cube from which to instantiate the camera model.
*
* @return Isis::Camera* Chandrayaan2TmcCamera
*
*/
extern "C" Isis::Camera *Chandrayaan2TmcCameraPlugin(Isis::Cube &cube) {
return new Isis::Chandrayaan2TmcCamera(cube);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#ifndef TMCCamera_h
#define TMCCamera_h

/** This is free and unencumbered software released into the public domain.

The authors of ISIS do not claim copyright on the contents of this file.
For more details about the LICENSE terms and the AUTHORS, you will
find files of those names at the top level of this repository. **/

/* SPDX-License-Identifier: CC0-1.0 */

#include "LineScanCamera.h"

namespace Isis {
/**
* @brief Chandrayaan2 TMC (Terrain Mapping Camera) Camera Model
*
* This is the camera model for the Chandrayaan2 Terrain Mapping Camera
*/
class Chandrayaan2TmcCamera : public LineScanCamera {
public:
Chandrayaan2TmcCamera(Cube &cube);

//! Destroys the CTXCamera object.
~Chandrayaan2TmcCamera() {};

/**
* CK frame ID - - Instrument Code from spacit run on CK
*
* @return @b int The appropriate instrument code for the "Camera-matrix"
* Kernel Frame ID
*/
virtual int CkFrameId() const { return (-152001); }

/**
* CK Reference ID - MRO_MME_OF_DATE
*
* @return @b int The appropriate instrument code for the "Camera-matrix"
* Kernel Reference ID
*/
virtual int CkReferenceId() const { return (1); }

/**
* SPK Reference ID - J2000
*
* @return @b int The appropriate instrument code for the Spacecraft
* Kernel Reference ID
*/
virtual int SpkReferenceId() const { return (1); }
};
};
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Unit Test for Chandrayaan1M3Camera...
FileName: out.cub
CK Frame: -152210

Kernel IDs:
CK Frame ID = -152001
CK Reference ID = 1
SPK Target ID = -152
SPK Reference ID = 1

Spacecraft Name Long: Chandrayaan 2
Spacecraft Name Short: Chan2
Instrument Name Long: Terrain Mapping Camera-2
Instrument Name Short: TMC-2

For upper left corner ...
DeltaSample = 0.000000000
DeltaLine = 0.000000000

For upper right corner ...
DeltaSample = 0.000000000
DeltaLine = 0.000000000

For lower left corner ...
DeltaSample = 0.000000000
DeltaLine = 0.000000000

For lower right corner ...
DeltaSample = 0.000000000
DeltaLine = 0.000000000

For center pixel position ...
Latitude OK
Longitude OK
RightAscension = 120.8153761895855354
Declination = -23.1624991236805506
7 changes: 7 additions & 0 deletions isis/src/chandrayaan2/objs/Chandrayaan2TmcCamera/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ifeq ($(ISISROOT), $(BLANK))
.SILENT:
error:
echo "Please set ISISROOT";
else
include $(ISISROOT)/make/isismake.objs
endif
Loading