Ignore:
Timestamp:
06/09/10 19:03:06 (14 years ago)
Author:
Kana Sugimoto
Message:

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.


Location:
branches/alma
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/alma

  • branches/alma/external/atnf/PKSIO/PKSreader.cc

    r1453 r1757  
    22//# PKSreader.cc: Class to read Parkes multibeam data.
    33//#---------------------------------------------------------------------------
    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
    1315//# 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 $
    2932//#---------------------------------------------------------------------------
    3033//# Original: 2000/08/23, Mark Calabretta, ATNF
     
    4144#include <casa/OS/File.h>
    4245
    43 
    4446//--------------------------------------------------------------- getPKSreader
    4547
     
    5052        const Int retry,
    5153        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)
    6055{
    6156  // Check accessibility of the input.
     
    6358  if (!inFile.exists()) {
    6459    format = "DATASET NOT FOUND";
    65     return 0;
     60    return 0x0;
    6661  }
    6762
    6863  if (!inFile.isReadable()) {
    6964    format = "DATASET UNREADABLE";
    70     return 0;
     65    return 0x0;
    7166  }
    7267
    7368  // Determine the type of input.
    74   PKSreader *reader = 0;
     69  PKSreader *reader = 0x0;
    7570  if (inFile.isRegular()) {
    7671    // 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.
    8374      format = "SDFITS";
    8475      reader = new PKSFITSreader("SDFITS");
    8576
    8677    } 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       }
    9092    }
    9193
     
    104106    format = "UNRECOGNIZED INPUT FORMAT";
    105107  }
    106 
     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);
    107158
    108159  // Try to open it.
    109160  if (reader) {
    110     if (reader->open(name, beams, IFs, nChan, nPol, haveXPol, haveBase,
    111                      haveSpectra)) {
     161    if (reader->open(name, antenna, beams, IFs, nChan, nPol, haveXPol,
     162                     haveBase, haveSpectra)) {
    112163      format += " OPEN ERROR";
    113164      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}
    122171
    123172//--------------------------------------------------------------- getPKSreader
     
    125174// Search a list of directories for a Parkes Multibeam dataset and return an
    126175// appropriate PKSreader for it.
    127 
    128 PKSreader* getPKSreader(
    129         const String name,
     176PKSreader* getPKSreader(
     177        const String name,
     178        const String antenna,
    130179        const Vector<String> directories,
    131180        const Int retry,
     
    141190        Bool   &haveSpectra)
    142191{
    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.