@@ -600,8 +600,6 @@ class SOTable {
600600 std::vector<double > _ZSO;
601601 /* ! @brief SO radii. */
602602 std::vector<double > _RSO;
603- /* ! @brief SO masses */
604- std::vector<double > _MSO;
605603 /* ! @brief IDs of the halos. */
606604 std::vector<uint64_t > _haloIDs;
607605
@@ -634,9 +632,12 @@ class SOTable {
634632 * variable Overdensity_output_maximum_radius_in_critical_density. But again,
635633 * any possible valid array would work (including those that do not represent
636634 * any radius at all, so be careful - again!).
635+ * @param keep_selection_name Name of the array in the .properties file that
636+ * will be used to determine which halos to keep
637637 * @param memory MemoryLogBlock used to log memory usage.
638638 */
639639 SOTable (const std::string prefix, const std::string radius_selection_name,
640+ const std::string keep_selection_name,
640641 MemoryLog::MemoryLogBlock &memory)
641642 : _prefix(prefix) {
642643
@@ -734,11 +735,16 @@ class SOTable {
734735 }
735736 CofP.clear ();
736737
737-
738- // HDF5FileOrGroup SOAPgroup = OpenGroup(file, "SOAP");
739- // ReadEntireDataset(SOAPgroup, "IncludedInReducedSnapshot", keep);
740- HDF5FileOrGroup SOAPgroup = OpenGroup (file, " InputHalos" );
741- ReadEntireDataset (SOAPgroup, " IsCentral" , keep);
738+ if (keep_selection_name == " SOAP/IncludedInReducedSnapshot" ) {
739+ HDF5FileOrGroup SOAPgroup = OpenGroup (file, " SOAP" );
740+ ReadEntireDataset (SOAPgroup, " IncludedInReducedSnapshot" , keep);
741+ } else if (keep_selection_name == " InputHalos/IsCentral" ) {
742+ HDF5FileOrGroup SOAPgroup = OpenGroup (file, " InputHalos" );
743+ ReadEntireDataset (SOAPgroup, " IsCentral" , keep);
744+ } else {
745+ my_error (" Invalid keep_selection_name" );
746+ }
747+
742748 {
743749 const auto radius_path = decompose_dataset_path (radius_selection_name);
744750 const auto group_names = radius_path.first ;
@@ -983,7 +989,8 @@ int main(int argc, char **argv) {
983989 std::cerr << " Usage: ./reduce_snapshots SOAP_OUTPUT_PREFIX "
984990 " SNAPSHOT_FILE_PREFIX MEMBERSHIP__FILE_PREFIX "
985991 " OUTPUT_FILE_PREFIX "
986- " RADIUS_SELECTION_NAME [CELLBUFSIZE] "
992+ " RADIUS_SELECTION_NAME "
993+ " KEEP_SELECTION_NAME [CELLBUFSIZE] "
987994 " [HDF5BUFSIZE]"
988995 << std::endl;
989996 }
@@ -994,8 +1001,9 @@ int main(int argc, char **argv) {
9941001 const std::string membership_file_prefix (argv[3 ]);
9951002 const std::string output_file_prefix (argv[4 ]);
9961003 std::string radius_selection_name (argv[5 ]);
997- const uint32_t cellbufsize = (argc > 6 ) ? atoi (argv[6 ]) : 8 ;
998- const size_t hdf5bufsize = (argc > 7 ) ? atoll (argv[7 ]) : -1 ;
1004+ std::string keep_selection_name (argv[6 ]);
1005+ const uint32_t cellbufsize = (argc > 7 ) ? atoi (argv[7 ]) : 8 ;
1006+ const size_t hdf5bufsize = (argc > 8 ) ? atoll (argv[8 ]) : -1 ;
9991007
10001008 const std::string catalog_file = find_file (SOAP_output_prefix, " " );
10011009 // const std::string siminfo_file = find_file(SOAP_output_prefix, ".siminfo");
@@ -1024,6 +1032,8 @@ int main(int argc, char **argv) {
10241032 output_file_prefix.c_str ());
10251033 timelog (LOGLEVEL_GENERAL, " Radius selection name: %s" ,
10261034 radius_selection_name.c_str ());
1035+ timelog (LOGLEVEL_GENERAL, " Keep selection name: %s" ,
1036+ keep_selection_name.c_str ());
10271037 timelog (LOGLEVEL_GENERAL, " Cellbufsize: %u" , cellbufsize);
10281038 timelog (LOGLEVEL_GENERAL, " HDF5bufsize: %s" ,
10291039 human_readable_bytes (hdf5bufsize).c_str ());
@@ -1055,7 +1065,7 @@ int main(int argc, char **argv) {
10551065 }
10561066
10571067 // read the SOTable: this is the entire first step mentioned above
1058- const SOTable SOtable (SOAP_output_prefix, radius_selection_name, memory);
1068+ const SOTable SOtable (SOAP_output_prefix, radius_selection_name, keep_selection_name, memory);
10591069
10601070 MPI_Barrier (MPI_COMM_WORLD);
10611071
@@ -1605,17 +1615,9 @@ int main(int argc, char **argv) {
16051615 haloIDs[itype][offset + ipart] = SOID;
16061616 ++this_keepcount;
16071617 } else {
1608- // duplicate! particle has been assigned to multiple halo ids
1609- // We must decide which halo to assign this particle too.
1610- //
1611- // Assign particle to closest halo as function of r/R200c
1612- //
1618+ // duplicate! We just keep the first halo id that was
1619+ // assigned to the particle.
16131620 ++this_dupcount;
1614- const int64_t oldhalo = haloIDs[itype][offset + ipart];
1615- const int64_t newhalo = SOID;
1616- if (d/SOtable.RSO (newhalo) < d/SOtable.RSO (oldhalo)) {
1617- haloIDs[itype][offset + ipart] = newhalo;
1618- }
16191621 }
16201622 }
16211623 }
@@ -1701,7 +1703,6 @@ int main(int argc, char **argv) {
17011703 ++new_sizes[orphan.type ][orphan.cell ];
17021704 ++this_keepcount;
17031705 }
1704- }
17051706 }
17061707 }
17071708 }
0 commit comments