27 using std::runtime_error;
31 using namespace hippodraw;
73 vector < string > labels;
74 vector < double > values;
75 m_file -> fillColumnNames ( labels );
76 unsigned int size = labels.size ();
77 for (
unsigned int i = 0;
i <
size;
i++ ) {
78 const string & label = labels [
i];
84 m_dups.push_back ( label );
100 return m_file -> getNumberOfRows ();
108 return dc ->
size ();
117 vector < intptr_t >
shape;
121 std::size_t
size = data_column ->
size ();
122 vector < double > &
data = data_column -> getData ();
123 data.resize ( size );
124 int status =
m_file -> fillDoubleVectorFromColumn ( data, column );
164 if ( data.empty () ) {
172 const vector < double > &
179 const vector < double > &
data = dc -> getData ();
180 if ( data.empty () ) {
188 const std::vector < double > &
205 bool isValid =
true;;
208 if ( data.empty () ) {
211 if ( status != 0 ) isValid =
false;
214 range.
setRange ( data.begin(), data.end() );
224 string what (
"FitsNTuple: The column label `" );
226 what +=
"' already exists in this DataSource.";
227 throw runtime_error ( what );
234 const std::vector < double > &
column )
236 unsigned int size = column.size ();
237 const vector < intptr_t >
shape ( 1, size );
239 return addColumn ( label, column, shape );
247 const std::vector < double > &
column,
248 const std::vector < intptr_t > &
shape )
254 column.empty() == false ) {
255 unsigned int old_size =
rows ();
256 unsigned int new_size = shape[0];
258 if ( old_size != 0 && old_size != new_size ) {
259 string what (
"FitsNTuple Attempt to add a column whose size"
260 " is not equal to other columns." );
261 throw runtime_error ( what );
267 if ( column.empty () == false ) {
281 int size = data.size();
282 const vector < intptr_t >
shape ( 1, size );
290 const std::vector < double > &
data,
291 const std::vector < intptr_t > &
shape )
294 if ( index >= size ) {
295 string what (
"FitsNTuple: Attempt to replace column " );
297 what +=
" with only ";
299 what +=
" columns in data source.";
300 throw runtime_error ( what );
303 unsigned int new_size = data.size ();
304 if ( size != 0 && size != new_size ) {
306 (
"FitsNTuple: Attempt to replace column with one whose "
307 "size is not equal to other columns." );
308 throw runtime_error ( what );
311 vector < double > & pvec = dc -> getData ();
312 pvec.resize ( new_size );
313 std::copy ( data.begin(), data.end (), pvec.begin () );
322 const std::vector < double > &
data,
323 const std::vector < intptr_t > &
shape )
337 const vector < unsigned int > &
virtual double operator[](std::vector< unsigned int > &indices) const
Raises assertion as this method is not yet implemented.
int addColumn(const std::string &label, const std::vector< double > &column)
Adds a column to the end of the FitsNTuple.
virtual void notifyObservers() const
Notifies Observer objects of a change.
FitsFile * m_file
The FitsFile used for this DataSource.
virtual ~FitsNTuple()
The destructor.
int m_hdu_num
The HDU number used for this object.
std::vector< std::string > m_dups
A list of labels that duplicated others in a DataSource file.
virtual double * doubleArrayAt(unsigned int row, unsigned int column) const
Returns data array as double for row and column.
std::size_t size(unsigned int c) const
Returns the the column.
hippodraw::FitsNTuple class interface.
int fillDataCache(unsigned int column)
Fills the data cache for column column.
virtual bool fillRange(unsigned int column, Range &) const
Fills the Range object from data indexed by column.
void initColumns()
Initializes the columns of the DataSource.
void * data(numeric::array arr)
void replaceColumn(unsigned int index, const std::vector< double > &data)
Replaces the data in column index.
virtual void addLabel(const std::string &label)
Adds a new label for a column.
column
The column indices for 2 dimension data point tuple.
virtual void setShape(std::vector< unsigned int > &shape)
Sets the shape of the data elements.
std::vector< intptr_t > shape(numeric::array arr)
bool isValidLabel(const std::string &label) const
Returns true if label is a valid label for a column in the DataSource.
virtual void fillShape(std::vector< intptr_t > &shape, unsigned int index) const
Returns the shape of the column index.
const std::vector< unsigned int > & getShape() const
Returns the shape of the data elements.
The namespace for conversion to string.
virtual void clear()
Clears the data cache; doesn't not modify the contained fits file.
hippodraw::DataColumn class interface.
std::vector< unsigned int > m_shape
The shape of the data.
virtual void reserve(unsigned int count)
Raises assertion as the contained FITS file should not be changed.
virtual const std::vector< double > & getRow(unsigned int) const
Returns a const reference to slice along the axis known as a row.
virtual const std::vector< double > & getColumn(unsigned int c) const
Returns the data of the column.
virtual unsigned int rows() const
Returns the number of rows of FITS ASCII or binary table.
Wrapper class to CFITSIO.
virtual void copy(const DataSource &)
Raises exception because with this release, copying the fits table is not supported.
void checkLabel(const std::string &label)
If label already exists for a column, throw DataSourceException, otherwise do nothing.
bool isValidColumn(unsigned int index) const
Returns true if index is valid, otherwise throws a DataSourceException.
virtual double valueAt(unsigned int row, unsigned int column) const
Returns the value in the table in position given by the row and column indexes.
string convert(int i)
Converts an integer to a string.
void setRange(double low, double high, double pos)
Changes the current Range.
hippodraw::Range class interface
virtual int indexOf(const std::string &label) const
Returns true if the specified column labeled label has been filled.
unsigned int columns() const
Returns the number of columns or data arrays available from this DataSource.
A DataSource class implemented with a vector < DataColumn * > objects.
FitsNTuple()
The default constructor.
A class to hold data and its attributes.
hippodraw::FitsFile interface
Expresses a range of values.
virtual bool empty() const
Returns true, if FitsNTuple is empty, i.e.
void clear()
Clears the data array.
const FitsFile * getFile() const
Returns the FITS file used to create this object.
virtual void notifyObservers() const
Notifies observers.
std::vector< DataColumn * > m_columns
The DataColumn objects that contains the data and its attributes.
std::vector< double > m_array
A temporary array that can be returned by const reference.
Base class for DataSource.