90 m_file.seekg(0, std::ios_base::beg);
94 while (
m_file.read(readBuf, 80) &&
m_file.gcount() == 80) {
104 while (line.substr(0, 3) !=
"END") {
107 if (line.substr(0, 1) !=
" " && line.substr(0, 1) !=
"/") {
110 if (QString::compare(label.name(),
"OBJECT", Qt::CaseInsensitive) == 0) {
112 label.addComment(
"NOTE: This keyword name was changed from 'OBJECT' in the original " 118 if (label.name() ==
"COMMENT" || label.name() ==
"HISTORY") {
119 label += line.
ToQt();
123 if (line.substr(0,1) ==
"'") {
133 label += value.
ToQt();
137 if (line.size() > 0) {
139 label.addComment(line.
ToQt());
141 if (line != line.
Token(
"[")) {
164 m_file.seekg(jump, std::ios_base::cur);
175 int bytesPerPixel = 0;
176 bytesPerPixel = (int)((*fitsLabel)[
"BITPIX"]);
177 bytesPerPixel = std::abs(bytesPerPixel);
180 unsigned int axis1 = 1;
181 axis1 =
toInt((*fitsLabel)[
"NAXIS1"]);
183 unsigned int axis2 = 1;
185 axis2 =
toInt((*fitsLabel)[
"NAXIS2"]);
188 unsigned int axis3 = 1;
190 axis3 =
toInt((*fitsLabel)[
"NAXIS3"]);
193 jump = (int)(ceil(bytesPerPixel * axis1 * axis2 * axis3 / 2880.0) * 2880.0);
194 m_file.seekg(jump, std::ios_base::cur);
203 extraLabelGroup->
setName(
"FitsExtras");
221 QString msg = QObject::tr(
"The FITS file does not contain a section header that appears " 242 QString msg = QObject::tr(
"The requested label number [%1], from file [%2] is " 243 "past the last extra group found in this FITS file. " 244 "Extra label count is [%3]").arg(labelNumber).
250 QString msg = QObject::tr(
"The FITS label has not been initialized, " 251 "call setFitsFile() first.");
255 QString msg = QObject::tr(
"The requested FITS label number " 260 return *(*m_extraFitsLabels)[labelNumber];
278 QString msg = QObject::tr(
"The requested label number [%1], from file [%2] is " 279 "past the last image group found in this FITS file. " 280 "Image label count is [%3]").arg(labelNumber).
286 QString msg = QObject::tr(
"The FITS label has not been initialized, " 287 "call setFitsFile first.");
291 QString msg = QObject::tr(
"The requested FITS label number " 296 return *(*m_fitsImageLabels)[labelNumber];
318 inst +=
PvlKeyword(
"StartTime", fitsLabel[
"DATE-OBS"][0]);
321 inst +=
PvlKeyword(
"Target", fitsLabel[
"TARGET"][0]);
324 inst +=
PvlKeyword(
"InstrumentId", fitsLabel[
"INSTRUME"][0]);
327 inst +=
PvlKeyword(
"SpacecraftName", fitsLabel[
"OBSERVER"][0]);
345 m_file.open(fitsFile.
expanded().toLocal8Bit().constData(), std::ios::in | std::ios::binary);
348 QString msg = QObject::tr(
"Unable to open FITS formatted file [%1].")
358 if (label.
hasKeyword(
"SIMPLE") && label[
"SIMPLE"][0] ==
"F") {
359 QString msg = QObject::tr(
"The file [%1] cannot be processed. " 360 "It is an unsupported format.").
382 QString msg = QObject::tr(
"The requested label number [%1], from file [%2] is " 383 "past the last image in this FITS file [%3].").arg(labelNumber).
388 PvlGroup label = *(*m_fitsImageLabels)[labelNumber];
397 switch (
toInt(label[
"BITPIX"][0])) {
399 type = Isis::UnsignedByte;
402 type = Isis::SignedWord;
405 type = Isis::SignedInteger;
411 msg =
"Signed 64-bit integer (long) pixel type is not supported for FITS imports.";
418 msg =
"Unknown pixel type [" + label[
"BITPIX"][0] +
"] is not supported for FITS imports.";
433 if (
toInt(label[
"NAXIS"][0]) == 2) {
436 toInt(label[
"NAXIS2"][0]), 1);
438 else if (
toInt(label[
"NAXIS"][0]) == 3) {
441 toInt(label[
"NAXIS2"][0]),
toInt(label[
"NAXIS3"][0]));
444 QString msg =
"NAXIS count of [" 446 +
"] is not supported for FITS imports.";
451 if (
toInt(label[
"NAXIS"][0]) == 2) {
454 1,
toInt(label[
"NAXIS2"][0]));
456 else if (
toInt(label[
"NAXIS"][0]) == 3) {
459 toInt(label[
"NAXIS3"][0]),
toInt(label[
"NAXIS2"][0]));
462 QString msg =
"NAXIS count of [" 464 +
"] is not supported for FITS imports.";
469 QString msg =
"BIP (Band Interleaved by Pixel) " 470 "organization is not supported for FITS imports.";
474 QString msg =
"Unknown organization is not supported for FITS imports.";
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
QList< PvlGroup * > * m_fitsImageLabels
Holds the PvlGroups with the converted FITS image labels from the main and all extensions.
ProcessImportFits()
Constructor for ProcessImportFits.
File name manipulation and expansion.
int SizeOf(Isis::PixelType pixelType)
Returns the number of bytes of the specified PixelType.
int DataSuffixBytes() const
This method returns the number of data duffix bytes.
int toInt(const QString &string)
Global function to convert from a string to an integer.
void setName(QString name)
Sets the keyword name.
IString TrimHead(const std::string &chars)
Trims The input characters from the beginning of the object IString.
void addKeyword(const PvlKeyword &keyword, const InsertMode mode=Append)
Add a keyword to the container.
void setProcessFileStructure(int labelNumber)
Sets the Process file structure parameters based on the given image label index.
double toDouble(const QString &string)
Global function to convert from a string to a double.
This error is for when a programmer made an API call that was illegal.
void setName(const QString &name)
Set the name of the container.
FileName m_name
The name of the input FITS file.
QString InputFile()
Sets the name of the input file to be read in the import StartProcess method and verifies its existan...
void SetDimensions(const int ns, const int nl, const int nb)
Sets the physical size of the input cube.
PixelType
Enumerations for Isis Pixel Types.
IString Token(const IString &separator)
Returns the first token in the IString.
QList< int > * m_headerSizes
The number, or count, of 2880 byte header records for each image header section.
Interleave Organization() const
Gets the organization of the input cube.
Contains multiple PvlContainers.
#define _FILEINFO_
Macro for the filename and line number.
A type of error that could only have occurred due to a mistake on the user's part (e...
A single keyword-value pair.
QString ToQt() const
Retuns the object string as a QString.
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
PvlGroup fitsImageLabel(int labelNumber) const
Supplies the FITS image label corresponding to the given index.
void SetPixelType(const Isis::PixelType type)
Sets the pixel type of the input file.
QList< int > * m_dataStarts
The starting byte of the data for each image.
void extractFitsLabels()
Extract all the FITS labels from the file.
PvlKeyword & findKeyword(const QString &name)
Find a keyword with a specified name.
Band Sequential Format (i.e.
Band Interleaved By Pixel Format (i.e.
PvlGroup extraFitsLabel(int labelNumber) const
Supplies the extra FITS label corresponding to the given index.
QString toString() const
Returns a QString of the full file name including the file path, excluding the attributes with any Is...
int DataPrefixBytes() const
This method returns the number of data prefix bytes.
void setFitsFile(FileName fitsFile)
Opens a FITS image file with header and reads the FITS labels.
Adds specific functionality to C++ strings.
Namespace for ISIS/Bullet specific routines.
void SetMultiplier(const double mult)
Sets the core multiplier of the input cube.
QList< PvlGroup * > * m_extraFitsLabels
Holds the PvlGroups with the converted extra FITS labels from the main and all extensions.
virtual ~ProcessImportFits()
Destructor for ProcessImportFits.
void SetFileHeaderBytes(const int bytes)
This method sets the number of bytes in the header of a file.
void SetBase(const double base)
Sets the core base of the input cube.
void SetInputFile(const QString &file)
Sets the name of the input file to be read in the import StartProcess method and verifies its existan...
PvlGroup standardInstrumentGroup(PvlGroup fitsLabel) const
Return a PVL instrument group populated with expected default values.
std::ifstream m_file
The stream used to read the FITS file.
IString TrimTail(const std::string &chars)
Trims the input characters from the end of the object IString.
void SetByteOrder(const Isis::ByteOrder order)
Sets the byte order of the input file.
Band Interleaved By Line Format (i.e.