subhaloscript 1.0.7__tar.gz → 1.0.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/PKG-INFO +1 -1
  2. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/meta.yaml +1 -1
  3. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/pyproject.toml +1 -1
  4. subhaloscript-1.0.8/subscript/defaults.py +61 -0
  5. subhaloscript-1.0.8/subscript/tracking.py +81 -0
  6. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/subscript/wrappers.py +1 -1
  7. subhaloscript-1.0.7/subscript/defaults.py +0 -32
  8. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/.github/workflows/main.yml +0 -0
  9. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/.gitignore +0 -0
  10. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/LICENSE +0 -0
  11. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/README.md +0 -0
  12. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/example-notebooks/basic-usage.ipynb +0 -0
  13. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/subscript/external.py +0 -0
  14. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/subscript/macros.py +0 -0
  15. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/subscript/scripts/histograms.py +0 -0
  16. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/subscript/scripts/nfilters.py +0 -0
  17. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/subscript/scripts/nodes.py +0 -0
  18. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/subscript/scripts/spatial.py +0 -0
  19. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/subscript/tabulatehdf5.py +0 -0
  20. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/subscript/util.py +0 -0
  21. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/tests/test_histograms.py +0 -0
  22. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/tests/test_macros.py +0 -0
  23. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/tests/test_nfilters.py +0 -0
  24. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/tests/test_nfilters_legacy.py +0 -0
  25. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/tests/test_nodes.py +0 -0
  26. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/tests/test_spatial.py +0 -0
  27. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/tests/test_symphony.py +0 -0
  28. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/tests/test_tabulatehdf5.py +0 -0
  29. {subhaloscript-1.0.7 → subhaloscript-1.0.8}/tests/test_wrappers.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: subhaloscript
3
- Version: 1.0.7
3
+ Version: 1.0.8
4
4
  Summary: Utility functions for analyzing subhalo distributions.
5
5
  Author-email: Charles Gannon <cgannon@ucmerced.edu>
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  package:
2
2
  name: subhaloscript
3
- version: "1.0.7"
3
+ version: "1.0.8"
4
4
 
5
5
  source:
6
6
  path: . # Or use `git_url`/`url` if not building from local files
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
5
5
  [project]
6
6
  dependencies = ["numpy","pandas","scipy","h5py", "scikit-learn"]
7
7
  name = "subhaloscript"
8
- version = "1.0.7"
8
+ version = "1.0.8"
9
9
  authors = [
10
10
  { name="Charles Gannon", email="cgannon@ucmerced.edu" },
11
11
  ]
