summaryrefslogtreecommitdiffstats
path: root/funtools/fitsy/headset.c
blob: ed586c762dc1e5c4bb77fff49305ba37a42c5046 (plain)
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
/* Fitsy FITS header set routines.

   EXAMPLES

   Set the value part of a card in a header:
+
		int	i = 15;
		double	d = 34.7;
		char   *c = "Shutter";

		FITSCard	fits;
		FITSCard	card;

	card = #ft_headsetl(fits, "Cosmic", 0, 1, "Removed Cosimics (silver bullet method)");
	card = #ft_headseti(fits, "IValue" , 0, i, "15 is the number");

	card = #ft_headsetr(fits, "Gain", 1, d, 2, "GAIN1");
	card = #ft_headsetr(fits, "Gain", 2, d, 2, "GAIN2");

	card = #ft_headsets(fits, "XHIST", 1, "Xray processed!", NULL);

	/-* In this example the special pointer #ft_comment is used to 
	   use the existing comment in the card.
	 *-/
	card = #ft_headsets(fits, "FILTER", 0, "V", ft_comment);
+
 */

#include "fitsy.h"

/* Find a FITS card in the header and format a logical value into it.
 */
FITSCard ft_headsetl(fits, name, n, lvalue, comm, append)
	FITSHead	 fits;		/* FITS header to search in.		*/
	char		*name;		/* keyword name.                        */
	int		 n;		/* keyword index number, if is zero no
                                           index number is appended to the keyword.
					 */

	int		 lvalue;	/* Logical to format as a FITS value.	*/
	char		*comm;		/* Comment for the card.                */
	int		 append;	/* Append the card if not found		*/
{
	    FITSCard	card;

	if ( !(card = ft_cardsetl(ft_headfind(fits, name, n, 1), lvalue, comm))
	  && append )
		card = ft_headappl(fits, name, n, lvalue, comm);

	return card;
}

/* Find a FITS card in the header and format a logical value into it.
 */
FITSCard ft_headseti(fits, name, n, ivalue, comm, append)
	FITSHead	 fits;
	char		*name;
	int		 n;
	int		 ivalue;	/* Integer to format as a FITS value.	*/
	char		*comm;
	int		 append;
{
	    FITSCard	card;

	if ( !(card = ft_cardseti(ft_headfind(fits, name, n, 1), ivalue, comm))
	  && append )
		card = ft_headappi(fits, name, n, ivalue, comm);

	return card;
}

/* Find a FITS card in the header and format a logical value into it.
 */
FITSCard ft_headsetil(fits, name, n, ivalue, comm, append)
	FITSHead	 fits;
	char		*name;
	int		 n;
	longlong	 ivalue;	/* Integer to format as a FITS value.	*/
	char		*comm;
	int		 append;
{
	    FITSCard	card;

	if ( !(card = ft_cardsetil(ft_headfind(fits, name, n, 1), ivalue, comm))
	  && append )
		card = ft_headappil(fits, name, n, ivalue, comm);

	return card;
}

/* Find a FITS card in the header and format a logical value into it.
 */
FITSCard ft_headsetr(fits, name, n, rvalue, prec, comm, append)
	FITSHead	 fits;
	char		*name;
	int		 n;
	double		 rvalue;	/* Double to format as a FITS value.	*/
	int		 prec;		/* The value is formatted
                                           at this precision.
                                         */
	char		*comm;
	int		 append;
{
	    FITSCard	card;

	if ( !(card = ft_cardsetr(ft_headfind(fits, name, n, 1)
			, rvalue, prec, comm))
	  && append )
		card = ft_headappr(fits, name, n, rvalue, prec, comm);

	return card;
}

/* Find a FITS card in the header and format a string value into it.
 */
FITSCard ft_headsets(fits, name, n, svalue, comm, append)
	FITSHead	 fits;
	char		*name;
	int		 n;
	char		*svalue;	/* String to format as a FITS value.	*/
	char		*comm;
	int		 append;
{
	    FITSCard	card;

	if ( !(card = ft_cardsets(ft_headfind(fits, name, n, 1), svalue, comm))
	  && append )
		card = ft_headapps(fits, name, n, svalue, comm);

	return card;
}