Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALMetaIO 4.0.6.1-b246709
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
sim_inspiral.c
Go to the documentation of this file.
1/*
2 * sim_inspiral.c
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with with program; see the file COPYING. If not, write to the Free
16 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301 USA
18 */
19
20#include <stdlib.h>
21#include <stdio.h>
22#include <string.h>
23
24
25#include <metaio.h>
26
27
28#include <lal/Date.h>
29#include <lal/LALMalloc.h>
30#include <lal/LIGOLwXML.h>
31#include <lal/LIGOLwXMLRead.h>
32#include <lal/LIGOMetadataTables.h>
33#include <lal/LIGOMetadataUtils.h>
34#include <lal/XLALError.h>
35
36
37/**
38 * Create a SimInspiralTable structure.
39 */
41 const ProcessTable *process
42)
43{
44 SimInspiralTable *new = XLALMalloc(sizeof(*new));
45
46 if(!new)
48
49 new->next = NULL;
50 memset(new->waveform, 0, sizeof(new->waveform));
51 memset(new->source, 0, sizeof(new->source));
52 memset(new->numrel_data, 0, sizeof(new->numrel_data));
53 memset(new->taper, 0, sizeof(new->taper));
54 if(process)
55 new->process_id = process->process_id;
56 else
57 new->process_id = -1; /* impossible */
58 new->simulation_id = -1; /* impossible */
59
60 return new;
61}
62
63
64/**
65 * Destroy a SimInspiralTable structure.
66 */
69)
70{
71 SimInspiralTable *next = row ? row->next : NULL;
72 XLALFree(row);
73 return next;
74}
75
76
77/**
78 * Destroy a SimInspiralTable linked list.
79 */
82)
83{
84 while(head)
86}
87
88
89/**
90 * Assign simulation_id values to the entries in a SimInspiral linked list.
91 * All SimInspiral rows in the list will be blamed on the given process_id,
92 * and assigned sequential simulation_ids starting with the given
93 * simulation_id. The return value is the next simulation_id after the
94 * last one assigned to a row in the list.
95 */
96long
98 SimInspiralTable *head,
99 long process_id,
100 long simulation_id
101)
102{
103 for(; head; head = head->next) {
104 head->process_id = process_id;
105 head->simulation_id = simulation_id++;
106 }
107 return simulation_id;
108}
109
110
111/**
112 * Read the sim_inspiral table from a LIGO Light Weight XML file into a
113 * linked list of SimInspiralTable structures.
114 */
116 const char *filename
117)
118{
119 static const char table_name[] = "sim_inspiral";
120 int miostatus;
121 SimInspiralTable *head = NULL;
122 SimInspiralTable **next = &head;
123 struct MetaioParseEnvironment env;
124 struct {
125 int process_id;
126 int waveform;
127 int geocent_end_time;
128 int geocent_end_time_ns;
129 int h_end_time;
130 int h_end_time_ns;
131 int l_end_time;
132 int l_end_time_ns;
133 int g_end_time;
134 int g_end_time_ns;
135 int t_end_time;
136 int t_end_time_ns;
137 int v_end_time;
138 int v_end_time_ns;
139 int end_time_gmst;
140 int source;
141 int mass1;
142 int mass2;
143 int eta;
144 int distance;
145 int longitude;
146 int latitude;
147 int inclination;
148 int coa_phase;
149 int polarization;
150 int psi0;
151 int psi3;
152 int alpha;
153 int alpha1;
154 int alpha2;
155 int alpha3;
156 int alpha4;
157 int alpha5;
158 int alpha6;
159 int beta;
160 int spin1x;
161 int spin1y;
162 int spin1z;
163 int spin2x;
164 int spin2y;
165 int spin2z;
166 int theta0;
167 int phi0;
168 int f_lower;
169 int f_final;
170 int mchirp;
171 int eff_dist_h;
172 int eff_dist_l;
173 int eff_dist_g;
174 int eff_dist_t;
175 int eff_dist_v;
176 int numrel_mode_min;
177 int numrel_mode_max;
178 int numrel_data;
179 int amp_order;
180 int taper;
181 int bandpass;
182 int simulation_id;
183 } column_pos;
184
185 /* open the file and find table */
186
187 if(MetaioOpenFile(&env, filename)) {
188 XLALPrintError("%s(): error opening \"%s\": %s\n", __func__, filename, env.mierrmsg.data ? env.mierrmsg.data : "unknown reason");
190 }
191 if(MetaioOpenTableOnly(&env, table_name)) {
192 MetaioAbort(&env);
193 XLALPrintError("%s(): cannot find %s table: %s\n", __func__, table_name, env.mierrmsg.data ? env.mierrmsg.data : "unknown reason");
195 }
196
197 /* find columns */
198
200 column_pos.process_id = XLALLIGOLwFindColumn(&env, "process_id", METAIO_TYPE_INT_8S, 1);
201 column_pos.waveform = XLALLIGOLwFindColumn(&env, "waveform", METAIO_TYPE_LSTRING, 1);
202 column_pos.geocent_end_time = XLALLIGOLwFindColumn(&env, "geocent_end_time", METAIO_TYPE_INT_4S, 1);
203 column_pos.geocent_end_time_ns = XLALLIGOLwFindColumn(&env, "geocent_end_time_ns", METAIO_TYPE_INT_4S, 1);
204 column_pos.h_end_time = XLALLIGOLwFindColumn(&env, "h_end_time", METAIO_TYPE_INT_4S, 1);
205 column_pos.h_end_time_ns = XLALLIGOLwFindColumn(&env, "h_end_time_ns", METAIO_TYPE_INT_4S, 1);
206 column_pos.l_end_time = XLALLIGOLwFindColumn(&env, "l_end_time", METAIO_TYPE_INT_4S, 1);
207 column_pos.l_end_time_ns = XLALLIGOLwFindColumn(&env, "l_end_time_ns", METAIO_TYPE_INT_4S, 1);
208 column_pos.g_end_time = XLALLIGOLwFindColumn(&env, "g_end_time", METAIO_TYPE_INT_4S, 1);
209 column_pos.g_end_time_ns = XLALLIGOLwFindColumn(&env, "g_end_time_ns", METAIO_TYPE_INT_4S, 1);
210 column_pos.t_end_time = XLALLIGOLwFindColumn(&env, "t_end_time", METAIO_TYPE_INT_4S, 1);
211 column_pos.t_end_time_ns = XLALLIGOLwFindColumn(&env, "t_end_time_ns", METAIO_TYPE_INT_4S, 1);
212 column_pos.v_end_time = XLALLIGOLwFindColumn(&env, "v_end_time", METAIO_TYPE_INT_4S, 1);
213 column_pos.v_end_time_ns = XLALLIGOLwFindColumn(&env, "v_end_time_ns", METAIO_TYPE_INT_4S, 1);
214 column_pos.end_time_gmst = XLALLIGOLwFindColumn(&env, "end_time_gmst", METAIO_TYPE_REAL_8, 1);
215 column_pos.source = XLALLIGOLwFindColumn(&env, "source", METAIO_TYPE_LSTRING, 1);
216 column_pos.mass1 = XLALLIGOLwFindColumn(&env, "mass1", METAIO_TYPE_REAL_4, 1);
217 column_pos.mass2 = XLALLIGOLwFindColumn(&env, "mass2", METAIO_TYPE_REAL_4, 1);
218 column_pos.eta = XLALLIGOLwFindColumn(&env, "eta", METAIO_TYPE_REAL_4, 1);
219 column_pos.distance = XLALLIGOLwFindColumn(&env, "distance", METAIO_TYPE_REAL_4, 1);
220 column_pos.longitude = XLALLIGOLwFindColumn(&env, "longitude", METAIO_TYPE_REAL_4, 1);
221 column_pos.latitude = XLALLIGOLwFindColumn(&env, "latitude", METAIO_TYPE_REAL_4, 1);
222 column_pos.inclination = XLALLIGOLwFindColumn(&env, "inclination", METAIO_TYPE_REAL_4, 1);
223 column_pos.coa_phase = XLALLIGOLwFindColumn(&env, "coa_phase", METAIO_TYPE_REAL_4, 1);
224 column_pos.polarization = XLALLIGOLwFindColumn(&env, "polarization", METAIO_TYPE_REAL_4, 1);
225 column_pos.psi0 = XLALLIGOLwFindColumn(&env, "psi0", METAIO_TYPE_REAL_4, 1);
226 column_pos.psi3 = XLALLIGOLwFindColumn(&env, "psi3", METAIO_TYPE_REAL_4, 1);
227 column_pos.alpha = XLALLIGOLwFindColumn(&env, "alpha", METAIO_TYPE_REAL_4, 1);
228 column_pos.alpha1 = XLALLIGOLwFindColumn(&env, "alpha1", METAIO_TYPE_REAL_4, 1);
229 column_pos.alpha2 = XLALLIGOLwFindColumn(&env, "alpha2", METAIO_TYPE_REAL_4, 1);
230 column_pos.alpha3 = XLALLIGOLwFindColumn(&env, "alpha3", METAIO_TYPE_REAL_4, 1);
231 column_pos.alpha4 = XLALLIGOLwFindColumn(&env, "alpha4", METAIO_TYPE_REAL_4, 1);
232 column_pos.alpha5 = XLALLIGOLwFindColumn(&env, "alpha5", METAIO_TYPE_REAL_4, 1);
233 column_pos.alpha6 = XLALLIGOLwFindColumn(&env, "alpha6", METAIO_TYPE_REAL_4, 1);
234 column_pos.beta = XLALLIGOLwFindColumn(&env, "beta", METAIO_TYPE_REAL_4, 1);
235 column_pos.spin1x = XLALLIGOLwFindColumn(&env, "spin1x", METAIO_TYPE_REAL_4, 1);
236 column_pos.spin1y = XLALLIGOLwFindColumn(&env, "spin1y", METAIO_TYPE_REAL_4, 1);
237 column_pos.spin1z = XLALLIGOLwFindColumn(&env, "spin1z", METAIO_TYPE_REAL_4, 1);
238 column_pos.spin2x = XLALLIGOLwFindColumn(&env, "spin2x", METAIO_TYPE_REAL_4, 1);
239 column_pos.spin2y = XLALLIGOLwFindColumn(&env, "spin2y", METAIO_TYPE_REAL_4, 1);
240 column_pos.spin2z = XLALLIGOLwFindColumn(&env, "spin2z", METAIO_TYPE_REAL_4, 1);
241 column_pos.theta0 = XLALLIGOLwFindColumn(&env, "theta0", METAIO_TYPE_REAL_4, 1);
242 column_pos.phi0 = XLALLIGOLwFindColumn(&env, "phi0", METAIO_TYPE_REAL_4, 1);
243 column_pos.f_lower = XLALLIGOLwFindColumn(&env, "f_lower", METAIO_TYPE_REAL_4, 1);
244 column_pos.f_final = XLALLIGOLwFindColumn(&env, "f_final", METAIO_TYPE_REAL_4, 1);
245 column_pos.mchirp = XLALLIGOLwFindColumn(&env, "mchirp", METAIO_TYPE_REAL_4, 1);
246 column_pos.eff_dist_h = XLALLIGOLwFindColumn(&env, "eff_dist_h", METAIO_TYPE_REAL_4, 1);
247 column_pos.eff_dist_l = XLALLIGOLwFindColumn(&env, "eff_dist_l", METAIO_TYPE_REAL_4, 1);
248 column_pos.eff_dist_g = XLALLIGOLwFindColumn(&env, "eff_dist_g", METAIO_TYPE_REAL_4, 1);
249 column_pos.eff_dist_t = XLALLIGOLwFindColumn(&env, "eff_dist_t", METAIO_TYPE_REAL_4, 1);
250 column_pos.eff_dist_v = XLALLIGOLwFindColumn(&env, "eff_dist_v", METAIO_TYPE_REAL_4, 1);
251 column_pos.numrel_mode_min = XLALLIGOLwFindColumn(&env, "numrel_mode_min", METAIO_TYPE_INT_4S, 1);
252 column_pos.numrel_mode_max = XLALLIGOLwFindColumn(&env, "numrel_mode_max", METAIO_TYPE_INT_4S, 1);
253 column_pos.numrel_data = XLALLIGOLwFindColumn(&env, "numrel_data", METAIO_TYPE_LSTRING, 1);
254 column_pos.amp_order = XLALLIGOLwFindColumn(&env, "amp_order", METAIO_TYPE_INT_4S, 1);
255 column_pos.taper = XLALLIGOLwFindColumn(&env, "taper", METAIO_TYPE_LSTRING, 1);
256 column_pos.bandpass = XLALLIGOLwFindColumn(&env, "bandpass", METAIO_TYPE_INT_4S, 1);
257 column_pos.simulation_id = XLALLIGOLwFindColumn(&env, "simulation_id", METAIO_TYPE_INT_8S, 1);
258
259 /* check for failure (== a required column is missing) */
260
261 if(XLALGetBaseErrno()) {
262 MetaioAbort(&env);
263 XLALPrintError("%s(): failure reading %s table\n", __func__, table_name);
265 }
266
267 /* loop over the rows in the file */
268
269 while((miostatus = MetaioGetRow(&env)) > 0) {
270 /* create a new row */
271
273
274 if(!row) {
276 MetaioAbort(&env);
278 }
279
280 /* append to linked list */
281
282 *next = row;
283 next = &(*next)->next;
284
285 /* populate the columns */
286
287 row->process_id = env.ligo_lw.table.elt[column_pos.process_id].data.int_8s;
288 strncpy(row->waveform, env.ligo_lw.table.elt[column_pos.waveform].data.lstring.data, sizeof(row->waveform) - 1);
289 strncpy(row->source, env.ligo_lw.table.elt[column_pos.source].data.lstring.data, sizeof(row->source) - 1);
290 XLALGPSSet(&row->geocent_end_time, env.ligo_lw.table.elt[column_pos.geocent_end_time].data.int_4s, env.ligo_lw.table.elt[column_pos.geocent_end_time_ns].data.int_4s);
291 XLALGPSSet(&row->h_end_time, env.ligo_lw.table.elt[column_pos.h_end_time].data.int_4s, env.ligo_lw.table.elt[column_pos.h_end_time_ns].data.int_4s);
292 XLALGPSSet(&row->l_end_time, env.ligo_lw.table.elt[column_pos.l_end_time].data.int_4s, env.ligo_lw.table.elt[column_pos.l_end_time_ns].data.int_4s);
293 XLALGPSSet(&row->g_end_time, env.ligo_lw.table.elt[column_pos.g_end_time].data.int_4s, env.ligo_lw.table.elt[column_pos.g_end_time_ns].data.int_4s);
294 XLALGPSSet(&row->t_end_time, env.ligo_lw.table.elt[column_pos.t_end_time].data.int_4s, env.ligo_lw.table.elt[column_pos.t_end_time_ns].data.int_4s);
295 XLALGPSSet(&row->v_end_time, env.ligo_lw.table.elt[column_pos.v_end_time].data.int_4s, env.ligo_lw.table.elt[column_pos.v_end_time_ns].data.int_4s);
296 row->end_time_gmst = env.ligo_lw.table.elt[column_pos.end_time_gmst].data.real_8;
297 row->mass1 = env.ligo_lw.table.elt[column_pos.mass1].data.real_4;
298 row->mass2 = env.ligo_lw.table.elt[column_pos.mass2].data.real_4;
299 row->eta = env.ligo_lw.table.elt[column_pos.eta].data.real_4;
300 row->distance = env.ligo_lw.table.elt[column_pos.distance].data.real_4;
301 row->longitude = env.ligo_lw.table.elt[column_pos.longitude].data.real_4;
302 row->latitude = env.ligo_lw.table.elt[column_pos.latitude].data.real_4;
303 row->inclination = env.ligo_lw.table.elt[column_pos.inclination].data.real_4;
304 row->coa_phase = env.ligo_lw.table.elt[column_pos.coa_phase].data.real_4;
305 row->polarization = env.ligo_lw.table.elt[column_pos.polarization].data.real_4;
306 row->psi0 = env.ligo_lw.table.elt[column_pos.psi0].data.real_4;
307 row->psi3 = env.ligo_lw.table.elt[column_pos.psi3].data.real_4;
308 row->alpha = env.ligo_lw.table.elt[column_pos.alpha].data.real_4;
309 row->alpha1 = env.ligo_lw.table.elt[column_pos.alpha1].data.real_4;
310 row->alpha2 = env.ligo_lw.table.elt[column_pos.alpha2].data.real_4;
311 row->alpha3 = env.ligo_lw.table.elt[column_pos.alpha3].data.real_4;
312 row->alpha4 = env.ligo_lw.table.elt[column_pos.alpha4].data.real_4;
313 row->alpha5 = env.ligo_lw.table.elt[column_pos.alpha5].data.real_4;
314 row->alpha6 = env.ligo_lw.table.elt[column_pos.alpha6].data.real_4;
315 row->beta = env.ligo_lw.table.elt[column_pos.beta].data.real_4;
316 row->spin1x = env.ligo_lw.table.elt[column_pos.spin1x].data.real_4;
317 row->spin1y = env.ligo_lw.table.elt[column_pos.spin1y].data.real_4;
318 row->spin1z = env.ligo_lw.table.elt[column_pos.spin1z].data.real_4;
319 row->spin2x = env.ligo_lw.table.elt[column_pos.spin2x].data.real_4;
320 row->spin2y = env.ligo_lw.table.elt[column_pos.spin2y].data.real_4;
321 row->spin2z = env.ligo_lw.table.elt[column_pos.spin2z].data.real_4;
322 row->theta0 = env.ligo_lw.table.elt[column_pos.theta0].data.real_4;
323 row->phi0 = env.ligo_lw.table.elt[column_pos.phi0].data.real_4;
324 row->f_lower = env.ligo_lw.table.elt[column_pos.f_lower].data.real_4;
325 row->f_final = env.ligo_lw.table.elt[column_pos.f_final].data.real_4;
326 row->mchirp = env.ligo_lw.table.elt[column_pos.mchirp].data.real_4;
327 row->eff_dist_h = env.ligo_lw.table.elt[column_pos.eff_dist_h].data.real_4;
328 row->eff_dist_l = env.ligo_lw.table.elt[column_pos.eff_dist_l].data.real_4;
329 row->eff_dist_g = env.ligo_lw.table.elt[column_pos.eff_dist_g].data.real_4;
330 row->eff_dist_t = env.ligo_lw.table.elt[column_pos.eff_dist_t].data.real_4;
331 row->eff_dist_v = env.ligo_lw.table.elt[column_pos.eff_dist_v].data.real_4;
332 row->numrel_mode_min = env.ligo_lw.table.elt[column_pos.numrel_mode_min].data.int_4s;
333 row->numrel_mode_max = env.ligo_lw.table.elt[column_pos.numrel_mode_max].data.int_4s;
334 strncpy(row->numrel_data, env.ligo_lw.table.elt[column_pos.numrel_data].data.lstring.data, sizeof(row->numrel_data) - 1);
335 row->amp_order = env.ligo_lw.table.elt[column_pos.amp_order].data.int_4s;
336 strncpy(row->taper, env.ligo_lw.table.elt[column_pos.taper].data.lstring.data, sizeof(row->taper) - 1);
337 row->bandpass = env.ligo_lw.table.elt[column_pos.bandpass].data.int_4s;
338 row->simulation_id = env.ligo_lw.table.elt[column_pos.simulation_id].data.int_8s;
339 }
340 if(miostatus < 0) {
342 MetaioAbort(&env);
343 XLALPrintError("%s(): I/O error parsing %s table: %s\n", __func__, table_name, env.mierrmsg.data ? env.mierrmsg.data : "unknown reason");
345 }
346
347 /* close file */
348
349 if(MetaioClose(&env)) {
351 XLALPrintError("%s(): error parsing document after %s table: %s\n", __func__, table_name, env.mierrmsg.data ? env.mierrmsg.data : "unknown reason");
353 }
354
355 /* done */
356
357 return head;
358}
359
360
361/**
362 * Write a sim_inspiral table to an XML file.
363 */
364
366 LIGOLwXMLStream *xml,
367 const SimInspiralTable *sim_inspiral
368)
369{
370 const char *row_head = "\n\t\t\t";
371
372 /* table header */
373
375 XLALFilePuts("\t<Table Name=\"sim_inspiral:table\">\n", xml->fp);
376 XLALFilePuts("\t\t<Column Name=\"process:process_id\" Type=\"int_8s\"/>\n", xml->fp);
377 XLALFilePuts("\t\t<Column Name=\"waveform\" Type=\"lstring\"/>\n", xml->fp);
378 XLALFilePuts("\t\t<Column Name=\"geocent_end_time\" Type=\"int_4s\"/>\n", xml->fp);
379 XLALFilePuts("\t\t<Column Name=\"geocent_end_time_ns\" Type=\"int_4s\"/>\n", xml->fp);
380 XLALFilePuts("\t\t<Column Name=\"h_end_time\" Type=\"int_4s\"/>\n", xml->fp);
381 XLALFilePuts("\t\t<Column Name=\"h_end_time_ns\" Type=\"int_4s\"/>\n", xml->fp);
382 XLALFilePuts("\t\t<Column Name=\"l_end_time\" Type=\"int_4s\"/>\n", xml->fp);
383 XLALFilePuts("\t\t<Column Name=\"l_end_time_ns\" Type=\"int_4s\"/>\n", xml->fp);
384 XLALFilePuts("\t\t<Column Name=\"g_end_time\" Type=\"int_4s\"/>\n", xml->fp);
385 XLALFilePuts("\t\t<Column Name=\"g_end_time_ns\" Type=\"int_4s\"/>\n", xml->fp);
386 XLALFilePuts("\t\t<Column Name=\"t_end_time\" Type=\"int_4s\"/>\n", xml->fp);
387 XLALFilePuts("\t\t<Column Name=\"t_end_time_ns\" Type=\"int_4s\"/>\n", xml->fp);
388 XLALFilePuts("\t\t<Column Name=\"v_end_time\" Type=\"int_4s\"/>\n", xml->fp);
389 XLALFilePuts("\t\t<Column Name=\"v_end_time_ns\" Type=\"int_4s\"/>\n", xml->fp);
390 XLALFilePuts("\t\t<Column Name=\"end_time_gmst\" Type=\"real_8\"/>\n", xml->fp);
391 XLALFilePuts("\t\t<Column Name=\"source\" Type=\"lstring\"/>\n", xml->fp);
392 XLALFilePuts("\t\t<Column Name=\"mass1\" Type=\"real_4\"/>\n", xml->fp);
393 XLALFilePuts("\t\t<Column Name=\"mass2\" Type=\"real_4\"/>\n", xml->fp);
394 XLALFilePuts("\t\t<Column Name=\"mchirp\" Type=\"real_4\"/>\n", xml->fp);
395 XLALFilePuts("\t\t<Column Name=\"eta\" Type=\"real_4\"/>\n", xml->fp);
396 XLALFilePuts("\t\t<Column Name=\"distance\" Type=\"real_4\"/>\n", xml->fp);
397 XLALFilePuts("\t\t<Column Name=\"longitude\" Type=\"real_4\"/>\n", xml->fp);
398 XLALFilePuts("\t\t<Column Name=\"latitude\" Type=\"real_4\"/>\n", xml->fp);
399 XLALFilePuts("\t\t<Column Name=\"inclination\" Type=\"real_4\"/>\n", xml->fp);
400 XLALFilePuts("\t\t<Column Name=\"coa_phase\" Type=\"real_4\"/>\n", xml->fp);
401 XLALFilePuts("\t\t<Column Name=\"polarization\" Type=\"real_4\"/>\n", xml->fp);
402 XLALFilePuts("\t\t<Column Name=\"psi0\" Type=\"real_4\"/>\n", xml->fp);
403 XLALFilePuts("\t\t<Column Name=\"psi3\" Type=\"real_4\"/>\n", xml->fp);
404 XLALFilePuts("\t\t<Column Name=\"alpha\" Type=\"real_4\"/>\n", xml->fp);
405 XLALFilePuts("\t\t<Column Name=\"alpha1\" Type=\"real_4\"/>\n", xml->fp);
406 XLALFilePuts("\t\t<Column Name=\"alpha2\" Type=\"real_4\"/>\n", xml->fp);
407 XLALFilePuts("\t\t<Column Name=\"alpha3\" Type=\"real_4\"/>\n", xml->fp);
408 XLALFilePuts("\t\t<Column Name=\"alpha4\" Type=\"real_4\"/>\n", xml->fp);
409 XLALFilePuts("\t\t<Column Name=\"alpha5\" Type=\"real_4\"/>\n", xml->fp);
410 XLALFilePuts("\t\t<Column Name=\"alpha6\" Type=\"real_4\"/>\n", xml->fp);
411 XLALFilePuts("\t\t<Column Name=\"beta\" Type=\"real_4\"/>\n", xml->fp);
412 XLALFilePuts("\t\t<Column Name=\"spin1x\" Type=\"real_4\"/>\n", xml->fp);
413 XLALFilePuts("\t\t<Column Name=\"spin1y\" Type=\"real_4\"/>\n", xml->fp);
414 XLALFilePuts("\t\t<Column Name=\"spin1z\" Type=\"real_4\"/>\n", xml->fp);
415 XLALFilePuts("\t\t<Column Name=\"spin2x\" Type=\"real_4\"/>\n", xml->fp);
416 XLALFilePuts("\t\t<Column Name=\"spin2y\" Type=\"real_4\"/>\n", xml->fp);
417 XLALFilePuts("\t\t<Column Name=\"spin2z\" Type=\"real_4\"/>\n", xml->fp);
418 XLALFilePuts("\t\t<Column Name=\"theta0\" Type=\"real_4\"/>\n", xml->fp);
419 XLALFilePuts("\t\t<Column Name=\"phi0\" Type=\"real_4\"/>\n", xml->fp);
420 XLALFilePuts("\t\t<Column Name=\"f_lower\" Type=\"real_4\"/>\n", xml->fp);
421 XLALFilePuts("\t\t<Column Name=\"f_final\" Type=\"real_4\"/>\n", xml->fp);
422 XLALFilePuts("\t\t<Column Name=\"eff_dist_h\" Type=\"real_4\"/>\n", xml->fp);
423 XLALFilePuts("\t\t<Column Name=\"eff_dist_l\" Type=\"real_4\"/>\n", xml->fp);
424 XLALFilePuts("\t\t<Column Name=\"eff_dist_g\" Type=\"real_4\"/>\n", xml->fp);
425 XLALFilePuts("\t\t<Column Name=\"eff_dist_t\" Type=\"real_4\"/>\n", xml->fp);
426 XLALFilePuts("\t\t<Column Name=\"eff_dist_v\" Type=\"real_4\"/>\n", xml->fp);
427 XLALFilePuts("\t\t<Column Name=\"numrel_mode_min\" Type=\"int_4s\"/>\n", xml->fp);
428 XLALFilePuts("\t\t<Column Name=\"numrel_mode_max\" Type=\"int_4s\"/>\n", xml->fp);
429 XLALFilePuts("\t\t<Column Name=\"numrel_data\" Type=\"lstring\"/>\n", xml->fp);
430 XLALFilePuts("\t\t<Column Name=\"amp_order\" Type=\"int_4s\"/>\n", xml->fp);
431 XLALFilePuts("\t\t<Column Name=\"taper\" Type=\"lstring\"/>\n", xml->fp);
432 XLALFilePuts("\t\t<Column Name=\"bandpass\" Type=\"int_4s\"/>\n", xml->fp);
433 XLALFilePuts("\t\t<Column Name=\"simulation_id\" Type=\"int_8s\"/>\n", xml->fp);
434 XLALFilePuts("\t\t<Stream Name=\"sim_inspiral:table\" Type=\"Local\" Delimiter=\",\">\n", xml->fp);
435
436 if(XLALGetBaseErrno())
438
439 /* rows */
440
441 for(; sim_inspiral; sim_inspiral = sim_inspiral->next) {
442 if(XLALFilePrintf(xml->fp, "%s%ld,\"%s\",%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%.16g,\"%s\",%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%.16g,%16g,%d,%d,\"%s\",%d,\"%s\",%d,%ld",
443 row_head,
444 sim_inspiral->process_id,
445 sim_inspiral->waveform,
446 sim_inspiral->geocent_end_time.gpsSeconds,
447 sim_inspiral->geocent_end_time.gpsNanoSeconds,
448 sim_inspiral->h_end_time.gpsSeconds,
449 sim_inspiral->h_end_time.gpsNanoSeconds,
450 sim_inspiral->l_end_time.gpsSeconds,
451 sim_inspiral->l_end_time.gpsNanoSeconds,
452 sim_inspiral->g_end_time.gpsSeconds,
453 sim_inspiral->g_end_time.gpsNanoSeconds,
454 sim_inspiral->t_end_time.gpsSeconds,
455 sim_inspiral->t_end_time.gpsNanoSeconds,
456 sim_inspiral->v_end_time.gpsSeconds,
457 sim_inspiral->v_end_time.gpsNanoSeconds,
458 sim_inspiral->end_time_gmst,
459 sim_inspiral->source,
460 sim_inspiral->mass1,
461 sim_inspiral->mass2,
462 sim_inspiral->mchirp,
463 sim_inspiral->eta,
464 sim_inspiral->distance,
465 sim_inspiral->longitude,
466 sim_inspiral->latitude,
467 sim_inspiral->inclination,
468 sim_inspiral->coa_phase,
469 sim_inspiral->polarization,
470 sim_inspiral->psi0,
471 sim_inspiral->psi3,
472 sim_inspiral->alpha,
473 sim_inspiral->alpha1,
474 sim_inspiral->alpha2,
475 sim_inspiral->alpha3,
476 sim_inspiral->alpha4,
477 sim_inspiral->alpha5,
478 sim_inspiral->alpha6,
479 sim_inspiral->beta,
480 sim_inspiral->spin1x,
481 sim_inspiral->spin1y,
482 sim_inspiral->spin1z,
483 sim_inspiral->spin2x,
484 sim_inspiral->spin2y,
485 sim_inspiral->spin2z,
486 sim_inspiral->theta0,
487 sim_inspiral->phi0,
488 sim_inspiral->f_lower,
489 sim_inspiral->f_final,
490 sim_inspiral->eff_dist_h,
491 sim_inspiral->eff_dist_l,
492 sim_inspiral->eff_dist_g,
493 sim_inspiral->eff_dist_t,
494 sim_inspiral->eff_dist_v,
495 sim_inspiral->numrel_mode_min,
496 sim_inspiral->numrel_mode_max,
497 sim_inspiral->numrel_data,
498 sim_inspiral->amp_order,
499 sim_inspiral->taper,
500 sim_inspiral->bandpass,
501 sim_inspiral->simulation_id
502 ) < 0)
504 row_head = ",\n\t\t\t";
505 }
506
507 /* table footer */
508
509 if(XLALFilePuts("\n\t\t</Stream>\n\t</Table>\n", xml->fp) < 0)
511
512 /* done */
513
514 return 0;
515}
int XLALLIGOLwFindColumn(struct MetaioParseEnvironment *env, const char *name, unsigned int type, int required)
Convenience wrapper for MetaioFindColumn(), translating to XLAL-style error reporting and printing us...
int XLALFilePuts(const char *s, LALFILE *file)
int XLALFilePrintf(LALFILE *file, const char *fmt,...)
void * XLALMalloc(size_t n)
void XLALFree(void *p)
#define XLAL_ERROR_NULL(...)
int XLALGetBaseErrno(void)
#define XLAL_ERROR(...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
int XLALClearErrno(void)
XLAL_EFUNC
XLAL_EIO
LIGOTimeGPS * XLALGPSSet(LIGOTimeGPS *epoch, INT4 gpssec, INT8 gpsnan)
filename
void XLALDestroySimInspiralTable(SimInspiralTable *head)
Destroy a SimInspiralTable linked list.
Definition: sim_inspiral.c:80
SimInspiralTable * XLALCreateSimInspiralTableRow(const ProcessTable *process)
Create a SimInspiralTable structure.
Definition: sim_inspiral.c:40
long XLALSimInspiralAssignIDs(SimInspiralTable *head, long process_id, long simulation_id)
Assign simulation_id values to the entries in a SimInspiral linked list.
Definition: sim_inspiral.c:97
SimInspiralTable * XLALDestroySimInspiralTableRow(SimInspiralTable *row)
Destroy a SimInspiralTable structure.
Definition: sim_inspiral.c:67
SimInspiralTable * XLALSimInspiralTableFromLIGOLw(const char *filename)
Read the sim_inspiral table from a LIGO Light Weight XML file into a linked list of SimInspiralTable ...
Definition: sim_inspiral.c:115
int XLALWriteLIGOLwXMLSimInspiralTable(LIGOLwXMLStream *xml, const SimInspiralTable *sim_inspiral)
Write a sim_inspiral table to an XML file.
Definition: sim_inspiral.c:365
This structure contains the file stream and current table type for writing to LIGO lightweight XML fi...
Definition: LIGOLwXML.h:71
LALFILE * fp
Definition: LIGOLwXML.h:72
INT4 gpsNanoSeconds
LIGOTimeGPS geocent_end_time
CHAR source[LIGOMETA_SOURCE_MAX]
struct tagSimInspiralTable * next
CHAR taper[LIGOMETA_INSPIRALTAPER_MAX]
CHAR waveform[LIGOMETA_WAVEFORM_MAX]
CHAR numrel_data[LIGOMETA_STRING_MAX]