8#include "SpectralDefinition2D.h"
13#include "ProcessBySample.h"
31 Cube *smileCube = importCube.SetInputCube(smileDefFilename.expanded(), cai);
35 if (smileCube->lineCount() != 2) {
36 QString msg = QObject::tr(
"Input calibration file [%1] must have 2 lines: "
37 "one containing wavelength centers and one containing widths").
38 arg(smileDefFilename.toString());
45 m_ns = smileCube->sampleCount();
47 m_nb = smileCube->bandCount();
50 importCube.SetProcessingDirection(ProcessByBrick::BandsFirst);
51 importCube.Progress()->SetText(
"Importing Spectral Definition Cube");
52 importCube.ProcessCubeInPlace(*
this,
false);
53 importCube.Finalize();
65 QString msg = QObject::tr(
"Unable to open input cube [%1] and read it into a spectral "
66 "definition.").arg(smileDefFilename.toString());
86 if ( (b >
m_sectionList->at(i)) && (b < m_sectionList->at(i+1)) ) {
114 const int band)
const {
124 Spectel SpectralDefinition2D::findSpectelByWavelength(
const double wavelength,
125 const int sectionNumber)
const {
136 const int sectionNumber)
const {
138 double bestdiff = DBL_MAX;
141 QList<Spectel> *spectrum =
m_spectelList->at(inSpectel.sample()-1);
147 end = spectrum->length();
153 for (
int i=start; i<end; i++) {
154 diff = spectrum->at(i).centerWavelength() - wavelength;
155 if (std::abs(diff) < std::abs(bestdiff)) {
162 return spectrum->at(bestband);
175 for(
int band=0; band<
m_spectelList->at(samp)->size(); band++){
177 temp+=
"Spectel at (s,b) (";
178 temp+= QString::number(samp);
180 temp+= QString::number(band);
181 temp+=
") : Wavelength=";
182 temp+=QString::number(spec.centerWavelength());
184 temp+=QString::number(spec.filterWidth());
198 if (in.Band() == 1) {
199 QList<Spectel> *tempList =
new QList<Spectel>;
204 Spectel temp(in.Sample(), Isis::NULL8, in.Band(), Isis::NULL8, in[0], in[1]);
210 if (in.Sample() == 1) {
213 int index = in.Band() - 1;
217 (((spectrum->at(index-2).centerWavelength() <
218 spectrum->at(index-1).centerWavelength()) &&
219 (spectrum->at(index-1).centerWavelength() >
220 spectrum->at(index).centerWavelength())) ||
221 ((spectrum->at(index-2).centerWavelength() >
222 spectrum->at(index-1).centerWavelength()) &&
223 (spectrum->at(index-1).centerWavelength() <
224 spectrum->at(index).centerWavelength())))) {
Buffer for reading and writing cube data.
IO Handler for Isis Cubes.
File name manipulation and expansion.
@ Unknown
A type of error that cannot be classified as any of the other error types.
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Stores information about a "Spectral pixel" or spectel.
double centerWavelength() const
Gets central wavelength of spectel.
int sectionNumber(int s, int l, int b) const
returns section number given (s,l,b)
int m_numSections
The number of sections of this Spectral Definition.
SpectralDefinition2D(FileName smileDefFilename)
Construct a SpectralDefinition2D object using a filename.
QList< int > * m_sectionList
The list of sections.
QList< QList< Spectel > * > * m_spectelList
Internally represent the samples x 2 lines x n bands calibration file Outside list is the sample inde...
void operator()(Buffer &in) const
Internal function used to help read-in a calibration cube.
QString toString()
Returns QString representation of SpectralDefinition2D.
virtual int sectionCount() const
Returns the number of sections in the calibration image.
Spectel findSpectel(const int sample, const int line, const int band) const
Get the Spectel at some sample, line, band (associated with your input/calibration file)
~SpectralDefinition2D()
destructor
int m_nl
Number of lines in input Cube.
int m_ns
Number of samples in input Cube.
int m_nb
Number of bands in input Cube.
This is free and unencumbered software released into the public domain.