aboutsummaryrefslogtreecommitdiff
path: root/noao/mtlocal/camera/cam_keywords.x
blob: 6b5ad5ef3522c8e3afdbc20d5e9af1ef9a9f1be5 (plain) (blame)
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
include	<mach.h>
include <imhdr.h>
include "rcamera.h"

define	LEN_KEYWORD	8

# CAM_STORE_KEYWORDS -- store CAMERA specific keywords in the IRAF image header.

procedure cam_store_keywords (parameters, im)

short	parameters[ARB]	# Pointer to program data structure
pointer	im		# Pointer to image

int	fd
real	value
int	stropen()
errchk	stropen, cam_sicard, cam_rcard, cam_hmscard, cam_ymdcard, cam_obscard

begin
	# Open image user area as a string
	fd = stropen (UNKNOWN(im), (LEN_USER_AREA - 1) * SZ_STRUCT, WRITE_ONLY)

	# FITS keyword are formatted and appended to the image user area.
	call cam_sicard (fd, "CCDPICNO", CCD_PICNO(parameters),
	    "ORIGINAL CCD PICTURE NUMBER")
	if (IMAGE_TYPE(parameters) < BEG_IRDATA) {
	    call cam_sicard (fd, "EXPTIME", ITIME(parameters),
	        "ACTUAL INTEGRATION TIME (SECONDS)") 
	    call cam_sicard (fd, "DARKTIME", TTIME(parameters),
	        "TOTAL ELAPSED TIME (SECONDS)")
	    call cam_sicard (fd, "OTIME", OTIME(parameters),
	        "SHUTTER OPEN TIME (SECS)")
	} else if (IMAGE_TYPE(parameters) >= BEG_IRDATA &&
	    IMAGE_TYPE(parameters) <= END_IRDATA) {
	    value = TTIME(parameters) / 1000. + OTIME(parameters)
	    call cam_rcard (fd, "EXPTIME", value, 
	        "ACTUAL INTEGRATION TIME (SECONDS)", 3) 
	}

	# Observation date, time and position cards
	call cam_obscard (fd, "IMAGETYP", IMAGE_TYPE(parameters),
	    "OBJECT,DARK,BIAS,ETC.")
	if (PIC_IRBSCALE(parameters) > 0) {
	    value = 1.0 / PIC_IRBSCALE(parameters)
	    call cam_rcard (fd, "IRBSCALE", value, "PICTURE SCALING FACTOR", 3)
	}
		
	call cam_ymdcard (fd, "DATE-OBS", OBS_YR(parameters),
	    OBS_MON(parameters), OBS_DAY(parameters), "DATE DD/MM/YY")
	call cam_hmscard (fd, "RA", RA_HR(parameters), RA_MIN(parameters),
	    RA_SEC(parameters), "RIGHT ASCENSION (TELESCOPE)")
	call cam_hmscard (fd, "DEC", DEC_DEG(parameters),
	    DEC_MIN(parameters), DEC_SEC(parameters),
	    "DECLINATION (TELESCOPE)")
	value = EPOCH(parameters) / 10.
	call cam_rcard (fd, "EPOCH", value, "EPOCH OF RA AND DEC", 2)
	call cam_hmscard (fd, "ZD", ZD_DEG(parameters), ZD_MIN(parameters),
	    ZD_SEC(parameters), "ZENITH DISTANCE")
	call cam_hmscard (fd, "UT", UT_HR(parameters), UT_MIN(parameters),
	    UT_SEC(parameters), "UNIVERSAL TIME")
	call cam_hmscard (fd, "ST", ST_HR(parameters), ST_MIN(parameters),
	    ST_SEC(parameters), "SIDEREAL TIME")
	if (AIR_MASS(parameters) != 0) {	
	    value = AIR_MASS(parameters) / 100.
	    call cam_rcard (fd, "AIRMASS", value, "AIR MASS", 3)
	}
			    
	# Observation instrumentation cards
	call cam_detcard (fd, "DETECTOR", CAM_HEAD(parameters),
	    "DETECTOR (CCD TYPE, PHOTON COUNTER, ETC)")
	if (GAIN(parameters) != 0) {
	    value = GAIN(parameters) / 100.
	    call cam_rcard (fd, "GAIN", value, "GAIN (ELECTRONS/ADU)", 2)
	}
	if (RDNOISE(parameters) != 0) {
	    value = RDNOISE(parameters) / 100.
	    call cam_rcard (fd, "RDNOISE", value, "READOUT NOISE (ELECTRONS)",
	        1)
	}
	if (PREFLASH(parameters) != 0) {
	    call cam_sicard (fd, "PREFLASH", PREFLASH(parameters),
		"PREFLASH TIME (SECONDS)")
	}
	value = CAM_TEMP(parameters) / 100.
	call cam_rcard (fd, "CAMTEMP", value, "CAMERA TEMPERATURE, DEG C", 2) 
	value = DEW_TEMP(parameters) / 100.
	call cam_rcard (fd, "DEWTEMP", value, "DEWAR TEMPRATURE, DEG C", 2) 
	if (PFLEVEL(parameters) != 0) {
	    call cam_sicard (fd, "PFLEVEL", PFLEVEL(parameters),
		"PREFLASH LEVEL")
	}
	call cam_2sintcard (fd, "FILTERS", F1POS(parameters), F2POS(parameters),
	    "FILTER BOLT POSITIONS")
	call cam_sicard (fd, "TVFILT", TV_FILTER(parameters), "TV FILTER")
	call cam_sicard (fd, "COMPLAMP", COMP_LAMP(parameters),
	    "COMPARISON LAMP")
	if (TILT_POS(parameters) != 0) {
	    call cam_sicard (fd, "TILTPOS", TILT_POS(parameters),
	        "TILT POSITION")
	}
	if (PED_POS(parameters) != 0) {
	    call cam_sicard (fd, "TELEFOCUS", PED_POS(parameters),
		"TELESCOPE FOCUS")
	}

	# Reduction flags
	if (BIAS_PIX(parameters) != 0) {
	    call cam_sicard (fd, "BIASPIX", BIAS_PIX(parameters), "")
	}
	if (BT_FLAG(parameters) != 0) {
	    call cam_sicard (fd, "OVERSCAN", BT_FLAG(parameters),
	        "OVERSCAN VALUE SUBTRACTED")
	    call cam_sicard (fd, "TRIM", short (1), "TRIMMED IMAGE")
	}
	if (BI_FLAG(parameters) != 0) {
	    call cam_sicard (fd, "ZEROCOR", BI_FLAG(parameters),
	        "ZERO IMAGE SUBTRACTED (PREFLASH, BIAS)")
	}
	if (BP_FLAG(parameters) != 0) {
	    call cam_sicard (fd, "FIXPIX", BP_FLAG(parameters),
	        "BAD PIXEL CORRECTION")
	}
	if (CR_FLAG(parameters) != 0) {
	    call cam_sicard (fd, "CRFLAG", CR_FLAG(parameters),
	        "COSMIC RAYS REMOVED")
	}
	if (DK_FLAG(parameters) != 0) {
	    call cam_sicard (fd, "DARKCOR", DK_FLAG(parameters),
	        "DARK SUBTRACTED")
	}
	if (FF_FLAG(parameters) != 0) {
	    call cam_sicard (fd, "FLATCOR", FF_FLAG(parameters),
	        "FLAT FIELD CORRECTION")
	}
	if (FR_FLAG(parameters) != 0) {
	    call cam_sicard (fd, "FRINGCOR", FR_FLAG(parameters),
	        "FRINGING SUBTRACTED")
	}
	if (FR_SC100(parameters) != 0) {
	    call bitpak (int (FR_SC100(parameters)), value, 1, 32)
	    call cam_rcard (fd, "FRINGSCL", value, "FRINGE SCALING", 2)
	}

	# Geometry parameters
	call cam_section (fd, parameters)

	if (PIC_XSUM(parameters) != 0 && PIC_YSUM(parameters) != 0) {
	    call cam_2sintcard (fd, "CCDSUM", PIC_XSUM(parameters),
	        PIC_YSUM(parameters), "ON CHIP SUMMATION (X,Y)")
	}

	call close (fd)

