Exemplo n.º 1
0
 internal WCSInfo(HDU hdu)
 {
     _hdu = hdu;
     // create primary transformation
     _primaryTransformation = new Transformation(this, true);
     // allocate 26 possible transformations. Those missing from the header will be null.
     _transformations = new Transformation[26];
     // map to convert an index to its alternative letter
     _index2LetterMap = new char[26];
     _numAlternatives = 0;
 }
Exemplo n.º 2
0
 internal HDUTable(HDU hdu, TableType type, long numRows, int numFields, long bytesPerRow)
 {
     _hdu         = hdu;
     _type        = type;
     _numRows     = numRows;
     _bytesPerRow = bytesPerRow;
     _data        = null;
     // IMPORTANT: TableHeader must be constructed after setting the type of the table
     //            this is because it will call HDUTable and get the type to decide
     //            what kind of IFieldInfo & ITableCell implementation to use
     _header = new TableHeader(this, numFields);
 }
Exemplo n.º 3
0
        private void Load(FileStream fs)
        {
            // is it empty?
            ///////////////////////////////////////////////////////////////////
            Utils.CheckBool(fs.Length != 0, "File is empty");

            // loop to read all HDUs
            ///////////////////////////////////////////////////////////////////
            _curHDUPosiotion = 0;
            while (fs.Position < fs.Length)
            {
                // load this hdu
                HDU hdu = new HDU(this, _curHDUPosiotion++);
                hdu.Load(fs);
                // if we didn't read any card images in this HDU - which means the first card image in the header
                // is empty, leave at this point
                if (hdu.CardImages.Length == 0)
                {
                    break;
                }
                // add it to our array. do this early so we can free later with array
                _hdus.Add(hdu);

                // keep a map of name index as well
                if (!string.IsNullOrEmpty(hdu.Name) && !_hduIndexMap.ContainsKey(hdu.Name))
                {
                    _hduIndexMap.Add(hdu.Name, _hdus.Count - 1);
                }

                // seek past the data of this hdu to prepare for loading next one
                if (hdu.RawDataSize != 0)
                {
                    long recordsLess = hdu.RawDataSize % (36 * 80);
                    if (recordsLess > 0)
                    {
                        long dataPadding = 36 * 80 - recordsLess;
                        fs.Seek(dataPadding, SeekOrigin.Current);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public DataManager(HDU hdu, byte[] data, int bitsPerPixel, double blank, int numSlices)
        {
            // init things
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////
            _hdu          = hdu;
            _rawData      = data;
            _bitsPerPixel = bitsPerPixel;
            _elementSize  = (bitsPerPixel > 0) ? (bitsPerPixel / 8) : (-bitsPerPixel / 8);  // in bytes
            _blank        = blank;

            // create slies
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////
            long numElements = (long)data.Length / numSlices / _elementSize;

            _slices = new List <ISlice>(numSlices);
            for (int i = 0; i < numSlices; i++)
            {
                long offset = i * numElements * _elementSize;
                _slices.Add(new Slice(data, offset, numElements, _elementSize, bitsPerPixel, blank));
            }
        }