source: branches/alma/src/STSelector.h@ 1643

Last change on this file since 1643 was 1639, checked in by Kana Sugimoto, 15 years ago

New Development: Yes

JIRA Issue: Yes (CAS-1429)

Ready to Release: Yes

Interface Changes: Yes

What Interface Changed:
A new python method, selector.set_rows(rownrs=[]),
and a cpp function,
STSelector::setRows( const std::vector< int >& rows ),
are added.
The cpp function can be called with selector._setrows()
from python scripts.

Test Programs:

# @casa
s=sd.scantable('ORIGINAL_TABLE_NAME', False)
sel=sd.selector()
rownrs=[1,3,5,7]
sel.set_rows(rownrs)
s.set_selection(sel)
s2=s.copy()
s2.save(name='NEW_TABLE_NAME',format='ASAP',overwrite=True)

Put in Release Notes: Yes

Module(s):

Description:

Data selection by a list of row numbers can be done by
the new method selector.set_rows.

File size: 2.4 KB
Line 
1//
2// C++ Interface: STSelector
3//
4// Description:
5//
6//
7// Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2006
8//
9// Copyright: See COPYING file that comes with this distribution
10//
11//
12#ifndef ASAPSTSELECTOR_H
13#define ASAPSTSELECTOR_H
14
15#include <string>
16#include <vector>
17#include <map>
18
19#include <casa/Containers/Block.h>
20#include <casa/BasicSL/String.h>
21#include <tables/Tables/Table.h>
22
23namespace asap {
24
25/**
26A class to set a subselection of a Scantable
27
28@author Malte Marquarding
29*/
30class STSelector {
31
32public:
33 STSelector();
34 STSelector(const STSelector& other);
35
36 STSelector& operator=(const STSelector& other);
37
38 virtual ~STSelector();
39
40 void setScans(const std::vector<int>& scans);
41 void setBeams(const std::vector<int>& beams);
42 void setIFs(const std::vector<int>& ifs);
43 void setPolarizations(const std::vector<int>& pols);
44 void setPolFromStrings(const std::vector<std::string>& pols);
45 void setCycles(const std::vector<int>& cycs);
46 void setName(const std::string&);
47 virtual void setTaQL(const std::string& taql);
48
49 void setSortOrder(const std::vector<std::string>& order);
50 void setRows(const std::vector<int>& rows);
51
52 std::vector<int> getScans() const;
53 std::vector<int> getBeams() const;
54 std::vector<int> getIFs() const;
55 std::vector<int> getPols() const;
56 std::vector<int> getCycles() const;
57 std::vector<std::string> getPolTypes() const;
58 std::string getTaQL() const { return taql_; }
59 std::vector<std::string> getSortOrder() const;
60
61 casa::Table apply(const casa::Table& tab);
62 casa::Table operator()(const casa::Table& tab) { return apply(tab); };
63
64 void reset() { intselections_.clear();stringselections_.clear(); taql_ = "";};
65
66 bool empty() const;
67
68 std::string print();
69
70protected:
71 std::vector< int > getint( const std::string& key) const;
72 //std::vector< std::string > getstring( const std::string& key) const;
73
74 void setint(const std::string& key, const std::vector< int >& val);
75 void setstring(const std::string& key, const std::vector< std::string >& val);
76
77private:
78
79 casa::Table sort(const casa::Table& tab);
80
81 typedef std::map<std::string, std::vector<int> > intidmap;
82 typedef std::map<std::string, std::vector<std::string> > stringidmap;
83 // has to be mutable, as to stl limitations
84 mutable intidmap intselections_;
85 mutable stringidmap stringselections_;
86 std::vector<std::string> poltypes_;
87 casa::Block<casa::String> order_;
88 std::string taql_;
89 std::vector<int> rowselection_;
90};
91
92}
93
94#endif
Note: See TracBrowser for help on using the repository browser.