|
Mike,> My script is now working well but I'd like to polish it up a bit.Cool.> I have three questions:
>
> 1) I'd like to write formatted output to a file. Is there a way to
> do this?Use printf, for example: cl> x = 225.7
cl> y = -34.8
cl> printf ("RA = %H, Dec = %h\n", x, y)The %h format prints the result in sexigesimal, while %H divides by 15
first to convert to HMS. I've appended a list of the possible codes.> 2) I use "curfit" within my procedure. Do you know of a way of saving
> the results to variables?I presume you're referring to results that are printed out? If so, just
pipe the standard output to the scan function, for instance: cl> imstat dev$pix fields=stddev format- | scan (x)
cl> = x
131.298It can be tricky to get the right bit of the output into the right
variable, though. Add multiple arguments to scan to read more variables.
Use scanf() with a format (but formatted reads can be annoyingly coy) to
break out very specific fields. Add a section of pipe before the scan to
the match task or some such to winnow down the output. (Etc.)> 3) Do you know how I can convert the errors in the legendre coeficients
> into errors in the power-series coeficients?Perhaps someone else will comment, too. I note that the curfit task has
a parameter "power" that should convert the coefficients themselves into
power series terms, but the errors are a different issue. I see no reason
that a simple-minded error propagation between legendre and power series
coefficients shouldn't be valid - but simple-minded doesn't mean simple
in practice. (Sounds like a nice chore for a grad student, though.)Rob---PRINTF FORMATS
A format specification has the form "%w.dCn", where W is the field
width, D is the number of decimal places or the number of digits of
precision, C is the format code, and N is radix character for
format code "r" only. The W and D fields are optional. The format
codes C are as follows:
b boolean (YES or NO)
c single character (c or '\c' or '\0nnn')
d decimal integer
e exponential format (D specifies the precision)
f fixed format (D specifies the number of decimal places)
g general format (D specifies the precision)
h hms format (hh:mm:ss.ss, D = no. decimal places)
H hms format, divide by 15 first
m minutes, seconds (or hours, minutes) (mm:ss.ss)
o octal integer
rN convert integer in any radix N
s string (D field specifies max chars to print)
t advance To column given as field W
u unsigned decimal integer
w output the number of spaces given by field W
x hexadecimal integer
z complex format (r,r) (D = precision)
Conventions for W (field width) specification:
W = n right justify in field of N characters, blank fill
-n left justify in field of N characters, blank fill
0n zero fill at left (only if right justified)
absent, 0 use as much space as needed (D field sets precision)
Escape sequences (e.g. "\n" for newline):
\f formfeed
\n newline (crlf)
\r carriage return
\t tab
\" string delimiter character
\' character constant delimiter character
\\ backslash character
\nnn octal value of character
|