source: branches/newfiller/external-alma/atnf/PKSIO/PKSreader.cc

Last change on this file was 1757, checked in by Kana Sugimoto, 14 years ago

New Development: Yes

JIRA Issue: Yes (CAS-2211)

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: ASAP 3.0.0 interface changes

Test Programs:

Put in Release Notes: Yes

Module(s): all the CASA sd tools and tasks are affected.

Description: Merged ATNF-ASAP 3.0.0 developments to CASA (alma) branch.

Note you also need to update casa/code/atnf.


File size: 5.9 KB
Line 
1//#---------------------------------------------------------------------------
2//# PKSreader.cc: Class to read Parkes multibeam data.
3//#---------------------------------------------------------------------------
4//# livedata - processing pipeline for single-dish, multibeam spectral data.
5//# Copyright (C) 2000-2009, Australia Telescope National Facility, CSIRO
6//#
7//# This file is part of livedata.
8//#
9//# livedata is free software: you can redistribute it and/or modify it under
10//# the terms of the GNU General Public License as published by the Free
11//# Software Foundation, either version 3 of the License, or (at your option)
12//# any later version.
13//#
14//# livedata is distributed in the hope that it will be useful, but WITHOUT
15//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17//# more details.
18//#
19//# You should have received a copy of the GNU General Public License along
20//# with livedata. If not, see <http://www.gnu.org/licenses/>.
21//#
22//# Correspondence concerning livedata may be directed to:
23//# Internet email: mcalabre@atnf.csiro.au
24//# Postal address: Dr. Mark Calabretta
25//# Australia Telescope National Facility, CSIRO
26//# PO Box 76
27//# Epping NSW 1710
28//# AUSTRALIA
29//#
30//# http://www.atnf.csiro.au/computing/software/livedata.html
31//# $Id: PKSreader.cc,v 19.13 2009-09-29 07:33:39 cal103 Exp $
32//#---------------------------------------------------------------------------
33//# Original: 2000/08/23, Mark Calabretta, ATNF
34//#---------------------------------------------------------------------------
35
36#include <atnf/PKSIO/PKSreader.h>
37#include <atnf/PKSIO/PKSFITSreader.h>
38
39#ifndef NOPKSMS
40#include <atnf/PKSIO/PKSMS2reader.h>
41#endif
42
43#include <casa/IO/RegularFileIO.h>
44#include <casa/OS/File.h>
45
46//--------------------------------------------------------------- getPKSreader
47
48// Return an appropriate PKSreader for a Parkes Multibeam dataset.
49
50PKSreader* getPKSreader(
51 const String name,
52 const Int retry,
53 const Int interpolate,
54 String &format)
55{
56 // Check accessibility of the input.
57 File inFile(name);
58 if (!inFile.exists()) {
59 format = "DATASET NOT FOUND";
60 return 0x0;
61 }
62
63 if (!inFile.isReadable()) {
64 format = "DATASET UNREADABLE";
65 return 0x0;
66 }
67
68 // Determine the type of input.
69 PKSreader *reader = 0x0;
70 if (inFile.isRegular()) {
71 // Is it MBFITS or SDFITS?
72 if (strstr(name.chars(), ".sdfits")) {
73 // Looks like SDFITS, possibly gzip'd.
74 format = "SDFITS";
75 reader = new PKSFITSreader("SDFITS");
76
77 } else {
78 RegularFileIO file(name);
79 char buf[32];
80 file.read(30, buf, False);
81 buf[30] = '\0';
82 if (String(buf) == "SIMPLE = T") {
83 // Looks like SDFITS.
84 format = "SDFITS";
85 reader = new PKSFITSreader("SDFITS");
86
87 } else {
88 // Assume it's MBFITS.
89 format = "MBFITS";
90 reader = new PKSFITSreader("MBFITS", retry, interpolate);
91 }
92 }
93
94 } else if (inFile.isDirectory()) {
95 if (File(name + "/DATA_DESCRIPTION").exists()) {
96 // MS version 2.
97 #ifdef NOPKSMS
98 format = "MS2 INPUT FORMAT IS NO LONGER SUPPORTED";
99 #else
100 format = "MS2";
101 reader = new PKSMS2reader();
102 #endif
103 }
104
105 } else {
106 format = "UNRECOGNIZED INPUT FORMAT";
107 }
108 return reader;
109}
110
111//--------------------------------------------------------------- getPKSreader
112
113// Search a list of directories for a Parkes Multibeam dataset and return an
114
115PKSreader* getPKSreader(
116 const String name,
117 const Vector<String> directories,
118 const Int retry,
119 const Int interpolate,
120 Int &iDir,
121 String &format)
122{
123 PKSreader *reader = 0x0;
124
125 iDir = -1;
126 Int nDir = directories.nelements();
127 for (Int i = 0; i < nDir; i++) {
128 String inName = directories(i) + "/" + name;
129 reader = getPKSreader(inName, retry, interpolate, format);
130 if (reader) {
131 iDir = i;
132 break;
133 }
134 }
135
136 return reader;
137}
138
139//--------------------------------------------------------------- getPKSreader
140
141// Open an appropriate PKSreader for a Parkes Multibeam dataset.
142
143PKSreader* getPKSreader(
144 const String name,
145 const String antenna,
146 const Int retry,
147 const Int interpolate,
148 String &format,
149 Vector<Bool> &beams,
150 Vector<Bool> &IFs,
151 Vector<uInt> &nChan,
152 Vector<uInt> &nPol,
153 Vector<Bool> &haveXPol,
154 Bool &haveBase,
155 Bool &haveSpectra)
156{
157 PKSreader *reader = getPKSreader(name, retry, interpolate, format);
158
159 // Try to open it.
160 if (reader) {
161 if (reader->open(name, antenna, beams, IFs, nChan, nPol, haveXPol,
162 haveBase, haveSpectra)) {
163 format += " OPEN ERROR";
164 delete reader;
165 reader = 0x0;
166 }
167 }
168
169 return reader;
170}
171
172//--------------------------------------------------------------- getPKSreader
173
174// Search a list of directories for a Parkes Multibeam dataset and return an
175// appropriate PKSreader for it.
176PKSreader* getPKSreader(
177 const String name,
178 const String antenna,
179 const Vector<String> directories,
180 const Int retry,
181 const Int interpolate,
182 Int &iDir,
183 String &format,
184 Vector<Bool> &beams,
185 Vector<Bool> &IFs,
186 Vector<uInt> &nChan,
187 Vector<uInt> &nPol,
188 Vector<Bool> &haveXPol,
189 Bool &haveBase,
190 Bool &haveSpectra)
191{
192 PKSreader *reader = getPKSreader(name, directories, retry, interpolate,
193 iDir, format);
194
195 // Try to open it.
196 if (reader) {
197 if (reader->open(name, antenna, beams, IFs, nChan, nPol, haveXPol,
198 haveBase, haveSpectra)) {
199 format += " OPEN ERROR";
200 delete reader;
201 reader = 0x0;
202 }
203 }
204
205 return reader;
206}
Note: See TracBrowser for help on using the repository browser.