1 |
#include <drms.h> |
2 |
|
3 |
#define GETKEY_ERROR_1 1 |
4 |
#define GETKEY_ERROR_2 2 |
5 |
#define GETKEY_ERROR_3 3 |
6 |
#define GETKEY_ERROR_4 4 |
7 |
#define GETKEY_ERROR_5 5 |
8 |
#define GETKEY_ERROR_6 6 |
9 |
#define GETKEY_ERROR_7 7 |
10 |
#define GETKEY_ERROR_8 8 |
11 |
#define GETKEY_ERROR_9 9 |
12 |
#define GETKEY_ERROR_10 10 |
13 |
#define GETKEY_ERROR_11 11 |
14 |
#define GETKEY_ERROR_12 12 |
15 |
#define GETKEY_ERROR_13 13 |
16 |
#define GETKEY_ERROR_14 14 |
17 |
#define GETKEY_ERROR_15 15 |
18 |
#define GETKEY_ERROR_16 16 |
19 |
#define GETKEY_ERROR_17 17 |
20 |
#define GETKEY_ERROR_18 18 |
21 |
#define GETKEY_ERROR_19 19 |
22 |
#define GETKEY_ERROR_20 20 |
23 |
#define SETKEY_ERROR_1 -1 |
24 |
#define SETKEY_ERROR_2 -2 |
25 |
#define SETKEY_ERROR_3 -3 |
26 |
#define SETKEY_ERROR_4 -4 |
27 |
#define SETKEY_ERROR_5 -5 |
28 |
#define SETKEY_ERROR_6 -6 |
29 |
#define SETKEY_ERROR_7 -7 |
30 |
#define SETKEY_ERROR_8 -8 |
31 |
#define SETKEY_ERROR_9 -9 |
32 |
#define SETKEY_ERROR_10 -10 |
33 |
#define SETKEY_ERROR_11 -11 |
34 |
#define SETKEY_ERROR_12 -12 |
35 |
#define SETKEY_ERROR_13 -13 |
36 |
#define SETKEY_ERROR_14 -14 |
37 |
#define SETKEY_ERROR_15 -15 |
38 |
#define SETKEY_ERROR_16 -16 |
39 |
#define SETKEY_ERROR_17 -17 |
40 |
#define SETKEY_ERROR_18 -18 |
41 |
#define SETKEY_ERROR_19 -19 |
42 |
#define SETKEY_ERROR_20 -20 |
43 |
#define BAD_INSTRUMENT_NAME -99 |
44 |
#define BAD_IMG_PATH -98 |
45 |
|
46 |
#define RADEG (180.0/M_PI) |
47 |
|
48 |
int iris_isp2wcs(DRMS_Record_t *rs0, DRMS_Record_t *rs1, double scroll) |
49 |
{ |
50 |
int i, status; |
51 |
|
52 |
// Set database values |
53 |
|
54 |
int version = 2; |
55 |
double |
56 |
al_fu1 = -0.05000, |
57 |
al_fu2 = -0.43700, |
58 |
al_nuv = -0.31800, |
59 |
be_133 = -0.20000, |
60 |
be_140 = -0.22400, |
61 |
be_279 = 0.27400, |
62 |
be_283 = 0.28600, |
63 |
be_fsi = 0.28000, |
64 |
be_mir = -0.21000, |
65 |
be_fu1 = -1.5000, |
66 |
be_fu2 = -1.9700, |
67 |
be_nuv = 1.2600, |
68 |
cdlt1_f1 = 0.01298, |
69 |
cdlt1_f2 = 0.01272, |
70 |
cdlt1_nu = 0.02546, |
71 |
cdlt2_f1 = 0.16632, |
72 |
cdlt2_f2 = 0.16632, |
73 |
cdlt2_nu = 0.16637, |
74 |
cdlt_133 = 0.16560, |
75 |
cdlt_140 = 0.16560, |
76 |
cdlt_279 = 0.16790, |
77 |
cdlt_283 = 0.16790, |
78 |
cdlt_fsi = 0.16790, |
79 |
cdlt_mir = 0.16560, |
80 |
cpx1_133 = 537.30, |
81 |
cpx1_140 = 529.32, |
82 |
cpx1_279 = 504.69, |
83 |
cpx1_283 = 506.47, |
84 |
cpx1_fsi = 505.20, |
85 |
cpx1_fu1 = 219.50, |
86 |
cpx1_fu2 = 3807.3, |
87 |
cpx1_mir = 534.00, |
88 |
cpx1_nuv = 659.30, |
89 |
cpx2_133 = 524.03, |
90 |
cpx2_140 = 510.46, |
91 |
cpx2_279 = 502.91, |
92 |
cpx2_283 = 502.22, |
93 |
cpx2_fsi = 504.70, |
94 |
cpx2_fu1 = 487.92, |
95 |
cpx2_fu2 = 518.21, |
96 |
cpx2_mir = 516.70, |
97 |
cpx2_nuv = 530.35, |
98 |
cvl1_fu1 = 1334.53, |
99 |
cvl1_fu2 = 1402.77, |
100 |
cvl1_nuv = 2798.65, |
101 |
focus_regcal = -100.00, |
102 |
focus_xregr1 = -0.0514701, |
103 |
focus_xregr2 = 0.000248873, |
104 |
focus_yregr1 = 0.0739689, |
105 |
focus_yregr2 = -0.00047510, |
106 |
pzt_off_homea = -250.00, |
107 |
pzt_off_homeb = -250.00, |
108 |
pzt_off_homec = -250.00, |
109 |
pzt_off_pixel = 0.16790, |
110 |
pzt_off_sjixa = 0.001300, |
111 |
pzt_off_sjixb = -0.14929, |
112 |
pzt_off_sjixc = 0.14783, |
113 |
pzt_off_sjiya = -0.17203, |
114 |
pzt_off_sjiyb = 0.08709, |
115 |
pzt_off_sjiyc = 0.08687, |
116 |
pzt_x_sign = 1.0000, |
117 |
pzt_y_sign = 1.0000, |
118 |
sji_ccd_roll_bias = -0.28600, |
119 |
slit_roll_bias = 0.64600, |
120 |
slit_rot = 0.64600, |
121 |
wm1_rmax = 634.80, |
122 |
wm2_rmax = 628.50, |
123 |
wm_focus_cal = -100.00, |
124 |
wm_m1v = 217.875, |
125 |
wm_offset2 = 113.57, |
126 |
wm_roll_bias = -0.646, |
127 |
wm_x_sign = -1.000, |
128 |
wm_xoff = 103.00, |
129 |
wm_y_sign = 1.000, |
130 |
wm_yoff = -92.000; |
131 |
|
132 |
//Regression coefficients for NUV SJI X & Y motion of laser spot on |
133 |
//image in pixels vs focus motor position in steps, |
134 |
double |
135 |
focus_xregr[] = {focus_xregr1, focus_xregr2}, |
136 |
focus_yregr[] = {focus_yregr1, focus_yregr2}, |
137 |
foc_rgcl = focus_regcal; |
138 |
|
139 |
//Derive the X & Y shifts (px) due to focus, for the position wm_focus_cal |
140 |
double focus_temp[] = {wm_focus_cal-foc_rgcl, pow((wm_focus_cal-foc_rgcl),2)}; |
141 |
double wm_focus_cal_x = focus_xregr[0]*focus_temp[0]+focus_xregr[1]*focus_temp[1]; |
142 |
double wm_focus_cal_y = focus_yregr[0]*focus_temp[0]+focus_yregr[1]*focus_temp[1]; |
143 |
|
144 |
// ***************************************************************** |
145 |
|
146 |
//get relevant keywords from Image Status Packet (image header) |
147 |
|
148 |
char *instrume, *img_path, *iissloop; |
149 |
int isqpzta, isqpztb, isqpztc; |
150 |
short iwbpzta, iwbpztb, iwbpztc, igtpoffx, igtpoffy; |
151 |
float ifmpos, iwm1cpos, iwm2cpos; |
152 |
short sum1, sum2; |
153 |
float off1, off2; |
154 |
|
155 |
instrume = drms_getkey_string(rs0, "INSTRUME", &status); |
156 |
if (status) return GETKEY_ERROR_1; |
157 |
img_path = drms_getkey_string(rs0, "IMG_PATH", &status); |
158 |
if (status) return GETKEY_ERROR_2; |
159 |
iissloop = drms_getkey_string(rs0, "IISSLOOP", &status); |
160 |
if (status) return GETKEY_ERROR_3; |
161 |
isqpzta = drms_getkey_int(rs0, "ISQPZTA", &status); |
162 |
if (status) return GETKEY_ERROR_4; |
163 |
isqpztb = drms_getkey_int(rs0, "ISQPZTB", &status); |
164 |
if (status) return GETKEY_ERROR_5; |
165 |
isqpztc = drms_getkey_int(rs0, "ISQPZTC", &status); |
166 |
if (status) return GETKEY_ERROR_6; |
167 |
iwbpzta = drms_getkey_short(rs0, "IWBPZTA", &status); |
168 |
if (status) return GETKEY_ERROR_7; |
169 |
iwbpztb = drms_getkey_short(rs0, "IWBPZTB", &status); |
170 |
if (status) return GETKEY_ERROR_8; |
171 |
iwbpztc = drms_getkey_short(rs0, "IWBPZTC", &status); |
172 |
if (status) return GETKEY_ERROR_9; |
173 |
igtpoffx = drms_getkey_short(rs0, "IGTPOFFX", &status); |
174 |
if (status) return GETKEY_ERROR_10; |
175 |
igtpoffy = drms_getkey_short(rs0, "IGTPOFFY", &status); |
176 |
if (status) return GETKEY_ERROR_11; |
177 |
ifmpos = drms_getkey_float(rs0, "IFMPOS", &status); |
178 |
if (status) return GETKEY_ERROR_12; |
179 |
iwm1cpos = drms_getkey_float(rs0, "IWM1CPOS", &status); |
180 |
if (status) return GETKEY_ERROR_13; |
181 |
iwm2cpos = drms_getkey_float(rs0, "IWM2CPOS", &status); |
182 |
if (status) return GETKEY_ERROR_14; |
183 |
sum1 = drms_getkey_short(rs0, "SUMSPTRL", &status); |
184 |
if (status) return GETKEY_ERROR_15; |
185 |
sum2 = drms_getkey_short(rs0, "SUMSPAT", &status); |
186 |
if (status) return GETKEY_ERROR_16; |
187 |
off1 = (sum1-1.0)/(sum1*2.0); |
188 |
off2 = (sum2-1.0)/(sum2*2.0); |
189 |
|
190 |
|
191 |
// ***************************************************************** |
192 |
|
193 |
// Set spacecraft roll |
194 |
//if n_elements(scroll) ne 1 then scroll = 0.0 |
195 |
double roll_angle = scroll; |
196 |
//double garad = (slit_rot - scroll) * RADEG; |
197 |
double garad = (-1.0*slit_rot - scroll)/RADEG; |
198 |
|
199 |
// ***************************************************************** |
200 |
|
201 |
int pzts[3]; |
202 |
float pzt_off_sjix[3], pzt_off_sjiy[3]; |
203 |
|
204 |
pzts[0] = isqpzta - iwbpzta - pzt_off_homea; |
205 |
pzts[1] = isqpztb - iwbpztb - pzt_off_homeb; |
206 |
pzts[2] = isqpztc - iwbpztc - pzt_off_homec; |
207 |
|
208 |
pzt_off_sjix[0] = pzt_off_sjixa; |
209 |
pzt_off_sjix[1] = pzt_off_sjixb; |
210 |
pzt_off_sjix[2] = pzt_off_sjixc; |
211 |
|
212 |
pzt_off_sjiy[0] = pzt_off_sjiya; |
213 |
pzt_off_sjiy[1] = pzt_off_sjiyb; |
214 |
pzt_off_sjiy[2] = pzt_off_sjiyc; |
215 |
|
216 |
// minus sign because solar coord change = -motion of image |
217 |
double ccdx=0.0, ccdy=0.0; |
218 |
for (i=0;i<3;++i) { |
219 |
ccdx -= (pzt_off_sjix[i]*pzts[i])*pzt_off_pixel*pzt_x_sign; |
220 |
ccdy -= (pzt_off_sjiy[i]*pzts[i])*pzt_off_pixel*pzt_y_sign; |
221 |
} |
222 |
|
223 |
// add shift of image by focus mechanism using current position focus |
224 |
// and subtract image shift by focus at the calibration pos |
225 |
//focus_temp = [float(ifmpos)-foc_rgcl, (float(ifmpos)-foc_rgcl)^2] |
226 |
focus_temp[0] = ifmpos - foc_rgcl; |
227 |
focus_temp[1] = focus_temp[0] * focus_temp[0]; |
228 |
double focusx, focusy; |
229 |
focusx = focus_temp[0]*focus_xregr[0]+focus_temp[1]*focus_xregr[1] - wm_focus_cal_x; |
230 |
focusy = focus_temp[0]*focus_yregr[0]+focus_temp[1]*focus_yregr[1] - wm_focus_cal_y; |
231 |
|
232 |
// minus sign because solar coord change = -motion of image |
233 |
double ccdx2, ccdy2; |
234 |
ccdx2 = ccdx - focusx*pzt_off_pixel; |
235 |
ccdy2 = ccdy - focusy*pzt_off_pixel; |
236 |
|
237 |
// rotate these to solar X, Y at roll = 0 |
238 |
double sth, cth; |
239 |
sth = sin((slit_roll_bias+sji_ccd_roll_bias)/RADEG); |
240 |
cth = cos((slit_roll_bias+sji_ccd_roll_bias)/RADEG); |
241 |
ccdx = ccdx2*cth + ccdy2*sth; |
242 |
ccdy = -ccdx2*sth + ccdy2*cth; |
243 |
|
244 |
// add wedge motor image shifts from formulae in iris_wedge2solar_tl |
245 |
double fac = 2.*M_PI/240.; |
246 |
double th1 = fac*(iwm1cpos-wm_m1v); |
247 |
double th2 = fac*(iwm2cpos-wm_m1v+120.-wm_offset2); |
248 |
double xwm2 = wm_x_sign*(wm1_rmax*sin(th1) + wm2_rmax*sin(th2)); |
249 |
double ywm2 = wm_y_sign*(wm1_rmax*cos(th1) + wm2_rmax*cos(th2)); |
250 |
|
251 |
// rotate by roll bias wrt solar North at roll=0 degrees |
252 |
sth = sin((slit_roll_bias + wm_roll_bias)/RADEG); |
253 |
cth = cos((slit_roll_bias + wm_roll_bias)/RADEG); |
254 |
double xwm = xwm2*cth + ywm2*sth; |
255 |
double ywm = -xwm2*sth + ywm2*cth; |
256 |
|
257 |
// add the center of the WM coordinate system: note this is in solar |
258 |
// X & Y, not in the wedge motor or GT diode or CCD X & Y |
259 |
xwm = xwm + wm_xoff; |
260 |
ywm = ywm + wm_yoff; |
261 |
|
262 |
// co-add both contributions |
263 |
double x2 = xwm + ccdx; |
264 |
double y2 = ywm + ccdy; |
265 |
|
266 |
// add GT bias offsets in ACS packets, only if ISS loop is not closed |
267 |
// if loop is closed, then PZTs will zero this (assuming they have |
268 |
// enough range) |
269 |
// this is very rare and may never be used during science observing, |
270 |
// so ignore the small roll bias between the GT diodes coordinate |
271 |
// system and the others |
272 |
|
273 |
if (strncmp(iissloop,"CLOSED",6)) { |
274 |
// minus sign because solar coord change = -motion of image |
275 |
x2 = x2 - igtpoffx*0.01; |
276 |
y2 = y2 - igtpoffy*0.01; |
277 |
} |
278 |
|
279 |
// Now rotate everything to non-zero roll angle |
280 |
double sroll = sin(roll_angle/RADEG); |
281 |
double croll = cos(roll_angle/RADEG); |
282 |
double x = x2*croll + y2*sroll; |
283 |
double y = -x2*sroll + y2*croll; |
284 |
|
285 |
double crvalxy[] = {x,y}; |
286 |
|
287 |
//print, 'Calculated x and y', crvalxy |
288 |
|
289 |
// ***************************************************************** |
290 |
|
291 |
// set keywords: separate cases for FUV, NUV, SJI |
292 |
|
293 |
float cdelt,alrad,berad,wcsaxes,crpix1,crpix2,crval1,crval2,crval3,cdelt1,cdelt2,cdelt3,berad1,alrad1,ab1cos,pc1_1,pc1_2,pc2_1,pc2_2,pc3_1,pc3_2,crpix1a,crpix2a,crval1a,crval2a,crval3a,cdelt1a,cdelt2a,cdelt3a,berad2,alrad2,ab2cos,pc1_1a,pc1_2a,pc2_1a,pc2_2a,pc3_1a,pc3_2a,lonpole,crpix3,crpix3a,xcen,ycen; |
294 |
char *ctype1,*ctype2,*ctype3,*cunit1,*cunit2,*cunit3; |
295 |
char *ctype1a,*ctype2a,*ctype3a,*cunit1a,*cunit2a,*cunit3a; |
296 |
char *specsys1; |
297 |
DRMS_Segment_t *segment0; |
298 |
int naxis1, naxis2; |
299 |
segment0 = drms_segment_lookupnum(rs0, 0); |
300 |
naxis1 = segment0->axis[0]; |
301 |
naxis2 = segment0->axis[1]; |
302 |
|
303 |
if (strncmp(instrume,"FUV",3) == 0) { |
304 |
wcsaxes = 3; |
305 |
crpix1 = cpx1_fu1/sum1 + off1; |
306 |
crpix2 = cpx2_fu1/sum2 + off2; |
307 |
//crpix3 = 1.0; |
308 |
crval1 = cvl1_fu1; |
309 |
crval2 = crvalxy[1]; |
310 |
crval3 = crvalxy[0]; |
311 |
cdelt1 = cdlt1_f1*sum1; |
312 |
cdelt2 = cdlt2_f1*sum2; |
313 |
cdelt3 = cdelt2; |
314 |
ctype1 = "WAVE"; |
315 |
ctype2 = "HPLT-TAN"; |
316 |
ctype3 = "HPLN-TAN"; |
317 |
cunit1 = "Angstrom"; |
318 |
cunit2 = "arcsec"; |
319 |
cunit3 = cunit2; |
320 |
berad1 = be_fu1 / RADEG; |
321 |
alrad1 = al_fu1 / RADEG; |
322 |
ab1cos = cos(alrad1-berad1); |
323 |
pc1_1 = cos(berad1) / ab1cos; |
324 |
pc1_2 = -sin(berad1) / ab1cos * sum2/sum1; |
325 |
pc2_1 = cos(garad) * sin(alrad1) / ab1cos * sum1/sum2; |
326 |
pc2_2 = cos(garad) * cos(alrad1) / ab1cos; |
327 |
pc3_1 = -sin(garad) * sin(alrad1) / ab1cos * sum1/sum2; |
328 |
pc3_2 = -sin(garad) * cos(alrad1) / ab1cos; |
329 |
crpix1a = cpx1_fu2/sum1 + off1; |
330 |
crpix2a = cpx2_fu2/sum2 + off2; |
331 |
//crpix3a = 1.0; |
332 |
crval1a = cvl1_fu2; |
333 |
crval2a = crval2; |
334 |
crval3a = crval3; |
335 |
cdelt1a = cdlt1_f2*sum1; |
336 |
cdelt2a = cdlt2_f2*sum2; |
337 |
cdelt3a = cdelt2a; |
338 |
ctype1a = ctype1; |
339 |
ctype2a = ctype2; |
340 |
ctype3a = ctype3; |
341 |
cunit1a = cunit1; |
342 |
cunit2a = cunit2; |
343 |
cunit3a = cunit3; |
344 |
berad2 = be_fu2 / RADEG; |
345 |
alrad2 = al_fu2 / RADEG; |
346 |
ab2cos = cos(alrad2-berad2); |
347 |
pc1_1a = cos(berad2) / ab2cos; |
348 |
pc1_2a = -sin(berad2) / ab2cos * sum2/sum1; |
349 |
pc2_1a = cos(garad) * sin(alrad2) / ab2cos * sum1/sum2; |
350 |
pc2_2a = cos(garad) * cos(alrad2) / ab2cos; |
351 |
pc3_1a = -sin(garad) * sin(alrad2) / ab2cos * sum1/sum2; |
352 |
pc3_2a = -sin(garad) * cos(alrad2) / ab2cos; |
353 |
xcen = crval3 + cdelt3*(pc3_1*((naxis1+1)/2. - crpix1) + pc3_2*((naxis2+1)/2. - crpix2)); |
354 |
ycen = crval2 + cdelt2*(pc2_1*((naxis1+1)/2. - crpix1) + pc2_2*((naxis2+1)/2. - crpix2)); |
355 |
//lonpole = 180.0; |
356 |
//specsys1= "HELIOCEN"; |
357 |
} else if (strncmp(instrume,"NUV", 3)==0) { |
358 |
wcsaxes = 3; |
359 |
berad = be_nuv / RADEG; |
360 |
alrad = al_nuv / RADEG; |
361 |
crpix1 = cpx1_nuv/sum1 + off1; |
362 |
crpix2 = cpx2_nuv/sum2 + off2; |
363 |
//crpix3 = 1.0; |
364 |
crval1 = cvl1_nuv; |
365 |
crval2 = crvalxy[1]; |
366 |
crval3 = crvalxy[0]; |
367 |
cdelt1 = cdlt1_nu*sum1; |
368 |
cdelt2 = cdlt2_nu*sum2; |
369 |
cdelt3 = cdelt2; |
370 |
ctype1 = "WAVE"; |
371 |
ctype2 = "HPLT-TAN"; |
372 |
ctype3 = "HPLN-TAN"; |
373 |
cunit1 = "Angstrom"; |
374 |
cunit2 = "arcsec"; |
375 |
cunit3 = cunit2; |
376 |
pc1_1 = cos(berad) / cos(alrad-berad); |
377 |
pc1_2 = -sin(berad) / cos(alrad-berad) * sum2/sum1; |
378 |
pc2_1 = cos(garad) * sin(alrad) / cos(alrad-berad) * sum1/sum2; |
379 |
pc2_2 = cos(garad) * cos(alrad) / cos(alrad-berad); |
380 |
pc3_1 = -sin(garad) * sin(alrad) / cos(alrad-berad) * sum1/sum2; |
381 |
pc3_2 = -sin(garad) * cos(alrad) / cos(alrad-berad); |
382 |
crpix1a = crpix1; |
383 |
crpix2a = crpix2; |
384 |
//crpix3a = 1.0; |
385 |
crval1a = crval1; |
386 |
crval2a = crval2; |
387 |
crval3a = crval3; |
388 |
cdelt1a = cdelt1; |
389 |
cdelt2a = cdelt2; |
390 |
cdelt3a = cdelt3; |
391 |
ctype1a = ctype1; |
392 |
ctype2a = ctype2; |
393 |
ctype3a = ctype3; |
394 |
cunit1a = cunit1; |
395 |
cunit2a = cunit2; |
396 |
cunit3a = cunit3; |
397 |
pc1_1a = pc1_1; |
398 |
pc1_2a = pc1_2; |
399 |
pc2_1a = pc2_1; |
400 |
pc2_2a = pc2_2; |
401 |
pc3_1a = pc3_1; |
402 |
pc3_2a = pc3_2; |
403 |
xcen = crval3 + cdelt3*(pc3_1*((naxis1+1)/2. - crpix1) + pc3_2*((naxis2+1)/2. - crpix2)); |
404 |
ycen = crval2 + cdelt2*(pc2_1*((naxis1+1)/2. - crpix1) + pc2_2*((naxis2+1)/2. - crpix2)); |
405 |
//lonpole = 180.0; |
406 |
//specsys1= "HELIOCEN"; // or 'SOURCE ' if corrected for solar rot |
407 |
} else if (strncmp(instrume,"SJI", 3)==0) { |
408 |
if(strncmp(img_path,"SJI_5000W",9)==0) { |
409 |
// berad = be_nsj / RADEG; |
410 |
// cdelt = cdlt_nsj; |
411 |
berad = be_fsi / RADEG; |
412 |
cdelt = cdlt_fsi; |
413 |
crpix1 = cpx1_fsi; |
414 |
crpix2 = cpx2_fsi; |
415 |
} else if(strncmp(img_path,"SJI_1330",8) == 0) { |
416 |
// berad = be_fsj / RADEG; |
417 |
// cdelt = cdlt_fsj; |
418 |
berad = be_133 / RADEG; |
419 |
cdelt = cdlt_133; |
420 |
crpix1 = cpx1_133; |
421 |
crpix2 = cpx2_133; |
422 |
} else if(strncmp(img_path,"SJI_2796",8) == 0) { |
423 |
// berad = be_nsj / RADEG; |
424 |
// cdelt = cdlt_nsj; |
425 |
berad = be_279 / RADEG; |
426 |
cdelt = cdlt_279; |
427 |
crpix1 = cpx1_279; |
428 |
crpix2 = cpx2_279; |
429 |
} else if(strncmp(img_path,"SJI_1400",8) == 0) { |
430 |
// berad = be_fsj / RADEG; |
431 |
// cdelt = cdlt_fsj; |
432 |
berad = be_140 / RADEG; |
433 |
cdelt = cdlt_140; |
434 |
crpix1 = cpx1_140; |
435 |
crpix2 = cpx2_140; |
436 |
} else if(strncmp(img_path,"SJI_2832",8) == 0) { |
437 |
// berad = be_nsj / RADEG; |
438 |
// cdelt = cdlt_nsj; |
439 |
berad = be_283 / RADEG; |
440 |
cdelt = cdlt_283; |
441 |
crpix1 = cpx1_283; |
442 |
crpix2 = cpx2_283; |
443 |
} else if(strncmp(img_path,"SJI_1600W",9) == 0) { |
444 |
// berad = be_fsj / RADEG; |
445 |
// cdelt = cdlt_fsj; |
446 |
berad = be_mir / RADEG; |
447 |
cdelt = cdlt_mir; |
448 |
crpix1 = cpx1_mir; |
449 |
crpix2 = cpx2_mir; |
450 |
} else |
451 |
return BAD_IMG_PATH; |
452 |
wcsaxes = 2; |
453 |
crpix1 = crpix1/sum1 + off1; |
454 |
crpix2 = crpix2/sum2 + off2; |
455 |
crval1 = crvalxy[0]; |
456 |
crval2 = crvalxy[1]; |
457 |
//crpix3 = 0.0; |
458 |
// crpix3a = 0.0; |
459 |
crval3 = 0.0; |
460 |
cdelt1 = cdelt*sum1; |
461 |
cdelt2 = cdelt*sum2; |
462 |
cdelt3 = 0.0; |
463 |
ctype1 = "HPLN-TAN"; |
464 |
ctype2 = "HPLT-TAN"; |
465 |
ctype3 = "none"; |
466 |
cunit1 = "arcsec"; |
467 |
cunit2 = "arcsec"; |
468 |
cunit3 = "none"; |
469 |
pc1_1 = cos(berad+garad); |
470 |
pc1_2 = -sin(berad+garad) * sum2/sum1; |
471 |
pc2_1 = sin(berad+garad) * sum1/sum2; |
472 |
pc2_2 = cos(berad+garad); |
473 |
pc3_1 = 0.0; |
474 |
pc3_2 = 0.0; |
475 |
crpix1a = crpix1; |
476 |
crpix2a = crpix2; |
477 |
crval1a = crval1; |
478 |
crval2a = crval2; |
479 |
crval3a = crval3; |
480 |
cdelt1a = cdelt1; |
481 |
cdelt2a = cdelt2; |
482 |
cdelt3a = cdelt3; |
483 |
ctype1a = ctype1; |
484 |
ctype2a = ctype2; |
485 |
ctype3a = ctype3; |
486 |
cunit1a = cunit1; |
487 |
cunit2a = cunit2; |
488 |
cunit3a = cunit3; |
489 |
pc1_1a = pc1_1; |
490 |
pc1_2a = pc1_2; |
491 |
pc2_1a = pc2_1; |
492 |
pc2_2a = pc2_2; |
493 |
pc3_1a = pc3_1; |
494 |
pc3_2a = pc3_2; |
495 |
xcen = crval1 + cdelt1*(pc1_1*((naxis1+1)/2. - crpix1) + pc1_2*((naxis2+1)/2. - crpix2)); |
496 |
ycen = crval2 + cdelt2*(pc2_1*((naxis1+1)/2. - crpix1) + pc2_2*((naxis2+1)/2. - crpix2)); |
497 |
//lonpole = 180.0; |
498 |
//specsys1= "HELIOCEN"; // or 'SOURCE ' if corrected for solar rot |
499 |
} else |
500 |
return BAD_INSTRUMENT_NAME; |
501 |
|
502 |
/////////////////////////////////////////////////// |
503 |
if (drms_setkey_int(rs1,"WCSDBVER",version)) return SETKEY_ERROR_1; |
504 |
if (drms_setkey_int(rs1,"WCSAXES",wcsaxes)) return SETKEY_ERROR_1; |
505 |
if (drms_setkey_float(rs1,"CRPIX1",crpix1)) return SETKEY_ERROR_2; |
506 |
if (drms_setkey_float(rs1,"CRPIX2",crpix2)) return SETKEY_ERROR_2; |
507 |
//if (drms_setkey_float(rs1,"CRPIX3",crpix3)) return SETKEY_ERROR_2; |
508 |
if (drms_setkey_float(rs1,"CRPIX1A",crpix1a)) return SETKEY_ERROR_2; |
509 |
if (drms_setkey_float(rs1,"CRPIX2A",crpix2a)) return SETKEY_ERROR_2; |
510 |
//if (drms_setkey_float(rs1,"CRPIX3A",crpix3a)) return SETKEY_ERROR_2; |
511 |
if (drms_setkey_float(rs1,"CDELT1",cdelt1)) return SETKEY_ERROR_3; |
512 |
if (drms_setkey_float(rs1,"CDELT2",cdelt2)) return SETKEY_ERROR_3; |
513 |
if (drms_setkey_float(rs1,"CDELT3",cdelt3)) return SETKEY_ERROR_3; |
514 |
if (drms_setkey_float(rs1,"CDELT1A",cdelt1a)) return SETKEY_ERROR_3; |
515 |
if (drms_setkey_float(rs1,"CDELT2A",cdelt2a)) return SETKEY_ERROR_3; |
516 |
if (drms_setkey_float(rs1,"CDELT3A",cdelt3a)) return SETKEY_ERROR_3; |
517 |
if (drms_setkey_string(rs1,"CUNIT1",cunit1)) return SETKEY_ERROR_4; |
518 |
if (drms_setkey_string(rs1,"CUNIT2",cunit2)) return SETKEY_ERROR_4; |
519 |
if (drms_setkey_string(rs1,"CUNIT3",cunit3)) return SETKEY_ERROR_4; |
520 |
if (drms_setkey_string(rs1,"CUNIT1A",cunit1a)) return SETKEY_ERROR_4; |
521 |
if (drms_setkey_string(rs1,"CUNIT2A",cunit2a)) return SETKEY_ERROR_4; |
522 |
if (drms_setkey_string(rs1,"CUNIT3A",cunit3a)) return SETKEY_ERROR_4; |
523 |
if (drms_setkey_string(rs1,"CTYPE1",ctype1)) return SETKEY_ERROR_5; |
524 |
if (drms_setkey_string(rs1,"CTYPE2",ctype2)) return SETKEY_ERROR_5; |
525 |
if (drms_setkey_string(rs1,"CTYPE3",ctype3)) return SETKEY_ERROR_5; |
526 |
if (drms_setkey_string(rs1,"CTYPE1A",ctype1)) return SETKEY_ERROR_5; |
527 |
if (drms_setkey_string(rs1,"CTYPE2A",ctype2a)) return SETKEY_ERROR_5; |
528 |
if (drms_setkey_string(rs1,"CTYPE3A",ctype3a)) return SETKEY_ERROR_5; |
529 |
if (drms_setkey_float(rs1,"PC1_1",pc1_1)) return SETKEY_ERROR_6; |
530 |
if (drms_setkey_float(rs1,"PC2_1",pc2_1)) return SETKEY_ERROR_6; |
531 |
if (drms_setkey_float(rs1,"PC3_1",pc3_1)) return SETKEY_ERROR_6; |
532 |
if (drms_setkey_float(rs1,"PC1_2",pc1_2)) return SETKEY_ERROR_6; |
533 |
if (drms_setkey_float(rs1,"PC2_2",pc2_2)) return SETKEY_ERROR_6; |
534 |
if (drms_setkey_float(rs1,"PC3_2",pc3_2)) return SETKEY_ERROR_6; |
535 |
if (drms_setkey_float(rs1,"PC1_1A",pc1_1a)) return SETKEY_ERROR_6; |
536 |
if (drms_setkey_float(rs1,"PC2_1A",pc2_1a)) return SETKEY_ERROR_6; |
537 |
if (drms_setkey_float(rs1,"PC3_1A",pc3_1a)) return SETKEY_ERROR_6; |
538 |
if (drms_setkey_float(rs1,"PC1_2A",pc1_2a)) return SETKEY_ERROR_6; |
539 |
if (drms_setkey_float(rs1,"PC2_2A",pc2_2a)) return SETKEY_ERROR_6; |
540 |
if (drms_setkey_float(rs1,"PC3_2A",pc3_2a)) return SETKEY_ERROR_6; |
541 |
if (drms_setkey_float(rs1,"CRVAL1",crval1)) return SETKEY_ERROR_7; |
542 |
if (drms_setkey_float(rs1,"CRVAL2",crval2)) return SETKEY_ERROR_7; |
543 |
if (drms_setkey_float(rs1,"CRVAL3",crval3)) return SETKEY_ERROR_7; |
544 |
if (drms_setkey_float(rs1,"CRVAL1A",crval1a)) return SETKEY_ERROR_7; |
545 |
if (drms_setkey_float(rs1,"CRVAL2A",crval2a)) return SETKEY_ERROR_7; |
546 |
if (drms_setkey_float(rs1,"CRVAL3A",crval3a)) return SETKEY_ERROR_7; |
547 |
if (drms_setkey_float(rs1,"SAT_ROT",scroll)) return SETKEY_ERROR_8; |
548 |
if (drms_setkey_float(rs1,"XCEN",xcen)) return SETKEY_ERROR_9; |
549 |
if (drms_setkey_float(rs1,"YCEN",ycen)) return SETKEY_ERROR_9; |
550 |
|
551 |
return 0; |
552 |
} |