From owner-fitsbits at kochab.cv.nrao.edu  Tue Jan 12 09:49:44 1999
Received: (from majordom at localhost)
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) id JAA23903
	for fitsbits-spinner; Tue, 12 Jan 1999 09:42:14 -0500 (EST)
Received: from fits.cv.nrao.edu (dwells at fits.cv.nrao.edu [192.33.115.8])
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) with ESMTP id JAA23896
	for <fitsbits at kochab.cv.nrao.edu>; Tue, 12 Jan 1999 09:41:52 -0500 (EST)
Received: (from dwells at localhost)
	by fits.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) id JAA29661
	for fitsbits at majordomo.cv.nrao.edu; Tue, 12 Jan 1999 09:41:51 -0500
Received: from fits.cv.nrao.edu (root at fits.cv.nrao.edu [192.33.115.8])
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) with ESMTP id GAA22537
	for <fitsbits at kochab.cv.nrao.edu>; Tue, 12 Jan 1999 06:50:45 -0500 (EST)
Received: from newsfeed.cv.nrao.edu (newsfeed.cv.nrao.edu [192.33.115.17])
	by fits.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) with ESMTP id GAA29449
	for <fitsbits at fits.cv.nrao.edu>; Tue, 12 Jan 1999 06:50:44 -0500
Received: (from news at localhost)
	by newsfeed.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) id GAA00991;
	Tue, 12 Jan 1999 06:49:21 -0500
To: fitsbits at fits.cv.nrao.edu
Date: 12 Jan 1999 11:24:46 -0000
From: Clive Page <cgp at nospam.le.ac.uk>
Message-ID: <77fbdu$483 at owl.le.ac.uk>
Organization: University of Leicester, UK
Path: newsfeed.cv.nrao.edu!chaos.aoc.nrao.edu!lynx.unm.edu!jobone!newsxfer3.itd.umich.edu!rill.news.pipex.net!pipex!server1.netnews.ja.net!leicester!leicester!not-for-mail
References: <77e9ip$7lh at post.gsfc.nasa.gov>
Subject: Re: FITS WCS with Terrestrial Satellite Data
Newsgroups: sci.astro.fits
Sender: owner-fitsbits at kochab.cv.nrao.edu
Precedence: bulk

In article <77e9ip$7lh at post.gsfc.nasa.gov>,
Louis Giglio <giglio at hades.gsfc.nasa.gov> wrote:
>  (We've used HDF for both of these purposes in
>the past, but have largely dropped it for a host of reasons.  But I
>digress...)

I know you were digressing (and I'm not expert enough to help by answering
your main questions) but I would be interested in knowing some of these
reasons - from time to time the limitations of FITS seem almost
overwhelming (after all it was designed  many computer generations ago)
and in disucssions  someone is sure to say "why don't we switch to
something more modern and flexible like CDF/netCDF/HDF/HDS...  ".  I can
think of some of the reasons, but would be interested all the same.


-- 
Clive Page,                         e-mail:  cgp (at) le (dot) ac (dot) uk
Dept of Physics & Astronomy,               
University of Leicester.                   

From owner-fitsbits at kochab.cv.nrao.edu  Tue Jan 12 09:49:49 1999
Received: (from majordom at localhost)
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) id JAA23872
	for fitsbits-spinner; Tue, 12 Jan 1999 09:38:49 -0500 (EST)
Received: from fits.cv.nrao.edu (dwells at fits.cv.nrao.edu [192.33.115.8])
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) with ESMTP id JAA23867
	for <fitsbits at kochab.cv.nrao.edu>; Tue, 12 Jan 1999 09:38:46 -0500 (EST)
Received: (from dwells at localhost)
	by fits.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) id JAA29649
	for fitsbits at majordomo.cv.nrao.edu; Tue, 12 Jan 1999 09:38:45 -0500
Received: from fits.cv.nrao.edu (root at fits.cv.nrao.edu [192.33.115.8])
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) with ESMTP id VAA13517
	for <fitsbits at kochab.cv.nrao.edu>; Mon, 11 Jan 1999 21:04:05 -0500 (EST)
Received: from newsfeed.cv.nrao.edu (newsfeed.cv.nrao.edu [192.33.115.17])
	by fits.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) with ESMTP id VAA28456
	for <fitsbits at fits.cv.nrao.edu>; Mon, 11 Jan 1999 21:04:05 -0500
Received: (from news at localhost)
	by newsfeed.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) id VAA22947;
	Mon, 11 Jan 1999 21:02:43 -0500
