aboutsummaryrefslogtreecommitdiff
path: root/noao/twodspec/multispec/msput.x
blob: e24e825b86d42f6a942f2cadba23388c303cb26d (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
include "ms.h"

# MSPUT -- Put information in the MULTISPEC database.
#
# MSPHDR	-- Put MULTISPEC header record in the database.
# MSPCOMMENTS	-- Put MULTISPEC comment record into the database.
# MSPSAMPLE	-- Put MULTISPEC sample record into the database.
# MSPPARAM	-- Put a line of MULTISPEC parameter data.
# MSPGAUSS5	-- Put a line of GAUSS5 parameter data.
# MSPFIT	-- Put fit coefficients for a spectrum.
# MSPFITS	-- Put fit coefficients for all spectra.


# MSPHDR -- Put MULTISPEC header record in the database.

procedure msphdr (ms)

pointer	ms				# MSIO descriptor

begin
	call dbwrite (MS_DB(ms), NAME(ms, HDR), HEADER(ms), 1)
end


# MSPCOMMENTS -- Put MULTISPEC comment record into the database.

procedure mspcomments (ms)

pointer	ms				# MSIO descriptor

begin
	call dbwrite (MS_DB(ms), NAME(ms, COMMENTS), COMMENT(ms, 1), 1)
end


# MSPSAMPLE -- Put MULTISPEC sample record into the database.

procedure mspsample (ms)

pointer	ms				# MSIO descriptor

begin
	call dbwrite (MS_DB(ms), NAME(ms, SAMPLE), LINE(ms,1), 1)
end

# MSPPARAM -- Put a line of MULTISPEC parameter data.

procedure mspparam (ms, parameter, line)

pointer	ms				# MSIO descriptor
int	parameter			# Index to parameter array
int	line				# Line to be read

char	reference[SZ_MS_KEY]

bool	is_param_id()

begin
	if (!is_param_id (parameter))
	    call error (MS_ERROR, "Bad parameter identifier")

	call sprintf (reference, SZ_MS_KEY, "%s[%d]")
	    call pargstr (NAME(ms, parameter))
	    call pargi (line)

	call dbwrite (MS_DB(ms), reference, PARAMETER(ms,parameter,1), 1)
end


# MSPGAUSS5 -- Put a line of GAUSS5 parameter data.

procedure mspgauss5 (ms, line)

pointer	ms
int	line

begin
	call mspparam (ms, I0, line)
	call mspparam (ms, X0, line)
	call mspparam (ms, S0, line)
	call mspparam (ms, S1, line)
	call mspparam (ms, S2, line)
end

# MSPFIT -- Put parameter fit data.

procedure mspfit (ms, parameter, spectrum)

pointer	ms				# MSIO descriptor
int	parameter			# Parameter to be put
int	spectrum			# Spectrum to be put

char	reference[SZ_MS_KEY]
pointer	sp, fit

begin
	call smark (sp)
	call salloc (fit, 7 + MS_NSAMPLES(ms), TY_REAL)

	call sprintf (reference, SZ_MS_KEY, "%s[%d]")
	    call pargstr (NAME(ms, parameter))
	    call pargi (spectrum)

	call cvsave (CV(ms, parameter, spectrum), Memr[fit])
	call dbwrite (MS_DB(ms), reference, Memr[fit], 1)

	call sfree (sp)
end


# MSPFITS -- Put parameter fits.

procedure mspfits (ms, parameter)

pointer	ms				# MULTISPEC data structure
int	parameter			# Parameter ID for desired fit

int	i

begin
	do i = 1, MS_NSPECTRA(ms)
	    call mspfit (ms, parameter, i)
end