C#
fits

C# FITS形式


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();

}