source: branches/alma/external/atnf/PKSIO/PKSreader.cc@ 1470

Last change on this file since 1470 was 1453, checked in by TakTsutsumi, 16 years ago

New Development: No

JIRA Issue: No

Ready to Release: Yes

Interface Changes: Yes

What Interface Changed: many

Test Programs: sd.scantable(), sd.scantable.save()

Put in Release Notes: N/A

Description: copied from current casapy code tree


File size: 4.5 KB
RevLine 
[1325]1//#---------------------------------------------------------------------------
2//# PKSreader.cc: Class to read Parkes multibeam data.
3//#---------------------------------------------------------------------------
4//# Copyright (C) 2000-2006
5//# Associated Universities, Inc. Washington DC, USA.
6//#
7//# This library is free software; you can redistribute it and/or modify it
8//# under the terms of the GNU Library General Public License as published by
9//# the Free Software Foundation; either version 2 of the License, or (at your
10//# option) any later version.
11//#
12//# This library is distributed in the hope that it will be useful, but WITHOUT
13//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15//# License for more details.
16//#
17//# You should have received a copy of the GNU Library General Public License
18//# along with this library; if not, write to the Free Software Foundation,
19//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
20//#
21//# Correspondence concerning AIPS++ should be addressed as follows:
22//# Internet email: aips2-request@nrao.edu.
23//# Postal address: AIPS++ Project Office
24//# National Radio Astronomy Observatory
25//# 520 Edgemont Road
26//# Charlottesville, VA 22903-2475 USA
27//#
[1453]28//# $Id$
[1325]29//#---------------------------------------------------------------------------
30//# Original: 2000/08/23, Mark Calabretta, ATNF
31//#---------------------------------------------------------------------------
32
33#include <atnf/PKSIO/PKSreader.h>
34#include <atnf/PKSIO/PKSFITSreader.h>
35
36#ifndef NOPKSMS
37#include <atnf/PKSIO/PKSMS2reader.h>
38#endif
39
40#include <casa/IO/RegularFileIO.h>
41#include <casa/OS/File.h>
42
43
44//--------------------------------------------------------------- getPKSreader
45
46// Return an appropriate PKSreader for a Parkes Multibeam dataset.
47
48PKSreader* getPKSreader(
49 const String name,
50 const Int retry,
51 const Int interpolate,
52 String &format,
53 Vector<Bool> &beams,
54 Vector<Bool> &IFs,
55 Vector<uInt> &nChan,
56 Vector<uInt> &nPol,
57 Vector<Bool> &haveXPol,
58 Bool &haveBase,
59 Bool &haveSpectra)
60{
61 // Check accessibility of the input.
62 File inFile(name);
63 if (!inFile.exists()) {
64 format = "DATASET NOT FOUND";
65 return 0;
66 }
67
68 if (!inFile.isReadable()) {
69 format = "DATASET UNREADABLE";
70 return 0;
71 }
72
73 // Determine the type of input.
74 PKSreader *reader = 0;
75 if (inFile.isRegular()) {
76 // Is it MBFITS or SDFITS?
77 RegularFileIO file(name);
78 char buf[32];
79 file.read(30, buf, False);
80 buf[30] = '\0';
81 if (String(buf) == "SIMPLE = T") {
82 // Looks like SDFITS.
83 format = "SDFITS";
84 reader = new PKSFITSreader("SDFITS");
85
86 } else {
87 // Assume it's MBFITS.
88 format = "MBFITS";
89 reader = new PKSFITSreader("MBFITS", retry, interpolate);
90 }
91
92 } else if (inFile.isDirectory()) {
93 if (File(name + "/DATA_DESCRIPTION").exists()) {
94 // MS version 2.
95 #ifdef NOPKSMS
96 format = "MS2 INPUT FORMAT IS NO LONGER SUPPORTED";
97 #else
98 format = "MS2";
99 reader = new PKSMS2reader();
100 #endif
101 }
102
103 } else {
104 format = "UNRECOGNIZED INPUT FORMAT";
105 }
106
107
108 // Try to open it.
109 if (reader) {
110 if (reader->open(name, beams, IFs, nChan, nPol, haveXPol, haveBase,
111 haveSpectra)) {
112 format += " OPEN ERROR";
113 delete reader;
114 } else {
115 return reader;
116 }
117 }
118
119 return 0;
120}
121
122
123//--------------------------------------------------------------- getPKSreader
124
125// Search a list of directories for a Parkes Multibeam dataset and return an
126// appropriate PKSreader for it.
127
128PKSreader* getPKSreader(
129 const String name,
130 const Vector<String> directories,
131 const Int retry,
132 const Int interpolate,
133 Int &iDir,
134 String &format,
135 Vector<Bool> &beams,
136 Vector<Bool> &IFs,
137 Vector<uInt> &nChan,
138 Vector<uInt> &nPol,
139 Vector<Bool> &haveXPol,
140 Bool &haveBase,
141 Bool &haveSpectra)
142{
143 Int nDir = directories.nelements();
144 for (iDir = 0; iDir < nDir; iDir++) {
145 String inName = directories(iDir) + "/" + name;
146 PKSreader *reader = getPKSreader(inName, retry, interpolate, format,
147 beams, IFs, nChan, nPol, haveXPol,
148 haveBase, haveSpectra);
149 if (reader != 0) {
150 return reader;
151 }
152 }
153
154 iDir = -1;
155 return 0;
156}
Note: See TracBrowser for help on using the repository browser.