Ejemplo n.º 1
0
        private bool OpenFile(string filePath)
        {
            var retval = false;

            var status = 0;

            if (string.IsNullOrEmpty(filePath))
            {
                throw new ArgumentException("The file path cannot be a null or empty string!");
            }

            if (FilePath != null)
            {
                throw new InvalidOperationException("OpenFile cannot be called a again once a file has been opened!");
            }


            CFits.OpenFile(out _fitsPointer, filePath, CFits.READONLY, ref status);
            Header = GetHeaderData();
            Status = status;

            if (status == 0)
            {
                FilePath = filePath;

                retval = true;
            }

            return(retval);
        }
Ejemplo n.º 2
0
        public void CloseFile()
        {
            if (_fitsPointer != IntPtr.Zero)
            {
                var status = 0;

                FilePath = null;
                CFits.CloseFile(_fitsPointer, ref status);
                _fitsPointer = IntPtr.Zero;
                Status       = status;
            }
        }
Ejemplo n.º 3
0
        private FitsHeader GetHeaderData()
        {
            if (Status != 0)
            {
                return(null);
            }

            var status = 0;

            var fitsHeader = new FitsHeader();

            var ndx = 1;

            while (true)
            {
                string keyName    = null;
                string keyValue   = null;
                string keyComment = null;

                CFits.ReadHeaderRecord(_fitsPointer, ndx++, ref keyName, ref keyValue, ref keyComment, ref status);

                if (status == (int)ErrorStatusCode.KEY_OUT_BOUNDS)
                {
                    break;
                }
                else if (status != 0)
                {
                    Status = status;
                    var errText = CFits.GetErrorStatus(status);

                    throw new Exception("FITS ReadHeaderRecord error - " + errText);
                }

                var keyUnits = "";

                ExtractUnits(ref keyUnits, ref keyComment);
                var item = new FitsHeaderItem(keyName, keyValue, keyUnits, keyComment);

                fitsHeader.Add(item);
            }

            Header = fitsHeader;

            return(fitsHeader);
        }
Ejemplo n.º 4
0
 public static string GetErrorText(int status)
 {
     return(CFits.GetErrorStatus(status));
 }