The ardlib.h header file must be included in any file that makes use of ardlib via a line such as
#include <ardlib.h>
Before the library can be used, it must first be initialized via the
ardlib_initialize function. This function is also used to
specify the mission for which quantities are to be computed, e.g.,
if (-1 == ardlib_initialize ("CHANDRA", "acisf00105N002_evt2.fits"))
{
fprintf (stderr, "Failed to initialized ardlib\n");
exit (1);
}
Here, the second argument to ardlib_initialize is the name of a
fits file containing observation specific information, e.g., a events
file. This file is used to access calibration files from the CALDB.
When one is finished using the library, the application should call
ardlib_finalize to allow the library to deallocate any internal
data structures that it may have created:
(void) ardlib_finalize ();
After calling ardlib_initialize, the application may call other
ardlib functions to compute effective areas, QEs, and so forth. The
use of the latter functions all follow the same general pattern.
First of all, a function call to an object-specific open
function must be made to obtain a pointer (specifically, an opaque
pointer) to the object (e.g., a mirror) representing the desired
instrument (e.g., HRMA). The pointer may then be passed to an
object-specific compute function that performs the actual
calculation pertaining to the instrument. Finally, the pointer is to
be freed via a call to a close function.
For example, to compute mirror effective areas, the application must
call ardlib_open_mirror_ea to obtain a pointer to the specified
mirror effective area object. The pointer is then passed to the
ardlib_compute_mirror_ea function, which computes the
effective areas for a specified off-axis angle and list of energies.
Finally, the ardlib_close_mirror_ea function must be used to
delete the pointer after it is no longer needed. Here is a simple
example that illustrates the computation of the on-axis effective
area for several energies (one at a time):
Ardlib_Mirror_EA_Type *m;
float energy, eff_area;
m = ardlib_open_mirror_ea ("HRMA");
for (energy = 0.1; energy < 10.0; energy += 0.1)
{
ardlib_compute_mirror_ea (m, 0, 0, &energy, 1, &eff_area);
fprintf (stdout, "%g\t%g\n", energy, eff_area);
}
ardlib_close_mirror_ea (m);
Detector quantum efficiencies may be obtained in a similar manner:
Ardlib_Det_QE_Type *q;
float en, qe;
q = ardlib_open_det_qe ("ACIS-S3");
for (en = 0.1; en < 10.0; en += 0.1)
{
ardlib_compute_det_qe (q, 512, 512, &en, 1, &qe);
fprintf (stdout, "%g\t%g\n", en, qe);
}
ardlib_close_det_qe (q);