2
$\begingroup$

Looks to me that the FITS Export is borged. Here is the problem:

When I export out images with accustom metadata into a FITS file, Mathematica truncates and overwrites it.

Here is the metadata I got with Import:

In[530]:= (* Read fits file metadata. *)
fpa425meta=Import["img_a_425.fits.seg.fit","Metadata"]
Out[530]= {SIMPLE->True,BITPIX->16,NAXIS->3,NAXIS1->256,NAXIS2->256,NAXIS3->1000,BZERO->32768.,BSCALE->1.,INSTRUME->KAF 4200,PMISGAIN->1,FILE->img_001,OBJECT->KOI,IMAGETYP->emccd speckle,FILTER->754.0 nm,OBSERVER->E. Horch, S. Howell, M. Everett, D. Ciardi,TELESCOP->Gemini-N,DETECTOR->Andor iXon EMCCD,EXPTIME->50,DATE-OBS->21/12/104,TIME-OBS->03:17:01,ORIGIN->PMIS Image Processing Software,ORIGIN->Copyright (C) 1991-1998 GKR Computer Consulting}

I make this modification to it:

In[554]:= fpa425metaPos=Position[fpa425meta,"NAXIS3"]
Out[554]= {{6,1}}

In[555]:= fpa425metaPos[[1,2]]++
Out[555]= 1

In[558]:= fpa425meta=ReplacePart[fpa425meta,fpa425metaPos->Length[ext1fpa425]]
Out[558]= {SIMPLE->True,BITPIX->16,NAXIS->3,NAXIS1->256,NAXIS2->256,NAXIS3->3,BZERO->32768.,BSCALE->1.,INSTRUME->KAF 4200,PMISGAIN->1,FILE->img_001,OBJECT->KOI,IMAGETYP->emccd speckle,FILTER->754.0 nm,OBSERVER->E. Horch, S. Howell, M. Everett, D. Ciardi,TELESCOP->Gemini-N,DETECTOR->Andor iXon EMCCD,EXPTIME->50,DATE-OBS->21/12/104,TIME-OBS->03:17:01,ORIGIN->PMIS Image Processing Software,ORIGIN->Copyright (C) 1991-1998 GKR Computer Consulting}

Then I write my expression out into the fits file with the modified Metadata:

Export["/Users/jancsi/Documents/MasterDegree/Theses/programs/scsu/Results/425/Exported/LessMin1sigMet.fits",{ext1fpa425},"Metadata"->fpa425meta];

When I read back the Metadata, I am getting something totally different:

In[560]:= fpa425metaMod=Import["/Users/jancsi/Documents/MasterDegree/Theses/programs/scsu/Results/425/Exported/LessMin1sigMet.fits","Metadata"]
Out[560]= {SIMPLE->{True,Normal FITS file},BITPIX->{-32,Bits/pixel, negative is floating point},NAXIS->{3,Dimensionality of data},NAXIS1->256,NAXIS2->256,NAXIS3->3,EXTENDED->{True,Extensions may be present},PCOUNT->{0,Deprecated},GCOUNT->{1,Deprecated},BSCALE->{1,Scale factor},BZERO->{0,Zero factor real=tape*bscale+bzero},CREATOR->Created with the Wolfram Language : www.wolfram.com}
<nyassz>

Sent this to Wolfram Support who answered:

Unfortunately in the current version of Mathematica the metadata would be overwritten when exporting in the FITS format, and this default behaviour cannot be changed. I am forwarding your message to the existing incidence report and you will be informed for any updates on this topic.

Now, I do not know how long it will take Wolfram to comply with FITS 3.0 specification already published 4 years ago. So I am open to any suggestion which way can I get around this problem. I need to write out the "right" FITS header, because other programs rely on it and right now they bombing out on Floating Point exeption /divison by 0/

Right now I am thinking just to use BinaryRead and avoid Import and also use BinaryWrite to write the results back after some manipulations, but I am open to any other good suggestions.

$\endgroup$
  • 1
    $\begingroup$ Welcome to Mathematica.SE, you could consider taking the tour. it would facilitate other people trying to answer your question if you edit your question to make it more readable. $\endgroup$ – rhermans Sep 25 '14 at 16:43
  • $\begingroup$ This is not going to be easier than the Binary thing you suggest, but at least you can pack it as an Exporter $\endgroup$ – Dr. belisarius Sep 25 '14 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.