To: fitsbits at fits.cv.nrao.edu
Date: 12 Jan 1999 01:47:05 GMT
From: giglio at hades.gsfc.nasa.gov (Louis Giglio)
Message-ID: <77e9ip$7lh at post.gsfc.nasa.gov>
Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA
Path: newsfeed.cv.nrao.edu!newsgate.duke.edu!newsfeed.mathworks.com!nntprelay.mathworks.com!newsfeed.berkeley.edu!news.msfc.nasa.gov!centauri.hq.nasa.gov!newsfeed.gsfc.nasa.gov!hades.gsfc.nasa.gov!giglio
Subject: FITS WCS with Terrestrial Satellite Data
Newsgroups: sci.astro.fits
Sender: owner-fitsbits at kochab.cv.nrao.edu
Precedence: bulk

Greetings all,

For the past several months our group has been generating and working
with FITS files containing terrestrial satellite data.  Although FITS
was intended for sharing astronomical data, we've found that it is
quite useful as an archival earth-science data format.  In fact, at
least for our purposes, FITS has turned out to be a very practical
working format as well.  (We've used HDF for both of these purposes in
the past, but have largely dropped it for a host of reasons.  But I
digress...)

Much of our data has been mapped into a variety of cartographic
projections.  Rather than reinventing the wheel, I'd like to use the
proposed WCS conventions of Greisen and Calabretta (1996) to describe
the geographic (as opposed to celestial) coordinates of our mapped
data.

Currently I've been creating experimental terrestrial FITS files that
use the WCS conventions.  The only disadvantage I know of in using WCS
for this purpose is that the left handed spherical coordinate system
is confusing to most folks.  It's easy enough to convert to right
handed longitudes within our display software, however, so I don't
view this as a significant problem.

In the course of working with our experimental FITS files, several
issues have arisen for which I'm hoping to get some advice:


1) CTYPEn keywords

What are reasonable values for the "xLON" and "xLAT" keywords?  The
codes x = G (galactic), E (ecliptic), and H (helioecliptic) have
already been defined by Greisen and Calabrettta.  We've been using use
"XLON" and "XLAT", but we'd prefer to use a convention that will never
conflict with the needs of the astronomical community.  Others have
suggested "PLON" / "PLAT" (for "planetary") and "TLON" / "TLAT" (for
"terrestrial").


2) EQUINOX keyword

For terrestrial data this keyword has no meaning.  Is it OK to omit
it?


3) RADECSYS keyword

Is it correct that this keyword should _not_ be supplied for "xLON"
and "xLAT" type reference frames?  If it should be supplied, what
value should we use?


4) Is anyone else attempting to do this sort of thing?  What
cartographic formats are used for mapped data from unmanned planetary
missions?


5) Am I missing something that makes this a stupid idea?


I'm also interested in hearing general comments and suggestions.


Thanks very much,
Louis Giglio

giglio at hades.gsfc.nasa.gov

NASA/GSFC
Biospheric Sciences Branch
Greenbelt, MD USA

From owner-fitsbits at kochab.cv.nrao.edu  Tue Jan 12 20:39:37 1999
Received: (from majordom at localhost)
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) id UAA29437
	for fitsbits-spinner; Tue, 12 Jan 1999 20:39:21 -0500 (EST)
Received: from fits.cv.nrao.edu (dwells at fits.cv.nrao.edu [192.33.115.8])
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) with ESMTP id UAA29432
	for <fitsbits at kochab.cv.nrao.edu>; Tue, 12 Jan 1999 20:39:18 -0500 (EST)
Received: (from dwells at localhost)
	by fits.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) id UAA32512
	for fitsbits at majordomo.cv.nrao.edu; Tue, 12 Jan 1999 20:39:18 -0500
Received: from fits.cv.nrao.edu (root at fits.cv.nrao.edu [192.33.115.8])
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) with ESMTP id TAA29087
	for <fitsbits at kochab.cv.nrao.edu>; Tue, 12 Jan 1999 19:04:55 -0500 (EST)
Received: from newsfeed.cv.nrao.edu (newsfeed.cv.nrao.edu [192.33.115.17])
	by fits.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) with ESMTP id TAA32393
	for <fitsbits at fits.cv.nrao.edu>; Tue, 12 Jan 1999 19:04:54 -0500
Received: (from news at localhost)
	by newsfeed.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) id TAA20780;
	Tue, 12 Jan 1999 19:03:31 -0500