end


#  CAM_RCARD -- Format and append a FITS header card with a real
#  keyword value to the input string buffer.  

procedure cam_rcard (fd, keyword, value, comment, precision)

int	fd			# File descriptor of input string buffer
char	keyword[LEN_KEYWORD]	# FITS keyword
real	value			# Value of FITS keyword
char	comment[ARB]		# Comment string
int	precision		# Number of decimal places output


begin
	call fprintf (fd, "%-8.8s= %20.*f  /  %-45.45s\n")
	    call pargstr (keyword)
	    call pargi (precision)
	    call pargr (value)
	    call pargstr (comment)
end


#  CAM_ICARD -- Format and append a FITS header card with a short integer
#  keyword value to the input string buffer.

procedure cam_icard (fd, keyword, value, comment)

int	fd			# File descriptor of input string buffer
char	keyword[LEN_KEYWORD]	# FITS keyword
int	value			# Value of FITS keyword
char	comment[ARB]		# Comment string

begin
	call fprintf (fd, "%-8.8s= %20d  /  %-45.45s\n")
	    call pargstr (keyword)
	    call pargs (value)
	    call pargstr (comment)
end


#  CAM_SICARD -- Format and append a FITS header card with a short integer
#  keyword value to the input string buffer.

procedure cam_sicard (fd, keyword, value, comment)

