8 #ifndef SINGLEDISH_FILLER_SCANTABLEITERATOR_H_
9 #define SINGLEDISH_FILLER_SCANTABLEITERATOR_H_
43 if (current_id != id_prev) {
44 id_max = index_list[i - 1];
45 current_index[0] = id_min;
46 current_index[1] = id_max;
47 range_index[id_prev] = current_index;
54 if (range_index.find(last_id) == range_index.end()) {
55 id_max = index_list[end - 1];
56 current_index[0] = id_min;
57 current_index[1] = id_max;
58 range_index[last_id] = current_index;
69 current_iter_(0), main_table_(table), num_iter_(0) {
78 return current_iter_ < num_iter_;
94 typedef std::map<casacore::Int, casacore::Int>
Product;
98 sub_table_ = header.
asTable(
"FREQUENCIES");
109 ifno_list_.resize(n);
111 ifno_list_[i] = ifno_list[index_vector[i]];
117 id_column_.attach(sub_table_,
"ID");
118 refpix_column_.attach(sub_table_,
"REFPIX");
119 refval_column_.attach(sub_table_,
"REFVAL");
120 increment_column_.attach(sub_table_,
"INCREMENT");
121 id_list_ = id_column_.getColumn();
127 size_t const irow = current_iter_;
135 if (id_list_[i] == freq_id) {
142 casacore::String freq_frame = sub_table_.keywordSet().asString(
"BASEFRAME");
162 product_[spw_id] = num_chan;
166 for (
auto iter = product_.begin(); iter != product_.end(); ++iter) {
167 (*p)[iter->first] = iter->second;
185 typedef std::map<casacore::String, casacore::Int>
Product;
188 main_table_,
"FIELDNAME"), source_column_(main_table_,
"SRCNAME"), time_column_(
189 main_table_,
"TIME"), direction_column_(main_table_,
"SRCDIRECTION"), scanrate_column_(
190 main_table_,
"SCANRATE"), direction_storage_(2, 2, 0.0) {
196 is_reserved_.resize(n);
197 is_reserved_ =
false;
207 auto pos = field_name_with_id.
find(
"__");
208 auto defaultFieldId =
211 while (is_reserved_[my_field_id] && (
casacore::uInt)my_field_id < is_reserved_.size()) {
217 is_reserved_[my_field_id] =
true;
221 record.
name = field_name_with_id.
substr(0, pos);
226 || !is_reserved_[field_id]) {
228 is_reserved_[field_id] =
true;
233 record.
name = field_name_with_id;
236 record.
time = time_column_(irow) * 86400.0;
243 direction_storage_.column(0) = direction_column_(irow);
244 if (scanrate_column_.isDefined(irow)) {
246 if (
anyNE(scan_rate, 0.0)) {
247 direction_storage_.column(1) = scan_rate;
256 product_[field_name_with_id] = record.
field_id;
260 for (
auto iter = product_.begin(); iter != product_.end(); ++iter) {
261 (*p)[iter->first] = iter->second;
283 main_table_,
"SRCDIRECTION"), proper_motion_column_(main_table_,
284 "SRCPROPERMOTION"), sysvel_column_(main_table_,
"SRCVELOCITY"), molecule_id_column_(
285 main_table_,
"MOLECULE_ID"), ifno_column_(main_table_,
"IFNO"), molecules_table_(), row_list_(), source_id_map_() {
287 molecules_table_ = header.
asTable(
"MOLECULES");
288 restfrequency_column_.attach(molecules_table_,
"RESTFREQUENCY");
289 molecule_name_column_.attach(molecules_table_,
"NAME");
298 source_id_map_[name_column_(unique_vector[i])] = (
casacore::Int) i;
301 sorter2.
sortKey(source_name_list.
data(), TpString);
304 num_unique = sorter2.
sort(row_list_, source_name_list.
size(),
310 initialize(num_unique);
316 molecule_id_map_[molecule_id_list[i]] = i;
334 std::vector<size_t> srcname_boundary;
335 srcname_boundary.push_back(0u);
339 if (current != name) {
340 srcname_boundary.push_back(i);
344 srcname_boundary.push_back(nrow_main);
346 constexpr
double kDay2Sec = 86400.0;
347 interval_column.
attach(main_table_,
"INTERVAL");
349 for (
size_t i = 0; i < srcname_boundary.size() - 1; ++i) {
351 size_t start = srcname_boundary[i];
352 size_t end = srcname_boundary[i + 1];
353 std::map<casacore::uInt, casacore::Block<casacore::Double> > range;
354 std::map<casacore::uInt, casacore::Block<casacore::uInt> > range_index;
355 getDataRangePerId(index_list, ifno_list, start, end,
357 for (
auto iter = range_index.begin(); iter != range_index.end(); ++iter) {
360 time_range[0] = time_list[idx[0]] * kDay2Sec
361 - 0.5 * interval_column(idx[0]);
362 time_range[1] = time_list[idx[1]] * kDay2Sec
363 + 0.5 * interval_column(idx[1]);
364 range[iter->first] = time_range;
366 time_range_[
name] = range;
384 record.
name = name_column_(irow);
392 auto iter = molecule_id_map_.find(molecule_id);
393 if (iter != molecule_id_map_.end()) {
395 if (restfrequency_column_.isDefined(jrow)) {
398 if (molecule_name_column_.isDefined(jrow)) {
399 record.
transition = molecule_name_column_(jrow);
442 record.
time = 0.5 * (time_min + time_max);
443 record.
interval = (time_max - time_min);
464 std::map<casacore::String, std::map<casacore::uInt, casacore::Block<casacore::Double> > >
time_range_;
A Vector of integers, for indexing into Array<T> objects.
virtual void getProduct(Product *)
casacore::ScalarColumn< casacore::String > field_column_
A Measure: astronomical direction.
casacore::ScalarColumn< casacore::uInt > id_column_
std::map< casacore::String, casacore::Int > source_id_map_
static Bool getType(MFrequency::Types &tp, const String &in)
Translate string to reference code.
casacore::Int num_chan
mandatory
ScantableSourceIterator(casacore::Table const &table)
static Int toInt(const String &s, Bool chk=False)
Convert a string to an Int, Float or Double.
casacore::Vector< casacore::Double > sysvel
ScantableFieldIterator(casacore::Table const &table)
casacore::ScalarColumn< casacore::Double > time_column_
ScantableIteratorInterface(casacore::Table const &table)
casacore::ArrayColumn< casacore::Double > scanrate_column_
size_t nelements() const
How many elements does this array have? Product of all axis lengths.
Main interface class to a read/write table.
virtual ~ScantableFieldIterator()
casacore::Int source_id
mandatory
casacore::Matrix< casacore::Double > direction
casacore::Vector< casacore::Bool > is_reserved_
casacore::Vector< casacore::String > transition
void getEntry(sdfiller::FieldRecord &record)
IPosition shape(uInt rownr) const
Get the shape of an array in a particular cell.
Table asTable(const RecordFieldId &) const
Get the table from the given field.
casacore::ScalarColumn< casacore::uInt > ifno_column_
casacore::ScalarColumn< casacore::String > source_column_
uInt nrow() const
Get the number of rows in the column.
void getEntry(sdfiller::SpectralWindowRecord &record)
casacore::ScalarColumn< casacore::uInt > molecule_id_column_
A 2-D Specialization of the Array class.
casacore::String source_name
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the if a human readable name(i.e."black").In many places throughout the plotter
const_iterator end() const
Bool anyNE(const TableVector< T > &l, const TableVector< T > &r)
T * data()
Get a pointer to the beginning of the array.
ScantableFrequenciesIterator(casacore::Table const &table)
Sort on one or more keys, ascending and/or descending.
virtual ~ScantableSourceIterator()
void attach(const Table &table, const String &columnName)
Attach a column to the object.
virtual void getProduct(Product *p)
std::map< casacore::String, std::map< casacore::uInt, casacore::Block< casacore::Double > > > time_range_
casacore::ArrayColumn< casacore::String > molecule_name_column_
virtual void getProduct(Product *p)
casacore::ScalarColumn< casacore::Double > increment_column_
casacore::Int field_id
meta
virtual ~ScantableIteratorInterface()
casacore::Vector< casacore::uInt > row_list_
casacore::ScalarColumn< casacore::Double > time_column_
String substr(size_type pos=0, size_type n=npos) const
Get a sub string.
casacore::ScalarColumn< casacore::Double > sysvel_column_
bool Bool
Define the standard types used by Casacore.
casacore::ScalarColumn< casacore::String > name_column_
casacore::ScalarColumn< casacore::Double > refval_column_
casacore::Vector< casacore::Double > rest_frequency
Quantities (i.e. dimensioned values)
casacore::Matrix< casacore::Double > direction_storage_
A hierarchical collection of named fields of various types.
casacore::ArrayColumn< casacore::Double > direction_column_
casacore::Vector< casacore::uInt > id_list_
casacore::ArrayColumn< casacore::Double > direction_column_
casacore::MDirection direction
casacore::Vector< casacore::Double > proper_motion
virtual ~ScantableFrequenciesIterator()
size_type find(const string &str, size_type pos=0) const
Search functions.
casacore::String name
mandatory
casacore::ArrayColumn< casacore::Double > restfrequency_column_
void getEntry(sdfiller::SourceRecord &record)
casacore::Table sub_table_
Base class for all Casacore library errors.
casacore::MDirection::Types frame
casacore::Double interval
std::map< casacore::Int, casacore::Int > Product
String: the storage and methods of handling collections of characters.
std::map< casacore::uInt, casacore::uInt > molecule_id_map_
void initialize(size_t num_iter)
casacore::Vector< casacore::uInt > ifno_list_
casacore::ArrayColumn< casacore::Double > proper_motion_column_
void sortKey(const void *data, DataType, uInt increment=0, Order=Ascending)
Define a sort key (the most significant key should be defined first).
casacore::Table const main_table_
Types
Types of known MFrequencies Warning: The order defines the order in the translation matrix FromTo in...
void resize(size_t len, Bool copyValues=False)
casacore::Double increment
casacore::Table molecules_table_
virtual void reference(const Array< T > &other)
Create a reference to "other", which must be of dimension one.
static const size_type npos
casacore::ScalarColumn< casacore::Double > interval_column_
casacore::ScalarColumn< casacore::Double > refpix_column_
uInt sort(Vector< uInt > &indexVector, uInt nrrec, int options=DefaultSort, Bool tryGenSort=True) const
Sort the data array of nrrec records.
casacore::Int meas_freq_ref
std::map< casacore::String, casacore::Int > Product
void getColumn(Vector< T > &vec, Bool resize=False) const
Get the vector of all values in the column.
#define casacore
<X11/Intrinsic.h> #defines true, false, casacore::Bool, and String.
casacore::Vector< casacore::uInt > row_list_