Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALFrame 3.0.7.1-b246709
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
LALFrStreamLegacy.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Duncan Brown, Jolien Creighton, Kipp Cannon
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/* LEGACY CODE */
21
22#include <math.h>
23#include <stdio.h>
24#include <lal/LALStdlib.h>
25#include <lal/Date.h>
26#include <lal/LALCache.h>
27#include <lal/LALFrStream.h>
28
29void
31{
32 LALFrStream *stream;
33
34 XLAL_PRINT_DEPRECATION_WARNING("XLALFrStreamCacheOpen");
39
41 if (!stream) {
42 int errnum = xlalErrno;
44 switch (errnum) {
45 case XLAL_ENOMEM:
47 case XLAL_EIO:
49 default:
51 }
52 }
53
55}
56
57void
59 LALFrStream ** stream, const CHAR * dirname, const CHAR * pattern)
60{
61 XLAL_PRINT_DEPRECATION_WARNING("XLALFrStreamOpen");
66
67 *stream = XLALFrStreamOpen(dirname, pattern);
68
71}
72
73void LALFrClose(LALStatus * status, LALFrStream ** stream)
74{
75 XLAL_PRINT_DEPRECATION_WARNING("XLALFrStreamClose");
79 XLALFrStreamClose(*stream);
80 *stream = NULL;
82}
83
84void LALFrSeek(LALStatus * status, const LIGOTimeGPS * epoch,
85 LALFrStream * stream)
86{
87 CHAR frErrMsg[1024];
88 int code;
89
90 XLAL_PRINT_DEPRECATION_WARNING("XLALFrStreamSeek");
94 if (stream->state & LAL_FR_STREAM_ERR) {
96 }
97
98 code = XLALFrStreamSeek(stream, epoch);
99 if (code < 0) {
101 if (stream->state & LAL_FR_STREAM_ERR) { /* a file error */
102 if (stream->state & LAL_FR_STREAM_URL) { /* must have failed to open a file */
103 snprintf(frErrMsg, XLAL_NUM_ELEM(frErrMsg),
104 "Could not open URL %s\n",
105 stream->cache->list[stream->fnum].url);
106 LALError(status, frErrMsg);
108 }
109 if (stream->state & LAL_FR_STREAM_TOC) { /* must have failed to read a file */
110 snprintf(frErrMsg, XLAL_NUM_ELEM(frErrMsg),
111 "Could not read TOC from %s\n",
112 stream->cache->list[stream->fnum].url);
113 LALError(status, frErrMsg);
115 }
116 } else { /* must be too early, too late, or in a gap */
117
119 }
120 }
121
122 RETURN(status);
123}
124
125/* GET SERIES FUNCTIONS */
126
127#define DEFINE_LAL_GET_TS_FUNCTION(laltype) \
128 void LALFrGet ## laltype ## TimeSeries(LALStatus *status, laltype ## TimeSeries *series, FrChanIn *chanin, LALFrStream *stream) \
129 { \
130 int errnum; \
131 int code; \
132 XLAL_PRINT_DEPRECATION_WARNING("XLALFrStreamGet" #laltype "TimeSeries"); \
133 INITSTATUS(status); \
134 strcpy(series->name, chanin->name); \
135 XLAL_TRY(code = XLALFrStreamGet ## laltype ## TimeSeries(series, stream), errnum); \
136 if ((code < 0) || errnum) { \
137 if (stream->state & LAL_FR_STREAM_END) { \
138 ABORT(status, FRAMESTREAMH_EDONE, FRAMESTREAMH_MSGEDONE); \
139 } \
140 ABORT(status, FRAMESTREAMH_EREAD, FRAMESTREAMH_MSGEREAD); \
141 } \
142 RETURN(status); \
143 }
144
145#define DEFINE_LAL_GET_TSM_FUNCTION(laltype) \
146 void LALFrGet ## laltype ## TimeSeriesMetadata(LALStatus *status, laltype ## TimeSeries *series, FrChanIn *chanin, LALFrStream *stream) \
147 { \
148 int code; \
149 XLAL_PRINT_DEPRECATION_WARNING("XLALFrStreamGet" #laltype "TimeSeriesMetadata"); \
150 INITSTATUS(status); \
151 strcpy(series->name, chanin->name); \
152 code = XLALFrStreamGet ## laltype ## TimeSeriesMetadata(series, stream); \
153 if (code < 0) { \
154 ABORT(status, FRAMESTREAMH_EREAD, FRAMESTREAMH_MSGEREAD); \
155 } \
156 RETURN(status); \
157 }
158
159#define DEFINE_LAL_GET_FS_FUNCTION(laltype) \
160 void LALFrGet ## laltype ## FrequencySeries(LALStatus *status, laltype ## FrequencySeries *series, FrChanIn *chanin, LALFrStream *stream) \
161 { \
162 int code; \
163 XLAL_PRINT_DEPRECATION_WARNING("XLALFrStreamGet" #laltype "FrequencySeries"); \
164 INITSTATUS(status); \
165 strcpy(series->name, chanin->name); \
166 code = XLALFrStreamGet ## laltype ## FrequencySeries(series, stream); \
167 if (code < 0) { \
168 ABORT(status, FRAMESTREAMH_EREAD, FRAMESTREAMH_MSGEREAD); \
169 } \
170 RETURN(status); \
171 }
172
173/* *INDENT-OFF* */
180
187
189/* *INDENT-ON* */
190
191/* WRITE SERIES FUNCTIONS */
192
193/* FIXME: now only supports one frame per file and ProcData channels only */
194#define DEFINE_LAL_WRITE_TS_FUNCTION(laltype) \
195 void LALFrWrite ## laltype ## TimeSeries(LALStatus *status, laltype ## TimeSeries *series, FrOutPar *params) \
196 { \
197 LALFrameH *frame; \
198 char fname[FILENAME_MAX]; \
199 double duration; \
200 int t0, dt; \
201 XLAL_PRINT_DEPRECATION_WARNING("XLALFrWrite" #laltype "TimeSeries"); \
202 INITSTATUS(status); \
203 duration = series->deltaT * series->data->length; \
204 t0 = series->epoch.gpsSeconds; \
205 dt = (int)ceil(XLALGPSGetREAL8(&series->epoch)+duration) - t0; \
206 snprintf(fname, sizeof(fname), "%s-%s-%d-%d.gwf", \
207 params->source ? params->source : "F", \
208 params->description ? params->description : "UNKNOWN", \
209 t0, dt); \
210 frame = XLALFrameNew(&series->epoch, duration, "LAL", params->run, params->frame, 0); \
211 XLALFrameAdd ## laltype ## TimeSeriesProcData(frame, series); \
212 XLALFrameWrite(frame, fname); \
213 XLALFrameFree(frame); \
214 RETURN(status); \
215 }
216
217/* *INDENT-OFF* */
220/* *INDENT-ON* */
#define FRAMESTREAMH_ENULL
Definition: LALFrStream.h:250
#define FRAMESTREAMH_ERROR
Definition: LALFrStream.h:260
#define FRAMESTREAMH_EOPEN
Definition: LALFrStream.h:254
#define FRAMESTREAMH_MSGETREQ
Definition: LALFrStream.h:276
#define FRAMESTREAMH_MSGEREAD
Definition: LALFrStream.h:269
#define FRAMESTREAMH_MSGERROR
Definition: LALFrStream.h:274
#define FRAMESTREAMH_EALOC
Definition: LALFrStream.h:252
#define FRAMESTREAMH_ETREQ
Definition: LALFrStream.h:262
#define FRAMESTREAMH_EREAD
Definition: LALFrStream.h:255
#define FRAMESTREAMH_MSGENNUL
Definition: LALFrStream.h:265
#define FRAMESTREAMH_MSGEALOC
Definition: LALFrStream.h:266
#define FRAMESTREAMH_MSGEOPEN
Definition: LALFrStream.h:268
#define FRAMESTREAMH_MSGENULL
Definition: LALFrStream.h:264
#define FRAMESTREAMH_ENNUL
Definition: LALFrStream.h:251
#define DEFINE_LAL_GET_TS_FUNCTION(laltype)
#define DEFINE_LAL_GET_TSM_FUNCTION(laltype)
void LALFrSeek(LALStatus *status, const LIGOTimeGPS *epoch, LALFrStream *stream)
#define DEFINE_LAL_GET_FS_FUNCTION(laltype)
void LALFrOpen(LALStatus *status, LALFrStream **stream, const CHAR *dirname, const CHAR *pattern)
#define DEFINE_LAL_WRITE_TS_FUNCTION(laltype)
void LALFrCacheOpen(LALStatus *status, LALFrStream **output, LALCache *cache)
void LALFrClose(LALStatus *status, LALFrStream **stream)
#define ABORT(statusptr, code, mesg)
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
#define ABORTXLAL(sp)
#define XLAL_NUM_ELEM(x)
double REAL8
int16_t INT2
int64_t INT8
char CHAR
float complex COMPLEX8
int32_t INT4
float REAL4
int LALError(LALStatus *status, const char *statement)
int XLALFrStreamSeek(LALFrStream *stream, const LIGOTimeGPS *epoch)
Seeks a LALFrStream stream to data at a given time.
Definition: LALFrStream.c:542
int XLALFrStreamClose(LALFrStream *stream)
Closes a LALFrStream.
Definition: LALFrStream.c:170
LALFrStream * XLALFrStreamCacheOpen(LALCache *cache)
Opens a LALFrStream associated with a LALCache.
Definition: LALFrStream.c:189
LALFrStream * XLALFrStreamOpen(const char *dirname, const char *pattern)
Opens a LALFrStream for specified frame files.
Definition: LALFrStream.c:253
@ LAL_FR_STREAM_URL
error opening frame URL
Definition: LALFrStream.h:75
@ LAL_FR_STREAM_ERR
error in frame stream
Definition: LALFrStream.h:72
@ LAL_FR_STREAM_TOC
error reading frame TOC
Definition: LALFrStream.h:76
#define xlalErrno
int XLALClearErrno(void)
#define XLAL_PRINT_DEPRECATION_WARNING(replacement)
XLAL_ENOMEM
XLAL_EIO
string status
code
LALCache * cache
Definition: stream.c:107
CHAR * url
LALCacheEntry * list
This structure details the state of the frame stream.
Definition: LALFrStream.h:95
LALFrStreamState state
Definition: LALFrStream.h:96
LALCache * cache
Definition: LALFrStream.h:99
enum @1 epoch
void output(int gps_sec, int output_type)