aboutsummaryrefslogtreecommitdiff
path: root/noao/astcat/src/agetcat/atwedit.x
blob: 7678eb355e243fe3c9acf418ebfcbb8fd4aa3898 (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
include <imhdr.h>
include <pkg/cq.h>

# Add a valid WCS to the image header if it does not already have one using
# the image WCS status specified by the wcs keyword in the image survey
# database. If the wcs keyord  is "fits", the image is assumed to have a
# valid FITS WCS and no new wcs is computed, if it is "dss" the image is assumed
# to have a valid DSS image header which will be transformed to a valid FITS
# WCS if a FITS WCS is not already present, if it is "none" the image is
# assumed to have no valid WCS and the code will attempt to insert one using
# information in the image results structure. An error status is returned
# only if there is no valid wcs code.

procedure at_wedit (im, res, at, wcstype, update, verbose)

pointer	im			#I the input image descriptor
pointer	res			#I the image query results descriptor
pointer	at			#I the astrometry package descriptor
int	wcstype			#I the default wcs type
bool	update			#I actually update the header ?
bool	verbose			#I verbose mode ?

int	cq_istati(), at_mkdss(), at_dbwcs(), at_parwcs()

begin
	# Update WCS from database
	if (res != NULL) {

	    switch (cq_istati (res, CQWCS)) {

	    # Image surveys database indicates image already has a FITS WCS.
	    case CQ_WFITS:
	        ;

	    # Image surveys database indicates image has a DSS WCS.
	    case CQ_WDSS:
	        if (at_mkdss (im, update, verbose) == ERR) {
	            #if (update || verbose)
	            if (verbose)
		        call printf (
			    "    Error converting DSS wcs to FITS wcs\n")
	        }

	    # Image surveys database indicates image has no WCS. If the proper
	    # information is not in the image survey then default to awcspars.
	    default:
	        if (at_dbwcs (im, res, update, verbose) == ERR) {
	            #if (update || verbose)
	            if (verbose)
		        call printf (
		        "    Error creating FITS wcs using image survey db\n")
	        }
	    }

	} else {

	    switch (wcstype) {

	    # User parameter indicates image already has a FITS WCS.
	    case CQ_WFITS:
		;

	    # User parameter indicates image has a DSS WCS.
	    case CQ_WDSS:
	        if (at_mkdss (im, update, verbose) == ERR) {
	            #if (update || verbose)
	            if (verbose)
		        call printf (
			    "    Error converting DSS wcs to FITS wcs\n")
	        }

	    default:
	        if (at == NULL)
		    ;
	        else if (at_parwcs (im, at, update, verbose) == ERR) {
	            #if (update || verbose)
	            if (verbose)
		        call printf (
		       "    Error creating FITS wcs using default parameters\n")
	        }
	    }
	}
end