@@ -0,0 +1,61 @@
1
+ class Meta():
2
+ cache = True
3
+ """If true, use custom code when reading hdf5 to cache read data."""
4
+ disableDepreciatedWarning = False
5
+
6
+ class ParamKeys():
7
+ """Library of default galacticus parameters."""
8
+ x = 'positionOrbitalX'
9
+ y = 'positionOrbitalY'
10
+ z = 'positionOrbitalZ'
11
+ relx = 'satellitePositionX'
12
+ rely = 'satellitePositionY'
13
+ relz = 'satellitePositionZ'
14
+ mass = 'basicMass'
15
+ mass_bound = 'satelliteBoundMass'
16
+ rvir = 'darkMatterOnlyRadiusVirial'
17
+ mass_basic = 'basicMass'
18
+ is_isolated = 'nodeIsIsolated'
19
+ hierarchylevel = 'nodeHierarchyLevel'
20
+ sphere_radius = 'spheroidRadius'
21
+ sphere_anglularmomentum = 'spheroidAngularMomentum'
22
+ sphere_mass_stellar = 'spheroidMassStellar'
23
+ sphere_mass_gas = 'spheroidMassGas'
24
+ scale_radius = 'darkMatterProfileScaleRadius'
25
+ density_profile_radius = 'densityProfileRadius'
26
+ density_profile = 'densityProfile'
27
+ z_lastisolated = 'redshiftLastIsolated'
28
+ tnfw_rt = 'radiusTidalTruncationNFW'
29
+ tnfw_p0 = 'densityNormalizationTidalTruncationNFW'
30
+ custom_id = 'custom_id'
31
+ custom_tree_index = 'custom_node_tree'
32
+ custom_tree_outputorder = 'custom_node_outputorder'
33
+ concentration = 'concentration'
34
+ merger_tree_count = 'mergerTreeCount'
35
+ merger_tree_index = 'mergerTreeIndex'
36
+ merger_tree_seed = 'mergerTreeSeed'
37
+ merger_tree_start_index = 'mergerTreeStartIndex'
38
+ merger_tree_weight = 'mergerTreeWeight'
39
+ basic_time_last_isolated = 'basicTimeLastIsolated'
40
+ dark_matter_temperature_virial = 'darkMatterOnlyTemperatureVirial'
41
+ dark_matter_velocity_virial = 'darkMatterOnlyVelocityVirial'
42
+ dark_matter_profile_dmo_radius_velocity_max = 'darkMatterProfileDMORadiusVelocityMaximum'
43
+ dark_matter_profile_dmo_velocity_max = 'darkMatterProfileDMOVelocityMaximum'
44
+ dark_matter_profile_scale = 'darkMatterProfileScale'
45
+ mass_halo_enclosed_current = 'massHaloEnclosedCurrent'
46
+ hierarchy_level_depth = 'nodeHierarchyLevelDepth'
47
+ hierarchy_level_maximum = 'nodeHierarchyLevelMaximum'
48
+ node_index = 'nodeIndex'
49
+ subsampling_weight = 'nodeSubsamplingWeight'
50
+ parent_index = 'parentIndex'
51
+ satellite_index = 'satelliteIndex'
52
+ satellite_velocity_x = 'satelliteVelocityX'
53
+ satellite_velocity_y = 'satelliteVelocityY'
54
+ satellite_velocity_z = 'satelliteVelocityZ'
55
+ satellite_tidal_field = 'satelliteTidalField'
56
+ satellite_tidal_heating_normalized = 'satelliteTidalHeatingNormalized'
57
+ sibling_index = 'siblingIndex'
58
+ spin_angular_momentum = 'spinAngularMomentum'
59
+ spin_angular_momentum_vector_x = 'spinAngularMomentumVectorX'
60
+ spin_angular_momentum_vector_y = 'spinAngularMomentumVectorY'
61
+ spin_angular_momentum_vector_z = 'spinAngularMomentumVectorZ'
@@ -0,0 +1,81 @@
1
+ import numpy as np
2
+ import subscript.scripts.nfilters as nf
3
+ from subscript.tabulatehdf5 import get_galacticus_outputs, tabulate_trees
4
+ from subscript.scripts.nodes import nodedata
5
+ from subscript.defaults import ParamKeys
6
+
7
+ def track_subhalos(galacticus_out, nodeIndices, treeIndex, param_keys = None):
8
+ """Extract time-series data for specified subhalo nodes across all Galacticus snapshots.
9
+ NOTE: To use this function, galacticus must be run with the nodeOperator indexShift.
10
+ Ie
11
+ ```
12
+ <nodeOperator value="indexShift" />
13
+ ```
14
+
15
+
16
+ Parameters
17
+ ----------
18
+ galacticus_out : h5py.File
19
+ Opened HDF5 file object containing Galacticus simulation output
20
+ nodeIndices : array-like
21
+ Array of node indices for subhalos to track
22
+ treeIndex : int
23
+ Index of the merger tree to extract data from
24
+ param_keys : list of str, optional
25
+ List of parameter keys to extract for each subhalo. If None, extracts all available keys
26
+ from the tree at the first snapshot
27
+
28
+ Returns
29
+ -------
30
+ subhalo_data : dict
31
+ Nested dictionary with structure {node_id: {param_key: time_series_array, 'zsnap': redshift_array}}
32
+ zsnaps : ndarray
33
+ Array of redshifts at each snapshot (averaged over host halos)
34
+ """
35
+ snaps = np.flip(np.asarray(get_galacticus_outputs(galacticus_out)))
36
+
37
+ param_keys = param_keys if param_keys is not None else [_key for _key in tabulate_trees(galacticus_out, snaps[0])[treeIndex].keys()]
38
+
39
+ subhalo_data = {id : {key: np.zeros(len(snaps)) for key in param_keys} | {'zsnap' : np.zeros(len(snaps))} for id in nodeIndices}
40
+
41
+ zsnaps = np.zeros(len(snaps))
42
+
43
+ for j, isnap in enumerate(snaps):
44
+ snap = tabulate_trees(galacticus_out, isnap)[treeIndex]
45
+ nd = nodedata(snap, key=param_keys)
46
+
47
+ ids = nodedata(snap, 'nodeIndex')
48
+
49
+ zsnaps[j] = np.mean(nodedata(snap, ParamKeys.z_lastisolated, nfilter=nf.hosthalos))
50
+
51
+ for n, id in enumerate(ids):
52
+ if id not in nodeIndices:
53
+ continue
54
+ for i, key in enumerate(param_keys):
55
+ subhalo_data[id][key][j] = nd[i][n]
56
+
57
+ return subhalo_data, zsnaps
58
+
59
+ def track_subalo(subhalos_over_time, zsnaps, nodeindex, param_keys):
60
+ """Filter subhalo time-series data to retain only non-isolated, bound snapshots.
61
+ Parameters
62
+ ----------
63
+ subhalos_over_time : dict
64
+ Nested dictionary output from track_subhalos containing time-series for each subhalo
65
+ zsnaps : ndarray
66
+ Array of redshifts at each snapshot
67
+ nodeindex : int
68
+ Node index of the subhalo to filter
69
+ param_keys : list of str
70
+ List of parameter keys to include in filtered output
71
+
72
+ Returns
73
+ -------
74
+ filtered_data : dict
75
+ Dictionary with structure {param_key: filtered_time_series_array} where filtering removes
76
+ snapshots where the subhalo is isolated (is_isolated == 1) or has no bound mass (mass_bound <= 0)
77
+ filtered_zsnaps : ndarray
78
+ Filtered array of redshifts corresponding to non-isolated, bound snapshots
79
+ """
80
+ _filter = (subhalos_over_time[nodeindex][ParamKeys.is_isolated] == 0) & (subhalos_over_time[nodeindex][ParamKeys.mass_bound] > 0)
81
+ return {key: subhalos_over_time[nodeindex][key][_filter] for key in param_keys}, zsnaps[_filter]
@@ -169,7 +169,7 @@ def gscript(func):
169
169
  elif is_arraylike(nfilter):
