[casacore] r21249 committed - Issue #47: support BITPIX=8. This is in line with BITPIX=16 now.

0 views
Skip to first unread message

casa...@googlecode.com

unread,
May 17, 2012, 9:39:23 PM5/17/12
to casacor...@googlegroups.com
Revision: 21249
Author: Malte.Marquarding
Date: Thu May 17 18:38:49 2012
Log: Issue #47: support BITPIX=8. This is in line with BITPIX=16 now.
http://code.google.com/p/casacore/source/detail?r=21249

Modified:
/trunk/images/Images/FITS2Image.tcc
/trunk/images/Images/FITSImage.cc
/trunk/images/Images/FITSImage.h
/trunk/images/Images/ImageProxy.cc
/trunk/lattices/Lattices/FITSMask.cc
/trunk/lattices/Lattices/FITSMask.h
/trunk/tables/Tables/TiledFileAccess.cc
/trunk/tables/Tables/TiledFileAccess.h
/trunk/tables/Tables/TiledFileHelper.cc
/trunk/tables/Tables/test/tTiledFileAccess.cc

=======================================
--- /trunk/images/Images/FITS2Image.tcc Tue Oct 18 00:39:05 2011
+++ /trunk/images/Images/FITS2Image.tcc Thu May 17 18:38:49 2012
@@ -49,7 +49,8 @@
void FITSImage::crackHeader (CoordinateSystem& cSys,
IPosition& shape, ImageInfo& imageInfo,
Unit& brightnessUnit, RecordInterface&
miscInfo,
- Float& scale, Float& offset, Short&
magicShort,
+ Float& scale, Float& offset,
+ uChar& magicUChar, Short& magicShort,
Int& magicInt, Bool& hasBlanks,
LogIO& os, FitsInput& infile, uInt whichRep)
{
@@ -100,6 +101,10 @@
if (bitpix != 16) {
throw (AipsError("bitpix card inconsistent with data type:
expected bitpix = 16"));
}
+ } else if (dataType==TpUChar) {
+ if (bitpix != 8) {
+ throw (AipsError("bitpix card inconsistent with data type:
expected bitpix = 8"));
+ }
} else {
throw (AipsError("Unsupported Template type; Float & Double only
are supported"));
}
@@ -121,7 +126,7 @@
scale = s;
offset = o;

-// Will only be present for Int and Short
+// Will only be present for Int and Short and uChar

hasBlanks = False;
if (headerRec.isDefined("blank")) {
@@ -129,11 +134,14 @@
Int m;
subRec.get("value", m);
headerRec.removeField("blank");
- if (dataType==TpShort) {
+ if (dataType==TpUChar) {
+ magicUChar = m;
+ } else if (dataType==TpShort) {
magicShort = m;
} else if (dataType==TpInt) {
magicInt = m;
} else {
+ magicUChar = m;
magicShort = m;
magicInt = m;
}
@@ -199,11 +207,12 @@

template <typename T>
void FITSImage::crackExtHeader (CoordinateSystem& cSys,
- IPosition& shape, ImageInfo& imageInfo,
- Unit& brightnessUnit, RecordInterface&
miscInfo,
- Float& scale, Float& offset, Short&
magicShort,
- Int& magicInt, Bool& hasBlanks,
- LogIO& os, FitsInput& infile, uInt whichRep)
+ IPosition& shape, ImageInfo& imageInfo,
+ Unit& brightnessUnit, RecordInterface& miscInfo,
+ Float& scale, Float& offset, uChar& magicUChar,
+ Short& magicShort,
+ Int& magicInt, Bool& hasBlanks,
+ LogIO& os, FitsInput& infile, uInt whichRep)
{

// Shape
@@ -254,6 +263,10 @@
if (bitpix != 16) {
throw (AipsError("bitpix card inconsistent with data type:
expected bitpix = 16"));
}
+ } else if (dataType==TpUChar) {
+ if (bitpix != 8) {
+ throw (AipsError("bitpix card inconsistent with data type:
expected bitpix = 16"));
+ }
} else {
throw (AipsError("Unsupported Template type; Float & Double only
are supported"));
}
@@ -283,11 +296,14 @@
Int m;
subRec.get("value", m);
headerRec.removeField("blank");
- if (dataType==TpShort) {
+ if (dataType==TpUChar) {
+ magicUChar = m;
+ } else if (dataType==TpShort) {
magicShort = m;
} else if (dataType==TpInt) {
magicInt = m;
} else {
+ magicUChar = m;
magicShort = m;
magicInt = m;
}
=======================================
--- /trunk/images/Images/FITSImage.cc Tue Oct 18 00:39:05 2011
+++ /trunk/images/Images/FITSImage.cc Thu May 17 18:38:49 2012
@@ -71,6 +71,7 @@
scale_p (1.0),
offset_p (0.0),
shortMagic_p (0),
+ uCharMagic_p (0),
longMagic_p (0),
hasBlanks_p (False),
dataType_p (TpOther),
@@ -92,6 +93,7 @@
scale_p (1.0),
offset_p (0.0),
shortMagic_p (0),
+ uCharMagic_p (0),
longMagic_p (0),
hasBlanks_p (False),
dataType_p (TpOther),
@@ -114,6 +116,7 @@
scale_p (other.scale_p),
offset_p (other.offset_p),
shortMagic_p (other.shortMagic_p),
+ uCharMagic_p (other.uCharMagic_p),
longMagic_p (other.longMagic_p),
hasBlanks_p (other.hasBlanks_p),
dataType_p (other.dataType_p),
@@ -150,6 +153,7 @@
scale_p = other.scale_p;
offset_p = other.offset_p;
shortMagic_p = other.shortMagic_p;
+ uCharMagic_p = other.uCharMagic_p;
longMagic_p = other.longMagic_p;
hasBlanks_p = other.hasBlanks_p;
dataType_p = other.dataType_p;
@@ -378,6 +382,9 @@
} else if (pTiledFile_p->dataType() == TpShort) {
pTiledFile_p->get (buffer, section, scale_p, offset_p,
shortMagic_p, hasBlanks_p);
+ } else if (pTiledFile_p->dataType() == TpUChar) {
+ pTiledFile_p->get (buffer, section, scale_p, offset_p,
+ uCharMagic_p, hasBlanks_p);
}
return False; // Not a reference
}
@@ -580,7 +587,8 @@
// hasBlanks only relevant to Integer images. Says if 'blank' value
defined in header

getImageAttributes(cSys, shape, imageInfo, brightnessUnit, miscInfo,
- recsize, recno, dataType, scale_p, offset_p,
shortMagic_p,
+ recsize, recno, dataType, scale_p, offset_p,
+ uCharMagic_p, shortMagic_p,
longMagic_p, hasBlanks_p, fullName, whichRep_p,
whichHDU_p);
setMiscInfoMember (miscInfo);

@@ -611,6 +619,8 @@
dataType_p = TpShort;
} else if (dataType == FITS::LONG) {
dataType_p = TpInt;
+ } else if (dataType == FITS::BYTE) {
+ dataType_p = TpUChar;
}

// See if there is a mask specifier. Defaults to apply mask.
@@ -658,6 +668,9 @@
pPixelMask_p = new FITSMask(&(*pTiledFile_p));
} else if (dataType_p == TpDouble) {
pPixelMask_p = new FITSMask(&(*pTiledFile_p));
+ } else if (dataType_p == TpUChar) {
+ pPixelMask_p = new FITSMask(&(*pTiledFile_p), scale_p, offset_p,
+ uCharMagic_p, hasBlanks_p);
} else if (dataType_p == TpShort) {
pPixelMask_p = new FITSMask(&(*pTiledFile_p), scale_p, offset_p,
shortMagic_p, hasBlanks_p);
@@ -679,7 +692,8 @@
RecordInterface& miscInfo,
Int& recordsize, Int& recordnumber,
FITS::ValueType& dataType,
- Float& scale, Float& offset, Short&
shortMagic,
+ Float& scale, Float& offset,
+ uChar& uCharMagic, Short& shortMagic,
Int& longMagic, Bool& hasBlanks, const
String& name,
uInt whichRep, uInt whichHDU)
{
@@ -720,9 +734,11 @@
// Check type
dataType = infile.datatype();
if (dataType != FITS::FLOAT &&
- dataType != FITS::DOUBLE &&
- dataType != FITS::SHORT &&
- dataType != FITS::LONG) {
+ dataType != FITS::DOUBLE &&
+ dataType != FITS::SHORT &&
+ dataType != FITS::LONG &&
+ dataType != FITS::BYTE)
+ {
throw AipsError("FITS file " + name +
" should contain float, double, short or long data");
}
@@ -753,32 +769,42 @@
{
if (dataType==FITS::FLOAT) {
crackHeader<Float>(cSys, shape, imageInfo, brightnessUnit,
miscInfo, scale,
- offset, shortMagic, longMagic, hasBlanks, os, infile, whichRep);
+ offset, uCharMagic, shortMagic, longMagic, hasBlanks, os, infile,
whichRep);
} else if (dataType==FITS::DOUBLE) {
crackHeader<Double>(cSys, shape, imageInfo, brightnessUnit,
miscInfo, scale,
- offset, shortMagic, longMagic, hasBlanks, os, infile, whichRep);
+ offset, uCharMagic, shortMagic, longMagic, hasBlanks, os, infile,
whichRep);
} else if (dataType==FITS::LONG) {
crackHeader<Int>(cSys, shape, imageInfo, brightnessUnit, miscInfo,
scale,
- offset, shortMagic, longMagic, hasBlanks, os, infile, whichRep);
- } if (dataType==FITS::SHORT) {
- crackHeader<Short>(cSys, shape, imageInfo, brightnessUnit, miscInfo,
scale,
- offset, shortMagic, longMagic, hasBlanks, os, infile, whichRep);
+ offset, uCharMagic, shortMagic, longMagic, hasBlanks, os, infile,
whichRep);
+ } else if (dataType==FITS::SHORT) {
+ crackHeader<Short>(cSys, shape, imageInfo, brightnessUnit,
+ miscInfo, scale, offset, uCharMagic, shortMagic,
+ longMagic, hasBlanks, os, infile, whichRep);
+ } else if (dataType==FITS::BYTE) {
+ crackHeader<uChar>(cSys, shape, imageInfo, brightnessUnit,
+ miscInfo, scale, offset, uCharMagic, shortMagic,
+ longMagic, hasBlanks, os, infile, whichRep);
}
}
else
{
if (dataType==FITS::FLOAT) {
crackExtHeader<Float>(cSys, shape, imageInfo, brightnessUnit,
miscInfo, scale,
- offset, shortMagic, longMagic, hasBlanks, os, infile, whichRep);
+ offset, uCharMagic, shortMagic, longMagic, hasBlanks, os, infile,
whichRep);
} else if (dataType==FITS::DOUBLE) {
crackExtHeader<Double>(cSys, shape, imageInfo, brightnessUnit,
miscInfo, scale,
- offset, shortMagic, longMagic, hasBlanks, os, infile, whichRep);
+ offset, uCharMagic, shortMagic, longMagic, hasBlanks, os, infile,
whichRep);
} else if (dataType==FITS::LONG) {
crackExtHeader<Int>(cSys, shape, imageInfo, brightnessUnit,
miscInfo, scale,
- offset, shortMagic, longMagic, hasBlanks, os, infile, whichRep);
- } if (dataType==FITS::SHORT) {
- crackExtHeader<Short>(cSys, shape, imageInfo, brightnessUnit,
miscInfo, scale,
- offset, shortMagic, longMagic, hasBlanks, os, infile, whichRep);
+ offset, uCharMagic, shortMagic, longMagic, hasBlanks, os, infile,
whichRep);
+ } else if (dataType==FITS::SHORT) {
+ crackExtHeader<Short>(cSys, shape, imageInfo, brightnessUnit,
+ miscInfo, scale, offset, uCharMagic, shortMagic,
+ longMagic, hasBlanks, os, infile, whichRep);
+ } else if (dataType==FITS::BYTE) {
+ crackExtHeader<uChar>(cSys, shape, imageInfo, brightnessUnit,
+ miscInfo, scale, offset, uCharMagic, shortMagic,
+ longMagic, hasBlanks, os, infile, whichRep);
}
}
// }
=======================================
--- /trunk/images/Images/FITSImage.h Tue Oct 18 00:39:05 2011
+++ /trunk/images/Images/FITSImage.h Thu May 17 18:38:49 2012
@@ -262,6 +262,7 @@
Float scale_p;
Float offset_p;
Short shortMagic_p;
+ uChar uCharMagic_p;
Int longMagic_p;
Bool hasBlanks_p;
DataType dataType_p;
@@ -286,7 +287,8 @@
Unit& brightnessUnit, RecordInterface&
miscInfo,
Int& recsize, Int& recno,
FITS::ValueType& dataType,
- Float& scale, Float& offset, Short& shortMagic,
+ Float& scale, Float& offset,
+ uChar& uCharMagic, Short& shortMagic,
Int& longMagic, Bool& hasBlanks, const String&
name,
uInt whichRep, uInt whichHDU);

@@ -294,7 +296,7 @@
template <typename T>
void crackHeader (CoordinateSystem& cSys, IPosition& shape, ImageInfo&
imageInfo,
Unit& brightnessUnit, RecordInterface& miscInfo,
- Float& scale, Float& offset, Short& magicShort,
+ Float& scale, Float& offset, uChar& magicUChar,
Short& magicShort,
Int& magicLong, Bool& hasBlanks, LogIO& os,
FitsInput& infile,
uInt whichRep);

@@ -302,7 +304,8 @@
template <typename T>
void crackExtHeader (CoordinateSystem& cSys, IPosition& shape,
ImageInfo& imageInfo,
Unit& brightnessUnit, RecordInterface& miscInfo,
- Float& scale, Float& offset, Short& magicShort,
+ Float& scale, Float& offset, uChar& uCharMagic,
+ Short& magicShort,
Int& magicLong, Bool& hasBlanks, LogIO& os,
FitsInput& infile,
uInt whichRep);

=======================================
--- /trunk/images/Images/ImageProxy.cc Thu Apr 5 23:04:23 2012
+++ /trunk/images/Images/ImageProxy.cc Thu May 17 18:38:49 2012
@@ -156,6 +156,7 @@
}
}
switch (value.dataType()) {
+ case TpUChar:
case TpShort:
case TpUShort:
case TpInt:
=======================================
--- /trunk/lattices/Lattices/FITSMask.cc Sun Jul 5 22:04:32 2009
+++ /trunk/lattices/Lattices/FITSMask.cc Thu May 17 18:38:49 2012
@@ -45,6 +45,7 @@
: itsTiledFilePtr(tiledFile),
itsScale(1.0),
itsOffset(0.0),
+ itsUCharMagic(0),
itsShortMagic(0),
itsLongMagic(0),
itsHasIntBlanks(False)
@@ -53,12 +54,26 @@
itsTiledFilePtr->dataType()==TpDouble,
AipsError);
}
+
+FITSMask::FITSMask (TiledFileAccess* tiledFile, Float scale, Float offset,
+ uChar magic, Bool hasBlanks)
+: itsTiledFilePtr(tiledFile),
+ itsScale(scale),
+ itsOffset(offset),
+ itsUCharMagic(magic),
+ itsShortMagic(0),
+ itsLongMagic(0),
+ itsHasIntBlanks(hasBlanks)
+{
+ AlwaysAssert(itsTiledFilePtr->dataType()==TpUChar, AipsError);
+}

FITSMask::FITSMask (TiledFileAccess* tiledFile, Float scale, Float offset,
Short magic, Bool hasBlanks)
: itsTiledFilePtr(tiledFile),
itsScale(scale),
itsOffset(offset),
+ itsUCharMagic(0),
itsShortMagic(magic),
itsLongMagic(0),
itsHasIntBlanks(hasBlanks)
@@ -71,6 +86,7 @@
: itsTiledFilePtr(tiledFile),
itsScale(scale),
itsOffset(offset),
+ itsUCharMagic(0),
itsShortMagic(0),
itsLongMagic(magic),
itsHasIntBlanks(hasBlanks)
@@ -84,6 +100,7 @@
itsTiledFilePtr(other.itsTiledFilePtr),
itsScale(other.itsScale),
itsOffset(other.itsOffset),
+ itsUCharMagic(other.itsUCharMagic),
itsShortMagic(other.itsShortMagic),
itsLongMagic(other.itsLongMagic),
itsHasIntBlanks(other.itsHasIntBlanks)
@@ -100,6 +117,7 @@
itsBuffer = other.itsBuffer.copy();
itsScale = other.itsScale;
itsOffset = other.itsOffset;
+ itsUCharMagic = other.itsUCharMagic;
itsShortMagic = other.itsShortMagic;
itsLongMagic = other.itsLongMagic;
itsHasIntBlanks = other.itsHasIntBlanks;
@@ -140,6 +158,9 @@
} else if (itsTiledFilePtr->dataType()==TpShort) {
itsTiledFilePtr->get(itsBuffer, section, itsScale, itsOffset,
itsShortMagic, itsHasIntBlanks);
+ } else if (itsTiledFilePtr->dataType()==TpUChar) {
+ itsTiledFilePtr->get(itsBuffer, section, itsScale, itsOffset,
+ itsUCharMagic, itsHasIntBlanks);
}
//
Bool deletePtrD;
=======================================
--- /trunk/lattices/Lattices/FITSMask.h Tue Nov 30 09:51:10 2004
+++ /trunk/lattices/Lattices/FITSMask.h Thu May 17 18:38:49 2012
@@ -101,6 +101,12 @@
// just copied.
FITSMask (TiledFileAccess* tiledFileAccess);

