Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with rayfiles #73

Merged
merged 3 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion marx/libsrc/dither.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,25 @@ static int get_internal_dither (double t, Marx_Dither_Type *d,
return 1;
}

/* Record the dither state but do not actually dither the rays, which are
* already assumed to be dithered a;ready in the input file.
*/
static int get_internal_dither_record_only(double t, Marx_Dither_Type *d,
double *rap, double *decp, double *rollp)
{
int status;

if (1 != (status = get_internal_dither(t, d, rap, decp, rollp)))
return status;

*rap = 0;
*decp = 0;
*rollp = 0;

return 1;
}


static int get_zeroamp_internal_dither (double t, Marx_Dither_Type *d,
double *rap, double *decp, double *rollp)
{
Expand Down Expand Up @@ -209,7 +228,10 @@ static int init_internal_dither (int dither_flag)
Ra_Amp = Ra_Amp * (PI/(180.0 * 3600));
Dec_Amp = Dec_Amp * (PI/(180.0 * 3600));
Roll_Amp = Roll_Amp * (PI/(180.0 * 3600));
Get_Dither_Function = get_internal_dither;
if (dither_flag & _MARX_DITHER_RECORD_ONLY)
Get_Dither_Function = get_internal_dither_record_only;
else
Get_Dither_Function = get_internal_dither;
marx_message ("[Using INTERNAL dither model]\n");
}
Get_Dither_Par_Means = get_dither_par_means_0;
Expand Down
7 changes: 5 additions & 2 deletions marx/libsrc/s-rayfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ int marx_dump_rayfile (char *file) /*{{{*/
fprintf (stdout, "\t\tPX\t\tPY\t\tPZ");
fprintf (stdout, "\tY-Pixel\tZ-Pixel");
fprintf (stdout, "\tOrder\tMirrorShell\tCCD_Num\tHRC_Region");

#if MARX_HAS_DITHER
fprintf(stdout, "\tRA\tDEC\tROLL");
fprintf(stdout, "\tDY\tDZ\tDTHETA");
#endif
putc ('\n', stdout);

while (1 == fread (&at, sizeof (Marx_Photon_Attr_Type), 1, fp))
Expand All @@ -94,7 +97,7 @@ int marx_dump_rayfile (char *file) /*{{{*/
fprintf (stdout, "%d\t%u\t%d\t%d",
at.order, at.mirror_shell, at.ccd_num, at.detector_region);

putc ('\n', stdout);
putc ('\n', stdout);
}

fclose (fp);
Expand Down
2 changes: 1 addition & 1 deletion marx/libsrc/source.def
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static Source_Object_Type Sources [] =
{"GAUSS", marx_select_gauss_source, 0, 0},
{"LINE", marx_select_line_source, 0, 0},
{"BETA", marx_select_beta_source, 0, 0},
{"RAYFILE", marx_select_rayfile_source, _MARX_DITHER_UNSUPPORTED, 0},
{"RAYFILE", marx_select_rayfile_source, _MARX_DITHER_RECORD_ONLY, 0},
{"DISK", marx_select_disk_source, 0, 0},
{"USER", marx_select_user_source, 0, 0},
{"SAOSAC", marx_select_saosac_source, _MARX_DITHER_ZERO_AMP|_MARX_DITHER_RECORD_ONLY, 0},
Expand Down
40 changes: 21 additions & 19 deletions marx/src/marx.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,31 +579,33 @@ int main (int argc, char **argv) /*{{{*/

total_num_collected += num_collected;

if (-1 == process_photons (pt))
goto return_error;
if (!Dump_To_Rayfile)
{
if (-1 == process_photons(pt))
goto return_error;
}
if (-1 == (*write_function)(pt, num_collected, open_mode, write_mask, total_time, pt->total_time))
goto return_error;

if (-1 == (*write_function) (pt, num_collected, open_mode, write_mask, total_time, pt->total_time))
goto return_error;
open_mode = 0;
marx_message("\n");

open_mode = 0;
marx_message ("\n");
marx_prune_photons(pt);
total_num_detected += pt->num_sorted;
total_time += pt->total_time;

marx_prune_photons (pt);
total_num_detected += pt->num_sorted;
total_time += pt->total_time;
marx_message("Total photons: %lu, Total Photons detected: %lu, (efficiency: %f)\n",
total_num_collected, total_num_detected, (double)total_num_detected / total_num_collected);

marx_message ("Total photons: %lu, Total Photons detected: %lu, (efficiency: %f)\n",
total_num_collected, total_num_detected, (double)total_num_detected / total_num_collected);
marx_message(" (efficiency this iteration %f) Total time: %f\n",
(double)pt->num_sorted / num_collected,
total_time);

marx_message (" (efficiency this iteration %f) Total time: %f\n",
(double)pt->num_sorted / num_collected,
total_time);
marx_message("\n");

marx_message ("\n");

if ((unsigned long)Num_Rays_Per_Iteration != num_collected)
break;
}
if ((unsigned long)Num_Rays_Per_Iteration != num_collected)
break;
}

/* drop */
status = 0;
Expand Down