To: fitsbits at fits.cv.nrao.edu
Date: 12 Jan 1999 23:58:54 GMT
From: giglio at hades.gsfc.nasa.gov (Louis Giglio)
Message-ID: <77gnju$pmr at post.gsfc.nasa.gov>
Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA
Path: newsfeed.cv.nrao.edu!newsgate.duke.edu!newsfeed.berkeley.edu!cnn.nas.nasa.gov!newsfeed.gsfc.nasa.gov!hades.gsfc.nasa.gov!giglio
References: <77e9ip$7lh at post.gsfc.nasa.gov> <77fbdu$483 at owl.le.ac.uk>
Subject: FITS/HDF (Was: FITS WCS with Terrestrial Satellite Data)
Newsgroups: sci.astro.fits
Sender: owner-fitsbits at kochab.cv.nrao.edu
Precedence: bulk



In article <77fbdu$483 at owl.le.ac.uk>, Clive Page <cgp at nospam.le.ac.uk>
writes:

>In article <77e9ip$7lh at post.gsfc.nasa.gov>,
>Louis Giglio <giglio at hades.gsfc.nasa.gov> wrote:
>>  (We've used HDF for both of these purposes in
>>the past, but have largely dropped it for a host of reasons.  But I
>>digress...)
>
>I know you were digressing (and I'm not expert enough to help by answering
>your main questions) but I would be interested in knowing some of these
>reasons - from time to time the limitations of FITS seem almost
>overwhelming (after all it was designed  many computer generations ago)
>and in disucssions  someone is sure to say "why don't we switch to
>something more modern and flexible like CDF/netCDF/HDF/HDS...  ".  I can
>think of some of the reasons, but would be interested all the same.


My general reasons for using FITS are:

     * FITS is defined in terms of physical file layout rather than
       a software interface.

     * The simpler structure of FITS files makes them easier to
       understand, read, and write.

     * It's very easy to ignore FITS headers and read data directly if
       necessary.

     * New FITS features/conventions are defined by community consensus
       after a great deal of haggling.  (I suspect this is a
       disadvantage sometimes.)

     * FITS has been around for a long time and is well documented.


Now for the general reasons we've steered away from HDF:

     * HDF is defined in terms of a software interface rather than
       a physical file layout.

     * The HDF format is in fact a collection of several different
       file formats.  (Different versions have different formats.)

     * Poor I/O performance when updating existing HDF files.

     * Extremely difficult to ignore internal HDF information and read
       data directly if necessary.

     * Any HDF operations require the use of the NCSA HDF library.
       If this library cannot be built on a particular platform,
       there's no way to access HDF files.

     * New HDF features/conventions defined by relatively small group
       of people.  (This I'm sure is an advantage sometimes.)

     * Portions of old HDF files are sometimes not readable by newer
       releases of the HDF library.  It is quite possible to have
       information stored in an HDF file that is unreadable by the
       current HDF library.

These very general reasons weren't sufficient to sway me completely.
What really did it was the more mundane, practical issues we run into
on a day to day basis.  These include:

1) We sometimes share data with investigators in relatively poor
countries.  It does no good to give them HDF files (which absolutely
require the use of the memory hungry HDF library) when all they have
is an old IBM AT with 320K of RAM.  Many FITS utilities, however,
will work with such small amounts of memory, and with FITS it's very
easy to read the files as binary when necessary.

2) I've created FITS files from C shell scripts using only standard
UNIX commands such as "cat" and "dd".  I also rolled my own REXX
procedures to write FITS files.  I don't believe it is practical to
write HDF files this way.

3) A huge amount of freely available software has been written to
manipulate FITS files, much of which is quite general and useful
regardless of the type of data contained within the file.  We're able
to use much of this software, saving us from having to write a lot of
code from scratch.

(Contrast this to a few of the folks I work with, who have contracted
a programmer for several _years_ to write an HDF SDS display program
with some image processing bells and whistles [histograms, etc.]).

4) Many of the FITS-related issues ironed out by astronomers are
applicable to other disciplines.  Examples of this include date
and time formats, checksum conventions, and the WCS proposal.

5) A surprising number of my coworkers handle HDF files by converting
them into native binary before working with the data.  Frequently
confusion arises later because all of the metadata was stripped in
the process.  I've never seen them do this with a FITS file.

Don't get me wrong, FITS definitely drags along its own set of ugly
features and peculiarities.  And on paper HDF looks great: groups,
support for arbitrary stuctures, etc.  But when it comes down to
routine, everyday sharing and archiving of data in a simple, efficient
manner, FITS provides considerable advantages in my opinion.

Cheers,
Louis

                

From owner-fitsbits at kochab.cv.nrao.edu  Thu Jan 14 10:33:06 1999
Received: (from majordom at localhost)
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) id KAA27871
	for fitsbits-spinner; Thu, 14 Jan 1999 10:32:08 -0500 (EST)
