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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
/******************************************************************************
* Johns Hopkins University
* Center For Astrophysical Sciences
* FUSE
******************************************************************************
*
* Synopsis: cf_coadd root_name
*
* This program calls the routines that produce the exposure-level
* all files and the observation-level all, ano, and nvo files.
*
* 03/29/04 v0.1 bjg Begin work.
* 04/05/04 v0.2 bjg Remove unused variables
* Include unistd.h
* 06/07/04 v0.3 bjg Updated some keywords
* 08/12/04 v0.4 bjg Keywords QIK_COR and COMB_COR
* now set to COMPLETE.
* 08/26/04 v0.5 bjg Handle case aperture=RFPT
* 03/17/05 v0.6 tc Rename EXPTIME to OBSTIME in all extensions
* 08/22/05 v1.0 wvd Completely re-write for CalFUSE v3.1.7.
* Calls cf_make_all_exp for each exposure and
* cf_make_all_obs.csh only once.
* 08/27/07 v1.1 bot Changed i from int to long to match n
* Added L to corresponding values
*
*****************************************************************************/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "calfuse.h"
static char CF_PRGM_ID[] = "cf_coadd";
static char CF_VER_NUM[] = "1.1";
/*********************************************************************/
int main(int argc, char *argv[])
{
char asnf_file[120], filename[120], instmode[100], aper_string[100], aper_num[100];
fitsfile *asnf_fits_ptr, *infits;
long n;
int status = 0;
long i;
int anynull;
FILE * ffile;
char command0[256];
char memname[120], *memname_ptr;
char memtype[120], *memtype_ptr;
char ** memname_ptr2;
char ** memtype_ptr2;
char NULL_STR[] = {'\0'};
char file_present;
char expo_num_string[10];
int expo_num;
char know=0;
/* Enter a timestamp into the log. */
cf_timestamp(CF_PRGM_ID, CF_VER_NUM, "Begin Processing");
cf_error_init(CF_PRGM_ID, CF_VER_NUM, stderr);
memname_ptr=memname;
memtype_ptr=memtype;
memname_ptr2=&memname_ptr;
memtype_ptr2=&memtype_ptr;
/* Input Parameters */
if (argc != 2)
cf_if_error("Usage: cf_coadd rootname");
/*Open association file*/
strcpy(asnf_file, argv[1]);
strcat(asnf_file, "asnf.fit");
FITS_open_file(&asnf_fits_ptr, asnf_file, READONLY, &status);
FITS_movabs_hdu(asnf_fits_ptr, 2, NULL, &status);
FITS_read_key(asnf_fits_ptr, TLONG, "NAXIS2", &n, NULL, &status);
for (i=0L;i<n;i++){
cf_if_fits_error(fits_read_col_str(asnf_fits_ptr, 1, i+1L, 1,1, NULL_STR,
memname_ptr2, &anynull, &status));
cf_if_fits_error(fits_read_col_str(asnf_fits_ptr, 2, i+1L, 1,1, NULL_STR,
memtype_ptr2, &anynull, &status));
cf_if_fits_error(fits_read_col_log(asnf_fits_ptr, 3, i+1L, 1, 1, 0,
&file_present, &anynull, &status));
if (file_present == FALSE) continue;
if (strncasecmp(memtype,"EXPOSURE",8)) continue;
strncpy(expo_num_string,&memname[8],3);
expo_num=atoi(expo_num_string);
if (expo_num==701) continue;
strcpy(filename,memname);
strcat(filename,"1ahistfraw.fit");
strcpy(instmode,"hist");
ffile=fopen(filename,"r");
if (ffile == NULL) {
strcpy(instmode,"ttag");
strcpy(filename,memname);
strcat(filename,"1attagfraw.fit");
ffile=fopen(filename,"r");
if (ffile == NULL) {
printf("Warning: Expo %s not present\n",expo_num_string);
continue;
}
fclose(ffile);
}
else {
fclose(ffile);
}
if (!know) {
FITS_open_file(&infits, filename, READONLY, &status);
FITS_read_key(infits, TSTRING, "APERTURE", aper_string, NULL, &status);
if (!strncasecmp(aper_string,"LWRS",4)) strcpy(aper_num,"4");
if (!strncasecmp(aper_string,"MDRS",4)) strcpy(aper_num,"2");
if (!strncasecmp(aper_string,"HIRS",4)) strcpy(aper_num,"3");
if (!strncasecmp(aper_string,"PINH",4)) strcpy(aper_num,"1");
if (!strncasecmp(aper_string,"RFPT",4)) strcpy(aper_num,"4");
FITS_close_file(infits, &status);
know=1;
}
strcpy(command0,"cf_make_all_exp ");
strcat(command0,memname);
strcat(command0,"00all");
strcat(command0,aper_num);
strcat(command0,instmode);
strcat(command0,"fcal.fit ");
strcat(command0,memname);
strcat(command0,"1alif");
strcat(command0,aper_num);
strcat(command0,instmode);
strcat(command0,"fcal.fit ");
strcat(command0,memname);
strcat(command0,"1blif");
strcat(command0,aper_num);
strcat(command0,instmode);
strcat(command0,"fcal.fit ");
strcat(command0,memname);
strcat(command0,"2alif");
strcat(command0,aper_num);
strcat(command0,instmode);
strcat(command0,"fcal.fit ");
strcat(command0,memname);
strcat(command0,"2blif");
strcat(command0,aper_num);
strcat(command0,instmode);
strcat(command0,"fcal.fit ");
system(command0);
}
FITS_close_file(asnf_fits_ptr,&status);
sprintf(command0,"cf_make_all_obs.csh %s", asnf_file);
system(command0);
cf_timestamp(CF_PRGM_ID, CF_VER_NUM, "Done Processing");
return(EXIT_SUCCESS);
}
|