source: trunk/external-alma/atnf/PKSIO/ASTEDataset.cc@ 2937

Last change on this file since 2937 was 2785, checked in by Takeshi Nakazato, 12 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Candidate bug fix for seg. fault on Mac.

File size: 3.7 KB
RevLine 
[1757]1//#---------------------------------------------------------------------------
2//# ASTEDataset.cc: Class for ASTE dataset.
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//#
28//# $Id$
29//#---------------------------------------------------------------------------
30//# Original: 2008/10/30, Takeshi Nakazato, NAOJ
31//#---------------------------------------------------------------------------
32
33#include <atnf/PKSIO/ASTEDataset.h>
34
35#include <iostream>
36#include <cstring>
37
[2785]38#define STRING2CHAR(s) const_cast<char *>((s).c_str())
39
[1757]40using namespace std ;
41
42// constructor
43ASTEDataset::ASTEDataset( string name )
44 : NRODataset( name )
[2782]45{}
[1757]46
47// destructor
48ASTEDataset::~ASTEDataset()
[2782]49{}
[1757]50
51// data initialization
52void ASTEDataset::initialize()
53{
[2782]54 int arymax = arrayMax() ;
[1757]55
[2782]56 // it must be called
[2783]57 initializeCommon() ;
[1757]58
[2782]59 // additional initialization
60 datasize_ += sizeof( char ) * arymax * 16 // RX
61 + sizeof( double ) * arymax * 6 // HPBW, EFFA, EFFB, EFFL, EFSS GAIN
62 + sizeof( char ) * arymax * 4 // HORN
63 + sizeof( char ) * arymax * 4 // POLTP
64 + sizeof( double ) * arymax * 3 // POLDR, POLAN, DFRQ
65 + sizeof( char ) * arymax * 4 // SIDBID
66 + sizeof( int ) * arymax * 3 // REFN, IPINT, MULTN
67 + sizeof( double ) * arymax // MLTSCF
68 + sizeof( char ) * arymax * 8 // LAGWIND
69 + sizeof( double ) * arymax * 3 // BEBW, BERES, CHWID
70 + sizeof( int ) * arymax * 2 // ARRY, NFCAL
71 + sizeof( double ) * arymax // F0CAL
72 + sizeof( double ) * arymax * 10 * 3 // FQCAL, CHCAL, CWCAL
[1757]73 + sizeof( char ) * 116 // CDMY1
[2782]74 + sizeof( double ) * arymax ; // DSBFC
[1757]75}
76
[2782]77int ASTEDataset::fillHeader( int sameEndian )
[1757]78{
79 LogIO os( LogOrigin( "ASTEDataset", "fillHeader()", WHERE ) ) ;
80
[2782]81 int arymax = arrayMax();
[1757]82
83 // make sure file pointer points a beginning of the file
84 fseek( fp_, 0, SEEK_SET ) ;
85
[2783]86 fillHeaderCommon( sameEndian ) ;
87
88 // specific part
[2785]89 CDMY1.resize(116);
90 if ( readHeader( STRING2CHAR(CDMY1), 116 ) == -1 ) {
[1757]91 os << LogIO::WARN << "Error while reading data CDMY1." << LogIO::POST ;
92 return -1 ;
93 }
94 // DEBUG
95 //cout << "CDMY1 = " << CDMY1 << endl ;
96 //
[2782]97 for ( int i = 0 ; i < arymax ; i++ ) {
[1757]98 if ( readHeader( DSBFC[i], sameEndian ) == -1 ) {
99 os << LogIO::WARN << "Error while reading data DSBFC[" << i << "]." << LogIO::POST ;
100 return -1 ;
101 }
102 }
[2436]103 // DEBUG
[2782]104// nro_debug_output( "DSBFC", arymax, DSBFC ) ;
[2436]105 //
[1757]106
107 return 0 ;
108}
Note: See TracBrowser for help on using the repository browser.