+ // Constructor (for 8 bit integers). The pointer is not cloned, just
copied
+ // The scale, offset, magic blanking values must come from
+ // the FITS header ('bscale', 'bzero', 'blank')
+ FITSMask (TiledFileAccess* tiledFileAccess, Float scale, Float offset,
+ uChar magic, Bool hasBlanks);
+
// Constructor (for 16 bit integers). The pointer is not cloned, just
copied
// The scale, offset, magic blanking values must come from
// the FITS header ('bscale', 'bzero', 'blank')
@@ -151,6 +157,7 @@
TiledFileAccess* itsTiledFilePtr;
Array<Float> itsBuffer;
Float itsScale, itsOffset;
+ Short itsUCharMagic;
Short itsShortMagic;
Int itsLongMagic;
Bool itsHasIntBlanks;
=======================================
--- /trunk/tables/Tables/TiledFileAccess.cc Wed Feb 3 05:14:15 2010
+++ /trunk/tables/Tables/TiledFileAccess.cc Thu May 17 18:38:49 2012
@@ -90,6 +90,12 @@
get (arr, section);
return arr;
}
+Array<uChar> TiledFileAccess::getUChar (const Slicer& section)
+{
+ Array<uChar> arr;
+ get (arr, section);
+ return arr;
+}
Array<Short> TiledFileAccess::getShort (const Slicer& section)
{
Array<Short> arr;
@@ -140,6 +146,20 @@
itsLocalPixelSize, itsLocalPixelSize, False);
buffer.putStorage (dataPtr, deleteIt);
}
+
+void TiledFileAccess::get (Array<uChar>& buffer, const Slicer& section)
+{
+ AlwaysAssert (itsDataType == TpUChar, AipsError);
+ IPosition start, end, stride;
+ IPosition shp = section.inferShapeFromSource (itsCube->cubeShape(),
+ start, end, stride);
+ buffer.resize (shp);
+ Bool deleteIt;
+ uChar* dataPtr = buffer.getStorage (deleteIt);
+ itsCube->accessStrided (start, end, stride, (char*)dataPtr, 0,
+ itsLocalPixelSize, itsLocalPixelSize, False);
+ buffer.putStorage (dataPtr, deleteIt);
+}

