27 using std::runtime_error;
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 )
325 unsigned int index =
indexOf ( label );
337 const vector < unsigned int > &
virtual double * doubleArrayAt(unsigned int row, unsigned int column) const
Returns data array as double for row and column.
void * data(numeric::array arr)
void setRange(double low, double high, double pos)
Changes the current Range.
virtual const std::vector< double > & getRow(unsigned int) const
Returns a const reference to slice along the axis known as a row.
column
The column indices for 2 dimension data point tuple.
hippodraw::DataColumn class interface.
A DataSource class implemented with a vector < DataColumn * > objects.
A class to hold data and its attributes.
void checkLabel(const std::string &label)
If label already exists for a column, throw DataSourceException, otherwise do nothing.
int fillDataCache(unsigned int column)
Fills the data cache for column column.
virtual void fillShape(std::vector< intptr_t > &shape, unsigned int index) const
Returns the shape of the column index.
void initColumns()
Initializes the columns of the DataSource.
bool isValidColumn(unsigned int index) const
Returns true if index is valid, otherwise throws a DataSourceException.
void clear()
Clears the data array.
int m_hdu_num
The HDU number used for this object.
virtual void setShape(std::vector< unsigned int > &shape)
Sets the shape of the data elements.
virtual void reserve(unsigned int count)
Raises assertion as the contained FITS file should not be changed.
std::vector< double > m_array
A temporary array that can be returned by const reference.
virtual void notifyObservers() const
Notifies Observer objects of a change.
void replaceColumn(unsigned int index, const std::vector< double > &data)
Replaces the data in column index.
const FitsFile * getFile() const
Returns the FITS file used to create this object.
virtual void clear()
Clears the data cache; doesn't not modify the contained fits file.
virtual void copy(const DataSource &)
Raises exception because with this release, copying the fits table is not supported.
hippodraw::Range class interface
bool isValidLabel(const std::string &label) const
Returns true if label is a valid label for a column in the DataSource.
std::size_t size(unsigned int c) const
Returns the the column.
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.
int addColumn(const std::string &label, const std::vector< double > &column)
Adds a column to the end of the FitsNTuple.
std::vector< DataColumn * > m_columns
The DataColumn objects that contains the data and its attributes.
virtual unsigned int rows() const
Returns the number of rows of FITS ASCII or binary table.
std::vector< std::string > m_dups
A list of labels that duplicated others in a DataSource file.
string convert(int i)
Converts an integer to a string.
virtual ~FitsNTuple()
The destructor.
Base class for DataSource.
const std::vector< unsigned int > & getShape() const
Returns the shape of the data elements.
virtual const std::vector< double > & getColumn(unsigned int c) const
Returns the data of the column.
Wrapper class to CFITSIO.
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.
FitsNTuple()
The default constructor.
hippodraw::FitsNTuple class interface.
virtual bool fillRange(unsigned int column, Range &) const
Fills the Range object from data indexed by column.
std::vector< unsigned int > m_shape
The shape of the data.
std::vector< intptr_t > shape(numeric::array arr)
virtual void notifyObservers() const
Notifies observers.
hippodraw::FitsFile interface
The namespace for conversion to string.
virtual void addLabel(const std::string &label)
Adds a new label for a column.
FitsFile * m_file
The FitsFile used for this DataSource.
virtual double operator[](std::vector< unsigned int > &indices) const
Raises assertion as this method is not yet implemented.
Expresses a range of values.
virtual bool empty() const
Returns true, if FitsNTuple is empty, i.e.