/// <summary>Create FITS data object corresponding to a given header.</summary> public static Data ManufactureData(Header hdr) { int gcount = hdr.GetIntValue("GCOUNT", -1); int pcount = hdr.GetIntValue("PCOUNT", -1); if (!hdr.GetBooleanValue("GROUPS") || hdr.GetIntValue("NAXIS1", -1) != 0 || gcount < 0 || pcount < 0 || hdr.GetIntValue("NAXIS") < 2) { throw new FitsException("Invalid Random Groups Parameters"); } // Allocate the object. Object[][] dataArray; if (gcount > 0) { dataArray = new Object[gcount][]; for (int i = 0; i < gcount; i++) { dataArray[i] = new Object[2]; } } else { dataArray = new Object[0][]; } Object[] sampleRow = GenerateSampleRow(hdr); for (int i = 0; i < gcount; i += 1) { ((Object[][])dataArray)[i][0] = ((Object[])ArrayFuncs.DeepClone(sampleRow))[0]; ((Object[][])dataArray)[i][1] = ((Object[])ArrayFuncs.DeepClone(sampleRow))[1]; } return(new RandomGroupsData(dataArray)); }