source: trunk/src/LineCatalog.cpp@ 1110

Last change on this file since 1110 was 1108, checked in by mar637, 18 years ago

first version which compiles

File size: 1.8 KB
Line 
1
2//
3// C++ Implementation: LineCatalog
4//
5// Description: A class representing a line catalog
6//
7//
8// Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2006
9//
10// Copyright: See COPYING file that comes with this distribution
11//
12//
13
14// std includes
15
16// casa includes
17#include <casa/Exceptions/Error.h>
18#include <casa/OS/Path.h>
19#include <casa/OS/File.h>
20#include <tables/Tables/ReadAsciiTable.h>
21#include <tables/Tables/TableParse.h>
22
23#include "LineCatalog.h"
24
25using namespace casa;
26
27namespace asap
28{
29
30LineCatalog::LineCatalog(const std::string& name)
31{
32 Path path(name);
33 std::string inname = path.expandedName();
34 File f(inname);
35 if (f.isDirectory()) { //assume its a table
36 table_ = Table(inname);
37 } else {
38 String formatString;
39 // formatSring , TableType, ascii file name, TableDesc name, table name, autoheader
40 table_ = readAsciiTable(formatString, Table::Plain, inname, "", "", True);
41 }
42 baseTable_ = table_;
43}
44
45void LineCatalog::setStrengthLimits(float smin, float smax)
46{
47 table_ = setLimits(smin, smax, "Column4");
48}
49
50void LineCatalog::setFrequencyLimits(float fmin, float fmax)
51{
52 table_ = setLimits(fmin, fmax, "Column2");
53}
54
55void LineCatalog::setPattern(const std::string& name, const std::string& stype)
56{
57 std::string mode = stype+"('"+name+"')";
58 std::string taql = "SELECT from $1 WHERE Column1 == "+mode;
59 Table tmp = tableCommand(taql, table_);
60 if (tmp.nrow() > 0) table_ = tmp;
61 else throw(AipsError("No match."));
62}
63
64Table LineCatalog::setLimits(float lmin, float lmax, const std::string& colname)
65{
66 Table tmp = table_(table_.col(colname) > lmin && table_.col(colname) > lmax);
67 if (tmp.nrow() > 0) return tmp;
68 else throw(AipsError("No match."));
69}
70
71void LineCatalog::save(const std::string& name)
72{
73 Path path(name);
74 std::string inname = path.expandedName();
75 table_.deepCopy(inname, Table::New);
76}
77
78} // namespace
Note: See TracBrowser for help on using the repository browser.