# Errors of exporting FITS file

**URL:** <https://community.wolfram.com/t/errors-of-exporting-fits-file/579>\
**Category:** Questions\
**Tags:** astronomy, computer-science, data-science, image-processing\
**Created:** [September 19, 2013, 7:44pm UTC](https://community.wolfram.com/t/errors-of-exporting-fits-file/579 "2013-09-19T19:44:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![wangxin](https://avatars.discourse-cdn.com/v4/letter/w/e495f1/32.png) [@wangxin](https://community.wolfram.com/u/wangxin)\
**Post date:** [September 19, 2013, 7:44pm UTC](https://community.wolfram.com/t/errors-of-exporting-fits-file/579/1 "2013-09-19T19:44:31Z")

</div>

Could anyone help? Always getting errors when export simple data to FITS format. I’m using Macbook Air, OS X 10.8.4. Not sure if it’s machine dependent.

e.g.,

```auto
d = First@
   Import["http://exampledata.wolfram.com/messier61.fits.gz", 
    "RawData"];

Export["image.fits", d]

ConstantArray::ilsmn: Single or list of non-negative machine-sized integers expected at position 2 of ConstantArray[32,{-17}]. >>
Join::heads: Heads List and ConstantArray at positions 1 and 3 are expected to be the same. >>
BinaryWrite::nocoerce: Join[{83,73,77,80,76,69,32,32,61,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,84,32,47,32,78,111,114,109,97,108,32,70,73,84,83,32,102,105,108,101,32,<<750>>},<<3>>,{32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,<<13>>,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,<<27>>}] cannot be coerced to the specified format. >>

```

---

<div class="post-metadata">

**Author:** ![franki](https://avatars.discourse-cdn.com/v4/letter/f/71c47a/32.png) [@franki](https://community.wolfram.com/u/franki)\
**Post date:** [September 19, 2013, 10:37pm UTC](https://community.wolfram.com/t/errors-of-exporting-fits-file/579/2 "2013-09-19T22:37:03Z")

</div>

Hi,

It worked for me using Mathematica9 under Windows 7. Here is the header dump of the exported file using DS9:

SIMPLE = T / Normal FITS file  
BITPIX = 16 / Bits/pixel, negative is floating point  
NAXIS = 2 / Dimensionality of data  
NAXIS1 = 561  
NAXIS2 = 561  
EXTENDED= T / Extensions may be present  
PCOUNT = 0 / Deprecated  
GCOUNT = 1 / Deprecated  
BSCALE = 1 / Scale factor  
BZERO = 0 / Zero factor real=tape\*bscale+bzero  
CREATOR = ‘Created by Wolfram Mathematica 9.0 : [www.wolfram.com](http://www.wolfram.com)’  
END

Let me know if you want it tried using Mathematica8 (under Windows).

---

<div class="post-metadata">

**Author:** ![jaguilar](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@jaguilar](https://community.wolfram.com/u/jaguilar)\
**Post date:** [October 24, 2013, 9:01pm UTC](https://community.wolfram.com/t/errors-of-exporting-fits-file/579/3 "2013-10-24T21:01:05Z")

</div>

I have the same problem exporting FITS files. I’m running Mathematica 9 on Ubuntu 12.04 LTS (KDE). The error message when I export a known good FITS file is:

```auto
ConstantArray::ilsmn: "Single or list of non-negative machine-sized integers expected at position 2 of ConstantArray[32,{-17}]"

```

---

<div class="post-metadata">

**Author:** ![siriustar06](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@siriustar06](https://community.wolfram.com/u/siriustar06)\
**Post date:** [July 23, 2015, 10:14pm UTC](https://community.wolfram.com/t/errors-of-exporting-fits-file/579/4 "2015-07-23T22:14:23Z")

</div>

Did you ever find the solution? I have the same error, even in the help documentation. I’m on Mathematica 10 - I’ve never encountered the error before.

---

<div class="post-metadata">

**Author:** ![franki](https://avatars.discourse-cdn.com/v4/letter/f/71c47a/32.png) [@franki](https://community.wolfram.com/u/franki)\
**Post date:** [July 24, 2015, 2:21pm UTC](https://community.wolfram.com/t/errors-of-exporting-fits-file/579/5 "2015-07-24T14:21:52Z")

</div>

Hello,

I just tried the OP’s test code again, this time on Mathematica 10.1 under Win7 64-bit. It worked again.

One suggestion is to modify the Export statement to be so:

```
Export["image1.fits", d, "Data"]

```

Here’s a reminder that I use: (\* !! FITS: Export[] “Data”, Import “RawData” !! \*)

---

<div class="post-metadata">

**Author:** ![siriustar06](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@siriustar06](https://community.wolfram.com/u/siriustar06)\
**Post date:** [July 24, 2015, 4:55pm UTC](https://community.wolfram.com/t/errors-of-exporting-fits-file/579/6 "2015-07-24T16:55:51Z")

</div>

Hmm… I still get the error on Mathematica 10.1 under OSX Yosemite, even using the Export[“image1.fits”, d, “Data”] line.  
I can’t seem to find any more documentation on this issue.

Thanks for the reply though.
