[1325] | 1 | //#---------------------------------------------------------------------------
|
---|
| 2 | //# FITSreader.cc: ATNF single-dish FITS reader.
|
---|
| 3 | //#---------------------------------------------------------------------------
|
---|
| 4 | //# Copyright (C) 2000-2006
|
---|
| 5 | //# Mark Calabretta, ATNF
|
---|
| 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 this software should be addressed as follows:
|
---|
| 22 | //# Internet email: mcalabre@atnf.csiro.au.
|
---|
| 23 | //# Postal address: Dr. Mark Calabretta,
|
---|
| 24 | //# Australia Telescope National Facility,
|
---|
| 25 | //# P.O. Box 76,
|
---|
| 26 | //# Epping, NSW, 2121,
|
---|
| 27 | //# AUSTRALIA
|
---|
| 28 | //#
|
---|
[1453] | 29 | //# $Id$
|
---|
[1325] | 30 | //#---------------------------------------------------------------------------
|
---|
| 31 | //# The FITSreader class is an abstract base class for the Parkes Multibeam
|
---|
| 32 | //# RPFITS and SDFITS readers.
|
---|
| 33 | //#
|
---|
| 34 | //# Original: 2000/07/28 Mark Calabretta
|
---|
| 35 | //#---------------------------------------------------------------------------
|
---|
| 36 |
|
---|
| 37 | #include <atnf/PKSIO/FITSreader.h>
|
---|
| 38 |
|
---|
| 39 | #include <algorithm>
|
---|
| 40 |
|
---|
| 41 | using namespace std;
|
---|
| 42 |
|
---|
| 43 | //--------------------------------------------------------- FITSreader::select
|
---|
| 44 |
|
---|
| 45 | // Set data selection criteria. Note that cBeams and cIFs, the addresses of
|
---|
| 46 | // int arrays, are returned by open() thereby allowing their elements to be
|
---|
| 47 | // modified directly elsewhere (specifically by PKSFITSreader::select()).
|
---|
| 48 |
|
---|
| 49 | int FITSreader::select(
|
---|
| 50 | const int startChan[],
|
---|
| 51 | const int endChan[],
|
---|
| 52 | const int refChan[],
|
---|
| 53 | const int getSpectra,
|
---|
| 54 | const int getXPol,
|
---|
| 55 | const int getFeedPos)
|
---|
| 56 | {
|
---|
| 57 | int maxNChan = 0;
|
---|
| 58 |
|
---|
| 59 | for (int iIF = 0; iIF < cNIF; iIF++) {
|
---|
| 60 | if (!cIFs[iIF]) {
|
---|
| 61 | continue;
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | cStartChan[iIF] = startChan[iIF];
|
---|
| 65 | cEndChan[iIF] = endChan[iIF];
|
---|
| 66 | cRefChan[iIF] = refChan[iIF];
|
---|
| 67 |
|
---|
| 68 | if (cStartChan[iIF] <= 0) {
|
---|
| 69 | cStartChan[iIF] += cNChan[iIF];
|
---|
| 70 | } else if (cStartChan[iIF] > cNChan[iIF]) {
|
---|
| 71 | cStartChan[iIF] = cNChan[iIF];
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | if (cEndChan[iIF] <= 0) {
|
---|
| 75 | cEndChan[iIF] += cNChan[iIF];
|
---|
| 76 | } else if (cEndChan[iIF] > cNChan[iIF]) {
|
---|
| 77 | cEndChan[iIF] = cNChan[iIF];
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | maxNChan = max(maxNChan, abs(cEndChan[iIF] - cStartChan[iIF]) + 1);
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | cGetSpectra = getSpectra && cHaveSpectra;
|
---|
| 84 | cGetXPol = getXPol && cGetXPol;
|
---|
| 85 | cGetFeedPos = getFeedPos;
|
---|
| 86 |
|
---|
| 87 | return maxNChan;
|
---|
| 88 | }
|
---|