86 m_file.seekg(0, std::ios_base::beg);
90 while (
m_file.read(readBuf, 80) &&
m_file.gcount() == 80) {
100 while (line.substr(0, 3) !=
"END") {
103 if (line.substr(0, 1) !=
" " && line.substr(0, 1) !=
"/") {
109 if (label.name() ==
"COMMENT" || label.name() ==
"HISTORY") {
110 label += line.
ToQt();
114 if (line.substr(0,1) ==
"'") {
124 label += value.
ToQt();
128 if (line.size() > 0) {
130 label.addComment(line.
ToQt());
132 if (line != line.
Token(
"[")) {
155 m_file.seekg(jump, std::ios_base::cur);
165 int bytesPerPixel = 0;
166 bytesPerPixel = (int)((*fitsLabel)[
"BITPIX"]);
167 bytesPerPixel = std::abs(bytesPerPixel);
170 unsigned int axis1 = 1;
171 axis1 =
toInt((*fitsLabel)[
"NAXIS1"]);
173 unsigned int axis2 = 1;
175 axis2 =
toInt((*fitsLabel)[
"NAXIS2"]);
178 unsigned int axis3 = 1;
180 axis3 =
toInt((*fitsLabel)[
"NAXIS3"]);
183 jump = (int)(ceil(bytesPerPixel * axis1 * axis2 * axis3 / 2880.0) * 2880.0);
184 m_file.seekg(jump, std::ios_base::cur);
195 QString msg = QObject::tr(
"The FITS file does not contain a section header that looks "
196 "like it describes an image [%1]").arg(
m_name.toString());
212 QString msg = QObject::tr(
"The requested label number [%1], from file [%2] is "
213 "past the last image in this FITS file. Image count is [%3]").arg(labelNumber).
219 QString msg = QObject::tr(
"The FITS label has not been initialized, call setFitsFile first");
223 QString msg = QObject::tr(
"The requested FITS label number does not exist from file [%1]").arg(
m_name.toString());
227 return *(*m_fitsLabels)[labelNumber];
244 inst +=
PvlKeyword(
"StartTime", fitsLabel[
"DATE-OBS"][0]);
247 inst +=
PvlKeyword(
"Target", fitsLabel[
"OBJECT"][0]);
250 inst +=
PvlKeyword(
"InstrumentId", fitsLabel[
"INSTRUME"][0]);
253 inst +=
PvlKeyword(
"SpacecraftName", fitsLabel[
"OBSERVER"][0]);
270 m_file.open(fitsFile.expanded().toLocal8Bit().constData(), std::ios::in | std::ios::binary);
273 QString msg = QObject::tr(
"Unable to open FITS formatted file [%1]").arg(fitsFile.toString());
282 if (label[
"SIMPLE"][0] ==
"F") {
283 QString msg = QObject::tr(
"The file [%1] can not be processed. It is an unsupported format.").
284 arg(fitsFile.toString());
304 QString msg = QObject::tr(
"The requested label number [%1], from file [%2] is "
305 "past the last image in this FITS file [%3]").arg(labelNumber).
310 PvlGroup label = *(*m_fitsLabels)[labelNumber];
320 switch (
toInt(label[
"BITPIX"][0])) {
322 type = Isis::UnsignedByte;
325 type = Isis::SignedWord;
328 type = Isis::SignedInteger;
334 msg =
"Signed 64 bit integer (long) pixel type is not supported at this time";
341 msg =
"Unknown pixel type [" + label[
"BITPIX"][0] +
"] is not supported for imported";
356 if (
toInt(label[
"NAXIS"][0]) == 2) {
358 toInt(label[
"NAXIS2"][0]), 1);
360 else if (
toInt(label[
"NAXIS"][0]) == 3) {
362 toInt(label[
"NAXIS2"][0]),
toInt(label[
"NAXIS3"][0]));
365 QString msg =
"NAXIS count of [" + label[
"NAXIS"][0] +
"] is not supported at this time";
370 if (
toInt(label[
"NAXIS"][0]) == 2) {
372 1,
toInt(label[
"NAXIS2"][0]));
374 else if (
toInt(label[
"NAXIS"][0]) == 3) {
376 toInt(label[
"NAXIS3"][0]),
toInt(label[
"NAXIS2"][0]));
379 QString msg =
"NAXIS count of [" + label[
"NAXIS"][0] +
"] is not supported at this time";
384 QString msg =
"BIP (Band interleaved by pixel) organization is not supported at this time.";
388 QString msg =
"Unknown organization is not supported.";
ProcessImportFits()
Constructor for ProcessImportFits.
QString ToQt() const
Retuns the object string as a QString.
File name manipulation and expansion.
int SizeOf(Isis::PixelType pixelType)
Returns the number of bytes of the specified PixelType.
int toInt(const QString &string)
Global function to convert from a string to an integer.
Interleave Organization() const
Gets the organization of the input cube.
IString TrimHead(const std::string &chars)
Trims The input characters from the beginning of the object IString.
int DataPrefixBytes() const
This method returns the number of data prefix bytes.
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 FITS labels of choice.
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.
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/count of 2880 byte header records for each header section.
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.
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.
Band Sequential Format (i.e.
Band Interleaved By Pixel Format (i.e.
int DataSuffixBytes() const
This method returns the number of data duffix bytes.
void setFitsFile(FileName fitsFile)
Opens a FITS file and reads the FITS labels.
Adds specific functionality to C++ strings.
void SetMultiplier(const double mult)
Sets the core multiplier of the input cube.
virtual ~ProcessImportFits()
Destructor for ProcessImportFits.
PvlGroup standardInstrumentGroup(PvlGroup fitsLabel) const
Return a populated instrument group.
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...
QList< PvlGroup * > * m_fitsLabels
Holds the PvlGroups with the converted FITS labels from the main and all extensions.
std::ifstream m_file
The stream used to read the FITS file.
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
PvlGroup fitsLabel(int labelNumber) const
Supplies the requested FITS label.
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.