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