Received: from fits.cv.nrao.edu (dwells at fits.cv.nrao.edu [192.33.115.8])
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) with ESMTP id KAA27866
	for <fitsbits at kochab.cv.nrao.edu>; Thu, 14 Jan 1999 10:32:05 -0500 (EST)
Received: (from dwells at localhost)
	by fits.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) id KAA05786
	for fitsbits at majordomo.cv.nrao.edu; Thu, 14 Jan 1999 10:32:04 -0500
Received: from fits.cv.nrao.edu (root at fits.cv.nrao.edu [192.33.115.8])
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) with ESMTP id XAA18060
	for <fitsbits at kochab.cv.nrao.edu>; Wed, 13 Jan 1999 23:46:59 -0500 (EST)
Received: from newsfeed.cv.nrao.edu (newsfeed.cv.nrao.edu [192.33.115.17])
	by fits.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) with ESMTP id XAA04689
	for <fitsbits at fits.cv.nrao.edu>; Wed, 13 Jan 1999 23:46:58 -0500
Received: (from news at localhost)
	by newsfeed.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) id XAA00882;
	Wed, 13 Jan 1999 23:45:32 -0500
To: fitsbits at fits.cv.nrao.edu
Date: 13 Jan 1999 23:45:57 -0500
From: phylcrx at panther.Gsu.EDU (Lewis C. Roberts)
Message-ID: <77jsq5$oud at panther.Gsu.EDU>
Organization: Georgia State University
Path: newsfeed.cv.nrao.edu!newsgate.duke.edu!newsfeed.mathworks.com!nntprelay.mathworks.com!btnet-peer!btnet!nntp.news.xara.net!xara.net!rill.news.pipex.net!pipex!ams.uu.net!ffx.uu.net!in5.uu.net!finch!news-feed-1.peachnet.edu!tattler!news.Gsu.EDU!not-for-mail
Subject: MATLAB routines to read FITS
Newsgroups: sci.astro.fits
Sender: owner-fitsbits at kochab.cv.nrao.edu
Precedence: bulk

Hi,

Does anyone have a Matlab routine to read in FITS files that
they would be willing to share? Or does anyone
know where I can download one?

Thanks,

Lewis Roberts     

From owner-fitsbits at kochab.cv.nrao.edu  Thu Jan 14 10:33:06 1999
Received: (from majordom at localhost)
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) id KAA27878
	for fitsbits-spinner; Thu, 14 Jan 1999 10:32:39 -0500 (EST)
Received: from fits.cv.nrao.edu (dwells at fits.cv.nrao.edu [192.33.115.8])
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) with ESMTP id KAA27873
	for <fitsbits at kochab.cv.nrao.edu>; Thu, 14 Jan 1999 10:32:35 -0500 (EST)
Received: (from dwells at localhost)
	by fits.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) id KAA05791
	for fitsbits at majordomo.cv.nrao.edu; Thu, 14 Jan 1999 10:32:35 -0500
Received: from fits.cv.nrao.edu (root at fits.cv.nrao.edu [192.33.115.8])
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) with ESMTP id FAA27609
	for <fitsbits at kochab.cv.nrao.edu>; Thu, 14 Jan 1999 05:46:45 -0500 (EST)
Received: from newsfeed.cv.nrao.edu (newsfeed.cv.nrao.edu [192.33.115.17])
	by fits.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) with ESMTP id FAA05353
	for <fitsbits at fits.cv.nrao.edu>; Thu, 14 Jan 1999 05:46:44 -0500
Received: (from news at localhost)
	by newsfeed.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) id FAA05674;
	Thu, 14 Jan 1999 05:45:18 -0500
To: fitsbits at fits.cv.nrao.edu
Date: Thu, 14 Jan 1999 10:44:57 +0000
From: Guy Rixon <gtr at mrao.cam.ac.uk>
Message-ID: <369DCAA9.AA57C616 at mrao.cam.ac.uk>
Organization: UK Astronomical Technology Centre
Path: newsfeed.cv.nrao.edu!newsgate.duke.edu!newsfeed.mathworks.com!nntprelay.mathworks.com!btnet-peer!btnet!diablo.theplanet.net!diablo.dera.gov.uk!server1.netnews.ja.net!hgmp.mrc.ac.uk!pegasus.csx.cam.ac.uk!not-for-mail
References: <77e9ip$7lh at post.gsfc.nasa.gov>
Subject: Re: FITS WCS with Terrestrial Satellite Data
Newsgroups: sci.astro.fits
Sender: owner-fitsbits at kochab.cv.nrao.edu
Precedence: bulk

Louis Giglio wrote:

> 2) EQUINOX keyword
>
> For terrestrial data this keyword has no meaning.  Is it OK to omit
> it?

