diff --git a/MANIFEST b/MANIFEST index 6f5050e..19b31e2 100644 --- a/MANIFEST +++ b/MANIFEST @@ -138,10 +138,6 @@ marx/data/caldb/hetgD1996-11-01greffpr001N0007.fits marx/data/caldb/letgD1996-11-01greffpr001N0007.fits marx/data/caldb/telD1999-07-23aimptsN0002.fits marx/data/caldb/telD1999-07-23geomN0006.fits -marx/data/ea-mirror/Ae_s1346.dat -marx/data/ea-mirror/mirr-ee.bin -marx/data/ea-mirror/Mirror_EE.bin -marx/data/ea-mirror/README marx/data/FORMAT.TXT marx/data/grating/hetgmp1D1996-11-01marxsectorN0002.tbl marx/data/grating/hetgmp3D1996-11-01marxsectorN0002.tbl @@ -268,10 +264,7 @@ marx/libsrc/diffract.c marx/libsrc/disperse.c marx/libsrc/dither.c marx/libsrc/drake.c -marx/libsrc/dump_ee.c -marx/libsrc/eamirror.c marx/libsrc/ffield.c -marx/libsrc/fix_ee.c marx/libsrc/grating.c marx/libsrc/hrc.h marx/libsrc/hrc-i.c @@ -287,7 +280,6 @@ marx/libsrc/marx-feat.h marx/libsrc/_marx.h marx/libsrc/marx.h marx/libsrc/marxio.c -marx/libsrc/mblur.c marx/libsrc/mirror.c marx/libsrc/modules.lis marx/libsrc/parm.c diff --git a/marx/autoconf/configure.ac b/marx/autoconf/configure.ac index 9eba5a9..d1f01a0 100644 --- a/marx/autoconf/configure.ac +++ b/marx/autoconf/configure.ac @@ -73,9 +73,6 @@ fi AC_CONFIG_FILES([$CF_Output_Files data/Makefile doc/Makefile]) AC_OUTPUT -JD_CREATE_EXEC_RULE(fix_ee) -JD_CREATE_EXEC_RULE(dump_ee) - JD_APPEND_RULES(libsrc/Makefile) dnl We may be configuring just marxlib and the src directory may not be diff --git a/marx/data/Makefile.in b/marx/data/Makefile.in index efecb24..c8aa2b3 100644 --- a/marx/data/Makefile.in +++ b/marx/data/Makefile.in @@ -16,7 +16,6 @@ SRC_FILES = Makefile bdat2tbl.c tbl2bdat.c OBS_FILES = acis_i_obs.par acis_s_obs.par hrc_i_obs.par hrc_s_obs.par PIXLIB_FILES = pix_corner_lsi.par pix_sim_table_flight.par ACIS_FILES = README -EA_MIRROR_FILES = README Ae_s1346.dat Mirror_EE.bin GRATING_FILES = README optical-constants.dat optical-constants.xray \ hetgmp1D1996-11-01marxsectorN0002.tbl hetgmp3D1996-11-01marxsectorN0002.tbl \ @@ -49,7 +48,6 @@ install-dirs: $(MKINSTDIR) $(DEST_DATADIR)/hrma $(MKINSTDIR) $(DEST_DATADIR)/hrc $(MKINSTDIR) $(DEST_DATADIR)/grating - $(MKINSTDIR) $(DEST_DATADIR)/ea-mirror $(MKINSTDIR) $(DEST_DATADIR)/acis $(MKINSTDIR) $(DEST_DATADIR)/pixlib $(MKINSTDIR) $(DEST_DATADIR)/obs @@ -95,14 +93,6 @@ install: install-dirs exit 1; \ fi; \ done - @for X in $(EA_MIRROR_FILES); do \ - Y=$(DEST_DATADIR)/ea-mirror; \ - echo Installing $$X in $$Y; \ - $(INSTALL_DATA) ea-mirror/$$X $$Y/; \ - if [ "$$?" != "0" ]; then \ - exit 1; \ - fi; \ - done @for X in $(GRATING_FILES); do \ Y=$(DEST_DATADIR)/grating; \ echo Installing $$X in $$Y; \ diff --git a/marx/data/README b/marx/data/README index be363cc..0d4cf89 100644 --- a/marx/data/README +++ b/marx/data/README @@ -10,16 +10,11 @@ files: ./caldb This directory contains files that are copied over from CALDB (so that MARX users don't need a full CALDB isntallation to run - MARX) or that are derived fomr CALDB files, e.g. by re-ordering - as CALDB file. ] + MARX) or that are derived from CALDB files, e.g. by re-ordering + as CALDB file. This directory also contains a S-Lang script to generate some of these files from CALDB. - ./ea-mirror - This directory contains data files need by the MARX EA-MIRROR - module. This module is deprecated and the files will not be - updated any longer. - ./grating This directory contains data files for the HETG and LETG. diff --git a/marx/data/ea-mirror/Ae_s1346.dat b/marx/data/ea-mirror/Ae_s1346.dat deleted file mode 100644 index aab4d53..0000000 Binary files a/marx/data/ea-mirror/Ae_s1346.dat and /dev/null differ diff --git a/marx/data/ea-mirror/Mirror_EE.bin b/marx/data/ea-mirror/Mirror_EE.bin deleted file mode 100644 index fa8c5ff..0000000 Binary files a/marx/data/ea-mirror/Mirror_EE.bin and /dev/null differ diff --git a/marx/data/ea-mirror/README b/marx/data/ea-mirror/README deleted file mode 100644 index 9486992..0000000 --- a/marx/data/ea-mirror/README +++ /dev/null @@ -1,17 +0,0 @@ -The files in this directory include: - - Mirror_EE.bin - - This file contains data for the EA-MIRROR blur. It was generated - by Dave H. via Leon's fold program. - - mirr-ee.bin - - This file is created when marx is compiled. It contains the same - data as Mirror_EE.bin but arranged in a format more suitable to - marx (see ../../libsrc/fix_ee.c). - - Ae_s1346.dat - - This is a binary data file containing the energy dependent effective - are curves for the four shells of the HRMA. diff --git a/marx/data/ea-mirror/mirr-ee.bin b/marx/data/ea-mirror/mirr-ee.bin deleted file mode 100644 index bb7880d..0000000 Binary files a/marx/data/ea-mirror/mirr-ee.bin and /dev/null differ diff --git a/marx/data/utils/README b/marx/data/utils/README index 06246a1..7cd6cca 100644 --- a/marx/data/utils/README +++ b/marx/data/utils/README @@ -1,13 +1,2 @@ This directory contains programs and scripts that are used to make several of the MARX data input files. Individual scripts are commented. - -Here some general remarks -------------------------- -mk_hrma_ea.sl, mkcorr.sl, run_mkarf.sh: - These scripts make input for the ea-mirror model. - See Makefile for invocation. - Since the ea-mirror model should not be used any longer and - is of historical interest only, these scripts are not used any more. - The ea-mirror model stays frozen and **does not** receive regular - updates; thus, it **does not** follow recent improvments in CALDB. - Users should use the more accurate HRMA mirror model. \ No newline at end of file diff --git a/marx/data/utils/mk_hrma_ea.sl b/marx/data/utils/mk_hrma_ea.sl deleted file mode 100644 index e795a2d..0000000 --- a/marx/data/utils/mk_hrma_ea.sl +++ /dev/null @@ -1,70 +0,0 @@ -require ("fits"); - -private variable Marx_Cmd = "../../src/objs/marx"; -private variable Marx_Args= "SourceRA=0 SourceDec=0" - + " SpectrumType=FLAT RA_Nom=0 Dec_Nom=0" - + " Roll_Nom=0 DitherModel=NONE"; -Marx_Args += " ExposureTime=0"; -Marx_Args += " GratingType=NONE Verbose=no"; -Marx_Args += " DetectorType=NONE"; -Marx_Args += " SourceFlux=1.0"; -% If HRMA_Use_Scale_Factors is yes, then prefix the output filename -% with "scaled". - -private variable Use_Scale_Factors = 0; -private variable Prefix = Use_Scale_Factors ? "scaled" : ""; -Marx_Args += " HRMA_Use_Scale_Factors=" + (Use_Scale_Factors ? "yes" : "no"); - -putenv ("MARX_DATA_DIR=.."); - -private define run_marx_sim (numrays, en_lo, en_hi, file, shell) -{ - variable shutters; - - if (shell == 1346) - shutters = "Shutters1=0000 Shutters3=0000 Shutters4=0000 Shutters6=0000"; - else - { - shutters = "Shutters1=1111 Shutters3=1111 Shutters4=1111 Shutters6=1111"; - shutters += sprintf (" Shutters%d=0000", shell); - } - - shutters += sprintf (" NumRays=%d", numrays); - - variable cmd = sprintf ("%s %s %s OutputDir=\"|./marxpipe\" MinEnergy=%g MaxEnergy=%g >> %s", - Marx_Cmd, Marx_Args, shutters, en_lo, en_hi, file); - - vmessage ("Running %s", cmd); - if (0 != system (cmd)) - { - verror ("%s failed", cmd); - } -} - -define slsh_main () -{ - variable de = 0.003; % if changed, update mkcorr.sl - variable en_lo = [0.03:12.0:de]; - variable en_hi = en_lo + de; - - () = system ("cp ../../par/marx.par ."); - - foreach ([1, 3, 4, 6]) - { - variable shell = (); - variable i; - variable Out_Dat = "${Prefix}_hrma_ea_${shell}.dat"$; - () = remove (Out_Dat); - variable numrays = -100000; - for (i = 0; i < length (en_lo); i++) - { - variable fp = fopen (Out_Dat, "a"); - if (en_lo[i] > 6.0) - numrays = 5000000; - () = fprintf (fp, "%g\t%g\t", en_lo[i], en_hi[i]); - () = fclose (fp); - run_marx_sim (numrays, en_lo[i], en_hi[i], Out_Dat, shell); - } - } -} - diff --git a/marx/data/utils/mkcorr.sl b/marx/data/utils/mkcorr.sl deleted file mode 100644 index cd753d8..0000000 --- a/marx/data/utils/mkcorr.sl +++ /dev/null @@ -1,222 +0,0 @@ -require ("fits"); -require ("gslinterp"); -require ("histogram"); -require ("xfig"); - -private variable Flux = 1.0; % simulation SourceFlux value -private variable Prefix = "scaled"; - -define read_file (shell) -{ - variable file = "${Prefix}_hrma_ea_$shell.dat"$; - variable e, n, t; - () = readascii (file, &e, &n, &t; cols=[1,4,5]); - %(e,n,t) = readcol (file, 1, 4, 5); - t *= Flux; - return e, n/t, sqrt(n)/t; -} - -define read_arf (shell) -{ - variable file = sprintf ("hrma%d.arf", shell); - variable t = fits_read_table (file); - return (0.5*(t.energ_lo+t.energ_hi), t.specresp); -} - -define compute_ratio (shell) -{ - variable e,a,da; - variable e1, a1; - - (e,a,da) = read_file (shell); - (e1, a1) = read_arf (shell); - - a1 = interp_linear (e, e1, a1); - variable i = where ((a != 0) and (a1 != 0)); - return e[i], a1[i]/a[i], da[i]/a1[i]; -} - -define prune (x, y, ysigma, tol) -{ - variable min_slope, max_slope; - variable len = length (x); - variable p = Int_Type[len]; - variable n = 0, i; - variable infinity = 1e38; - - p[n] = 0; - n++; - variable x0 = x[0]; - variable y0 = y[0]; - - min_slope = infinity; - max_slope = -infinity; - - i = 1; - while (i < len) - { - variable y1 = y[i]; - variable x1 = x[i]; - variable dx = x1 - x0; - variable dy = y1 - y0; - if (x1 == x0) - { - i++; - continue; - } - variable m = dy/dx; - if ((m < min_slope) or (m > max_slope)) - { - i--; - p[n] = i; n++; - x0 = x[i]; - y0 = y[i]; - min_slope = -infinity; - max_slope = infinity; - i++; - continue; - } - - variable dm = abs ((y1*tol)/dx); - if (ysigma != NULL) - dm += 0.5*abs (ysigma[i]/dx); - - if (m + dm < max_slope) - max_slope = m + dm; - if (m - dm > min_slope) - min_slope = m - dm; - - i++; - } - if (n == len) - n--; - else - p[n] = len-1; - return p[[1:n]]; -} - -define smooth (r) -{ - variable r0, r1, r2; - variable n = length (r); - variable new_r = Double_Type [n]; - r0 = r[0]; - new_r[0] = r0; - variable i; - _for (1, n-2, 1) - { - i = (); - r1 = r[i]; - r2 = r[i+1]; - new_r[i] = (r0 + r1 + r2)/3.0; - r0 = r1; - } - new_r[-1] = r[-1]; - return new_r; -} - -define smooth (r) -{ - variable r0, r1, r2; - variable n = length (r); - variable new_r = Double_Type [n]; - r0 = r[0]; - new_r[0] = r0; - variable i; - _for (1, n-2, 1) - { - i = (); - r1 = r[i]; - r2 = r[i+1]; - if (0) - new_r[i] = [r0, r1, r2][array_sort([r0,r1,r2])[1]]; - else - new_r[i] = (r0 + r1 + r2)/3.0; - r0 = r1; - } - new_r[-1] = r[-1]; - return new_r; -} - -define process_shell (shell, nsmooth) -{ - variable e, r, dr; - variable i; - (e,r,dr) = compute_ratio (shell); - variable e1, e2, r1, r2; - - variable cutoff; - variable cutoffs = [0.0, 6.8, 0.0, 6.8, 8.0, 0.0, 10.0]; - - if (nsmooth < 0) - return e, r; - - loop (nsmooth) - r = smooth (r); - - cutoff = cutoffs[shell]; - i = where (e <= cutoff); - e1 = e[i]; r1 = r[i]; - i = prune (e1, r1, NULL, 0.005/2); - e1 = e1[i]; r1 = r1[i]; - - i = where (e > cutoff); - e2 = [min(e[i]):max(e[i]):0.05]; - % The 0.003 factor must match the bin width in mk_hrma_ea.sl - r2 = hist1d_rebin (e2, e[i], r[i])*0.003/0.05; - i = prune (e2, r2, NULL, 0.01/2); - e2 = e2[i]; r2 = r2[i]; - - vmessage ("reduction of %d/%d [%d,%d]", - length (e1)+length(e2), length(e), length (e1), length (e2)); - return ([e1, e2, [e2[-1]+1]], [r1, r2, [r2[-1]]]); -} - -define plot_shell (shell, nsmooth) -{ - variable w = xfig_plot_new (15,7); - w.title ("HRMA shell $shell"$); - w.xlabel ("Energy [keV]"); - w.ylabel ("Correction Factor"); - - variable e1, r1, e, r, dr; - (e, r, dr) = compute_ratio (shell); - (e1,r1) = process_shell (shell, nsmooth); - w.plot (e,r;color="blue"); - w.plot (e1,r1;color="red"); - - variable w1 = xfig_plot_new (15,3); - r1 = interp_linear (e, e1, r1); - w1.plot (e, (r - r1)/dr; color="blue"); - w1.xlabel ("Energy [keV]"); - w1.ylabel ("Residual"); - return xfig_multiplot (w,w1); -} - -define write_shell (shell, nsmooth) -{ - variable fp = fopen ("${Prefix}corr_$shell.tbl"$, "w"); - () = array_map (Int_Type, &fprintf, fp, "%g %g\n", process_shell (shell, nsmooth)); - () = fclose (fp); -} - -define slsh_main () -{ - variable wlist = {}; - variable nsmooth = 2; - foreach ([1,3,4,6]) - { - variable shell = (); - write_shell (shell, nsmooth); - list_insert (wlist, plot_shell (shell, nsmooth)); - } - - xfig_new_vbox_compound - ( - xfig_new_hbox_compound (wlist[0], wlist[1], 1), - xfig_new_hbox_compound (wlist[2], wlist[3], 1), - 2 - ).render ("${Prefix}corr.pdf"$); -} - - diff --git a/marx/data/utils/run_mkarf.sh b/marx/data/utils/run_mkarf.sh deleted file mode 100644 index badc661..0000000 --- a/marx/data/utils/run_mkarf.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh -# This script creates the reference arfs. First it runs marx to create an -# on-axis simulation. From that, a pcad file is created. -# Then the reference arfs are created using the pcad and marx event file as -# input. - -runciao="./runciaotool.sh" -# $runciaox is a script that runs a ciaotool in its own environment - -outdir="point" -datadir=".." -bindir="../../src/objs" -pardir="../../par" -marx="$bindir/marx" -marx2fits="$bindir/marx2fits" -marxasp="$bindir/marxasp" -evtfile="marx.evt" -asolfile="marx.asol" -arfprefix="hrma" -aspfile="marx.asp" - -cp $pardir/marx.par . -cp $pardir/marxasp.par . - -# Run the simulation and create the evt, and asol files. -$marx OutputDir=$outdir DataDirectory=$datadir \ - SourceRA=0 SourceDec=0 RA_Nom=0 Dec_Nom=0 Roll_Nom=0 DitherModel=INTERNAL \ - SpectrumType=FLAT SourceFlux=0.001 MinEnergy=1.5 MaxEnergy=1.5 \ - ExposureTime=10000 GratingType=NONE DetectorType=ACIS-S \ - ACIS_Exposure_Time=3.2 ACIS_Frame_Transfer_Time=0.0 - -echo $marx2fits "$outdir" "$evtfile" -$marx2fits "$outdir" "$evtfile" -echo $marxasp OutputFile="$asolfile" MarxDir="$outdir" -$marxasp OutputFile="$asolfile" MarxDir="$outdir" - -# Now create the aspect histogram and the arfs -detname="ACIS-7;UNIFORM;ideal;bpmask=0" -grating="NONE" -engrid="0.03:12.0:0.003" -obsfile="$evtfile" - -echo asphist infile="$asolfile" outfile="$aspfile" evtfile="$evtfile" \ - verbose=0 mode=h clobber=yes -$runciao asphist infile="$asolfile" outfile="$aspfile" evtfile="$evtfile" \ - verbose=0 mode=h clobber=yes - -X=4096.5 Y=4096.5 - -for shell in 1 3 4 6 -do - outfile="$arfprefix$shell.arf" - echo mkarf mirror="hrma;shell=$shell" detsubsys="$detname" grating="$grating" \ - outfile="$outfile" engrid="$engrid" asphistfile="$aspfile" \ - sourcepixelx=$X sourcepixely=$Y obsfile="$evtfile" \ - maskfile=NONE pbkfile=NONE dafile=NONE verbose=1 mode=h clobber=yes - $runciao mkarf mirror="hrma;shell=$shell" detsubsys="$detname" grating="$grating" \ - outfile="$outfile" engrid="$engrid" asphistfile="$aspfile" \ - sourcepixelx=$X sourcepixely=$Y obsfile="$evtfile" \ - maskfile=NONE pbkfile=NONE dafile=NONE verbose=1 mode=h clobber=yes -done diff --git a/marx/doc/parms.txt b/marx/doc/parms.txt index 9f2da35..cbeb311 100644 --- a/marx/doc/parms.txt +++ b/marx/doc/parms.txt @@ -39,8 +39,8 @@ OutputDir MirrorType Type: s Mode: a - Value: "EA-MIRROR" - Min Value: "HRMA|EA-MIRROR" + Value: "HRMA" + Min Value: "HRMA" Max Value: Description: @@ -264,122 +264,7 @@ HRMAXOffset Description: HRMA XOffset (mm) -#---------------------------------------------------------------------------- -# EA Mirror Setup -#---------------------------------------------------------------------------- - - -MirrorF - Type: r - Mode: h - Value: 10.0692 - Min Value: 0.0 - Max Value: - Description: - - HRMA focal length (meters) - - -MirrorRadius1 - Type: r - Mode: h - Value: 600 - Min Value: 0.0 - Max Value: - Description: - - Mirror 1 radius (mm) - - -MirrorRadius3 - Type: r - Mode: h - Value: 480 - Min Value: 0.0 - Max Value: - Description: - - Mirror 3 radius (mm) - - -MirrorRadius4 - Type: r - Mode: h - Value: 425 - Min Value: 0.0 - Max Value: - Description: - - Mirror 4 radius (mm) - - -MirrorRadius6 - Type: r - Mode: h - Value: 310 - Min Value: 0.0 - Max Value: - Description: - - Mirror 6 radius (mm) - - -MirrorVig - Type: r - Mode: h - Value: 0.9 - Min Value: 0.0 - Max Value: 1.0 - Description: - - HRMA Vignetting factor - - -MirrorUseEA - Type: b - Mode: a - Value: yes - Min Value: - Max Value: - Description: - - Use effective area for HRMA? - - -MirrorEAFile - Type: f - Mode: h - Value: "Ae_s1346.tbl" - Min Value: - Max Value: - Description: - - mirror effective filename -#--------------------------------------------------------------------------- -# Mirror Blur Setup -#--------------------------------------------------------------------------- - - -MirrorBlur - Type: b - Mode: a - Value: yes - Min Value: - Max Value: - Description: - - Perform mirror blur? - - -MirrorBlurFile - Type: f - Mode: h - Value: "mirr-ee.dat" - Min Value: - Max Value: - Description: - mirror blur filename #--------------------------------------------------------------------------- # Grating setup #--------------------------------------------------------------------------- diff --git a/marx/libsrc/Makefile.in b/marx/libsrc/Makefile.in index 23465c2..3fa74d1 100644 --- a/marx/libsrc/Makefile.in +++ b/marx/libsrc/Makefile.in @@ -42,7 +42,6 @@ PFILEDIR = $(datarootdir)/marx/pfiles install_lib_dir = @libdir@ install_include_dir = @includedir@ -EE_DATADIR = $(SRCDIR)/../data/ea-mirror MARX_DATA_DIR=$(DATADIR) MARX_PFILE_DIR=$(PFILEDIR) @@ -80,7 +79,7 @@ CONFIG_H = config.h ALL_CFLAGS = $(CFLAGS) -Dunix $(OTHER_DEFINES) $(INCLUDE_DIRS) COMPILE_CMD = $(CC) -c $(ALL_CFLAGS) -all: $(TARGET_OBJ_LIB) $(EE_DATADIR)/mirr-ee.bin +all: $(TARGET_OBJ_LIB) marxlib: $(TARGET_OBJ_LIB) $(TARGET_OBJ_LIB): $(CONFIG_H) $(OBJDIR) $(OBJS) @@ -92,11 +91,7 @@ $(OBJDIR) : $(CONFIG_H) : $(SRCDIR)/sysconf.h /bin/cp $(SRCDIR)/sysconf.h $(CONFIG_H) -/bin/rm -f $(OBJDIR)/*.o -#--------------------------------------------------------------------------- -# Data files -#--------------------------------------------------------------------------- -$(EE_DATADIR)/mirr-ee.bin: $(OBJDIR)/fix_ee $(EE_DATADIR)/Mirror_EE.bin - cd $(EE_DATADIR); $(OBJDIR)/fix_ee + #--------------------------------------------------------------------------- # Intallation rules #--------------------------------------------------------------------------- @@ -117,7 +112,6 @@ clean: -/bin/rm -f $(OBJDIR)/* *~ distclean: clean -/bin/rm -rf $(OBJDIR) Makefile sysconf.h - -/bin/rm $(EE_DATADIR)/mirr-ee.bin #--------------------------------------------------------------------------- $(SRCDIR)/source.c: $(SRCDIR)/source.def touch $(SRCDIR)/source.c diff --git a/marx/libsrc/_marx.h b/marx/libsrc/_marx.h index a05bcac..e13f07f 100644 --- a/marx/libsrc/_marx.h +++ b/marx/libsrc/_marx.h @@ -156,9 +156,6 @@ void _marx_dither_detector (Marx_Dither_Type *); void _marx_dither_set_ray_tstart (double); #endif -extern int _marx_init_mirror_blur (Param_File_Type *); -extern int _marx_mirror_blur (Marx_Photon_Type *); - extern int _marx_hrc_s_detect (Marx_Photon_Type *); extern int _marx_hrc_i_detect (Marx_Photon_Type *); extern int _marx_acis_s_detect (Marx_Photon_Type *); @@ -182,8 +179,6 @@ extern int _marx_drake_flat_init (Param_File_Type *); extern int _marx_hrma_mirror_init (Param_File_Type *); extern int _marx_hrma_mirror_reflect (Marx_Photon_Type *); -extern int _marx_ea_mirror_init (Param_File_Type *); -extern int _marx_ea_mirror_reflect (Marx_Photon_Type *); extern int _marx_ff_mirror_init (Param_File_Type *); extern int _marx_ff_mirror_reflect (Marx_Photon_Type *); diff --git a/marx/libsrc/dump_ee.c b/marx/libsrc/dump_ee.c deleted file mode 100644 index 3421a51..0000000 --- a/marx/libsrc/dump_ee.c +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- mode: C; mode: fold; -*- */ -/* - This file is part of MARX - - Copyright (C) 2002-2022 Massachusetts Institute of Technology - - This software was developed by the MIT Center for Space Research - under contract SV1-61010 from the Smithsonian Institution. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#include "config.h" - -#include -#include -#include - -#ifdef HAVE_STDLIB_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif - -#include - - /* Now read in each encircled energy array one by one. Use the array to - * interpolate a new set of thetas for a common ee grid. That is, the - * file contains a mapping of encircled energies as a function of theta - * where there is a common theta axis. Simply transform to the reverse--- - * theta as a function of ee. - */ - -static void read_error (void) /*{{{*/ -{ - fprintf (stderr, "read error.\n"); - exit (-1); -} - -/*}}}*/ - -int main (int argc, char **argv) /*{{{*/ -{ - FILE *fp; - char *file = "mirr-ee.dat"; - int num_ee; - int num_energies; - float value; - float *energies; - float *ee; - - int i, n; - - if (NULL == (fp = fopen (file, "rb"))) return -1; - - if ((1 != JDMread_int32 (&num_energies, 1, fp)) - || (1 != JDMread_int32 (&num_ee, 1, fp))) - read_error (); - - if ((NULL == (ee = JDMfloat_vector (num_ee))) - || (NULL == (energies = JDMfloat_vector (num_energies)))) - JDMmsg_error (NULL); - - if ((num_energies != JDMread_float32 (energies, num_energies, fp)) - || (num_ee != JDMread_float32 (ee, num_ee, fp))) - read_error (); - - /* Now interpolate all thetas to this grid */ - for (n = 0; n < 4; n++) - { - for (i = 0; i < num_energies; i++) - { - int j; - fprintf (stdout, "#energy: %e\n", energies[i]); - for (j = 0; j < num_ee; j++) - { - if (1 != JDMread_float32 (&value, 1, fp)) - read_error (); - - fprintf (stdout, "%e %e\n", ee[j], value); - } - fprintf (stdout, "@eod\n"); - } - fprintf (stdout, "@pause\n@clear\n"); - } - - fclose (fp); - return 0; -} - -/*}}}*/ diff --git a/marx/libsrc/eamirror.c b/marx/libsrc/eamirror.c deleted file mode 100644 index f16d12b..0000000 --- a/marx/libsrc/eamirror.c +++ /dev/null @@ -1,495 +0,0 @@ -/* -*- mode: C; mode: fold -*- */ -/* - This file is part of MARX - - Copyright (C) 2002-2022 Massachusetts Institute of Technology - - This software was developed by the MIT Center for Space Research - under contract SV1-61010 from the Smithsonian Institution. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#include "config.h" -#include "marx-feat.h" - -/*{{{ #include files */ - -#include -#include - -#ifdef HAVE_STDLIB_H -# include -#endif -#include - -#include -#include - -#include "marx.h" -#include "_marx.h" - -/*}}}*/ - -static double Mirror_Vignetting_Factor = 1.0; - -/* This distance is distance from 1/2 H segment on HRMA to Focus. */ -static double HRMA_Position = (1000.0 * (10.0692 - 0.83 / 2.0)); /* mm */ -static char *HRMA_EA_File; - -/* These Numbers are taken from SIN */ -static double Mirror_Radii[MARX_NUM_MIRRORS] = /*{{{*/ -{ - 600.0, 480.0, 425.0, 310.0 /* mm */ -}; - -/*}}}*/ - -/* The mirror shutters consist of a string characters (0,1) that represent - * a bitmapped array for the mirror shutters. 1 means the shutter is closed - * for that quadrant. - */ -static char *Mirror_Shutters [MARX_NUM_MIRRORS]; - -static int Mirror_Use_Effective_Area; -static Param_Table_Type HRMA_Parm_Table [] = /*{{{*/ -{ - {"MirrorVig", PF_REAL_TYPE, &Mirror_Vignetting_Factor}, - {"MirrorRadius1", PF_REAL_TYPE, &Mirror_Radii[0]}, - {"MirrorRadius3", PF_REAL_TYPE, &Mirror_Radii[1]}, - {"MirrorRadius4", PF_REAL_TYPE, &Mirror_Radii[2]}, - {"MirrorRadius6", PF_REAL_TYPE, &Mirror_Radii[3]}, - {"MirrorEAFile", PF_FILE_TYPE, &HRMA_EA_File}, - {"MirrorUseEA", PF_BOOLEAN_TYPE, &Mirror_Use_Effective_Area}, - {"Shutters1", PF_STRING_TYPE, &Mirror_Shutters[0]}, - {"Shutters3", PF_STRING_TYPE, &Mirror_Shutters[1]}, - {"Shutters4", PF_STRING_TYPE, &Mirror_Shutters[2]}, - {"Shutters6", PF_STRING_TYPE, &Mirror_Shutters[3]}, - {NULL, 0, NULL} -}; - -/*}}}*/ - -typedef struct /*{{{*/ -{ - unsigned int n_energies; - float *energies; - float *cum_eff_area[MARX_NUM_MIRRORS]; /* normalized by the total geometric area */ - double radius[MARX_NUM_MIRRORS]; - unsigned int n_mirrors; - /* It is not quite clear that these parameters should be here or elsewhere. */ - double vignetting_factor; - unsigned int shutter_bitmap[MARX_NUM_MIRRORS]; - unsigned int num_open_shutters[MARX_NUM_MIRRORS]; -} - -/*}}}*/ -Mirror_Type; - -static Mirror_Type Mirrors; - -#ifdef NOT_IMPLEMENTED -static void create_on_axis_ray (Marx_Photon_Attr_Type *at) /*{{{*/ -{ - double azimuth; - - /* Assign an azimuthal angle */ - azimuth = JDMrandom () * (2.0 * PI); - at->x.x = 0.0; - at->x.y = cos (azimuth); - at->x.z = sin (azimuth); - at->p.x = 1.0; - at->p.y = 0.0; - at->p.z = 0.0; -} - -/*}}}*/ -#endif - -/* The mirror file contains 7 columns: - * wavelength, energy, total_area, area_1, area_3, area_4, area_6 - * The first line of this format contains geometric information (zero energy limit.) - * The following lines are effective areas. - */ -int _marx_ea_mirror_init (Param_File_Type *p) /*{{{*/ -{ - double g_area; - unsigned int nread; - unsigned int i, j; - unsigned int n_mirrors = MARX_NUM_MIRRORS; - char *file; - int verbose; - - if ((-1 == pf_get_parameters (p, HRMA_Parm_Table)) - || (HRMA_EA_File == NULL) || (0 == *HRMA_EA_File)) - return -1; - - for (j = 0; j < n_mirrors; j++) - { - if (-1 == _marx_parse_shutter_string (Mirror_Shutters[j], - &Mirrors.shutter_bitmap[j], &Mirrors.num_open_shutters[j])) - return -1; - } - - if (-1 == _marx_init_mirror_blur (p)) - { - JDMmsg_error ("Unable to initial mirror blur."); - return -1; - } - - if (NULL == (file = marx_make_data_file_name (HRMA_EA_File))) - return -1; - - /* clean up from a previous call */ - for (j = 0; j < n_mirrors; j++) - { - if (Mirrors.cum_eff_area[j] != NULL) - JDMfree_float_vector (Mirrors.cum_eff_area[j]); - Mirrors.cum_eff_area[j] = NULL; - } - if (Mirrors.energies != NULL) JDMfree_float_vector (Mirrors.energies); - Mirrors.energies = NULL; - - if (-1 == pf_get_integer(p, "Verbose", &verbose)) - return -1; - - if (verbose > 1) marx_message ("Reading binary mirror effective area file\n\t%s\n", file); - - if (-1 == marx_f_read_bdat (file, &nread, 7, - NULL, /* wavelength */ - &Mirrors.energies, - NULL, /* total area */ - &Mirrors.cum_eff_area[0], - &Mirrors.cum_eff_area[1], - &Mirrors.cum_eff_area[2], - &Mirrors.cum_eff_area[3])) - { - marx_free (file); - return -1; - } - marx_free (file); - - /* The zeroth element of the arrays is the geometric area. Find the total - * geometric area taking into account of shutters. - */ - g_area = 0.0; - for (j = 0; j < n_mirrors; j++) - { - if (Mirrors.num_open_shutters[j]) - { - g_area += 0.25 * Mirrors.cum_eff_area [j][0] * Mirrors.num_open_shutters[j]; - } - } - - if (g_area <= 0.0) - { - marx_error ("The mirror geometric area is 0. Check shutters."); - return -1; - } - - Marx_Mirror_Geometric_Area = g_area; - - /* Now compute the cumulative effective area. Take shutters into account. */ - for (i = 0; i < nread; i++) - { - double total = 0.0; - for (j = 0; j < n_mirrors; j++) - { - if (Mirrors.num_open_shutters[j]) - { - total += 0.25 * Mirrors.cum_eff_area[j][i] * Mirrors.num_open_shutters[j]; - } - Mirrors.cum_eff_area[j][i] = total / g_area; - } - } - - Mirrors.n_mirrors = n_mirrors; - Mirrors.n_energies = nread; - Mirrors.vignetting_factor = Mirror_Vignetting_Factor; - - for (j = 0; j < n_mirrors; j++) - { - Mirrors.radius[j] = Mirror_Radii[j]; - } - HRMA_Position = (Marx_Focal_Length - 830.0 / 2.0); /* mm */ - - return 0; -} - -/*}}}*/ - -/* Now we give the photon a position and direction. We must first project - * photons to the mirror as on-axis rays since that is all this module - * was designed for. - */ -static void reflect_photon (Marx_Photon_Attr_Type *at, unsigned int shell) /*{{{*/ -{ - JDMVector_Type *x, *p; - double radius, theta; - unsigned int bitmap, quad; - - at->mirror_shell = shell; - radius = Mirrors.radius[shell]; - bitmap = Mirrors.shutter_bitmap[shell]; - - do - { - theta = JDMrandom (); - quad = (unsigned int) (4.0 * theta); /* 0, 1, 2, 3 */ - } - while (0 == (bitmap & (1 << quad))); - - theta = (2.0 * PI) * (theta - 1.0 / 8.0); - - x = &(at->x); - - x->y = radius * sin (theta); - x->z = radius * cos (theta); - x->x = HRMA_Position; - - p = &(at->p); - /* For a perfectly focused ray, the direction is just -x/|x|. */ - p->x = -x->x; - p->y = -x->y; - p->z = -x->z; - JDMv_normalize (p); -} - -/*}}}*/ - -static int mirror_perfect_reflect (Marx_Photon_Type *); - -int _marx_ea_mirror_reflect (Marx_Photon_Type *pt) /*{{{*/ -{ - Marx_Photon_Attr_Type *photon_attributes, *at; - double r; - double *photon_energies; - unsigned int n, i, *sorted_index; - double **interp_areas; - unsigned int n_mirrors = Mirrors.n_mirrors; - - if (pt->history & MARX_MIRROR_SHELL_OK) - return 0; /* been here already */ - - pt->history |= MARX_MIRROR_SHELL_OK; - - if (Mirror_Use_Effective_Area == 0) - return mirror_perfect_reflect (pt); - - marx_prune_photons (pt); - n = pt->num_sorted; - photon_attributes = pt->attributes; - sorted_index = pt->sorted_index; - - /* First of all, apply to vignetting factor to kill a certain percentage - * of photons. - */ - for (i = 0; i < n; i++) - { - if (JDMrandom () > Mirrors.vignetting_factor) - { - (photon_attributes + sorted_index[i])->flags |= PHOTON_MIRROR_VBLOCKED; - } - } - - /* I could have pruned in the previous loop but it is a better idea to - * leave it for a function call. - */ - marx_prune_photons (pt); - photon_energies = pt->sorted_energies; - n = pt->num_sorted; - - interp_areas = JDMdouble_matrix (n_mirrors, n); - if (interp_areas == NULL) return -1; - - /* Now perform the interpolation */ - JDMinterpolate_n_dfvector (photon_energies, interp_areas, n, - Mirrors.energies, Mirrors.cum_eff_area, Mirrors.n_energies, - n_mirrors); - - for (i = 0; i < n; i++) - { - unsigned int shell; - - r = JDMrandom (); - at = photon_attributes + sorted_index[i]; - - for (shell = 0; shell < n_mirrors; shell++) - { - if (r <= interp_areas[shell][i]) - { - reflect_photon (at, shell); - break; - } - } - if (shell == n_mirrors) - { -#if 0 - static FILE *fp; - if (fp == NULL) fp = fopen ("out", "w"); - if (fp != NULL) - { - fprintf (fp, "%d\t%16g%16g\n", i, at->arrival_time, at->energy); - } -#endif - at->flags |= PHOTON_UNREFLECTED; - } - } - - JDMfree_double_matrix (interp_areas, n_mirrors); - return _marx_mirror_blur (pt); -} - -/*}}}*/ - -static int mirror_perfect_reflect (Marx_Photon_Type *pt) /*{{{*/ -{ - Marx_Photon_Attr_Type *photon_attributes, *at; - double r; - double *photon_energies; - unsigned int n, i, *sorted_index; - unsigned int n_mirrors = Mirrors.n_mirrors, shell; - double cum[MARX_NUM_MIRRORS]; - - marx_prune_photons (pt); - n = pt->num_sorted; - photon_attributes = pt->attributes; - sorted_index = pt->sorted_index; - - /* First of all, apply to vignetting factor to kill a certain percentage - * of photons. - */ - for (i = 0; i < n; i++) - { - if (JDMrandom () > Mirrors.vignetting_factor) - { - (photon_attributes + sorted_index[i])->flags |= PHOTON_MIRROR_VBLOCKED; - } - } - - marx_prune_photons (pt); - photon_energies = pt->sorted_energies; - n = pt->num_sorted; - - for (shell = 0; shell < n_mirrors; shell++) - { - cum[shell] = Mirrors.cum_eff_area[shell][0]; - } - - for (i = 0; i < n; i++) - { - r = JDMrandom (); - at = photon_attributes + sorted_index[i]; - - for (shell = 0; shell < n_mirrors; shell++) - { - if (r <= cum[shell]) - { - reflect_photon (at, shell); - break; - } - } - if (shell == n_mirrors) - at->flags |= PHOTON_UNREFLECTED; - } - - return _marx_mirror_blur (pt); -} - -/*}}}*/ - -#ifdef NOT_IMPLEMENTED -int init_mirror_module (void) /*{{{*/ -{ - return 0; -} - -/*}}}*/ -int dump_mirror_curves (double energy, FILE *fp) /*{{{*/ -{ - int i; - double **eff_area; - double total; - - for (i = 0; i < Mirrors.n_mirrors; i++) - { - if (Mirrors.cum_eff_area[i] == NULL) - { - marx_error ("dump_mirror_curves: no data."); - return -1; - } - } - - eff_area = JDMdouble_matrix (Mirrors.n_mirrors, 1); - if (eff_area == NULL) - { - marx_error ("dump_mirror_curves: Not enough memory."); - return -1; - } - - JDMinterpolate_n_dvector (&energy, eff_area, 1, - Mirrors.energies, Mirrors.cum_eff_area, - Mirrors.n_energies, - Mirrors.n_mirrors); - - total = 0.0; - for (i = 0; i < Mirrors.n_mirrors; i++) - { - double value; - - value = eff_area[i][0] - total; - total += value; - - if (EOF == fprintf (fp, "\t%e", value)) - { - marx_error ("dump_mirror_curves: write error."); - JDMfree_double_matrix (eff_area, Mirrors.n_mirrors); - return -1; - } - } -#if 1 - fprintf (fp, "\t%e", total); -#endif - JDMfree_double_matrix (eff_area, Mirrors.n_mirrors); - return 0; -} - -/*}}}*/ -unsigned int dump_mirror_curves_open (unsigned int i, FILE *fp) /*{{{*/ -{ - unsigned int j; - - fputs ("\n#Mirror:", fp); - for (j = 0; j < 4; j++) - { - fprintf (fp, " Col_%u:Mirror-Shell-%u", i, j); - i++; - } - - fprintf (fp, " Col_%u:Total_Mirror", i); - i++; - return i; -} - -/*}}}*/ -int dump_mirror_variables (FILE *fp) /*{{{*/ -{ - fprintf (fp, "--Mirror Module Variables--\n"); - fprintf (fp, " Mirror_Geometric_Area: %f\n", Mirror_Geometric_Area); - fprintf (fp, " Mirror_Vignetting_Factor: %f\n", Mirror_Vignetting_Factor); - return 0; -} - -/*}}}*/ -#endif diff --git a/marx/libsrc/fix_ee.c b/marx/libsrc/fix_ee.c deleted file mode 100644 index a6409b1..0000000 --- a/marx/libsrc/fix_ee.c +++ /dev/null @@ -1,165 +0,0 @@ -/* -*- mode: C; mode: fold; -*- */ -/* - This file is part of MARX - - Copyright (C) 2002-2022 Massachusetts Institute of Technology - - This software was developed by the MIT Center for Space Research - under contract SV1-61010 from the Smithsonian Institution. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#include "config.h" - -#include -#include -#include - -#ifdef HAVE_STDLIB_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif - -#include - - /* Now read in each encircled energy array one by one. Use the array to - * interpolate a new set of thetas for a common ee grid. That is, the - * file contains a mapping of encircled energies as a function of theta - * where there is a common theta axis. Simply transform to the reverse--- - * theta as a function of ee. - */ - -int main (int argc, char **argv) /*{{{*/ -{ - FILE *fp, *fpout; - char *file = "Mirror_EE.bin"; - float32 theta[564]; - float32 new_theta[564]; - float32 energy[25]; - float32 ee_n[4][25][564]; - int32 num_ee = 564; - int32 num_energies = 25; - float32 new_ee[564]; - unsigned int i, n; - - (void) argc; (void) argv; - - if (NULL == (fp = fopen (file, "rb"))) return -1; - - if (25 != JDMread_float32 (energy, 25, fp)) - return -1; - - if (564 != JDMread_float32 (theta, 564, fp)) - return -1; - - if (4 * 564 * 25 != JDMread_float32 ((float32 *)ee_n, 4 * 564 * 25, fp)) - return -1; - - fclose (fp); - - /* Fix up data. The EEs should be an increasing function ending at 1.0!! - */ - for (n = 0; n < 4; n++) - { - for (i = 0; i < 25; i++) - { - float min_ee = 0.0; - unsigned int j; - for (j = 0; j < 563; j++) - { - float this_ee = ee_n[n][i][j]; - if (this_ee < min_ee) ee_n[n][i][j] = min_ee; - else min_ee = this_ee; - } - ee_n[n][i][563] = 1.0; - } - } - - if (NULL == (fpout = fopen ("mirr-ee.bin", "wb"))) - { - fprintf (stderr, "Unable to open output file.\n"); - exit (-1); - } - - JDMwrite_int32 (&num_energies, 1, fpout); - JDMwrite_int32 (&num_ee, 1, fpout); - - if (num_energies != (int)JDMwrite_float32 (energy, (unsigned int) num_energies, fpout)) - { - fprintf (stderr, "Write error.\n"); - return -1; - } - - /* Create a new ee grid. Since the function goes up very fast and levels - * out at 1.0, use a log grid to give more samples near 1.0. - */ - for (i = 1; i <= (unsigned int) num_ee; i++) - { - new_ee[i - 1] = (float) (log ((double)i) / log((double) num_ee)); - } - - if (num_ee != (int)JDMwrite_float32 (new_ee, (unsigned int) num_ee, fpout)) - { - fprintf (stderr, "Write error.\n"); - return -1; - } - - /* Now interpolate all thetas to this grid */ - for (n = 0; n < 4; n++) - { - for (i = 0; i < 25; i++) - { - unsigned int j; - JDMinterpolate_fvector (new_ee, new_theta, (unsigned int) num_ee, - (float *)ee_n[n][i], theta, (unsigned int) num_ee); - - /* Convert the theta array to radians. */ - for (j = 0; j < (unsigned int) num_ee; j++) - { - new_theta[j] = (new_theta[j] / 3600.0) * (PI / 180.0); - if (new_theta[j] < 0.0) new_theta[j] = 0.0; - } - - if (num_ee != (int)JDMwrite_float32 (new_theta, (unsigned int) num_ee, fpout)) - { - fprintf (stderr, "Write error.\n"); - return -1; - } - } - } -#if 0 - for (i = 0; i < num_ee; i++) - { - int j; - for (j = 0; j < num_energies; j++) - { - fprintf (stdout, "%e %e %e %e %e %e\n", - - new_theta[i], - new_ee[0][3][i], new_ee[1][3][i], - new_ee[2][3][i], new_ee[3][3][i]); - } - fputs ("\n\n", stdout); - } - -#endif - - fclose (fpout); - return 0; -} - -/*}}}*/ diff --git a/marx/libsrc/marx.h b/marx/libsrc/marx.h index 2b0f3d2..1f503e9 100644 --- a/marx/libsrc/marx.h +++ b/marx/libsrc/marx.h @@ -368,7 +368,6 @@ extern int marx_grating_diffract (Marx_Photon_Type *, int); #define MARX_DETECTOR_PLANE 5 #define MARX_MAX_DETECTORS 10 -#define MARX_MIRROR_EA 1 #define MARX_MIRROR_HRMA 2 #define MARX_MIRROR_FFIELD 3 diff --git a/marx/libsrc/mblur.c b/marx/libsrc/mblur.c deleted file mode 100644 index b09bb17..0000000 --- a/marx/libsrc/mblur.c +++ /dev/null @@ -1,273 +0,0 @@ -/* -*- mode: C; mode: fold; -*- */ -/* - This file is part of MARX - - Copyright (C) 2002-2022 Massachusetts Institute of Technology - - This software was developed by the MIT Center for Space Research - under contract SV1-61010 from the Smithsonian Institution. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -/* Mirror Blur module */ - -#include "config.h" -#include "marx-feat.h" - -#include -#include - -#ifdef HAVE_STDLIB_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif - -#include -#include - -#include "marx.h" -#include "_marx.h" - -static int Perform_Blur = 0; -static int verbose = 0; - -/* This structure defines theta vs photon energy and encircled energy */ -typedef struct /*{{{*/ -{ - unsigned int num_ee; - unsigned int num_energies; - float *energies; - float *encircled_energies; - float **thetas[MARX_NUM_MIRRORS]; /* num_energies x num_ee */ -} -/*}}}*/ -Mirror_Blur_Type; - -static Mirror_Blur_Type Mirr_Blur; - -static void free_mirror_blurs (void) /*{{{*/ -{ - unsigned int i; - - if (Mirr_Blur.energies != NULL) - { - JDMfree_float_vector (Mirr_Blur.energies); - Mirr_Blur.energies = NULL; - } - - if (Mirr_Blur.encircled_energies != NULL) - { - JDMfree_float_vector (Mirr_Blur.encircled_energies); - Mirr_Blur.encircled_energies = NULL; - } - - for (i = 0; i < MARX_NUM_MIRRORS; i++) - { - if (Mirr_Blur.thetas[i] != NULL) - { - JDMfree_float_matrix (Mirr_Blur.thetas[i], Mirr_Blur.num_energies); - Mirr_Blur.thetas[i] = NULL; - } - } -} - -/*}}}*/ - -int _marx_init_mirror_blur (Param_File_Type *p) /*{{{*/ -{ - FILE *fp; - unsigned int num_energies; - unsigned int num_ee; - unsigned int i; - char filebuf[PF_MAX_LINE_LEN]; - char *file; - - if (-1 == pf_get_boolean (p, "MirrorBlur", &Perform_Blur)) - return -1; - - if (Perform_Blur == 0) return 0; - - if (-1 == pf_get_file (p, "MirrorBlurFile", filebuf, sizeof (filebuf))) - { - Perform_Blur = 0; - return -1; - } - - if (-1 == pf_get_integer(p, "Verbose", &verbose)) - return -1; - - if (NULL == (file = marx_make_data_file_name(filebuf))) - return -1; - if (verbose == 1) - marx_message("Reading blur data file"); - if (verbose > 1) - marx_message("Reading blur data file:\n\t%s\n", file); - - if (NULL == (fp = fopen(file, "rb"))) - { - marx_error ("Unable to open file: %s", file); - marx_free (file); - JDMath_Error = JDMATH_FILE_OPEN_ERROR; - return -1; - } - - if ((1 != JDMread_int32 ((int32 *)&num_energies, 1, fp)) - || (1 != JDMread_int32 ((int32 *)&num_ee, 1, fp))) - { - JDMath_Error = JDMATH_FILE_READ_ERROR; - goto return_error; - } - - marx_free (file); - file = NULL; - - free_mirror_blurs (); - - /* Now allocate space for the blur data */ - Mirr_Blur.num_energies = num_energies; - if (NULL == (Mirr_Blur.energies = JDMfloat_vector (num_energies))) - goto return_error; - - if (num_energies != JDMread_float32(Mirr_Blur.energies, num_energies, fp)) - { - JDMath_Error = JDMATH_FILE_READ_ERROR; - goto return_error; - } - - Mirr_Blur.num_ee = num_ee; - if (NULL == (Mirr_Blur.encircled_energies = JDMfloat_vector (num_ee))) - goto return_error; - - if (num_ee != JDMread_float32(Mirr_Blur.encircled_energies, num_ee, fp)) - { - JDMath_Error = JDMATH_FILE_READ_ERROR; - goto return_error; - } - - for (i = 0; i < MARX_NUM_MIRRORS; i++) - { - unsigned int n; - if (NULL == (Mirr_Blur.thetas[i] = JDMfloat_matrix (num_energies, num_ee))) - goto return_error; - - for (n = 0; n < num_energies; n++) - { - if (num_ee != JDMread_float32(Mirr_Blur.thetas[i][n], num_ee, fp)) - { - JDMath_Error = JDMATH_FILE_READ_ERROR; - goto return_error; - } - } - } - fclose (fp); - return 0; - - /* Get here only if something goes wrong. */ - return_error: - if (file != NULL) marx_free (file); - free_mirror_blurs (); - fclose (fp); - return -1; -} - -/*}}}*/ - -static void blur_photon (Marx_Photon_Attr_Type *at, double blur) /*{{{*/ -{ - double alpha, beta, px; - JDMVector_Type *p; - - p = &(at->p); - px = p->x; - - /* Note: by construction in calling routines, px is NOT 1.0 */ - beta = sin (blur) / sqrt (1.0 - px * px); - alpha = cos (blur) - beta * px; - - p->x = alpha * px + beta; - p->y = alpha * p->y; - p->z = alpha * p->z; -} - -/*}}}*/ - -int _marx_mirror_blur (Marx_Photon_Type *pt) /*{{{*/ -{ - Marx_Photon_Attr_Type *photon_attributes, *at; - unsigned int n, i, *sorted_index; - float *encircled_energies, *energies; - unsigned int num_ee, num_energies; - - if (Perform_Blur == 0) return 0; - - marx_prune_photons (pt); - n = pt->num_sorted; - photon_attributes = pt->attributes; - sorted_index = pt->sorted_index; - - encircled_energies = Mirr_Blur.encircled_energies; - num_ee = Mirr_Blur.num_ee; - energies = Mirr_Blur.energies; - num_energies = Mirr_Blur.num_energies; - - for (i = 0; i < n; i++) - { - unsigned int j; - float energy, r, theta0, theta1; - float e0, e1; - double blur; - - at = photon_attributes + sorted_index[i]; - - energy = (float) at->energy; - /* Now find which two energy curves to use: j - 1 and j */ - j = JDMbinary_search_f (energy, energies, num_energies); - if (j == 0) - { - /* extrapolate */ - j++; - } - if (j == num_energies) - { - /* extrapolate */ - j--; - } - e0 = energies[j - 1]; - e1 = energies[j]; - - /* Ideally a random number between 0 and 1 would be used. However, - * the blur data close to 1.0 cannot be trusted. - */ - r = (float) 0.99 * JDMrandom (); - - /* Now interpolate thetas on the two energy curves */ - theta0 = JDMinterpolate_f (r, encircled_energies, - Mirr_Blur.thetas[at->mirror_shell][j - 1], - num_ee); - theta1 = JDMinterpolate_f (r, encircled_energies, - Mirr_Blur.thetas[at->mirror_shell][j], - num_ee); - blur = theta0 + (theta1 - theta0) * (energy - e0) / (e1 - e0); - - /* pick the sign of the blur angle */ - if (2.0 * JDMrandom () < 1.0) blur = -blur; - blur_photon (at, blur); - } - return 0; -} - -/*}}}*/ diff --git a/marx/libsrc/mirror.c b/marx/libsrc/mirror.c index 52f8426..a33bac4 100644 --- a/marx/libsrc/mirror.c +++ b/marx/libsrc/mirror.c @@ -58,8 +58,6 @@ int marx_mirror_init (Param_File_Type *pf) /*{{{*/ if (!strcmp (buf, "HRMA")) type = MARX_MIRROR_HRMA; - else if (!strcmp (buf, "EA-MIRROR")) - type = MARX_MIRROR_EA; else if (!strcmp (buf, "FLATFIELD")) type = MARX_MIRROR_FFIELD; else @@ -70,11 +68,6 @@ int marx_mirror_init (Param_File_Type *pf) /*{{{*/ switch (type) { - case MARX_MIRROR_EA: - if (-1 == _marx_ea_mirror_init (pf)) - type = -1; - break; - case MARX_MIRROR_HRMA: if (-1 == _marx_hrma_mirror_init (pf)) type = -1; @@ -105,10 +98,6 @@ int marx_mirror_reflect (Marx_Photon_Type *p, int verbose) /*{{{*/ if (verbose > 0) marx_message ("Reflecting from HRMA\n"); return _marx_hrma_mirror_reflect (p); - case MARX_MIRROR_EA: - if (verbose > 0) marx_message ("Reflecting from EA-MIRROR\n"); - return _marx_ea_mirror_reflect (p); - case MARX_MIRROR_FFIELD: if (verbose > 0) marx_message ("Flat Fielding Rays\n"); return _marx_ff_mirror_reflect (p); diff --git a/marx/libsrc/modules.lis b/marx/libsrc/modules.lis index 45858ec..70aba56 100644 --- a/marx/libsrc/modules.lis +++ b/marx/libsrc/modules.lis @@ -22,9 +22,7 @@ reflect util hrma mirror -eamirror grating -mblur wfold pixlib rdb diff --git a/marx/marx.lis b/marx/marx.lis index 8ed7a81..9aca02c 100644 --- a/marx/marx.lis +++ b/marx/marx.lis @@ -81,10 +81,7 @@ @libsrc/mirror.c @libsrc/diffract.c @libsrc/disperse.c -@libsrc/mblur.c @libsrc/interp.c -@libsrc/fix_ee.c -@libsrc/dump_ee.c @libsrc/detector.c @libsrc/detpix.c @libsrc/wfold.c @@ -98,7 +95,6 @@ @libsrc/source.c @libsrc/source.def @libsrc/util.c -@libsrc/eamirror.c @libsrc/grating.c @libsrc/pixlib.c @libsrc/rdb.c @@ -177,10 +173,6 @@ #*data/acis/s5_w201c3r_eff_898_release.dat #*data/acis/acisD1999-12-10gain_marxN0001_110.fits -@data/ea-mirror/README -*data/ea-mirror/Ae_s1346.dat -*data/ea-mirror/Mirror_EE.bin - @data/grating/README *data/grating/optical-constants.dat @data/grating/optical-constants.xray diff --git a/marx/marxlib.lis b/marx/marxlib.lis index 9e1b0a8..46cac03 100644 --- a/marx/marxlib.lis +++ b/marx/marxlib.lis @@ -30,10 +30,7 @@ @libsrc/mirror.c @libsrc/diffract.c @libsrc/disperse.c -@libsrc/mblur.c @libsrc/interp.c -@libsrc/fix_ee.c -@libsrc/dump_ee.c @libsrc/detector.c @libsrc/detpix.c @libsrc/wfold.c @@ -47,7 +44,6 @@ @libsrc/source.c @libsrc/source.def @libsrc/util.c -@libsrc/eamirror.c @libsrc/grating.c @libsrc/pixlib.c @libsrc/rdb.c diff --git a/marx/par/marx.par b/marx/par/marx.par index 78094bb..87d0789 100644 --- a/marx/par/marx.par +++ b/marx/par/marx.par @@ -20,7 +20,7 @@ Verbose,i,a,1,,,"Verbose mode" # Science Instrument set up and control # #--------------------------------------------------------------------------- -MirrorType,s,a,"HRMA","HRMA|EA-MIRROR|FLATFIELD",,"mirror type" +MirrorType,s,a,"HRMA","HRMA|FLATFIELD",,"mirror type" GratingType,s,a,"HETG","HETG|LETG|NONE",,"grating type" DetectorType,s,a,"ACIS-S","HRC-S|ACIS-S|HRC-I|ACIS-I|NONE",,"detector type" DetIdeal,b,a,no,,,"Is Detector perfect (QE=1)?" @@ -224,20 +224,6 @@ HRMA_P6H6_XOffset,r,h,-0.541755,,,"HRMA P6H6 X offset (mm)" # PointingOffsetY,r,h,0,,,"Optical-Axis/Pointing Y Misalignment (arcsec)" PointingOffsetZ,r,h,0,,,"Optical-Axis/Pointing Z Misalignment (arcsec)" -#---------------------------------------------------------------------------- -# -# EA Mirror Setup -# -#---------------------------------------------------------------------------- -MirrorRadius1,r,h,600,0.0,,"Mirror 1 radius (mm)" -MirrorRadius3,r,h,480,0.0,,"Mirror 3 radius (mm)" -MirrorRadius4,r,h,425,0.0,,"Mirror 4 radius (mm)" -MirrorRadius6,r,h,310,0.0,,"Mirror 6 radius (mm)" -MirrorVig,r,h,0.9,0.0,1.0,"HRMA Vignetting factor" -MirrorUseEA,b,a,yes,,,"Use effective area for HRMA?" -MirrorEAFile,f,h,"ea-mirror/Ae_s1346.dat",,,"mirror effective filename" -MirrorBlur,b,a,yes,,,"Perform mirror blur?" -MirrorBlurFile,f,h,"ea-mirror/mirr-ee.bin",,,"mirror blur filename" #--------------------------------------------------------------------------- # # Grating setup diff --git a/marx/par/marx_xrcf.par b/marx/par/marx_xrcf.par index 4b1aed9..9f2fc4d 100644 --- a/marx/par/marx_xrcf.par +++ b/marx/par/marx_xrcf.par @@ -27,7 +27,7 @@ Verbose,b,a,yes,,,"Verbose mode" # Science Instrument set up and control # #--------------------------------------------------------------------------- -MirrorType,s,a,"HRMA","HRMA|EA-MIRROR",,"Select mirror type" +MirrorType,s,a,"HRMA","HRMA",,"Select mirror type" GratingType,s,a,"HETG","HETG|LETG|NONE",,"Select grating type" DetectorType,s,a,"ACIS-S","HRC-S|ACIS-S|HRC-I|ACIS-I|NONE",,"Select detector type" DetOffsetX,r,a,-195.002109,,,"Enter Detector X offset from nominal (mm)" @@ -158,21 +158,6 @@ HRMA_P1H1_XOffset,r,h,-3.274354,,,"Enter HRMA P1H1 X offset (mm)" HRMA_P3H3_XOffset,r,h,-0.256876,,,"Enter HRMA P3H3 X offset (mm)" HRMA_P4H4_XOffset,r,h,0.735539,,,"Enter HRMA P4H4 X offset (mm)" HRMA_P6H6_XOffset,r,h,-0.539117,,,"Enter HRMA P6H6 X offset (mm)" -#---------------------------------------------------------------------------- -# -# EA Mirror Setup -# -#---------------------------------------------------------------------------- -MirrorF,r,h,10.0692,0.0,,"Enter HRMA focal length (meters)" -MirrorRadius1,r,h,600,0.0,,"Enter Mirror 1 radius (mm)" -MirrorRadius3,r,h,480,0.0,,"Enter Mirror 3 radius (mm)" -MirrorRadius4,r,h,425,0.0,,"Enter Mirror 4 radius (mm)" -MirrorRadius6,r,h,310,0.0,,"Enter Mirror 6 radius (mm)" -MirrorVig,r,h,0.9,0.0,1.0,"Enter HRMA Vignetting factor" -MirrorUseEA,b,a,yes,,,"Use effective area for HRMA?" -MirrorEAFile,f,h,"Ae_s1346.dat",,,"Enter mirror effective filename" -MirrorBlur,b,a,yes,,,"Perform mirror blur?" -MirrorBlurFile,f,h,"mirr-ee.bin",,,"Enter mirror blur filename" #--------------------------------------------------------------------------- # # Grating setup