int	fd			# File descriptor of input string buffer
char	keyword[LEN_KEYWORD]	# FITS keyword
short	value			# Value of FITS keyword
char	comment[ARB]		# Comment string

begin
	call fprintf (fd, "%-8.8s= %20d  /  %-45.45s\n")
	    call pargstr (keyword)
	    call pargs (value)
	    call pargstr (comment)
end


# CAM_CCARD -- Procedure to format a FITS string parameter.

procedure cam_ccard (fd, keyword, param, maxch, comment)

int	fd			# Output file descriptor
char	keyword[ARB]		# FITS keyword
char	param[ARB]		# FITS string parameter
int	maxch			# maximum number of chars in parameter
char	comment[ARB]		# Comment string

int	i, maxchar, nblanks

begin
	# Trim off trailing blanks and compute length of string to encode.
	for (i = maxch; (i >= 1) && param[i] == ' '; i = i - 1) 
	    ;
	param[i+1] = EOS

	maxchar = max (LEN_KEYWORD, min (i, LEN_OBJECT))
	nblanks = min (LEN_OBJECT - maxchar + 2, LEN_OBJECT)

	# Print the string.
	if (nblanks < 45) {
	    call fprintf (fd, "%-8.8s= '%*.*s'%33t/  %*.*s\n")
	        call pargstr (keyword)
	        call pargi (-maxchar)
	        call pargi (maxchar)
	        call pargstr (param)
	        call pargi (-nblanks)
	        call pargi (nblanks)
	        call pargstr (comment)
	} else {
	    call fprintf (fd, "%-8.8s= '%*.*s'%33t/  %-45.-45s\n")
	        call pargstr (keyword)
	        call pargi (-maxchar)
	        call pargi (maxchar)
	        call pargstr (param)
	        call pargstr (comment)
	}
end


#  CAM_HMSCARD -- Format and append a FITS header card to the input
#  string buffer.  The value is input as 3 short integers; it is output
#  in HH:MM:SS.  The procedure can be used for RA, DEC
#  and ST, UT and HA.

procedure cam_hmscard (fd, keyword, hours, minutes, seconds, comment)

int	fd			# File descriptor
char	keyword[LEN_KEYWORD]	# FITS keyword
short	hours			# Hours
short	minutes			# Minutes
short	seconds			# Seconds
char	comment			# Comment string


begin
	call fprintf (fd, "%-8.8s= '%s%02d:%02d:%02d'%33t/  %-45.45s\n")
	    call pargstr (keyword)
	    if (hours < 0 || minutes < 0 || seconds < 0)
		call pargstr ("-")
	    else
		call pargstr (" ")
	    call pargs (abs(hours))
	    call pargs (abs(minutes))
	    call pargs (abs(seconds))
	    call pargstr (comment)
end


define	CENTURY		100

#  CAM_YMDCARD - Format and append a FITS header card to the input
#  string buffer.  The value is input as 3 short integers; it is output
#  in the format dd/mm/yy.

procedure cam_ymdcard (fd, keyword, years, months, days, comment)

