29 #include <lal/LALConfig.h>
30 #include <lal/LALMalloc.h>
31 #include <lal/LALStatusMacros.h>
32 #include <lal/LALStdlib.h>
33 #include <lal/LALMathematica.h>
34 #include <lal/LALStdio.h>
37 #define INSTRUCTIONS fprintf(nb, "Running this entire notebook using ctrl+A and shift+enter may crash your computer. Evaluate each section as needed. The Initialization and User Variables sections must be evaluated first. The 3-dimensional projections are represented in the sections below User Varibles as PointList (x1, x2, x3) etc. Evaluating the entire Image Generation sections creates animated plots (if AnimationPlot := True). If (AnimationPlot := False) you get only still plots, saving time and memory.")
97 if ((nb =
LALFopen(
"MathNDNotebook.nb",
"w")) == NULL) {
120 if (*ntiles != counter)
121 printf(
"\nWARNING!!! The value of argument ntiles (%i) != the MathNDPointList length (%i)\n",
127 PtSize = 0.50*(1.0/(pow((*ntiles),0.333333)));
129 printf(
"\nWARNING!!! More than 10,000 tiles may crash Mathematica:)\n");
133 if ((*pointSize <= 0.0) || (*pointSize >= 1.0)) {
134 printf(
"\nIllegal value of pointSize; it must be between 0 and 1.\n");
135 printf(
"The default value of 0.02 will be used");
143 fprintf(nb,
"LALMath3D Output");
156 fprintf(nb,
"Off[General::spell];");
159 fprintf(nb,
"Off[General::spell1];");
167 fprintf(nb,
"AnimationPlot\t:= False;");
170 fprintf(nb,
"AnimationSize\t= {400,400};");
173 fprintf(nb,
"StillSize\t= {600,600};");
176 fprintf(nb,
"PtSize\t= %f;", PtSize);
179 fprintf(nb,
"AnimationName\t:= \"AnimationTilePlot\"");
182 fprintf(nb,
"StillName\t:= \"StillTilePlot\"");
185 fprintf(nb,
"StillType\t:=\"EPS\"");
191 fprintf(nb,
"FrameTime\t= 0.2;");
193 for(counter = 1; counter <= dim; counter++){
195 fprintf(nb,
"X%iAxisLabel := \"x%i\"", counter, counter);
199 fprintf(nb,
"AnimationPlot:\tFlag to set for generating animations (may take a while to run)\n");
200 fprintf(nb,
"AnimationSize:\tThe size of the final animation in PIXELS x PIXELS\n");
201 fprintf(nb,
"StillSize:\t\tThe size of the final still image in PIXELS x PIXELS\n");
202 fprintf(nb,
"PtSize:\t\tThe relative size of the template points to the final display width.\n");
203 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");
204 fprintf(nb,
"AnimationName:\tWhat to name the final animation.\n");
205 fprintf(nb,
"StillName:\t\tWhat to name the final still image - extension determined by StillType\n");
206 fprintf(nb,
"StillType:\t\tThe file type and extension for the still image\n");
207 fprintf(nb,
"\t\t\tChoose any standard format (e.g. JPG, GIF, PDF, EPS, etc.)\n");
208 fprintf(nb,
"frames:\t\tThe number of frames for each rotation of the image.\n");
209 fprintf(nb,
"\t\t\tThe final image will have 2 times the number frames\n");
210 fprintf(nb,
"FrameTime:\t\tSets the delay time in seconds between each frame in the animated gif\n");
211 fprintf(nb,
"\t\t\tApplications seem to interpret this differently. You may have to adjust this setting\n");
212 fprintf(nb,
"\t\t\tbased on the intended application of the animations.\n");
213 fprintf(nb,
"XiAxisLabel:\t\tSets the Xi-axis label\n");
217 for(
x = 0;
x < dim;
x++){
218 for(
y = (
x+1);
y < dim;
y++){
219 for(z = (
y+1); z < dim; z++){
223 fprintf(nb,
"Point List (x%i,x%i,x%i)", (
x+1), (
y+1), (z+1));
226 fprintf(nb,
"TILES%i%i%i = \n", (
x+1), (
y+1), (z+1));
227 fprintf(nb,
"Graphics3D[{PointSize[PtSize]");
231 fprintf(nb,
",{GrayLevel[%f], Point[{%f,%f,%f}]}",
242 fprintf(nb,
"Image generation (x%i,x%i,x%i)", (
x+1), (
y+1), (z+1));
245 fprintf(nb,
"still%i%i%i = Show[TILES%i%i%i, Background-> RGBColor[.93, .91, .89], ViewPoint -> {1, 1.3, 2.4}, ",
246 (
x+1), (
y+1), (z+1), (
x+1), (
y+1), (z+1));
247 fprintf(nb,
"ImageSize->StillSize, Axes->True, AxesLabel->{X%iAxisLabel, X%iAxisLabel, X%iAxisLabel}];\n",
248 (
x+1), (
y+1), (z+1));
251 fprintf(nb,
"If[AnimationPlot,{Do[tile%i%i%i[T]=Show[TILES%i%i%i, Background -> RGBColor[.93, .91, .89], ",
252 (
x+1), (
y+1), (z+1), (
x+1), (
y+1), (z+1));
253 fprintf(nb,
"ViewPoint -> {1-(.99 T/frames)^2, T/(4 frames), 2 (T/frames)^2},ImageSize->AnimationSize], {T, 0, frames, 1}],\n");
254 fprintf(nb,
"Do[tile%i%i%i[frames+T]=Show[TILES%i%i%i, Background -> RGBColor[.93, .91, .89], ViewPoint -> {.005+(T/frames)^2, ",
255 (
x+1), (
y+1), (z+1), (
x+1), (
y+1), (z+1));
256 fprintf(nb,
"0.25-T/(4 frames), 2-2 (.99 T/frames)^2},ImageSize->AnimationSize], {T, 0, frames, 1}]}];\n");
261 fprintf(nb,
"Image Export (x%i,x%i,x%i)", (
x+1), (
y+1), (z+1));
264 fprintf(nb,
"If[AnimationPlot, images%i%i%i = Evaluate[Table[tile%i%i%i[j], {j, 0, 2 frames, 1}]]];\n",
265 (
x+1), (
y+1), (z+1), (
x+1), (
y+1), (z+1));
268 fprintf(nb,
"Export[StillName<>\"%i%i%i\"<>\".\"<>ToLowerCase[StillType], still%i%i%i, StillType, ImageSize->StillSize, ",
269 (
x+1), (
y+1), (z+1), (
x+1), (
y+1), (z+1));
270 fprintf(nb,
"ConversionOptions->{\"ColorReductionDither\" -> False}]");
273 fprintf(nb,
"If[AnimationPlot, Export[AnimationName<>\"%i%i%i\"<>\".gif\", images%i%i%i, \"GIF\", ImageSize -> AnimationSize, ",
274 (
x+1), (
y+1), (z+1), (
x+1), (
y+1), (z+1));
275 fprintf(nb,
"ConversionOptions -> {\"Loop\" -> True,\"AnimationDisplayTime\" -> FrameTime, ");
276 fprintf(nb,
"\"ColorReductionDither\" -> False}]]");
#define ABORT(statusptr, code, mesg)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
int32_t INT4
Four-byte signed integer.
float REAL4
Single precision real floating-point number (4 bytes).
#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.
void LALMathNDPlot(LALStatus *status, MathNDPointList *first, INT4 *ntiles, REAL4 *pointSize)
This function is for plotting N-Dimensional template banks by creating a MATHEMATICA notebook.
LAL status structure, see The LALStatus structure for more details.
This type is similar to Math3DPointList except the coordinates are stored as data in the REAL4Vector ...
REAL4Vector * coordinates
struct tagMathNDPointList * next
REAL4 * data
Pointer to the data array.
UINT4 length
Number of elements in array.