aboutsummaryrefslogtreecommitdiff
path: root/noao/digiphot/apphot/aplib/apotime.x
blob: 2da01e3eb74ee7817dee0592f3f2c7885213a8cc (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
include <imhdr.h>
include "../lib/apphot.h"

# AP_OTIME --  Fetch the time or epoch of the observation from the image
# header.

procedure ap_otime (im, ap)

pointer	im		# pointer to IRAF image
pointer	ap		# pointer to apphot structure

char	timechar
int	index
pointer	sp, key, otime
bool	streq()
int	strldx()

begin
	call smark (sp)
	call salloc (key, SZ_FNAME, TY_CHAR)
	call salloc (otime, SZ_FNAME, TY_CHAR)

	call apstats (ap, OBSTIME, Memc[key], SZ_FNAME)
	Memc[otime] = EOS
	if (Memc[key] == EOS)
	    call apstats (ap, OTIME, Memc[otime], SZ_FNAME)
	else {
	    iferr { 
	        call imgstr (im, Memc[key], Memc[otime], SZ_FNAME)
	    } then {
	        call apstats (ap, OTIME, Memc[otime], SZ_FNAME)
		call eprintf ("Warning: Image %s  Keyword: %s not found\n")
		    call pargstr (IM_HDRFILE(im))
		    call pargstr (Memc[key])
	    }
	}
	if (Memc[otime] == EOS) {
	    call apsets (ap, OTIME, "INDEF")
	} else if (streq ("DATE-OBS", Memc[key]) || streq ("date-obs",
	    Memc[key])) {
	    timechar = 'T'
	    index = strldx (timechar, Memc[otime])
	    if (index > 0)
		call apsets (ap, OTIME, Memc[otime+index])
	    else
	        call apsets (ap, OTIME, "INDEF")
	} else {
	    call apsets (ap, OTIME, Memc[otime])
	}

	call sfree (sp)
end