Data is read from a file into an array.
031
032
033
035
036
037
039
040
Then read out.
0 040
1 040
2 040
3 040
4 040
5 040
6 040
What's going on. A silly mistake I would think but I can't find it.
031
032
033
035
036
037
039
040
Then read out.
0 040
1 040
2 040
3 040
4 040
5 040
6 040
What's going on. A silly mistake I would think but I can't find it.
Code:
#include "string.h"
#include "stdlib.h"
#include "stdio.h"
#include "pcxp.h"
#include "math.h"
#define location_of_images "/users/doug/kappa_and/slices/"
#define number_of_cubes 8
#define number_of_slices 32
int main(int argc, char *argv[])
{
int cube, slice, row, col, inner_radius, outer_radius, x_off, y_off, row_off, col_off, best_inner_radius, best_outer_radius;
fitsfile *fptr;
int status = 0;
int anynull;
float nullval;
float *dbuf1, *dbuf2;
float ***centers;
char *slice1, *slice2, *image_directory, *tmp, *cube_number, **cube_numbers, *image1, *image2;
float min = 1e10, diff, radius;
FILE *x_ctrs, *y_ctrs, *cube_list;
fptr = (fitsfile*)calloc(1, sizeof(fitsfile));
dbuf1 = (float*) calloc(large_image_size, sizeof(float));
dbuf2 = (float*) calloc(large_image_size, sizeof(float));
centers = (float ***)calloc(number_of_cubes, sizeof(float**));
for (cube = 0; cube < number_of_cubes; cube++)
centers[cube] = (float**) calloc(number_of_slices,sizeof(float*));
for (cube = 0; cube < number_of_cubes; cube++)
for(slice = 0; slice < number_of_slices; slice++)
centers[cube][slice] = (float *) calloc(2, sizeof(float));
tmp = (char*) calloc(40, sizeof(char));
cube_number = (char*) calloc(40, sizeof(char));
cube_numbers = (char**) calloc(number_of_cubes, sizeof(char*));
for (cube = 0; cube < number_of_cubes; cube++)
cube_numbers[cube] = (char*) calloc(5,sizeof(char));
image1 = (char*) calloc(100, sizeof(char));
image2 = (char*) calloc(100, sizeof(char));
image_directory = (char*) calloc(100, sizeof(char));
strcpy(image_directory, location_of_images);
if ((x_ctrs = fopen("/users/doug/kappa_and/HD222439_2012-12-23CenterX1.dat","r")) == NULL)
printf("didn't open X file\n");
if ((y_ctrs = fopen("/users/doug/kappa_and/HD222439_2012-12-23CenterY1.dat","r")) == NULL)
printf("didn't open Y file\n");
for (cube = 0; cube < number_of_cubes; cube++)
for (slice = 0; slice < number_of_slices; slice++)
{
fgets(tmp, 40, x_ctrs);
centers[cube][slice][0] = atof(tmp);
fgets(tmp, 40, y_ctrs);
centers[cube][slice][1] = atof(tmp);
//printf("%d %d %6.2f %f6.2\n",cube, slice, centers[cube][slice][0],centers[cube][slice][1]);
}
fclose(x_ctrs);
fclose(y_ctrs);
if ((cube_list = fopen("/users/doug/kappa_and/slices/cube_list.txt","r")) == NULL)
printf("didn't open cube list\n");
cube= 0;
while(fscanf(cube_list, "%s\n",cube_number) != EOF)
{
cube_numbers[cube]= cube_number;
printf("%s\n", cube_numbers[cube]);
cube++;
}
// alignment for each slice
//for ( slice = 0; slice < number_of_slices; slice++)
for (cube = 0; cube < number_of_cubes - 1; cube++){
printf("%d %s\n",cube, cube_numbers[cube]);
}
return(1640);
}