From a27038c985bc9019eeecc9f70bd15d9a6825fcda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=2E=20Moritz=20G=C3=BCnther?= Date: Tue, 21 Nov 2023 14:39:53 -0500 Subject: [PATCH 1/3] add dither information to raydump --- marx/libsrc/s-rayfile.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/marx/libsrc/s-rayfile.c b/marx/libsrc/s-rayfile.c index fec83b8..ef9cb62 100644 --- a/marx/libsrc/s-rayfile.c +++ b/marx/libsrc/s-rayfile.c @@ -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)) @@ -94,7 +97,12 @@ 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); +#if MARX_HAS_DITHER + fprintf(stdout, "%f\t%f\t%f\t", at.dither_state.ra, at.dither_state.dec, at.dither_state.roll); + fprintf(stdout, "%f\t%f\t%f\t", at.dither_state.dy, at.dither_state.dz, at.dither_state.dtheta); +#endif + + putc ('\n', stdout); } fclose (fp); From b32df4a9691cb77b251fd68d78c5c58ad6776370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=2E=20Moritz=20G=C3=BCnther?= Date: Tue, 21 Nov 2023 14:40:40 -0500 Subject: [PATCH 2/3] Do not run through HRMA, grating, and detector when dumping to rayfile --- marx/src/marx.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/marx/src/marx.c b/marx/src/marx.c index 5674ae7..8fafe0a 100644 --- a/marx/src/marx.c +++ b/marx/src/marx.c @@ -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; From d29c8f7a9fe3007e5c4b58e94c6820e50d54bae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=2E=20Moritz=20G=C3=BCnther?= Date: Wed, 27 Dec 2023 19:59:32 -0500 Subject: [PATCH 3/3] set RAYFILE Source to RECORD tp make sure dither is written fixes #30 --- marx/libsrc/dither.c | 24 +++++++++++++++++++++++- marx/libsrc/s-rayfile.c | 5 ----- marx/libsrc/source.def | 2 +- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/marx/libsrc/dither.c b/marx/libsrc/dither.c index 1d1d380..687ae92 100644 --- a/marx/libsrc/dither.c +++ b/marx/libsrc/dither.c @@ -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) { @@ -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; diff --git a/marx/libsrc/s-rayfile.c b/marx/libsrc/s-rayfile.c index ef9cb62..c7eb882 100644 --- a/marx/libsrc/s-rayfile.c +++ b/marx/libsrc/s-rayfile.c @@ -97,11 +97,6 @@ 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); -#if MARX_HAS_DITHER - fprintf(stdout, "%f\t%f\t%f\t", at.dither_state.ra, at.dither_state.dec, at.dither_state.roll); - fprintf(stdout, "%f\t%f\t%f\t", at.dither_state.dy, at.dither_state.dz, at.dither_state.dtheta); -#endif - putc ('\n', stdout); } diff --git a/marx/libsrc/source.def b/marx/libsrc/source.def index b741bc8..4c99caa 100644 --- a/marx/libsrc/source.def +++ b/marx/libsrc/source.def @@ -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},