Exemple #1
0
        // suggested in .99.1 version:
        /// <summary>Delete a set of columns from a table.</summary>
        /// <param name="column">The zero-indexed start column.</param>
        /// <param name="len">The number of columns to delete.</param>
        /// <param name="fields">Stems for the header fields to be removed for the table.</param>
        public void DeleteColumnsIndexZero(int column, int len, String[] fields)
        {
            if (column < 0 || len < 0 || column + len > NCols)
            {
                throw new FitsException("Illegal columns deletion request- Start:" + column + " Len:" + len + " from table with " + NCols + " columns");
            }

            if (len == 0)
            {
                return;
            }

            int ncol = NCols;

            table.DeleteColumns(column, len);


            // Get rid of the keywords for the deleted columns
            for (int col = column; col < column + len; col += 1)
            {
                for (int fld = 0; fld < fields.Length; fld += 1)
                {
                    String key = fields[fld] + (col + 1);
                    myHeader.DeleteKey(key);
                }
            }

            // Shift the keywords for the columns after the deleted columns
            for (int col = column + len; col < ncol; col += 1)
            {
                for (int fld = 0; fld < fields.Length; fld += 1)
                {
                    String oldKey = fields[fld] + (col + 1);
                    String newKey = fields[fld] + (col + 1 - len);
                    if (myHeader.ContainsKey(oldKey))
                    {
                        myHeader.ReplaceKey(oldKey, newKey);
                    }
                }
            }
            // Update the number of fields.
            myHeader.AddValue("TFIELDS", NCols, "Number of table fields");

            // Give the data sections a chance to update the header too.
            table.UpdateAfterDelete(ncol, myHeader);
        }