170
170
  _nodefilter = np.asarray(nfilter, dtype=bool)
171
171
  else:
172
- TypeError("Unrecognized type provided to nodefilter")
172
+ raise TypeError("Unrecognized type provided to nodefilter")
173
173
 
174
174
  _nodestree_filtered = _nodestree.filter(_nodefilter)
175
175
 
@@ -1,32 +0,0 @@
1
- class Meta():
2
- cache = True
3
- """If true, use custom code when reading hdf5 to cache read data."""
4
- disableDepreciatedWarning = False
5
-
6
- class ParamKeys():
7
- """Library of default galacticus parameters."""
8
- x = 'positionOrbitalX'
9
- y = 'positionOrbitalY'
10
- z = 'positionOrbitalZ'
11
- relx = 'satellitePositionX'
12
- rely = 'satellitePositionY'
13
- relz = 'satellitePositionZ'
14
- mass = 'basicMass'
15
- mass_bound = 'satelliteBoundMass'
16
- rvir = 'darkMatterOnlyRadiusVirial'
17
- mass_basic = 'basicMass'
18
- is_isolated = 'nodeIsIsolated'
19
- hierarchylevel = 'nodeHierarchyLevel'
20
- sphere_radius = 'spheroidRadius'
21
- sphere_anglularmomentum = 'spheroidAngularMomentum'
22
- sphere_mass_stellar = 'spheroidMassStellar'
23
- sphere_mass_gas = 'spheroidMassGas'
24
- scale_radius = 'darkMatterProfileScaleRadius'
25
- density_profile_radius = 'densityProfileRadius'
26
- density_profile = 'densityProfile'
27
- z_lastisolated = 'redshiftLastIsolated'
28
- tnfw_rt = 'radiusTidalTruncationNFW'
29
- tnfw_p0 = 'densityNormalizationTidalTruncationNFW'
30
- custom_id = 'custom_id'
31
- custom_tree_index = 'custom_node_tree'
32
- custom_tree_outputorder = 'custom_node_outputorder'
File without changes
File without changes
File without changes