Changeset 1757 for branches/alma/external/atnf/PKSIO/PKSreader.cc
- Timestamp:
- 06/09/10 19:03:06 (14 years ago)
- Location:
- branches/alma
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alma
-
Property
svn:ignore
set to
.sconf_temp
.sconsign.dblite
-
Property
svn:mergeinfo
set to
/branches/asap-3.x merged eligible
-
Property
svn:ignore
set to
-
branches/alma/external/atnf/PKSIO/PKSreader.cc
r1453 r1757 2 2 //# PKSreader.cc: Class to read Parkes multibeam data. 3 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 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 13 15 //# 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 //# 28 //# $Id$ 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 $ 29 32 //#--------------------------------------------------------------------------- 30 33 //# Original: 2000/08/23, Mark Calabretta, ATNF … … 41 44 #include <casa/OS/File.h> 42 45 43 44 46 //--------------------------------------------------------------- getPKSreader 45 47 … … 50 52 const Int retry, 51 53 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) 54 String &format) 60 55 { 61 56 // Check accessibility of the input. … … 63 58 if (!inFile.exists()) { 64 59 format = "DATASET NOT FOUND"; 65 return 0 ;60 return 0x0; 66 61 } 67 62 68 63 if (!inFile.isReadable()) { 69 64 format = "DATASET UNREADABLE"; 70 return 0 ;65 return 0x0; 71 66 } 72 67 73 68 // Determine the type of input. 74 PKSreader *reader = 0 ;69 PKSreader *reader = 0x0; 75 70 if (inFile.isRegular()) { 76 71 // 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. 72 if (strstr(name.chars(), ".sdfits")) { 73 // Looks like SDFITS, possibly gzip'd. 83 74 format = "SDFITS"; 84 75 reader = new PKSFITSreader("SDFITS"); 85 76 86 77 } else { 87 // Assume it's MBFITS. 88 format = "MBFITS"; 89 reader = new PKSFITSreader("MBFITS", retry, interpolate); 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 } 90 92 } 91 93 … … 104 106 format = "UNRECOGNIZED INPUT FORMAT"; 105 107 } 106 108 return reader; 109 } 110 111 //--------------------------------------------------------------- getPKSreader 112 113 // Search a list of directories for a Parkes Multibeam dataset and return an 114 115 PKSreader* 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 143 PKSreader* 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); 107 158 108 159 // Try to open it. 109 160 if (reader) { 110 if (reader->open(name, beams, IFs, nChan, nPol, haveXPol, haveBase,111 have Spectra)) {161 if (reader->open(name, antenna, beams, IFs, nChan, nPol, haveXPol, 162 haveBase, haveSpectra)) { 112 163 format += " OPEN ERROR"; 113 164 delete reader; 114 } else { 115 return reader; 116 } 117 } 118 119 return 0; 120 } 121 165 reader = 0x0; 166 } 167 } 168 169 return reader; 170 } 122 171 123 172 //--------------------------------------------------------------- getPKSreader … … 125 174 // Search a list of directories for a Parkes Multibeam dataset and return an 126 175 // appropriate PKSreader for it. 127 128 PKSreader* getPKSreader( 129 const String name,176 PKSreader* getPKSreader( 177 const String name, 178 const String antenna, 130 179 const Vector<String> directories, 131 180 const Int retry, … … 141 190 Bool &haveSpectra) 142 191 { 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 } 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 TracChangeset
for help on using the changeset viewer.