int	fd			# File descriptor
char	keyword[ARB]		# FITS keyword
short	years			# Hours
short	months			# Minutes
short	days			# Seconds
char	comment			# Comment string

short	const

begin
	const = mod (int (years), CENTURY)
	call fprintf (fd, "%-8.8s= '%02d/%02d/%02d'%33t/  %-45.45s\n")
	    call pargstr (keyword)
	    call pargs (days)
	    call pargs (months)
	    call pargs (const)
	    call pargstr (comment)
end


# CAM_OBSCARD -- Procedure to code the object type into a FITS
# card

procedure cam_obscard (fd, keyword, data_code, comment)

int	fd			# File descriptor
char	keyword[LEN_KEYWORD]	# FITS keyword
short	data_code		# type of data
char	comment[ARB]		# coment string

int	nchars
pointer	sp, str
int	gstrcpy(), itoc()

begin
	call smark (sp)
	call salloc (str, LEN_OBJECT, TY_CHAR)

	switch (data_code) {
	CASE OBJECT,IROBJECT:
	    nchars = gstrcpy ("OBJECT", Memc[str], LEN_OBJECT)
	CASE DARK,IRDARK:
	    nchars = gstrcpy ("DARK", Memc[str], LEN_OBJECT)
	CASE PFLAT,IRPFLAT:
	    nchars = gstrcpy ("PROJECTOR FLAT", Memc[str], LEN_OBJECT)
	CASE SFLAT,IRSFLAT:
	    nchars = gstrcpy ("SKY FLAT", Memc[str], LEN_OBJECT)
	CASE COMP,IRCOMP:
	    nchars = gstrcpy ("COMPARISON", Memc[str], LEN_OBJECT)
	CASE BIAS,IRBIAS:
	    nchars =gstrcpy ("BIAS", Memc[str], LEN_OBJECT)
	CASE DFLAT,IRDFLAT:
	    nchars = gstrcpy ("DOME FLAT", Memc[str], LEN_OBJECT)
	CASE MASK,IRMASK:
	    nchars = gstrcpy ("MASK", Memc[str], LEN_OBJECT)
	CASE MULT,IRMULT:
	    nchars = gstrcpy ("MULTIPLE EXP", Memc[str], LEN_OBJECT)
	CASE SCAN,IRSCAN:
	    nchars = gstrcpy ("SCAN", Memc[str], LEN_OBJECT)
	case OCCULTATION:
	    nchars = gstrcpy ("OCCULTATION", Memc[str], LEN_OBJECT)
	case IRGRID:
	    nchars = gstrcpy ("INFRARED GRID", Memc[str], LEN_OBJECT)
	case IRSPECTRA:
	    nchars = gstrcpy ("INFRARED SPECTRA", Memc[str], LEN_OBJECT)
	case IRSPECKLE:
	    nchars = gstrcpy ("INFRARED SPECKLE", Memc[str], LEN_OBJECT)
	default:
	    nchars = itoc (int (data_code), Memc[str], LEN_OBJECT)
	}

	call cam_ccard (fd, keyword, Memc[str], nchars, comment)

	call sfree (sp)
end


# CAM_DETCARD -- Procedure to code the detector into a FITS card.

procedure cam_detcard (fd, keyword, data_code, comment)

int	fd			# File descriptor
char	keyword[LEN_KEYWORD]	# FITS keyword
short	data_code		# type of data
char	comment[ARB]		# coment string

int	nchars
pointer	sp, str	
int	gstrcpy(), itoc()

begin
	call smark (sp)
	call salloc (str, LEN_OBJECT, TY_CHAR)

	switch (data_code) {
	CASE TEK1:
	    nchars = gstrcpy ("TEK1", Memc[str], LEN_OBJECT)
	CASE RCA3:
	    nchars = gstrcpy ("RCA3", Memc[str], LEN_OBJECT)
	CASE TI1:
	    nchars = gstrcpy ("TI1", Memc[str], LEN_OBJECT)
	CASE RCA0:
	    nchars = gstrcpy ("RCA0", Memc[str], LEN_OBJECT)
	CASE RCA2:
	    nchars = gstrcpy ("RCA2", Memc[str], LEN_OBJECT)
	CASE RCA1:
	    nchars = gstrcpy ("RCA1", Memc[str], LEN_OBJECT)
	CASE TI2:
	    nchars = gstrcpy ("TI2", Memc[str], LEN_OBJECT)
	CASE TI3:
	    nchars = gstrcpy ("TI3", Memc[str], LEN_OBJECT)
	CASE TI4:
	    nchars = gstrcpy ("TI4", Memc[str], LEN_OBJECT)
	CASE TI5:
	    nchars = gstrcpy ("TI5", Memc[str], LEN_OBJECT)
	default:
	    nchars = itoc (int (data_code), Memc[str], LEN_OBJECT)
	}

	call cam_ccard (fd, keyword, Memc[str], nchars, comment)

	call sfree (sp)
