9#include "RosettaVirtisCamera.h"
20#include <tnt/tnt_array2d_utils.h>
23#include "CameraFocalPlaneMap.h"
24#include "IException.h"
28#include "LineScanCameraDetectorMap.h"
29#include "LineScanCameraGroundMap.h"
30#include "LineScanCameraSkyMap.h"
31#include "NaifStatus.h"
32#include "NumericalApproximation.h"
54 Pvl &lab = *cube.
label();
56 PvlGroup &inst = lab.findGroup(
"Instrument", Isis::Pvl::Traverse);
60 QString mess =
"This data is apparently not from the VIRTIS instrument but "
62 throw IException(IException::User, mess, _FILEINFO_);
66 int procLevel = inst[
"ProcessingLevelId"];
70 QString channelId = inst[
"ChannelId"];
78 if (channelId ==
"VIRTIS_M_VIS") {
80 virFrame = (hasArtCK) ? -226211 : -226112;
81 frameId =
"ROS_VIRTIS-M_VIS";
83 else if (channelId ==
"VIRTIS_M_IR") {
85 virFrame = (hasArtCK) ? -226213 : -226214;
86 frameId =
"ROS_VIRTIS-M_IR";
99 PvlKeyword &frameParam = inst[
"FrameParameter"];
124 double sampleBoreSight =
getDouble(ikernKey);
127 double lineBoreSight =
getDouble(ikernKey);
156#if defined(DUMP_INFO)
158 cout <<
"Total Records: " << cache.Records() <<
"\n";
160 for (
int i = 0 ; i < cache.Records() ; i++) {
161 TableRecord rec = cache[i];
162 string separator(
"");
163 for (
int f = 0 ; f < rec.Fields() ; f++) {
164 cout << separator << (double) rec[f];
299 std::vector<double> cacheTime;
300 Table hktable(
"VIRTISHouseKeeping", filename);
304 for (
int i = 0; i < hktable.Records(); i++) {
305 TableRecord &trec = hktable[i];
306 QString scetString = trec[
"dataSCET"];
355 Table hktable(
"VIRTISHouseKeeping", filename);
360 for (
int i = 0; i < hktable.Records(); i++) {
361 TableRecord &trec = hktable[i];
362 double scet = (double) trec[
"dataSCET"];
363 int shutterMode = (int) trec[
"Data Type__Shutter state"];
366 double mirrorSin = trec[
"M_MIRROR_SIN_HK"];
367 double mirrorCos = trec[
"M_MIRROR_COS_HK"];
368 double scanElecDeg = atan(mirrorSin/mirrorCos) * dpr_c();
369 double optAng = ((scanElecDeg - 3.7996979) * 0.25/0.257812);
377 bool isDark = (shutterMode == 1);
380 if ( ! isDark ) { angFit.
AddData(lineno, optAng); }
382#if defined(DUMP_INFO)
383 cout <<
"Line(" << ((isDark) ?
"C): " :
"O): ") << i
384 <<
", OptAng(D): " << setprecision(12) << optAng * dpr_c()
385 <<
", MidExpTime(ET): " << lineMidTime
427 for (
unsigned int a = 0 ; a <
m_mirrorData.size() ; a++) {
437 mess <<
"Number housekeeping lines determined (" <<
m_lineRates.size()
438 <<
") is not equal to image lines(" <<
Lines() <<
")";
439 throw IException(IException::Programmer, mess.str(), _FILEINFO_);
455 const int zeroFrame) {
458 TableField q0(
"J2000Q0", TableField::Double);
459 TableField q1(
"J2000Q1", TableField::Double);
460 TableField q2(
"J2000Q2", TableField::Double);
461 TableField q3(
"J2000Q3", TableField::Double);
462 TableField av1(
"AV1", TableField::Double);
463 TableField av2(
"AV2", TableField::Double);
464 TableField av3(
"AV3", TableField::Double);
465 TableField t(
"ET", TableField::Double);
478 Table quats(
"SpiceRotation", record);
479 int nfields = record.Fields();
481 QString virZero = virChannel +
"_ZERO";
484 int nvals = nfields - 1;
487 SpiceDouble eulang[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
488 SpiceDouble xform[6][6], xform2[6][6];
490 SpiceDouble q_av[7], *av(&q_av[4]);
492 for (
int i = 0 ; i < nlines ; i++) {
493 int index = min(i, nlines-1);
502 eul2xf_c(eulang, 1, 2, 3, xform);
503 mxmg_c(xform, &state[0][0], 6, 6, 6, xform2);
506 xf2rav_c(xform2, m, av);
510 for (
int k = 0 ; k < nvals ; k++) {
515 record[nvals] = etTime;
518 catch (IException &ie) {
520 mess <<
"Failed to get point state for line " << i+1;
521 throw IException(ie, IException::User, mess.str(), _FILEINFO_);
528 quats.Label() += PvlKeyword(
"CkTableOriginalSize",
toString(quats.Records()));
531 int virZeroId =
getInteger(
"FRAME_" + virZero);
532 PvlKeyword tdf(
"TimeDependentFrames",
toString(virZeroId));
533 tdf.addValue(
"-226200");
534 tdf.addValue(
"-226000");
536 quats.Label() += tdf;
539 PvlKeyword cf(
"ConstantFrames",
toString(virZeroId));
543 SpiceDouble identity[3][3];
547 PvlKeyword crot(
"ConstantRotation");
548 for (
int i = 0 ; i < 3 ; i++) {
549 for (
int j = 0 ; j < 3 ; j++) {
550 crot.addValue(
toString(identity[i][j]));
554 quats.Label() += crot;
577 const QString &frame2,
578 const double &etTime)
584 sxform_c(frame1.toLatin1().data(), frame2.toLatin1().data(), etTime,
585 (SpiceDouble (*)[6]) state[0]);
588 catch (IException &) {
591 pxform_c(frame1.toLatin1().data(), frame2.toLatin1().data(), etTime,
592 (SpiceDouble (*)[3]) rot[0]);
594 SpiceDouble av[3] = {0.0, 0.0, 0.0 };
595 rav2xf_c((SpiceDouble (*)[3]) rot[0], av,
596 (SpiceDouble (*)[6]) state[0]);
598 catch (IException &ie2) {
600 mess <<
"Could not get state rotation for Frame1 (" << frame1
601 <<
") to Frame2 (" << frame2 <<
") at time " << etTime;
602 throw IException(ie2, IException::User, mess.str(), _FILEINFO_);
626 QRegExp virCk(
"*ROS_VIRTIS_M_????_????_V?.BC");
627 virCk.setPatternSyntax(QRegExp::Wildcard);
628 for (
int i = 0 ; i < cks.size() ; i++) {
629 if ( virCk.exactMatch(cks[i]) )
return (
true);
void SetDetectorSampleSumming(const double summing)
Set sample summing mode.
Distort/undistort focal plane coordinates.
Convert between distorted focal plane and detector coordinates.
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
QString m_spacecraftNameLong
Full spacecraft name.
int Lines() const
Returns the number of lines in the image.
void SetFocalLength()
Reads the focal length from the instrument kernel.
void SetPixelPitch()
Reads the Pixel Pitch from the instrument kernel.
void LoadCache()
This loads the spice cache big enough for this image.
QString m_instrumentNameShort
Shortened instrument name.
QString instrumentId()
This method returns the InstrumentId as it appears in the cube.
QString m_spacecraftNameShort
Shortened spacecraft name.
CameraFocalPlaneMap * FocalPlaneMap()
Returns a pointer to the CameraFocalPlaneMap object.
QString m_instrumentNameLong
Full instrument name.
IO Handler for Isis Cubes.
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Determine SPICE kernels defined in an ISIS file.
QStringList getKernelList(const QString &ktype="") const
Provide a list of all the kernels found.
Container class for storing timing information for a section of an image.
Convert between undistorted focal plane and ground coordinates.
LineScanCamera(Isis::Cube &cube)
Constructs the LineScanCamera object.
LineScanCameraDetectorMap * DetectorMap()
Returns a pointer to the LineScanCameraDetectorMap object.
Convert between undistorted focal plane and ra/dec coordinates.
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
NumericalApproximation provides various numerical analysis methods of interpolation,...
double Evaluate(const double a, const ExtrapType &etype=ThrowError)
Calculates interpolated or extrapolated value of tabulated data set for given domain value.
@ NearestEndpoint
Evaluate() returns the y-value of the nearest endpoint if a is outside of the domain.
void AddData(const double x, const double y)
Add a datapoint to the set.
Camera model for both Rosetta VIRTIS-M instruments.
double startTime() const
Return start time for the entire cube.
double m_scanRate
Line scan rate.
double lineStartTime(const double midExpTime) const
Return the start time for a given line exposure time.
std::vector< ScanMirrorInfo > m_mirrorData
vector of mirror info for each line
double exposureTime() const
Return the exposure time.
RosettaVirtisCamera(Cube &cube)
Creates a camera for a Rosetta VIRTIS-M cube.
std::vector< LineRateChange > m_lineRates
vector of timing info for each line
double endTime() const
Return end time for the entire cube.
virtual int CkReferenceId() const
CK Reference ID - J2000.
int pixelSumming() const
Return the pixel summing rate.
void readHouseKeeping(const QString &filename, double lineRate)
Read the VIRTIS houskeeping table from cube.
int m_summing
Summing/binnning mode.
int hkLineCount() const
Returns number of housekeeping records found in the cube Table.
Table getPointingTable(const QString &channelId, const int zeroFrame)
Compute the pointing table for each line.
TNT::Array2D< SpiceDouble > SMatrix
2-D buffer
bool m_is1BCalibrated
is determined by Archive/ProcessingLevelId
virtual int CkFrameId() const
CK Frame ID - Instrument Code from spacit run on CK.
double scanLineTime() const
Return the line scan rate.
~RosettaVirtisCamera()
Destructor.
virtual int SpkReferenceId() const
SPK Reference ID - J2000.
SMatrix getStateRotation(const QString &frame1, const QString &frame2, const double &et) const
Compute the state rotation at a given time for given frames.
bool hasArticulationKernel(Pvl &label) const
determine if the CK articulation kernels are present/given
double m_exposureTime
Line exposure time.
double lineEndTime(const double midExpTime) const
Return the end time for a given line exposure time.
void readSCET(const QString &filename)
For calibrated VIRTIS-M images, read the SCET values from the cube.
void setTime(const iTime &time)
By setting the time you essential set the position of the spacecraft and body as indicated in the cla...
virtual iTime getClockTime(QString clockValue, int sclkCode=-1, bool clockTicks=false)
This converts the spacecraft clock ticks value (clockValue) to an iTime.
SpiceInt naifSpkCode() const
This returns the NAIF SPK code to use when reading from SPK kernels.
virtual SpiceRotation * instrumentRotation() const
Accessor method for the instrument rotation.
SpiceInt naifIkCode() const
This returns the NAIF IK code to use when reading from instrument kernels.
SpiceDouble getDouble(const QString &key, int index=0)
This returns a value from the NAIF text pool.
SpiceInt getInteger(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Table Cache(const QString &tableName)
Return a table with J2000 to reference rotations.
void LoadCache(double startTime, double endTime, int size)
Cache J2000 rotation quaternion over a time range.
void SetFrame(int frameCode)
Change the frame to the given frame code.
@ No
Do not downsize the cache.
void MinimizeCache(DownsizeStatus status)
Set the downsize status to minimize cache.
Convert between parent image coordinates and detector coordinates.
Parse and return pieces of a time string.
double Et() const
Returns the ephemeris time (TDB) representation of the time as a double.
This is free and unencumbered software released into the public domain.
QString toString(const LinearAlgebra::Vector &vector, int precision)
A global function to format LinearAlgebra::Vector as a QString with the given precision.
Namespace for the standard library.
bool m_isDarkCurrent
If the line is dark current data.
double m_opticalAngle
Optical angle in degrees.
double m_mirrorCos
Raw mirror cosine value.
int m_lineNum
The line the info is for.
double m_scanLineEt
Center of line time in ET.
double m_mirrorSin
Raw mirror sine value.