LoginSignup
0
1

More than 5 years have passed since last update.

C# FITS形式

Posted at

FITSファイル生成例

あまり使うことはないだろうが。

     //FITS形式ファイル生成
        private void FitsWrite(string filename, byte[] buf)
        {




            List<string> head = new List<string>
                    {
                        "SIMPLE  =                    T                                                  ",//T=true F=false
                        "BITPIX  =                   16                                                  ",//-32=48
                        "NAXIS   =                    2                                                  ",//dim
                        "NAXIS1  =                  800                                                  ",//width
                        "NAXIS2  =                  600                                                  ",//height
                        "END                                                                             ",//
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                ",
                        //10 (800byte)
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                ",
                        //20 (1600byte)
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                ",
                        //30 (2400byte)
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                ",
                        "                                                                                "
                        //36 (2880byte)
                    };


            FileStream fileStream = new FileStream(filename, FileMode.Create);
            BinaryWriter binaryWriter = new BinaryWriter(fileStream);
            int count = 0;
            foreach (var item in head)
            {
                count += item.Length;
                binaryWriter.Write(Encoding.ASCII.GetBytes(item));
            }




            binaryWriter.Write(buf);
            for (int i = 0; i < 2880 - buf.Length % 2880; i++)
            {
                binaryWriter.Write(' ');
            }
            binaryWriter.Close();
            fileStream.Close();


        }

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1