NASA's FITS standard (draft of NOST 100-1.2) lists EQUINOX in the set of
keywords which
"are optional but may be used only as defined in this standard."

--
Guy Rixon, ATC                                  gtr at mrao.cam.ac.uk
c/o Astrophysics Group, Cavendish Laboratory    Tel: +44-1223-766467
Madingley Road, Cambridge, CB3 0HE              Fax: +44-1223-766462



From owner-fitsbits at kochab.cv.nrao.edu  Thu Jan 14 13:32:38 1999
Received: (from majordom at localhost)
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) id NAA28814
	for fitsbits-spinner; Thu, 14 Jan 1999 13:32:06 -0500 (EST)
Received: from fits.cv.nrao.edu (dwells at fits.cv.nrao.edu [192.33.115.8])
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) with ESMTP id NAA28809
	for <fitsbits at kochab.cv.nrao.edu>; Thu, 14 Jan 1999 13:32:03 -0500 (EST)
Received: (from dwells at localhost)
	by fits.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) id NAA06062
	for fitsbits at majordomo.cv.nrao.edu; Thu, 14 Jan 1999 13:32:02 -0500
Received: from fits.cv.nrao.edu (root at fits.cv.nrao.edu [192.33.115.8])
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) with ESMTP id MAA28764
	for <fitsbits at kochab.cv.nrao.edu>; Thu, 14 Jan 1999 12:47:51 -0500 (EST)
Received: from newsfeed.cv.nrao.edu (newsfeed.cv.nrao.edu [192.33.115.17])
	by fits.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) with ESMTP id MAA05965
	for <fitsbits at fits.cv.nrao.edu>; Thu, 14 Jan 1999 12:47:50 -0500
Received: (from news at localhost)
	by newsfeed.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) id MAA16290;
	Thu, 14 Jan 1999 12:46:23 -0500
To: fitsbits at fits.cv.nrao.edu
Date: Thu, 14 Jan 1999 12:27:34 -0500
From: tim Cole <tim.cole at jhuapl.edu>
Message-ID: <369E2906.186BC879 at jhuapl.edu>
Organization: Johns Hopkins University Applied Physics Lab, Laurel, MD, USA
Path: newsfeed.cv.nrao.edu!newsgate.duke.edu!newsfeed.mathworks.com!nntprelay.mathworks.com!dca1-hub1.news.digex.net!dca1-feed1.news.digex.net!digex!netnews.jhuapl.edu!not-for-mail
References: <77jsq5$oud at panther.Gsu.EDU>
Subject: Re: MATLAB routines to read FITS
Newsgroups: sci.astro.fits
Sender: owner-fitsbits at kochab.cv.nrao.edu
Precedence: bulk

Lewis,

Did you get a response? I too am interested in such a routine.. if you
find one, please let me know. Thank you in advance.

Tim Cole

"Lewis C. Roberts" wrote:

> Hi,
>
> Does anyone have a Matlab routine to read in FITS files that
> they would be willing to share? Or does anyone
> know where I can download one?
>
> Thanks,
>
> Lewis Roberts

From owner-fitsbits at kochab.cv.nrao.edu  Mon Jan 18 13:09:16 1999
Received: (from majordom at localhost)
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) id NAA19373
	for fitsbits-spinner; Mon, 18 Jan 1999 13:07:57 -0500 (EST)
Received: from fits.cv.nrao.edu (dwells at fits.cv.nrao.edu [192.33.115.8])
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) with ESMTP id NAA19368
	for <fitsbits at kochab.cv.nrao.edu>; Mon, 18 Jan 1999 13:07:54 -0500 (EST)
Received: (from dwells at localhost)
	by fits.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) id NAA15958
	for fitsbits at majordomo.cv.nrao.edu; Mon, 18 Jan 1999 13:07:54 -0500
Received: from fits.cv.nrao.edu (root at fits.cv.nrao.edu [192.33.115.8])
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) with ESMTP id VAA08020
	for <fitsbits at kochab.cv.nrao.edu>; Sun, 17 Jan 1999 21:34:44 -0500 (EST)
Received: from newsfeed.cv.nrao.edu (newsfeed.cv.nrao.edu [192.33.115.17])
	by fits.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) with ESMTP id VAA14604
	for <fitsbits at fits.cv.nrao.edu>; Sun, 17 Jan 1999 21:34:43 -0500
Received: (from news at localhost)
	by newsfeed.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) id VAA08790;
	Sun, 17 Jan 1999 21:33:10 -0500
