Ignore:
Timestamp:
08/21/13 16:35:22 (11 years ago)
Author:
lyard
Message:
Added error when using wrong fits class and adapted MRawFitsRead to deal with compressed .fz fits
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/mcore/fits.h

    r16935 r17035  
    463463            return it==cols.end() ? 0 : it->second.num;
    464464        }
     465       
     466
    465467
    466468        // There may be a gap between the main table and the start of the heap:
     
    660662                // Check for table name. Skip until eof or requested table are found.
    661663                // skip the current table?
    662                 if (!tableName.empty() && tableName!=fTable.Get<string>("EXTNAME"))
     664                if ((!tableName.empty() &&         tableName!=fTable.Get<string>("EXTNAME")) ||
     665                    ( tableName.empty() && "ZDrsCellOffsets"==fTable.Get<string>("EXTNAME")))
    663666                {
    664667                    const streamoff skip = fTable.GetTotalBytes();
     
    711714    fits(const string &fname, const string& tableName="", bool force=false) : izstream(fname.c_str())
    712715    {
     716        gLog << "Here..." <<endl;
    713717        Constructor(fname, "", tableName, force);
     718        if ((fTable.is_compressed && !force) ||
     719            (fTable.name == "ZDrsCellOffsets" && !force))
     720        {
     721#ifdef __EXCEPTIONS
     722            throw runtime_error("You are trying to read a compressed fits with the base fits class. Please use factfits instead.");
     723#else
     724            gLog << ___err___ << "ERROR - You are trying to read a compressed fits with the base fits class. Please use factfits instead." << endl;
     725#endif
     726            clear(rdstate()|ios::badbit);
     727        }
    714728    }
    715729
    716730    fits(const string &fname, const string &fout, const string& tableName, bool force=false) : izstream(fname.c_str())
    717731    {
     732        gLog << "There..." << endl;
    718733        Constructor(fname, fout, tableName, force);
     734        if ((fTable.is_compressed && !force) ||
     735            (fTable.name == "ZDrsCellOffsets" && !force))
     736        {
     737#ifdef __EXCEPTIONS
     738            throw runtime_error("You are trying to read a compressed fits with the base fits class. Please use factfits instead.");
     739#else
     740            gLog << ___err___ << "ERROR - You are trying to read a compressed fits with the base fits class. Please use factfits instead." << endl;
     741#endif
     742            clear(rdstate()|ios::badbit);
     743        }
     744    }
     745
     746    fits() : izstream()
     747    {
     748
    719749    }
    720750
     
    9991029    }
    10001030
    1001     size_t GetNumRows() const { return fTable.num_rows; }
     1031//    size_t GetNumRows() const { return fTable.num_rows; }
    10021032    size_t GetRow() const { return fRow==(size_t)-1 ? 0 : fRow; }
    10031033
     
    10111041
    10121042    bool IsCompressedFITS() const { return fTable.is_compressed;}
     1043
     1044    virtual size_t GetNumRows() const
     1045    {
     1046        return fTable.Get<size_t>("NAXIS2");
     1047    }
     1048
     1049    virtual size_t GetBytesPerRow() const
     1050    {
     1051        return fTable.Get<size_t>("NAXIS1");
     1052    }
    10131053};
    10141054
Note: See TracChangeset for help on using the changeset viewer.