source: branches/plotter2/external-alma/atnf/PKSIO/ASTEDataset.cc@ 2846

Last change on this file since 2846 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
Line 
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
38#define STRING2CHAR(s) const_cast<char *>((s).c_str())
39
40using namespace std ;
41
42// constructor
43ASTEDataset::ASTEDataset( string name )
44 : NRODataset( name )
45{}
46
47// destructor
48ASTEDataset::~ASTEDataset()
49{}
50
51// data initialization
52void ASTEDataset::initialize()
53{
54 int arymax = arrayMax() ;
55
56 // it must be called
57 initializeCommon() ;
58
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
73 + sizeof( char ) * 116 // CDMY1
74 + sizeof( double ) * arymax ; // DSBFC
75}
76
77int ASTEDataset::fillHeader( int sameEndian )
78{
79 LogIO os( LogOrigin( "ASTEDataset", "fillHeader()", WHERE ) ) ;
80
81 int arymax = arrayMax();
82
83 // make sure file pointer points a beginning of the file
84 fseek( fp_, 0, SEEK_SET ) ;
85
86 fillHeaderCommon( sameEndian ) ;
87
88 // specific part
89 CDMY1.resize(116);
90 if ( readHeader( STRING2CHAR(CDMY1), 116 ) == -1 ) {
91 os << LogIO::WARN << "Error while reading data CDMY1." << LogIO::POST ;
92 return -1 ;
93 }
94 // DEBUG
95 //cout << "CDMY1 = " << CDMY1 << endl ;
96 //
97 for ( int i = 0 ; i < arymax ; i++ ) {
98 if ( readHeader( DSBFC[i], sameEndian ) == -1 ) {
99 os << LogIO::WARN << "Error while reading data DSBFC[" << i << "]." << LogIO::POST ;
100 return -1 ;
101 }
102 }
103 // DEBUG
104// nro_debug_output( "DSBFC", arymax, DSBFC ) ;
105 //
106
107 return 0 ;
108}
Note: See TracBrowser for help on using the repository browser.