1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
/*****************************************************************************
* Johns Hopkins University
* Center For Astrophysical Sciences
* FUSE
*****************************************************************************
*
* Synopsis: cf_screen_airglow (fitsfile *header, long nevents,
* float *x, float *y, unsigned char *location)
*
* Description: Flag photon events in airglow regions.
*
* Arguments: fitsfile *header Input FITS file pointer
* long nevents Number of photon events
* float *x X coordinate array
* float *y Y coordinate array
* unsigned char *location Photon location flag array
*
* Calls: cf_get_geocorona
*
* Returns: 0 on success
*
* History: 03/10/05 1.1 wvd Initial coding
*
****************************************************************************/
#include <stdlib.h>
#include "calfuse.h"
int
cf_screen_airglow (fitsfile *header, long nevents, float *x, float *y,
unsigned char *location)
{
char CF_PRGM_ID[] = "cf_screen_airglow";
char CF_VER_NUM[] = "1.1";
int errflg=0, ngeo;
long i, j;
short *gxmin, *gxmax, *gymin, *gymax;
cf_error_init(CF_PRGM_ID, CF_VER_NUM, stderr);
cf_timestamp(CF_PRGM_ID, CF_VER_NUM, "Begin Processing");
if ((errflg = cf_proc_check(header, CF_PRGM_ID))) return errflg;
/*
* Read limits of airglow regions from AIRG_CAL file.
*/
ngeo = cf_get_geocorona(header, &gxmin, &gxmax, &gymin, &gymax);
/*
* Set the airglow bit of photons in the airglow regions.
*/
for (i = 0; i < nevents; i++) {
for (j=0; j<ngeo; j++) {
if (x[i] > gxmin[j] && x[i] < gxmax[j] &&
y[i] > gymin[j] && y[i] < gymax[j] ) {
location[i] = location[i] | LOCATION_AIR;
break;
}
}
}
free(gxmin);
free(gxmax);
free(gymin);
free(gymax);
cf_proc_update(header, CF_PRGM_ID, "COMPLETE");
cf_timestamp(CF_PRGM_ID, CF_VER_NUM, "Done processing");
return 0;
}
|