Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar 7.1.1.1-8a6b96f
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
SetupData.c
Go to the documentation of this file.
1//
2// Copyright (C) 2016, 2017 Karl Wette
3//
4// This program is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation; either version 2 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with with program; see the file COPYING. If not, write to the
16// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17// MA 02110-1301 USA
18//
19
20///
21/// \file
22/// \ingroup lalpulsar_bin_Weave
23///
24
25#include "SetupData.h"
26
27#include <lal/LALInitBarycenter.h>
28#include <lal/FITSPulsarIO.h>
29
30///
31/// \name Internal functions
32///
33/// @{
34
35/// @}
36
37///
38/// Free contents of setup data
39///
41 WeaveSetupData *setup
42)
43{
44 if ( setup != NULL ) {
45 XLALDestroyStringVector( setup->detectors );
46 XLALSegListFree( setup->segments );
47 XLALDestroySuperskyMetrics( setup->metrics );
48 XLALDestroyEphemerisData( setup->ephemerides );
49 }
50}
51
52///
53/// Write setup data to a FITS file
54///
57 const WeaveSetupData *setup
58)
59{
60
61 // Check input
62 XLAL_CHECK( file != NULL, XLAL_EFAULT );
63 XLAL_CHECK( setup != NULL, XLAL_EFAULT );
64 XLAL_CHECK( setup->detectors != NULL, XLAL_EFAULT );
65 XLAL_CHECK( setup->segments != NULL, XLAL_EFAULT );
66 XLAL_CHECK( setup->metrics != NULL, XLAL_EFAULT );
67 XLAL_CHECK( setup->ephemerides != NULL, XLAL_EFAULT );
68
69 // Write reference time
70 XLAL_CHECK( XLALFITSHeaderWriteGPSTime( file, "date-obs", &setup->ref_time, "reference time" ) == XLAL_SUCCESS, XLAL_EFUNC );
71
72 // Write list of detector names
73 XLAL_CHECK( XLALFITSHeaderWriteStringVector( file, "detect", setup->detectors, "setup detectors" ) == XLAL_SUCCESS, XLAL_EFUNC );
74
75 // Write ephemerides
77
78 // Write segment list
79 XLAL_CHECK( XLALFITSWriteSegmentList( file, "segments", setup->segments, "segment list" ) == XLAL_SUCCESS, XLAL_EFUNC );
80
81 // Write supersky metrics
83
84 return XLAL_SUCCESS;
85
86}
87
88///
89/// Read setup data from a FITS file
90///
93 WeaveSetupData *setup
94)
95{
96
97 // Check input
98 XLAL_CHECK( file != NULL, XLAL_EFAULT );
99 XLAL_CHECK( setup != NULL, XLAL_EFAULT );
100
101 // Erase memory
102 XLAL_INIT_MEM( *setup );
103
104 // Read reference time
105 XLAL_CHECK( XLALFITSHeaderReadGPSTime( file, "date-obs", &setup->ref_time ) == XLAL_SUCCESS, XLAL_EFUNC );
106
107 // Read list of detector names
108 XLAL_CHECK( XLALFITSHeaderReadStringVector( file, "detect", &setup->detectors ) == XLAL_SUCCESS, XLAL_EFUNC );
109 XLAL_CHECK( setup->detectors != NULL, XLAL_EFAULT );
110
111 // Read ephemerides
112 XLAL_CHECK( XLALFITSReadEphemerisData( file, &setup->ephemerides ) == XLAL_SUCCESS, XLAL_EFUNC );
113 XLAL_CHECK( setup->ephemerides != NULL, XLAL_EFAULT );
114
115 // Read segment list
116 XLAL_CHECK( XLALFITSReadSegmentList( file, "segments", &setup->segments ) == XLAL_SUCCESS, XLAL_EFUNC );
117 XLAL_CHECK( setup->ephemerides != NULL, XLAL_EFAULT );
118
119 // Read supersky metrics
121 XLAL_CHECK( setup->metrics != NULL, XLAL_EFAULT );
122
123 return XLAL_SUCCESS;
124
125}
126
127// Local Variables:
128// c-file-style: "linux"
129// c-basic-offset: 2
130// End:
int XLALFITSHeaderWriteStringVector(FITSFile UNUSED *file, const CHAR UNUSED *key, const LALStringVector UNUSED *values, const CHAR UNUSED *comment)
Definition: FITSFileIO.c:1412
int XLALFITSHeaderWriteGPSTime(FITSFile UNUSED *file, const CHAR UNUSED *key, const LIGOTimeGPS UNUSED *value, const CHAR UNUSED *comment)
Definition: FITSFileIO.c:1494
int XLALFITSHeaderReadGPSTime(FITSFile UNUSED *file, const CHAR UNUSED *key, LIGOTimeGPS UNUSED *value)
Definition: FITSFileIO.c:1547
int XLALFITSHeaderReadStringVector(FITSFile UNUSED *file, const CHAR UNUSED *key, LALStringVector UNUSED **values)
Definition: FITSFileIO.c:1456
void XLALWeaveSetupDataClear(WeaveSetupData *setup)
Free contents of setup data.
Definition: SetupData.c:40
int XLALWeaveSetupDataWrite(FITSFile *file, const WeaveSetupData *setup)
Write setup data to a FITS file.
Definition: SetupData.c:55
int XLALWeaveSetupDataRead(FITSFile *file, WeaveSetupData *setup)
Read setup data from a FITS file.
Definition: SetupData.c:91
Module which handles the setup data.
struct tagFITSFile FITSFile
Representation of a FITS file.
Definition: FITSFileIO.h:54
int XLALFITSReadEphemerisData(FITSFile *file, EphemerisData **ephemerides)
Read ephemeris data from a FITS file.
Definition: FITSPulsarIO.c:144
int XLALFITSWriteEphemerisData(FITSFile *file, const EphemerisData *ephemerides)
Write ephemeris data to a FITS file.
Definition: FITSPulsarIO.c:106
int XLALFITSWriteSegmentList(FITSFile *file, const CHAR *name, const LALSegList *segments, const CHAR *comment)
Write a segment list to a FITS file.
Definition: FITSPulsarIO.c:37
int XLALFITSReadSegmentList(FITSFile *file, const CHAR *name, LALSegList **segments)
Read a segment list from a FITS file.
Definition: FITSPulsarIO.c:62
void XLALDestroyEphemerisData(EphemerisData *edat)
Destructor for EphemerisData struct, NULL robust.
#define XLAL_INIT_MEM(x)
int XLALSegListFree(LALSegList *seglist)
void XLALDestroyStringVector(LALStringVector *vect)
void XLALDestroySuperskyMetrics(SuperskyMetrics *metrics)
Destroy a SuperskyMetrics struct.
int XLALFITSWriteSuperskyMetrics(FITSFile *file, const SuperskyMetrics *metrics)
Write a SuperskyMetrics struct to a FITS file.
int XLALFITSReadSuperskyMetrics(FITSFile *file, SuperskyMetrics **metrics)
Read a SuperskyMetrics struct from a FITS file.
#define XLAL_CHECK(assertion,...)
XLAL_SUCCESS
XLAL_EFAULT
XLAL_EFUNC