|
Isis 3 Programmer Reference
|
7 #include "ProcessImportFits.h"
16 #include "IException.h"
18 #include "LineManager.h"
19 #include "Preference.h"
22 #include "PixelType.h"
23 #include "SpecialPixel.h"
24 #include "UserInterface.h"
74 m_file.seekg(0, std::ios_base::beg);
78 while (
m_file.read(readBuf, 80) &&
m_file.gcount() == 80) {
88 while (line.substr(0, 3) !=
"END") {
91 if (line.substr(0, 1) !=
" " && line.substr(0, 1) !=
"/") {
94 if (QString::compare(label.
name(),
"OBJECT", Qt::CaseInsensitive) == 0) {
96 label.
addComment(
"NOTE: This keyword name was changed from 'OBJECT' in the original "
102 if (label.
name() ==
"COMMENT" || label.
name() ==
"HISTORY") {
103 label += line.
ToQt();
107 if (line.substr(0,1) ==
"'") {
117 label += value.
ToQt();
121 if (line.size() > 0) {
125 if (line != line.
Token(
"[")) {
148 m_file.seekg(jump, std::ios_base::cur);
159 int bytesPerPixel = 0;
160 bytesPerPixel = (int)((*fitsLabel)[
"BITPIX"]);
161 bytesPerPixel = std::abs(bytesPerPixel);
164 unsigned int axis1 = 1;
165 axis1 =
toInt((*fitsLabel)[
"NAXIS1"]);
167 unsigned int axis2 = 1;
169 axis2 =
toInt((*fitsLabel)[
"NAXIS2"]);
172 unsigned int axis3 = 1;
174 axis3 =
toInt((*fitsLabel)[
"NAXIS3"]);
177 jump = (int)(ceil(bytesPerPixel * axis1 * axis2 * axis3 / 2880.0) * 2880.0);
178 m_file.seekg(jump, std::ios_base::cur);
187 extraLabelGroup->
setName(
"FitsExtras");
205 QString msg = QObject::tr(
"The FITS file does not contain a section header that appears "
226 QString msg = QObject::tr(
"The requested label number [%1], from file [%2] is "
227 "past the last extra group found in this FITS file. "
228 "Extra label count is [%3]").arg(labelNumber).
234 QString msg = QObject::tr(
"The FITS label has not been initialized, "
235 "call setFitsFile() first.");
239 QString msg = QObject::tr(
"The requested FITS label number "
244 return *(*m_extraFitsLabels)[labelNumber];
262 QString msg = QObject::tr(
"The requested label number [%1], from file [%2] is "
263 "past the last image group found in this FITS file. "
264 "Image label count is [%3]").arg(labelNumber).
270 QString msg = QObject::tr(
"The FITS label has not been initialized, "
271 "call setFitsFile first.");
275 QString msg = QObject::tr(
"The requested FITS label number "
280 return *(*m_fitsImageLabels)[labelNumber];
302 inst +=
PvlKeyword(
"StartTime", fitsLabel[
"DATE-OBS"][0]);
305 inst +=
PvlKeyword(
"Target", fitsLabel[
"TARGET"][0]);
308 inst +=
PvlKeyword(
"InstrumentId", fitsLabel[
"INSTRUME"][0]);
311 inst +=
PvlKeyword(
"SpacecraftName", fitsLabel[
"OBSERVER"][0]);
329 m_file.open(fitsFile.
expanded().toLocal8Bit().constData(), std::ios::in | std::ios::binary);
332 QString msg = QObject::tr(
"Unable to open FITS formatted file [%1].")
342 if (label.
hasKeyword(
"SIMPLE") && label[
"SIMPLE"][0] ==
"F") {
343 QString msg = QObject::tr(
"The file [%1] cannot be processed. "
344 "It is an unsupported format.").
366 QString msg = QObject::tr(
"The requested label number [%1], from file [%2] is "
367 "past the last image in this FITS file [%3].").arg(labelNumber).
372 PvlGroup label = *(*m_fitsImageLabels)[labelNumber];
381 switch (
toInt(label[
"BITPIX"][0])) {
383 type = Isis::UnsignedByte;
386 type = Isis::SignedWord;
389 type = Isis::SignedInteger;
395 msg =
"Signed 64-bit integer (long) pixel type is not supported for FITS imports.";
402 msg =
"Unknown pixel type [" + label[
"BITPIX"][0] +
"] is not supported for FITS imports.";
417 if (
toInt(label[
"NAXIS"][0]) == 2) {
420 toInt(label[
"NAXIS2"][0]), 1);
422 else if (
toInt(label[
"NAXIS"][0]) == 3) {
425 toInt(label[
"NAXIS2"][0]),
toInt(label[
"NAXIS3"][0]));
428 QString msg =
"NAXIS count of ["
430 +
"] is not supported for FITS imports.";
435 if (
toInt(label[
"NAXIS"][0]) == 2) {
438 1,
toInt(label[
"NAXIS2"][0]));
440 else if (
toInt(label[
"NAXIS"][0]) == 3) {
443 toInt(label[
"NAXIS3"][0]),
toInt(label[
"NAXIS2"][0]));
446 QString msg =
"NAXIS count of ["
448 +
"] is not supported for FITS imports.";
453 QString msg =
"BIP (Band Interleaved by Pixel) "
454 "organization is not supported for FITS imports.";
458 QString msg =
"Unknown organization is not supported for FITS imports.";
int SizeOf(Isis::PixelType pixelType)
Returns the number of bytes of the specified PixelType.
ProcessImportFits()
Constructor for ProcessImportFits.
QString name() const
Returns the keyword name.
QList< PvlGroup * > * m_fitsImageLabels
Holds the PvlGroups with the converted FITS image labels from the main and all extensions.
A single keyword-value pair.
This is free and unencumbered software released into the public domain.
IString TrimTail(const std::string &chars)
Trims the input characters from the end of the object IString.
void SetBase(const double base)
Sets the core base of the input cube.
QString InputFile()
Sets the name of the input file to be read in the import StartProcess method and verifies its existan...
int DataSuffixBytes() const
This method returns the number of data duffix bytes.
void setName(const QString &name)
Set the name of the container.
void addKeyword(const PvlKeyword &keyword, const InsertMode mode=Append)
Add a keyword to the container.
File name manipulation and expansion.
@ BIL
Band Interleaved By Line Format (i.e.
void setProcessFileStructure(int labelNumber)
Sets the Process file structure parameters based on the given image label index.
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
void setUnits(QString units)
Sets the unit of measure for all current values if any exist.
FileName m_name
The name of the input FITS file.
void setName(QString name)
Sets the keyword name.
void SetDimensions(const int ns, const int nl, const int nb)
Sets the physical size of the input cube.
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Contains multiple PvlContainers.
int DataPrefixBytes() const
This method returns the number of data prefix bytes.
int toInt(const QString &string)
Global function to convert from a string to an integer.
PvlGroup fitsImageLabel(int labelNumber) const
Supplies the FITS image label corresponding to the given index.
void SetInputFile(const QString &file)
Sets the name of the input file to be read in the import StartProcess method and verifies its existan...
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.
void addComment(QString comment)
Add a comment to the PvlKeyword.
QList< int > * m_dataStarts
The starting byte of the data for each image.
void SetPixelType(const Isis::PixelType type)
Sets the pixel type of the input file.
QString toString() const
Returns a QString of the full file name including the file path, excluding the attributes with any Is...
PvlGroup extraFitsLabel(int labelNumber) const
Supplies the extra FITS label corresponding to the given index.
void extractFitsLabels()
Extract all the FITS labels from the file.
PixelType
Enumerations for Isis Pixel Types.
double toDouble(const QString &string)
Global function to convert from a string to a double.
@ Programmer
This error is for when a programmer made an API call that was illegal.
void SetMultiplier(const double mult)
Sets the core multiplier of the input cube.
virtual ~ProcessImportFits()
Destructor for ProcessImportFits.
IString Token(const IString &separator)
Returns the first token in the IString.
void SetByteOrder(const Isis::ByteOrder order)
Sets the byte order of the input file.
@ BSQ
Band Sequential Format (i.e.
void setFitsFile(FileName fitsFile)
Opens a FITS image file with header and reads the FITS labels.
void SetFileHeaderBytes(const int bytes)
This method sets the number of bytes in the header of a file.
Adds specific functionality to C++ strings.
PvlKeyword & findKeyword(const QString &name)
Find a keyword with a specified name.
IString TrimHead(const std::string &chars)
Trims The input characters from the beginning of the object IString.
QList< PvlGroup * > * m_extraFitsLabels
Holds the PvlGroups with the converted extra FITS labels from the main and all extensions.
std::ifstream m_file
The stream used to read the FITS file.
PvlGroup standardInstrumentGroup(PvlGroup fitsLabel) const
Return a PVL instrument group populated with expected default values.
This is free and unencumbered software released into the public domain.
@ BIP
Band Interleaved By Pixel Format (i.e.
QString ToQt() const
Retuns the object string as a QString.
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....