void TiledFileAccess::get (Array<Short>& buffer, const Slicer& section)
{
@@ -228,12 +248,23 @@

Array<Float> TiledFileAccess::getFloat (const Slicer& section,
Float scale, Float offset,
- Short deleteValue, Bool examineForDeleteValues)
+ uChar deleteValue,
+ Bool examineForDeleteValues)
{
Array<Float> arr;
get (arr, section, scale, offset, deleteValue, examineForDeleteValues);
return arr;
}
+
+Array<Float> TiledFileAccess::getFloat (const Slicer& section,
+ Float scale, Float offset,
+ Short deleteValue,
+ Bool examineForDeleteValues)
+{
+ Array<Float> arr;
+ get (arr, section, scale, offset, deleteValue, examineForDeleteValues);
+ return arr;
+}

Array<Float> TiledFileAccess::getFloat (const Slicer& section,
Float scale, Float offset,
@@ -243,6 +274,33 @@
get (arr, section, scale, offset, deleteValue, examineForDeleteValues);
return arr;
}
+
+void TiledFileAccess::get (Array<Float>& buffer, const Slicer& section,
+ Float scale, Float offset, uChar deleteValue,
+ Bool examineForDeleteValues)
+{
+ Array<uChar> arr = getUChar (section);
+ buffer.resize (arr.shape());
+ Bool deleteArr, deleteBuf;
+ const uChar* arrPtr = arr.getStorage (deleteArr);
+ Float* bufPtr = buffer.getStorage (deleteBuf);
+ uInt n = arr.nelements();
+ if (examineForDeleteValues) {
+ for (uInt i=0; i<n; i++) {
+ if (arrPtr[i] == deleteValue) {
+ setNaN (bufPtr[i]);
+ } else {
+ bufPtr[i] = arrPtr[i] * scale + offset;
+ }
+ }
+ } else {
+ for (uInt i=0; i<n; i++) {
+ bufPtr[i] = arrPtr[i] * scale + offset;
+ }
+ }
+ arr.freeStorage (arrPtr, deleteArr);
+ buffer.putStorage (bufPtr, deleteBuf);
+}

