Skip to content

Commit 585aea5

Browse files
authored
Keep variable (#4)
* Revert "1. particles assigned to multiple haloes are now assigned to the halo by" This reverts commit 2a1a5e9. * Pass field to use for keeping halos
1 parent 2a1a5e9 commit 585aea5

5 files changed

Lines changed: 39 additions & 26 deletions

reduce_snapshots.cpp

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

scripts/reduce_snapshots_L1000N1800.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ out="${outdir}/flamingo_${snapnum}/flamingo_${snapnum}"
4444
# radius variable inside which particles are kept
4545
RlimVar=SO/100_crit/SORadius
4646

47+
# property variable to detemine which halos to keep
48+
KeepVar=SOAP/IncludedInReducedSnapshot
49+
4750
# number of SWIFT cells that is processed in one go
4851
# a larger number is better for performance, while a smaller number is better
4952
# for memory usage
@@ -62,6 +65,6 @@ export I_MPI_THREAD_YIELD=2
6265

6366
# note that the number of ranks cannot exceed the number of snapshot files,
6467
mpirun -- ${code} ${cat} ${snap} ${mem} ${out} \
65-
${RlimVar} ${Ncell} ${block_size}
68+
${RlimVar} ${KeepVar} ${Ncell} ${block_size}
6669

6770
echo "Job complete!"

scripts/reduce_snapshots_L1000N3600.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ out="${outdir}/flamingo_${snapnum}/flamingo_${snapnum}"
4444
# radius variable inside which particles are kept
4545
RlimVar=SO/100_crit/SORadius
4646

47+
# property variable to detemine which halos to keep
48+
KeepVar=SOAP/IncludedInReducedSnapshot
49+
4750
# number of SWIFT cells that is processed in one go
4851
# a larger number is better for performance, while a smaller number is better
4952
# for memory usage
@@ -62,7 +65,7 @@ export I_MPI_THREAD_YIELD=2
6265

6366
# note that the number of ranks cannot exceed the number of snapshot files,
6467
mpirun -- ${code} ${cat} ${snap} ${mem} ${out} \
65-
${RlimVar} ${Ncell} ${block_size}
68+
${RlimVar} ${KeepVar} ${Ncell} ${block_size}
6669

6770
echo "Job complete!"
6871

scripts/reduce_snapshots_L2800N5040.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ out="${outdir}/flamingo_${snapnum}/flamingo_${snapnum}"
4444
# radius variable inside which particles are kept
4545
RlimVar=SO/100_crit/SORadius
4646

47+
# property variable to detemine which halos to keep
48+
KeepVar=SOAP/IncludedInReducedSnapshot
49+
4750
# number of SWIFT cells that is processed in one go
4851
# a larger number is better for performance, while a smaller number is better
4952
# for memory usage
@@ -62,6 +65,6 @@ export I_MPI_THREAD_YIELD=2
6265

6366
# note that the number of ranks cannot exceed the number of snapshot files,
6467
mpirun -- ${code} ${cat} ${snap} ${mem} ${out} \
65-
${RlimVar} ${Ncell} ${block_size}
68+
${RlimVar} ${KeepVar} ${Ncell} ${block_size}
6669

6770
echo "Job complete!"

scripts/reduce_snapshots_L5600N5040.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ out="${outdir}/flamingo_${snapnum}/flamingo_${snapnum}"
4747
# and many objects don't since this run is such low resolution
4848
RlimVar=SO/200_crit/SORadius
4949

50+
# property variable to detemine which halos to keep
51+
KeepVar=SOAP/IncludedInReducedSnapshot
52+
5053
# number of SWIFT cells that is processed in one go
5154
# a larger number is better for performance, while a smaller number is better
5255
# for memory usage
@@ -65,6 +68,6 @@ export I_MPI_THREAD_YIELD=2
6568

6669
# note that the number of ranks cannot exceed the number of snapshot files,
6770
mpirun -- ${code} ${cat} ${snap} ${mem} ${out} \
68-
${RlimVar} ${Ncell} ${block_size}
71+
${RlimVar} ${KeepVar} ${Ncell} ${block_size}
6972

7073
echo "Job complete!"

0 commit comments

Comments
 (0)