Re: getting data/models written out

From: John Houck <houck_at_email.domain.hidden>
Date: Wed, 14 Mar 2007 11:57:02 -0400
On Wed, Mar 14, 2007 at 14:55 +0000, Rhaana Starling wrote:
>
> Hi all,
> A basic question: I have fitted a model to my data and plotted. How do I
> get that data and model fit out to say an ascii file? Can I also do this
> for unfolded spectra?
> Thanks,
> Rhaana
>

Hi Rhaana,

For ascii output, one quick method is to use 'writecol':

  m = get_model_counts(1);
  writecol ("model.txt", m.bin_lo, m.bin_hi, m.value);

'readcol' can be used to read from an ascii file containing
numerical data in columns:

  (a, b, c) = readcol ("file.txt", [1:3]);

S-Lang provides the full set of I/O functions available in C,
so one could also use e.g. fopen/fprintf/fclose to create a
custom output format.

Alternatively, FITS format may provide an easier and more
useful way to include metadata in an output file.

To save the flux-corrected spectrum in a FITS file, you
might do something like this:

  flux_corr(1);
  f = get_data_flux (1);
  fits_write_binary_table ("flux.fits", "SPECTRUM", f);

That will create a FITS binary table with a column for each
field of the 'f' structure and with EXTNAME="SPECTRUM".  If you
wanted the spectrum grid in keV instead of Angstrom units, you
could use the '_A' function to perform this conversion on
output:

  fits_write_binary_table ("flux.fits", "SPECTRUM", _A(f));

The help page for fits_write_binary_table describes how to
write out additional information in the header keywords and
how to include history comments.

To read such a file, use fits_read_table:

  isis> t = fits_read_table ("flux.fits");
  isis> print(t);
      bin_lo = Double_Type[4096]
      bin_hi = Double_Type[4096]
      value = Double_Type[4096]
      err = Double_Type[4096]

Thanks,
-John
----
You received this message because you are
subscribed to the isis-users list.
To unsubscribe, send a message to
isis-users-request_at_email.domain.hiddenwith the first line of the message as:
unsubscribe
Received on Wed Mar 14 2007 - 11:57:07 EDT

This archive was generated by hypermail 2.2.0 : Sat Mar 17 2007 - 10:14:19 EDT