6 #include <gsl/gsl_rng.h>
8 #include <lal/LALStdlib.h>
9 #include <lal/LALConstants.h>
10 #include <lal/AVFactories.h>
11 #include <lal/LALSimBurst.h>
14 #define char const char
15 #include "unicorn.xpm"
19 static double RGB2Y(
double R,
double G,
double B)
22 Y = 0.2126*R + 0.7152*
G + 0.0722*
B;
30 memcpy(&ul,
s, n <
sizeof(ul) ? n :
sizeof(ul));
43 width = strlen(
s + 1);
45 snprintf(fmt,
sizeof(fmt),
"#%%%dx%%%dx%%%dx", width, width, width);
46 sscanf(
s, fmt, &R, &
G, &
B);
47 for (max = 16; width > 1; --width)
49 return RGB2Y((
double)R/(
double)max, (
double)
G/(
double)max, (
double)
B/(
double)max);
58 int cols, rows, colors, chars_per_pixel;
63 sscanf(xpm[0],
"%d %d %d %d", &cols, &rows, &colors, &chars_per_pixel);
64 if (cols < 1 || rows < 1 || colors < 1 || chars_per_pixel < 1)
68 for (
c = 1, nY = 256;
c < chars_per_pixel; ++
c)
75 for (color = 0; color < colors; ++color) {
76 const char *
s = xpm[1 + color];
81 if (Y[
i] < 0.0 || Y[
i] > 1.0) {
94 for (row = 0; row < rows; ++row) {
95 const char *
s = xpm[1 + colors + row];
97 for (col = 0; col < cols; ++col) {
98 size_t offset = row * cols + col;
101 arr->
data[offset] = Y[
i];
102 s += chars_per_pixel;
113 size_t row, rows, col, cols;
116 for (row = 0; row < rows; ++row) {
117 for (col = 0; col < cols; ++col) {
118 int offset = row * cols + col;
120 if (arr->
data[offset] < 0.3)
122 else if (arr->
data[offset] < 0.6)
152 double dt, df, fstart;
168 fstart =
f_min + 0.5 * df;
static REAL8Array * xpmtoarr(const char *xpm[])
static unsigned long radix256toul(const char *s, size_t n)
static double strtolum(const char *s)
static double RGB2Y(double R, double G, double B)
REAL8Array * XLALCreateREAL8ArrayL(UINT4,...)
void XLALDestroyREAL8Array(REAL8Array *)
int XLALSimUnicorn(REAL8TimeSeries **hplus, REAL8TimeSeries **hcross, double f_min, double f_max, double V, double hrss, double deltaT, gsl_rng *rng)
Generates a time-frequency unicorn signal.
int XLALSimBurstImg(REAL8TimeSeries **hplus, REAL8TimeSeries **hcross, REAL8Array *image, double dt, double df, double fstart, double hrss, double deltaT, gsl_rng *rng)
Generates a burst injection with a time-frequency structure specified in an image array.
#define XLAL_CHECK(assertion,...)