20 #include <lal/LALConfig.h>
21 #include <lal/LALMalloc.h>
22 #include <lal/LALMathematica.h>
23 #include <lal/LALStatusMacros.h>
24 #include <lal/LALStdlib.h>
25 #include <lal/LALStdio.h>
27 #define INSTRUCTIONS fprintf(nb, "This notebook will produce an animated 3D plot of your template bank. See the next section to change any user variables before evaluating. The cells of this notebook must be evaluated sequentially. If you wish to evaluate the entire notebook at once press Ctrl+A then press Shift+Enter in most operating systems.")
78 REAL4 xmax, ymax, zmax;
79 INT2 xlog, ylog, zlog;
87 if ((nb =
LALFopen(
"Math3DNotebook.nb",
"w")) == NULL) {
106 if (*ntiles != counter)
107 printf(
"\nWARNING!!! The value of argument ntiles (%i) != the Math3DPointList length (%i)\n",
113 PtSize = 0.50*(1.0/(pow((*ntiles),0.333333)));
115 printf(
"\nWARNING!!! More than 10,000 tiles may crash Mathematica:)\n");
119 if ((*pointSize <= 0.0) || (*pointSize >= 1.0)) {
120 printf(
"\nIllegal value of pointSize; it must be between 0 and 1.\n");
121 printf(
"The default value of 0.02 will be used");
127 xmax = ymax = zmax = 0;
128 for( list = first; list != NULL; list = list->
next )
130 if( fabs( list->
x ) > xmax )
131 xmax = fabs( list->
x );
132 if( fabs( list->
y ) > ymax )
133 ymax = fabs( list->
y );
134 if( fabs( list->
z ) > zmax )
135 zmax = fabs( list->
z );
137 xlog = (
INT2)(log(xmax)/log(10));
138 ylog = (
INT2)(log(ymax)/log(10));
139 zlog = (
INT2)(log(zmax)/log(10));
144 fprintf(nb,
"LALMath3D Output");
157 fprintf(nb,
"Off[General::spell];");
160 fprintf(nb,
"Off[General::spell1];");
168 fprintf(nb,
"AnimationPlot\t:=True");
171 fprintf(nb,
"AnimationSize\t= {400,400};");
174 fprintf(nb,
"StillSize\t= {600,600};");
177 fprintf(nb,
"PtSize\t= %f;", PtSize);
180 fprintf(nb,
"AnimationName\t:= \"AnimationTilePlot.gif\"");
183 fprintf(nb,
"StillName\t:= \"StillTilePlot\"");
186 fprintf(nb,
"StillType\t:=\"EPS\"");
192 fprintf(nb,
"FrameTime\t= 0.2;");
195 fprintf(nb,
"XAxisLabel = \"Psi0 / 1e%d\"", xlog );
198 fprintf(nb,
"YAxisLabel = \"Psi3 / 1e%d\"", ylog );
201 fprintf(nb,
"ZAxisLabel = \"Beta / 1e%d\"", zlog );
204 fprintf(nb,
"AnimationPlot:\tFlag that determines whether to generate animations");
205 fprintf(nb,
"AnimationSize:\tThe size of the final animation in PIXELS x PIXELS\n");
206 fprintf(nb,
"StillSize:\t\tThe size of the final still image in PIXELS x PIXELS\n");
207 fprintf(nb,
"PtSize:\t\tThe relative size of the template points to the final display width.\n");
208 fprintf(nb,
"\t\t\tIt is given as a decimal part of one. (e.g. PtSize=0.02 is 1/20 of the display width)\n");
209 fprintf(nb,
"AnimationName:\tWhat to name the final animation - must use .gif extension\n");
210 fprintf(nb,
"StillName:\t\tWhat to name the final still image - extension determined by StillType\n");
211 fprintf(nb,
"StillType:\t\tThe file type and extension for the still image\n");
212 fprintf(nb,
"\t\t\tChoose any standard format (e.g. JPG, GIF, PDF, EPS, etc.)\n");
213 fprintf(nb,
"frames:\t\tThe number of frames for each rotation of the image.\n");
214 fprintf(nb,
"\t\t\tThe final image will have 2 times the number frames\n");
215 fprintf(nb,
"FrameTime:\t\tSets the delay time in seconds between each frame in the animated gif\n");
216 fprintf(nb,
"\t\t\tApplications seem to interpret this differently. You may have to adjust this setting\n");
217 fprintf(nb,
"\t\t\tbased on the intended application of the animations.\n");
218 fprintf(nb,
"XAxisLabel:\t\tSets the X-axis label\n");
219 fprintf(nb,
"XAxisLabel:\t\tSets the Y-axis label\n");
220 fprintf(nb,
"XAxisLabel:\t\tSets the Z-axis label");
230 fprintf(nb,
"Graphics3D[{PointSize[PtSize]");
234 fprintf( nb,
",{GrayLevel[%f], Point[{%f,%f,%f}]}",
236 list->
y/pow(10,ylog), list->
z/pow(10,zlog) );
246 fprintf(nb,
"Image generation");
249 fprintf(nb,
"still = Show[TILES, Background-> RGBColor[.93, .91, .89], ViewPoint -> {1, 1.3, 2.4}, ");
250 fprintf(nb,
"ImageSize->StillSize, Axes->True, AxesLabel->{XAxisLabel, YAxisLabel, ZAxisLabel}];\n");
253 fprintf(nb,
"If[AnimationPlot,{");
254 fprintf(nb,
"Do[tile[T]=Show[TILES, Background -> RGBColor[.93, .91, .89], ");
255 fprintf(nb,
"ViewPoint -> {1-(.99 T/frames)^2, T/(4 frames), 2 (T/frames)^2},ImageSize->AnimationSize], {T, 0, frames, 1}],\n");
256 fprintf(nb,
"Do[tile[frames+T]=Show[TILES, Background -> RGBColor[.93, .91, .89], ViewPoint -> {.005+(T/frames)^2, ");
257 fprintf(nb,
"0.25-T/(4 frames), 2-2 (.99 T/frames)^2},ImageSize->AnimationSize], {T, 0, frames, 1}]}];\n");
262 fprintf(nb,
"Animation Generation");
265 fprintf(nb,
"If[AnimationPlot,{images = Evaluate[Table[tile[j], {j, 0, 2 frames, 1}]]}];\n");
268 fprintf(nb,
"Export[StillName<>\".\"<>ToLowerCase[StillType], still, StillType, ImageSize->StillSize, ");
269 fprintf(nb,
"ConversionOptions->{\"ColorReductionDither\" -> False}]");
272 fprintf(nb,
"If[AnimationPlot,");
273 fprintf(nb,
"Export[AnimationName, images, \"GIF\", ImageSize -> AnimationSize, ");
274 fprintf(nb,
"ConversionOptions -> {\"Loop\" -> True,\"AnimationDisplayTime\" -> FrameTime, ");
275 fprintf(nb,
"\"ColorReductionDither\" -> False}]]");
#define ABORT(statusptr, code, mesg)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
int16_t INT2
Two-byte signed integer.
int32_t INT4
Four-byte signed integer.
float REAL4
Single precision real floating-point number (4 bytes).
void LALMath3DPlot(LALStatus *stat, Math3DPointList *first, INT4 *ntiles, REAL4 *pointSize)
This function is for plotting 3D template banks by creating a MATHEMATICA notebook.
#define LALMATHEMATICAH_EVAL
Invalid parameter value.
#define LALMATHEMATICAH_EFILE
Could not open file to write a Mathematica Notebook.
#define LALMATHEMATICAH_ENULL
NULL pointer to a LALMathematica.h input structure.
LAL status structure, see The LALStatus structure for more details.
This type is used by LALMath3DPlot.c as an input structure to plot 3-dimensional template banks.
struct tagMath3DPointList * next