private GroupProcess process; // for accessing useful config data #endregion Fields #region Constructors //string filename, bool _hasVelDisp, short snapnum, float redshift) /// <summary> /// /// </summary> /// <param name="_process"></param> /// <param name="filename"></param> /// <param name="_snapnum"></param> /// <param name="_ifile"></param> public GroupFile(GroupProcess _process, string filename, short _snapnum, GroupFile previous) { this.process = _process; this.snapnum = _snapnum; this.ifile = (previous == null?0:previous.ifile+1); float redshift = process.globals.redshifts[snapnum]; bool hasVelDisp = process.hasVelDisp; // no need for records/bytesRead, not in fortran format using (BinaryReader reader = new BinaryReader(new FileStream(filename, FileMode.Open))) { numGroups = reader.ReadInt32(); totalGroups = reader.ReadInt32(); numIDs = reader.ReadInt32(); totalIDs = reader.ReadInt64(); numFiles = reader.ReadInt32(); numSubgroups = reader.ReadInt32(); totalSubgroups = reader.ReadInt32(); previousLastGroupIndex = (previous == null ? -1 : previous.lastGroupIndex); previousLastSubhaloIndex = (previous == null ? -1 : previous.lastSubhaloIndex); groups = new GroupInfo[numGroups]; for (int i = 0; i < numGroups; i++) { groups[i] = new GroupInfo(); groups[i].snapnum = snapnum; groups[i].redshift = redshift; } subhalos = new SubhaloInfo[numSubgroups]; for (int i = 0; i < numSubgroups; i++) { subhalos[i] = new SubhaloInfo(); subhalos[i].snapnum = snapnum; subhalos[i].redshift = redshift; } for (int i = 0; i < numGroups; i++) groups[i].Length = reader.ReadInt32(); for (int i = 0; i < numGroups; i++) groups[i].offset = reader.ReadInt32(); for (int i = 0; i < numGroups; i++) groups[i].Mass = reader.ReadSingle(); for (int i = 0; i < numGroups; i++) { groups[i].x = reader.ReadSingle(); groups[i].y = reader.ReadSingle(); groups[i].z = reader.ReadSingle(); groups[i].ix = process.GetZone(groups[i].x); groups[i].iy = process.GetZone(groups[i].y); groups[i].iz = process.GetZone(groups[i].z); groups[i].phkey = process.GetPHKey(groups[i].x, groups[i].y, groups[i].z); } for (int i = 0; i < numGroups; i++) groups[i].M_Mean200 = reader.ReadSingle(); for (int i = 0; i < numGroups; i++) groups[i].R_Mean200 = reader.ReadSingle(); for (int i = 0; i < numGroups; i++) groups[i].M_Crit200 = reader.ReadSingle(); for (int i = 0; i < numGroups; i++) groups[i].R_Crit200 = reader.ReadSingle(); for (int i = 0; i < numGroups; i++) groups[i].M_TopHat200 = reader.ReadSingle(); for (int i = 0; i < numGroups; i++) groups[i].R_TopHat200 = reader.ReadSingle(); if (hasVelDisp) { for (int i = 0; i < numGroups; i++) groups[i].VelDisp_Mean200 = reader.ReadSingle(); for (int i = 0; i < numGroups; i++) groups[i].VelDisp_Crit200 = reader.ReadSingle(); for (int i = 0; i < numGroups; i++) groups[i].VelDisp_TopHat200 = reader.ReadSingle(); } for (int i = 0; i < numGroups; i++) reader.ReadInt32(); // groups[i].contamCount = reader.ReadInt32(); for (int i = 0; i < numGroups; i++) reader.ReadSingle(); // groups[i].contamMass = reader.ReadSingle(); for (int i = 0; i < numGroups; i++) groups[i].numSubs = reader.ReadInt32(); for (int i = 0; i < numGroups; i++) groups[i].firstSubIndex = reader.ReadInt32(); // ------------------------------------- // now we're at the subhalo table start // ------------------------------------- for (int i = 0; i < numSubgroups; i++) subhalos[i].length = reader.ReadInt32(); for (int i = 0; i < numSubgroups; i++) subhalos[i].offset = reader.ReadInt32(); // skip offsets and parents reader.ReadBytes(4 * numSubgroups); for (int i = 0; i < numSubgroups; i++) subhalos[i].mass = reader.ReadSingle(); for (int i = 0; i < numSubgroups; i++) { subhalos[i].x = reader.ReadSingle(); subhalos[i].y = reader.ReadSingle(); subhalos[i].z = reader.ReadSingle(); subhalos[i].ix = process.GetZone(subhalos[i].x); subhalos[i].iy = process.GetZone(subhalos[i].y); subhalos[i].iz = process.GetZone(subhalos[i].z); subhalos[i].phkey = process.GetPHKey(subhalos[i].x, subhalos[i].y, subhalos[i].z); } for (int i = 0; i < numSubgroups; i++) { subhalos[i].vx = reader.ReadSingle(); subhalos[i].vy = reader.ReadSingle(); subhalos[i].vz = reader.ReadSingle(); } for (int i = 0; i < numSubgroups; i++) { subhalos[i].cmx = reader.ReadSingle(); subhalos[i].cmy = reader.ReadSingle(); subhalos[i].cmz = reader.ReadSingle(); } for (int i = 0; i < numSubgroups; i++) { subhalos[i].sx = reader.ReadSingle(); subhalos[i].sy = reader.ReadSingle(); subhalos[i].sz = reader.ReadSingle(); } for (int i = 0; i < numSubgroups; i++) subhalos[i].veldisp = reader.ReadSingle(); for (int i = 0; i < numSubgroups; i++) subhalos[i].velMax = reader.ReadSingle(); for (int i = 0; i < numSubgroups; i++) subhalos[i].velMaxRad = reader.ReadSingle(); for (int i = 0; i < numSubgroups; i++) subhalos[i].hmradius = reader.ReadSingle(); for (int i = 0; i < numSubgroups; i++) subhalos[i].mostBoundId = reader.ReadInt64(); // skip GrNr reader.ReadBytes(4 * numSubgroups); } }
private GroupProcess RefreshGroupsProcess() { GroupProcess process; if ("milliMXXL".Equals(lbSimulation.SelectedItem.ToString()) || "centiMXXL".Equals(lbSimulation.SelectedItem.ToString()) || "Millennium-XXL".Equals(lbSimulation.SelectedItem.ToString()))// chkIsMXXL.Checked) process = new XXLGroupProcess(globalParameters); else if("Millennium-II".Equals(lbSimulation.SelectedItem.ToString())) process = new GroupProcess(globalParameters); else { DebugOut.PrintLine("Currently no support for millimil or Millennium FOF groups and subhalos."); return null; } process.inPath = txtFOFSubhaloSourceDir.Text; process.outPath = txtFOFSubhaloTargetDir.Text; process.writeFOFs = chkWriteFOF.Checked; process.writeSubHalos = chkWriteSubHalos.Checked; process.writeSubhaloIDs = chkIDs.Checked; process.hasVelDisp = chkDisp.Checked; process.fofTable = txtFOFTable.Text; process.subhaloTable = txtSubhaloTable.Text; process.firstSnap = Int16.Parse(txtFirstGroupsSnapshot.Text); process.lastSnap = Int16.Parse(txtLastGroupsSnapshot.Text); string sim = lbSimulation.SelectedItem.ToString(); return process; }