end
 
  
# CAM_2SINTCARD -- Procedure to encode the filter positions into a FITS card.

procedure cam_2sintcard (fd, keyword, sint1, sint2, comment)

int	fd			# File descriptor
char	keyword[LEN_KEYWORD]	# FITS keyword
short	sint1			# First short integer
short	sint2			# Second short integer
char	comment[ARB]		# comment string

int	maxch
pointer	sp, str
int	strlen()

begin
	call smark (sp)
	call salloc (str, LEN_OBJECT, TY_CHAR)

	call sprintf (Memc[str], LEN_OBJECT, "%d %d")
	    call pargs (sint1)
	    call pargs (sint2)

	maxch = max (strlen (Memc[str]), LEN_KEYWORD)
	call fprintf (fd, "%-8.8s= '%*.*s'%33t/  %-45.45s\n")
	    call pargstr (keyword)
	    call pargi (-maxch)
	    call pargi (maxch)
	    call pargstr (Memc[str])
	    call pargstr (comment)

	call sfree (sp)
end


# CAM_SECTION -- Procedure  to encode the camera keywords which are formated
# like sections.

procedure cam_section (fd, parameters)

int	fd			# pointer to string file descriptor
short	parameters[ARB]		# list of parameters

int	nx1, nx2, ny1, ny2, maxch
pointer	sp, str
int	strlen()

