Ejemplo n.º 1
0
        private static bool LoadFitsFileInternal <TData>(
            string fileName, IFITSTimeStampReader timeStampReader,
            out TData[,] pixels, out TData medianValue, out Type pixelDataType, out float frameExposure, out bool hasNegativePixels, out short minRawValue, out uint maxVal,
            CheckOpenedFitsFileCallback callback, LoadFitsDataCallback <TData> loadDataCallback)
        {
            Fits fitsFile = new Fits();

            using (BufferedFile bf = new BufferedFile(fileName, FileAccess.Read, FileShare.ReadWrite))
            {
                fitsFile.Read(bf);

                BasicHDU imageHDU    = fitsFile.GetHDU(0);
                Array    pixelsArray = (Array)imageHDU.Data.DataArray;
                return(LoadFitsDataInternal <TData>(
                           imageHDU, pixelsArray, fileName, timeStampReader,
                           out pixels, out medianValue, out pixelDataType, out frameExposure, out hasNegativePixels, out minRawValue, out maxVal,
                           callback, loadDataCallback));
            }
        }
Ejemplo n.º 2
0
        public static bool LoadFitsDataInternal <TData>(
            BasicHDU imageHDU, Array pixelsArray, string fileName, IFITSTimeStampReader timeStampReader,
            out TData[,] pixels, out TData medianValue, out Type pixelDataType, out float frameExposure, out bool hasNegativePixels, out short minRawValue, out uint maxVal,
            CheckOpenedFitsFileCallback callback, LoadFitsDataCallback <TData> loadDataCallback)
        {
            hasNegativePixels = false;

            if (callback != null && !(callback(imageHDU)))
            {
                pixels        = new TData[0, 0];
                medianValue   = default(TData);
                pixelDataType = typeof(TData);
                frameExposure = 0;
                minRawValue   = 0;
                maxVal        = 0;
                return(false);
            }

            int bzero = GetBZero(imageHDU);

            bool   isMidPoint;
            double?fitsExposure = null;

            try
            {
                ParseExposure(fileName, imageHDU.Header, timeStampReader, out isMidPoint, out fitsExposure);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
            }
            frameExposure = fitsExposure.HasValue ? (float)fitsExposure.Value : 0;

            loadDataCallback(pixelsArray, imageHDU.Axes[0], imageHDU.Axes[1], bzero, out pixels, out medianValue, out pixelDataType, out hasNegativePixels, out minRawValue, out maxVal);

            return(true);
        }