To: fitsbits at fits.cv.nrao.edu
Date: Sun, 17 Jan 1999 18:34:58 -0800
From: Stephen Walton <stephen.walton at csun.edu>
Message-ID: <77u64s$dk6$1 at news-2.news.gte.net>
Organization: gte.net
Path: newsfeed.cv.nrao.edu!newsgate.duke.edu!newsfeed.mathworks.com!nntprelay.mathworks.com!worldfeed.news.gte.net!not-for-mail
References: <77jsq5$oud at panther.Gsu.EDU>
Subject: Re: MATLAB routines to read FITS
Newsgroups: sci.astro.fits
Sender: owner-fitsbits at kochab.cv.nrao.edu
Precedence: bulk



Lewis C. Roberts wrote:

> Hi,
>
> Does anyone have a Matlab routine to read in FITS files that
> they would be willing to share?

Here's one which was posted on comp.soft-sys.matlab a while back.  It is
short enough to put here, I hope, and be found useful.  If  Netscape
wordwraps it in some weird way, let me know and I'll e-mail a clean
copy.

function output_image=fitsread(filename,n_hdr_areas)
% FITSREAD reads a very simple FITS image into a Matlab variable.
%
%  data=fitsread(filename)
%  data=fitsread(filename,n_hdr_areas)
%
%  The second form explicitly indicates the number of ascii header
%  areas present in the file. Explicitly telling FITSREAD
%  how many header areas are present greatly speeds up
%  the file access, since in this case the function does not need to
%  parse each header line to determine where the header ends
%  and the data begins.
%
%  The following syntax is also acceptible:
%
%    data=fitsread(filename,'hst')
%    data=fitsread(filename,'stsci')
%
%  where the 'hst' and 'stsci'  keywords indicate FITSREAD
%  should use the number of HDUs (=6) in some typical FITS files
%  originating from the Space Telescope Science Institute.
%
%
%  Useful FITS Definitions:
%
%  "card" = 80 byte line of ASCII data in a file. This
%           contains keyword/value pairs and/or comments.
%
%  "Header area" or "HDU" = a set of 36 "cards". Note
%          that FITS files must have an integer number of header
%          areas (typically between 1 and 6, depending on how much
%          header information is stored in the file.)
%
%
% Known deficiences:
%
%  1. does not use bscale or bzero -- if your data needs to be
%     rescaled you can add code to look for these keywords
%
%  2. does not read anything more complicated than a simple
%     image, ie. no binary tables or data cubes.


% Version 2.1
% R. Abraham, Institute of Astronomy, Cambridge University
%
% Changes
% Oct. 98 -- added code to detect 80X86 and Alpha machines and to read
%            data into these with the big endian switch


%The first few cards of the first header/data unit must give information

%in a pre-defined order (eg. the data format, number of axes,
%size etc) but after that the header keywords can come in any
%order. The end of the last card giving information is flagged by
%the keyword END, after which blank lines are added to pad the
%last header so it also contains 36 cards. After the last card
%the data begins, in a format specified by the BITPIX keyword.
%The dimensions of the data are specified by the NAXIS1 and
%NAXIS2 keywords.
%
%Reference:   NASA/Science Office of Standards and Technology
%           "Definition of the Flexible Image Transport System"
%                            NOST 100-1.0
%
%           This and other FITS documents are available on-line at:
%           http://www.gsfc.nasa.gov/astro/fits/basics_info.html

%Set flag indicating unknown number of HDUs
if nargin<2
   n_hdr_areas='unknown';
end;

if isstr(n_hdr_areas)
   n_hdr_areas=upper(n_hdr_areas);
end;

%Allow user to specify a few keywords to indicate number of header areas

if strmatch(n_hdr_areas,'HST') | strmatch(n_hdr_areas,'STSCI') | ...
   strmatch(n_hdr_areas,'MDS')
   n_hdr_areas=6;
end
if strmatch(n_hdr_areas,'FREI')
   n_hdr_areas=2;
end

% try to figure out if we need to swap bytes. This is
% imperfect as I don't know the endian-ness of each
% architecture, so I'm only looking for ones I know for
% sure.
friend = computer;
if strmatch(friend,'PCWIN')
   bswap = 'b';
elseif strmatch(friend,'LNX86')
   bswap = 'b';
elseif strmatch(friend,'ALPHA')
   bswap = 'b';
else
   bswap = 'l';
end

%Open the file
fid=-1;
if ~isstr(filename)
   filename=setstr(filename);
end;
if (isempty(findstr(filename,'.'))==1)
   filename=[filename,'.fits'];
end
[file,message] = fopen(filename,'r','l');
if file == -1
   error(message);
end