begin
	call smark (sp)
	call salloc (str, LEN_OBJECT, TY_CHAR)

	# Redefine the dimensions.
	if (PIC_NXRAW(parameters) <= 0)
	    PIC_NXRAW(parameters) = PIC_NX(parameters)
	if (PIC_NYRAW(parameters) <= 0)
	    PIC_NYRAW(parameters) = PIC_NY(parameters)

	# Write the DATASEC keyword.
	nx1 = 1 + PIC_XPRE(parameters) + PIC_NXOFF(parameters)
	nx2 = PIC_XPRE(parameters) + PIC_NXOFF(parameters) + PIC_NX(parameters)
	ny1 = 1 + PIC_YPRE(parameters) + PIC_NYOFF(parameters)
	ny2 = PIC_YPRE(parameters) + PIC_NYOFF(parameters) + PIC_NY(parameters)
	call sprintf (Memc[str], LEN_OBJECT, "[%d:%d,%d:%d]")
	    call pargi (nx1)
	    call pargi (nx2)
	    call pargi (ny1)
	    call pargi (ny2)
	maxch = strlen (Memc[str])
	call cam_ccard (fd, "DATASEC", Memc[str], maxch,
	    "IMAGE PORTION OF FRAME")

	# Write the BIASSEC keyword.
	if (BT_FLAG(parameters) == 0) {

	    if (PIC_XPRE(parameters) != 0) {
	        nx1 = 1 + PIC_S1(parameters)
	        nx2 = PIC_X0(parameters) - PIC_S2(parameters)
		ny1 = 1 + PIC_YPRE(parameters) + PIC_YT1(parameters)
		ny2 = PIC_YPRE(parameters) + PIC_NYRAW(parameters) - 
		    PIC_YT2(parameters)
	    }
	    if (PIC_X0(parameters) != 0) {
	        nx1 = 1 + PIC_XPRE(parameters) + PIC_NXRAW(parameters) +
	            PIC_S1(parameters)
	        nx2 = PIC_XPRE(parameters) + PIC_NXRAW(parameters) +
	            PIC_X0(parameters) - PIC_S2(parameters)
		ny1 = 1 + PIC_YPRE(parameters) + PIC_YT1(parameters)
		ny2 = PIC_YPRE(parameters) + PIC_NYRAW(parameters) -
		    PIC_YT2(parameters)
	    }

	    if (PIC_YPRE(parameters) != 0) {
		nx1 = 1 + PIC_XPRE(parameters) + PIC_XT1(parameters)
		nx2 = PIC_XPRE(parameters) +  PIC_NXRAW(parameters) -
		    PIC_XT2(parameters)
	        ny1 = 1 + PIC_S1(parameters)
	        ny2 = PIC_Y0(parameters) - PIC_S2(parameters)
	    }
	    if (PIC_Y0(parameters) != 0) {
		nx1 = 1 + PIC_XPRE(parameters) + PIC_XT1(parameters)
		nx2 = PIC_XPRE(parameters) +  PIC_NXRAW(parameters) -
		    PIC_XT2(parameters)
	        ny1 = 1 + PIC_YPRE(parameters) + PIC_NYRAW(parameters) +
	            PIC_S1(parameters)
	        ny2 = PIC_YPRE(parameters) + PIC_NYRAW(parameters) +
	            PIC_Y0(parameters) - PIC_S2(parameters)
	    }

	    call sprintf (Memc[str], LEN_OBJECT, "[%d:%d,%d:%d]")
	        call pargi (nx1)
	        call pargi (nx2)
	        call pargi (ny1)
	        call pargi (ny2)
	    maxch = strlen (Memc[str])
	    call cam_ccard (fd, "BIASSEC", Memc[str], maxch,
	        "OVERSCAN PORTION OF FRAME")
	}

	# Write the TRIMSEC keyword.
	if (BT_FLAG(parameters) == 0) {
	    nx1 = 1 + PIC_XPRE(parameters) +PIC_NXOFF(parameters) +
	        PIC_XT1(parameters)
	    nx2 = PIC_XPRE(parameters) + PIC_NXOFF(parameters) +
	        PIC_NX(parameters) - PIC_XT2(parameters)
	    ny1 = 1 + PIC_YPRE(parameters) + PIC_NYOFF(parameters) +
	        PIC_YT1(parameters)
	    ny2 = PIC_YPRE(parameters) + PIC_NYOFF(parameters) +
	        PIC_NY(parameters) - PIC_YT2(parameters)
	    call sprintf (Memc[str], LEN_OBJECT, "[%d:%d,%d:%d]")
	        call pargi (nx1)
	        call pargi (nx2)
	        call pargi (ny1)
	        call pargi (ny2)
	    maxch = strlen (Memc[str])
	    call cam_ccard (fd, "TRIMSEC", Memc[str], maxch,
	    "REGION TO BE EXTRACTED AFTER PROC")
	}

	# Write the CCDSEC keyword.
	nx1 = 1 + PIC_XPRE(parameters)
	nx2 = PIC_XPRE(parameters) + PIC_NXRAW(parameters)
	ny1 = 1 + PIC_XPRE(parameters)
	ny2 = PIC_YPRE(parameters) + PIC_NYRAW(parameters)
	call sprintf (Memc[str], LEN_OBJECT, "[%d:%d,%d:%d]")
	    call pargi (nx1)
	    call pargi (nx2)
	    call pargi (ny1)
	    call pargi (ny2)
	maxch = strlen (Memc[str])
	call cam_ccard (fd, "CCDSEC", Memc[str], maxch,
	    "ORIENTATION TO FULL FORMAT FRAME")

	# Write the ORIGSEC keyword.
	nx1 = 1 + PIC_XPRE(parameters)
	nx2 = PIC_XPRE(parameters) + PIC_NXRAW(parameters)
	ny1 = 1 + PIC_XPRE(parameters)
	ny2 = PIC_YPRE(parameters) + PIC_NYRAW(parameters)
	call sprintf (Memc[str], LEN_OBJECT, "[%d:%d,%d:%d]")
	    call pargi (nx1)
	    call pargi (nx2)
	    call pargi (ny1)
	    call pargi (ny2)
	maxch = strlen (Memc[str])
	call cam_ccard (fd, "ORIGSEC", Memc[str], maxch,
	    "ORIGINAL SIZE OF FULL FORMAT FRAME")

	call sfree (sp)
end