void TiledFileAccess::get (Array<Float>& buffer, const Slicer& section,
Float scale, Float offset, Short deleteValue,
@@ -313,6 +371,21 @@
itsLocalPixelSize, itsLocalPixelSize, True);
buffer.freeStorage (dataPtr, deleteIt);
}
+
+void TiledFileAccess::put (const Array<uChar>& buffer, const Slicer&
section)
+{
+ AlwaysAssert (isWritable(), AipsError);
+ AlwaysAssert (itsDataType == TpShort, AipsError);
+ IPosition start, end, stride;
+ IPosition shp = section.inferShapeFromSource (itsCube->cubeShape(),
+ start, end, stride);
+ AlwaysAssert (shp.isEqual (buffer.shape()), AipsError);
+ Bool deleteIt;
+ const uChar* dataPtr = buffer.getStorage (deleteIt);
+ itsCube->accessStrided (start, end, stride, (char*)dataPtr, 0,
+ itsLocalPixelSize, itsLocalPixelSize, True);
+ buffer.freeStorage (dataPtr, deleteIt);
+}

void TiledFileAccess::put (const Array<Short>& buffer, const Slicer&
section)
{
=======================================
--- /trunk/tables/Tables/TiledFileAccess.h Wed Feb 3 05:14:15 2010
+++ /trunk/tables/Tables/TiledFileAccess.h Thu May 17 18:38:49 2012
@@ -122,6 +122,7 @@
// The Array object is resized if needed.
// <group>
Array<Bool> getBool (const Slicer& section);
+ Array<uChar> getUChar (const Slicer& section);
Array<Short> getShort (const Slicer& section);
Array<Int> getInt (const Slicer& section);
Array<Float> getFloat (const Slicer& section);
@@ -129,6 +130,7 @@
Array<Complex> getComplex (const Slicer& section);
Array<DComplex> getDComplex (const Slicer& section);
void get (Array<Bool>&, const Slicer& section);
+ void get (Array<uChar>&, const Slicer& section);
void get (Array<Short>&, const Slicer& section);
void get (Array<Int>&, const Slicer& section);
void get (Array<Float>&, const Slicer& section);
@@ -138,14 +140,19 @@
// </group>

// Get the array and scale/offset the data using the given values.
- // It is meant for FITS, so for now they can only be used for TpShort
+ // It is meant for FITS, so for now they can only be used for TpUChar,
TpShort
// or TpInt TiledFileAccess objects.
// A deleteValue is set to a NaN without being scaled.
// <group>
+ Array<Float> getFloat (const Slicer& section, Float scale, Float offset,
+ uChar deleteValue, Bool examineForDeleteValues=True);
Array<Float> getFloat (const Slicer& section, Float scale, Float offset,
Short deleteValue, Bool examineForDeleteValues=True);
Array<Float> getFloat (const Slicer& section, Float scale, Float offset,
Int deleteValue, Bool examineForDeleteValues=True);
+ void get (Array<Float>&, const Slicer& section,
+ Float scale, Float offset, uChar deleteValue,
+ Bool examineForDeleteValues=True);
void get (Array<Float>&, const Slicer& section,
Float scale, Float offset, Short deleteValue,
Bool examineForDeleteValues=True);
@@ -157,6 +164,7 @@
// Put part of the array.
// <group>
void put (const Array<Bool>&, const Slicer& section);
+ void put (const Array<uChar>&, const Slicer& section);
void put (const Array<Short>&, const Slicer& section);
void put (const Array<Int>&, const Slicer& section);
void put (const Array<Float>&, const Slicer& section);
=======================================
--- /trunk/tables/Tables/TiledFileHelper.cc Wed Feb 3 05:14:15 2010
+++ /trunk/tables/Tables/TiledFileHelper.cc Thu May 17 18:38:49 2012
@@ -56,6 +56,10 @@
itsDesc.addColumn (ArrayColumnDesc<Bool> ("DATA", shape,
ColumnDesc::FixedShape));
break;
+ case TpUChar:
+ itsDesc.addColumn (ArrayColumnDesc<uChar> ("DATA", shape,
+ ColumnDesc::FixedShape));
+ break;
case TpShort:
itsDesc.addColumn (ArrayColumnDesc<Short> ("DATA", shape,
ColumnDesc::FixedShape));
=======================================
--- /trunk/tables/Tables/test/tTiledFileAccess.cc Wed Feb 3 05:14:15 2010
+++ /trunk/tables/Tables/test/tTiledFileAccess.cc Thu May 17 18:38:49 2012
@@ -186,6 +186,40 @@
return 1;
}
}
+
+ // Test for a uChar array written in canonical format.
+ // Read it also back as Float with a scale and offset.
+ {
+ IPosition shape(2,10,10);
+ Array<uChar> arrs(shape);
+ Array<Float> arrf(shape);
+ Float scale = 2;
+ Float offset = 2;
+ indgen(arrs);
+ indgen(arrf, float(2), float(2));
+ {
+ Bool deleteIt;
+ const uChar* dataPtr = arrs.getStorage (deleteIt);
+ RegularFileIO fios(RegularFile("tTiledFileAccess_tmp.dat"),
ByteIO::New);
+ CanonicalIO ios (&fios);
+ ios.write (shape.product(), dataPtr);
+ arrs.freeStorage (dataPtr, deleteIt);
+ }
+ try {
+ Slicer slicer (IPosition(2,0,0), shape);
+ TiledFileAccess tfac ("tTiledFileAccess_tmp.dat", 0, shape,
+ IPosition(2,10,5), TpUChar,
+ TSMOption::Cache, True, True);
+ AlwaysAssertExit (allEQ (arrs, tfac.getUChar (slicer)));
+ AlwaysAssertExit (allEQ (arrf, tfac.getFloat (slicer, scale, offset,
+ uChar(255))));
+ AlwaysAssertExit (tfac.shape() == shape);
+ AlwaysAssertExit (tfac.tileShape() == IPosition(2,10,5));
+ } catch (AipsError x) {
+ cout << "Exception: " << x.getMesg() << endl;
+ return 1;
+ }
+ }

// Test for a Short array written in canonical format.
// Read it also back as Float with a scale and offset.
Reply all
Reply to author
Forward
0 new messages