%First five cards must contain specific information
[d,simple,d]=parse_card(setstr(fread(file,80,'uchar')'));
[d,bitpix,d]=parse_card(setstr(fread(file,80,'uchar')'));
[d,naxis,d]=parse_card(setstr(fread(file,80,'uchar')'));
[d,naxis1,d]=parse_card(setstr(fread(file,80,'uchar')'));
[d,naxis2,d]=parse_card(setstr(fread(file,80,'uchar')'));

if strmatch(n_hdr_areas,'UNKNOWN')
   %Keep reading cards until one turns up with the keyword 'END'.
   n_card=5;
   keyword='NIL';
   while(~strcmp(deblank(upper(keyword)),'END'))
      n_card=n_card+1;
      card=setstr(fread(file,80,'uchar')');
      [keyword]=parse_card(card);
   end;
   %Go past the blank lines of padding before the start of the data
   if (rem(n_card,36) ~= 0)
      n_blanks = 36 - rem(n_card,36);
      dummy=fread(file,n_blanks*80,'uchar');
   end;
else
   dummy=fread(file,((n_hdr_areas*36)-5)*80,'uchar');
end;

%Read the data.
if bitpix==-64
   X=fread(file,naxis1*naxis2,'float32',bswap);
elseif bitpix==-32
   X=fread(file,naxis1*naxis2,'float',bswap);
elseif bitpix==8
   X=fread(file,naxis1*naxis2,'uint8',bswap);
elseif bitpix==16
   X=fread(file,naxis1*naxis2,'short',bswap);
elseif bitpix==32
   X=fread(file,naxis1*naxis2,'long',bswap);
else
   error('data type specified by BITPIX keyword is not -64, -32, 8, 16,
or 32');
end;

%Clean up and output data
fclose(file);

output_image=reshape(X,naxis1,naxis2);



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [keyword,value,comment] = parse_card(s)
%Parses a FITS header card.
%Reference:
%                NASA/Science Office of Standards and Technology
%           "Definition of the Flexible Image Transport System (FITS)"
%                        NOST 100-1.0    June 19, 1993

%Set defaults
keyword=[];value=[];comment=[];

%Get keyword in bytes 1 - 8
keyword=s(1:8);
if nargout==1
   return;
end

%If keyword is blank then the line is a comment
if strmatch(keyword,'       ')
    keyword=[];
 value=[];
 comment=deblank(s(11:80));
 return;
end;


%Keyword is non-blank. Check if there is a corresponding value/comment.
%If not then the only possibilities are that bytes 11:80 are a comment
%or that they are blank
if ~strmatch(s(9:10),'= ')
    keyword=deblank(keyword);
 value=[];
 comment=deblank(s(11:80));
 return;
end;

%Card is a standard keyword/value/comment structure. Break the
value/comment
%string (bytes 11 - 80) into separate strings by tokenizing on "/"
character.
%Remove the leading and trailing blanks on the value and the trailing
blanks
%on the comment.

keyword=deblank(keyword);
[value,comment]=strtok(s(11:80),'/');
comment=deblank(comment);
value=fliplr(deblank(fliplr(deblank(value))));

%Now figure out whether to output the value as a string or as a number.
%The FITS standard requires all values that are strings to be in single
%quotes like this: 'foo bar', so I can simply look for occurences of a
%single quote to flag a string. However, logical variables can take the
%values T or F without having any single quotes, so I'll have to look
%out for those also.

%Test for logical. Return logical as a string.
if strmatch(upper(value),'T') | strmatch(upper(value),'F')
 return;
end;

%Test for string. Return string unconverted.
if length(findstr('''',value)) ~= 0
 return;
end;

%Only thing left is a number. Convert string to number.
value=str2num(value);


From owner-fitsbits at kochab.cv.nrao.edu  Tue Jan 26 09:59:40 1999
Received: (from majordom at localhost)
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) id JAA15224
	for fitsbits-spinner; Tue, 26 Jan 1999 09:57:30 -0500 (EST)
Received: from fits.cv.nrao.edu (dwells at fits.cv.nrao.edu [192.33.115.8])
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) with ESMTP id JAA15219
	for <fitsbits at kochab.cv.nrao.edu>; Tue, 26 Jan 1999 09:57:27 -0500 (EST)
Received: (from dwells at localhost)
	by fits.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) id JAA08527
	for fitsbits at majordomo.cv.nrao.edu; Tue, 26 Jan 1999 09:57:26 -0500
Received: from fits.cv.nrao.edu (root at fits.cv.nrao.edu [192.33.115.8])
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) with ESMTP id TAA04429
	for <fitsbits at kochab.cv.nrao.edu>; Mon, 25 Jan 1999 19:49:16 -0500 (EST)
Received: from newsfeed.cv.nrao.edu (newsfeed.cv.nrao.edu [192.33.115.17])
	by fits.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) with ESMTP id TAA07267
	for <fitsbits at fits.cv.nrao.edu>; Mon, 25 Jan 1999 19:49:16 -0500
Received: (from news at localhost)
	by newsfeed.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) id TAA25822;
	Mon, 25 Jan 1999 19:49:05 -0500
To: fitsbits at fits.cv.nrao.edu
Date: 25 Jan 1999 16:39:46 -0800
From: sla at ucolick.borg (Steve Allen)
Message-ID: <78j2si$26m$1 at dei.ucolick.org>
Organization: UCO/Lick Observatory
Path: newsfeed.cv.nrao.edu!hearst.acc.Virginia.EDU!uunet!in5.uu.net!newsfeed.xcom.net!newsfeed.berkeley.edu!news.ucsc.edu!not-for-mail
Subject: Y2K checkup
Newsgroups: sci.astro.fits
Sender: owner-fitsbits at kochab.cv.nrao.edu
Precedence: bulk

We recently checked to see whether the Y2K fixes that were supposed to
become active at the beginning of the year actually worked as expected.

For the old-style data acquisition systems at Lick on Mt. Hamilton we
believe that all but one of the instruments changed to the new FITS
date format.  The holdout simply was never rebuilt using the new
library code.

For the new-style data acquisition systems in the UCO/Lick labs we
found that we are still recording old FITS format dates due to software
which we do not control directly.

How did the changeover go elsewhere?

-- 
Steve Allen          UCO/Lick Observatory       Santa Cruz, CA 95064
sla at ucolick.borg     Voice: +1 831 459 3046     FAX (don't): +1 831 459 5244
WWW: http://www.ucolick.borg/~sla               PGP public keys:  see WWW
Junk mail is irrelevant -- my return address has been assimilated.

From owner-fitsbits at kochab.cv.nrao.edu  Thu Jan 28 13:37:59 1999
Received: (from majordom at localhost)
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) id NAA27853
	for fitsbits-spinner; Thu, 28 Jan 1999 13:36:59 -0500 (EST)
Received: from fits.cv.nrao.edu (dwells at fits.cv.nrao.edu [192.33.115.8])
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) with ESMTP id NAA27848
	for <fitsbits at kochab.cv.nrao.edu>; Thu, 28 Jan 1999 13:36:56 -0500 (EST)
Received: (from dwells at localhost)
	by fits.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) id NAA15274
	for fitsbits at majordomo.cv.nrao.edu; Thu, 28 Jan 1999 13:36:56 -0500
Received: from fits.cv.nrao.edu (root at fits.cv.nrao.edu [192.33.115.8])
	by kochab.cv.nrao.edu (8.8.8/8.8.8/CV-2.2) with ESMTP id MAA27703
	for <fitsbits at kochab.cv.nrao.edu>; Thu, 28 Jan 1999 12:22:45 -0500 (EST)
Received: from newsfeed.cv.nrao.edu (newsfeed.cv.nrao.edu [192.33.115.17])
	by fits.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) with ESMTP id MAA15175
	for <fitsbits at fits.cv.nrao.edu>; Thu, 28 Jan 1999 12:22:44 -0500
Received: (from news at localhost)
	by newsfeed.cv.nrao.edu (8.8.7/8.8.8/CV-2.2) id MAA21526;
	Thu, 28 Jan 1999 12:22:30 -0500
To: fitsbits at fits.cv.nrao.edu
Date: Thu, 28 Jan 1999 16:19:26 +0100
From: Muriel Roche <mroche at unice.fr>
Message-ID: <36B07FFE.4DB0CC64 at unice.fr>
Organization: University of Nice Sophia-Antipolis
Path: newsfeed.cv.nrao.edu!newsgate.duke.edu!newsfeed.berkeley.edu!newsfeed.gamma.ru!Gamma.RU!news-feed.inet.tele.dk!bofh.vszbr.cz!news.belnet.be!news-zh.switch.ch!news-ge.switch.ch!in2p3.fr!univ-lyon1.fr!unice.fr!not-for-mail
Subject: Fits
Newsgroups: sci.astro.fits
Sender: owner-fitsbits at kochab.cv.nrao.edu
Precedence: bulk


Good afternoon,

I'm working actually on images of the HST. And I've problems with the
formats of the files (.fits). I want to read these files with
Mathematica and Mathlab, but I can't.
Does somebody know how to read this data?
Thank you .

~~Muriel~

my mail :
mroche at unice.fr

