linefinder.analyze_data.worldlines module¶
Tools for reading worldline data
@author: Zach Hafen @contact: zachary.h.hafen@gmail.com @status: Development
-
class
linefinder.analyze_data.worldlines.
WorldlineDataKeyParser
[source]¶ Bases:
galaxy_dive.analyze_data.generic_data.DataKeyParser
-
is_fraction_key
(data_key)¶ Check if the data should be some fraction of its relevant scale.
Parameters: data_key (str) – Data key to check. Returns: True if the data should be scaled as a fraction of the relevant scale. Return type: is_fraction_key (bool)
-
is_log_key
(data_key)¶ Check if the data key indicates the data should be put in log scale.
Parameters: data_key (str) – Data key to check. Returns: True if the data should be taken log10 of Return type: is_log_key (bool)
-
-
class
linefinder.analyze_data.worldlines.
WorldlineDataMasker
(worldlines)[source]¶ Bases:
galaxy_dive.analyze_data.simulation_data.TimeDataMasker
Data masker for worldline data.
-
clear_masks
(clear_optional_masks=False)¶ Reset the masks in total to nothing.
- Modifies:
- self.masks (lists) : Sets to empty
-
get_mask
(mask=None, classification=None, mask_after_first_acc=False, mask_before_first_acc=False, preserve_mask_shape=False, optional_masks=None, *args, **kwargs)[source]¶ Get a mask for the data.
Parameters: - mask (np.array) – Mask to apply to the data. If None, use the masks stored in self.masks (which Nones to empty).
- classification (str) – If provided, only select particles that meet this classification, as given in self.data_object.classifications.data
- tile_classification_mask (bool) – Whether or not to tile the classification mask. True for most data that’s time dependent, but False for data that’s one value per particle.
- mask_after_first_acc (bool) – If True, only select particles above first accretion.
- mask_before_first_acc (bool) – If True, only select particles after first accretion.
- preserve_mask_shape (bool) – If True, don’t tile masks that are single dimensional, and one per particle.
- optional_masks (list-like) – If given, the optional masks to include, by name (masks must be available in self.optional_masks).
Returns: Mask from all the combinations.
Return type: mask (bool np.ndarray)
-
get_selected_data
(data_key, mask=None, classification=None, mask_after_first_acc=False, mask_before_first_acc=False, preserve_mask_shape=False, optional_masks=None, *args, **kwargs)[source]¶ Get masked worldline data. Extra arguments are passed to the ParentClass’ get_selected_data.
Parameters: - data_key (str) – Data to get.
- mask (np.array) – Mask to apply to the data. If None, use the masks stored in self.masks (which Nones to empty).
- classification (str) – If provided, only select particles that meet this classification, as given in self.data_object.classifications.data
- tile_classification_mask (bool) – Whether or not to tile the classification mask. True for most data that’s time dependent, but False for data that’s one value per particle.
- mask_after_first_acc (bool) – If True, only select particles above first accretion.
- mask_before_first_acc (bool) – If True, only select particles after first accretion.
- preserve_mask_shape (bool) – If True, don’t tile masks that are single dimensional, and one per particle.
Returns: Flattened array of masked data.
Return type: masked_data (np.array)
-
get_selected_data_over_time
(data_key, mask=None, classification=None, mask_after_first_acc=False, mask_before_first_acc=False, preserve_mask_shape=False, optional_masks=None, *args, **kwargs)[source]¶ Get masked worldline data. Extra arguments are passed to the ParentClass’ get_selected_data.
Parameters: - data_key (str) – Data to get.
- mask (np.array) – Mask to apply to the data. If None, use the masks stored in self.masks (which defaults to empty).
- classification (str) – If provided, only select particles that meet this classification, as given in self.data_object.classifications.data
- tile_classification_mask (bool) – Whether or not to tile the classification mask. True for most data that’s time dependent, but False for data that’s one value per particle.
- mask_after_first_acc (bool) – If True, only select particles above first accretion.
- mask_before_first_acc (bool) – If True, only select particles after first accretion.
- preserve_mask_shape (bool) – If True, don’t tile masks that are single dimensional, and one per particle.
Returns: Flattened array of masked data.
Return type: masked_data (np.array)
-
get_total_mask
(optional_masks=None)¶ Get the result of combining all masks in the data.
Parameters: optional_masks (list-like) – List of names of optional masks to use (must be found in self.optional_masks). Returns: Result of all masks. Return type: total_mask (np.array of bools)
-
mask_data
(data_key, data_min=<object object>, data_max=<object object>, data_value=<object object>, custom_mask=<object object>, return_or_store='store', optional_mask=False, mask_name=<object object>, *args, **kwargs)¶ Get only the particle data within a certain range. Note that it retrieves the processed data.
Parameters: - data_key (str) – Data key to base the mask off of.
- data_min (float) – Everything below data_min will be masked.
- data_max (float) – Everything above data_max will be masked.
- data_value (float) – Everything except for data_value will be masked.
- custom_mask (bool) – If provided, take in a custom mask instead, using data_key as the label for the mask.
- return_or_store (str) – Whether to store the mask as part of the masks dictionary, or to return it.
- optional_mask (bool) – If True, store in the dictionary self.optional_masks instead.
- mask_name (str) – What name to associate with this mask? Currently only relevant if optional_mask is True. By default uses the data_key as the name.
- **kwargs (*args,) –
Passed to self.data_object.get_processed_data()
Returns: If requested, the mask for data in that range.
Return type: data_mask (np.array of bools)
- Modifies:
- self.masks (list of dicts) :
- Appends a dictionary describing the mask.
-
run_selection_routine
(selection_routine, ptype)[source]¶ Selection routines are routines for adding non-trivial combinations of masks to self.masks. Masked data then will be retrieved with these masks in mind.
Parameters: Returns: Clears and adds masks to self.masks.
Return type: self.masks (list)
-
select_accreted
(ptype_value)[source]¶ This selection routine selects only particles that are the snapshot before being accreted.
- ptype_value (int):
- In the data, what ptype do we select?
Returns: Adds masks needed to select only particles in a galaxy. Return type: self.masks (list)
-
select_galaxy
(ptype_value)[source]¶ This selection routine selects only particles in a galaxy.
- ptype_value (int):
- In the data, what ptype do we select?
Returns: Adds masks needed to select only particles in a galaxy. Return type: self.masks (list)
-
select_outside_all_galaxies
(ptype_value)[source]¶ This seleciton routine selects only particles that are outside all galaxies.
- ptype_value (int):
- In the data, what ptype do we select?
Returns: Adds masks needed to select only particles outside all galaxies. Return type: self.masks (list)
-
-
class
linefinder.analyze_data.worldlines.
Worldlines
(data_dir, tag, ids_tag=None, ptracks_tag=None, galids_tag=None, classifications_tag=None, events_tag=None, **kwargs)[source]¶ Bases:
galaxy_dive.analyze_data.simulation_data.TimeData
Wrapper for analysis of all data products. It loads data in on-demand.
Parameters: - data_dir (str) – Data directory for the classified data
- tag (str) – Identifying tag for the data to load.
- ids_tag (str) – Identifying tag for ids data. Defaults to tag.
- ptracks_tag (str) – Identifying tag for ptracks data. Defaults to tag.
- galids_tag (str) – Identifying tag for galids data. Defaults to tag.
- classifications_tag (str) – Identifying tag for classifications data. Defaults to tag.
- events_tag (str) – Identifying tag for events data. Defaults to tag.
- label (str) – Identifying label for the worldlines, used for plotting. Defaults to tag.
- color (str) – What color to use when plotting.
- **kwargs – Keyword arguments passed to self.ptracks, which is a PTracks object.
-
add_hubble_flow
()¶ Correct for hubble flow movement.
- Modifies:
- self.data[‘V’] : Accounts for hubble flow, relative to origin
-
base_data_shape
¶ Typical shape of arrays stored in the data
-
calc_CGM_event_id
()[source]¶ Indication of when a particle moves in or out of the CGM.
Returns: A value of -1 means the particle has left the CGM. A value of 1 means the particle has entered the CGM. A value of 0 indicates no change. Return type: array-like, (n_particles, n_snaps - 1)
-
calc_CGM_sat_event_id
()[source]¶ Indication of when a particle moves in or out of the CGM.
Returns: A value of -1 means the particle has left the CGM. A value of 1 means the particle has entered the CGM. A value of 0 indicates no change. Return type: array-like, (n_particles, n_snaps - 1)
-
calc_HDen
(X_H=0.75)[source]¶ Calculate the hydrogen number density from the number density (for particle tracking data Den data is baryon number density).
Parameters: X_H (float) – Hydrogen mass fraction. Returns: Value at [i,j] is the Hydrogen number density for particle i at index j. Return type: array-like of floats (n_particles, n_snaps)
-
calc_Z_asplund
()[source]¶ Calculate the metallicity in units of Z_sun = 0.0134 (from Asplund+2009), rescaled from the metallicity in units of Z_sun = 0.02 (the value used in the simulations, from Anders&Grevesse1989).
Returns: Value at [i,j] is the metallicity in units of Z_sun=0.0134 for particle i at index j. Return type: array-like of floats (n_particles, n_snaps)
-
calc_abs_phi
(normal_vector='total ang momentum')¶ Calculate the angle (in degrees) from some vector, but mirror values past 90 degrees (e.g. 135 -> 45 degrees, 180 -> 0 degrees). This is useful when there’s symmetry above and below 90.
Parameters: normal_vector (str or array-like) – Vector that represents the vertical. Defaults to using the total stellar angular momentum of the main galaxy. - Modifies:
- self.data[‘AbsPhi’] (array-like):
- Angle from the vector, in many cases acting as the angle from the disk axis.
-
calc_ang_momentum
()¶ The angular momentum (in the standard coordinates).
- Modifies:
- self.data[‘L’] (array-like):
- Angular momentum of each resolution element.
-
calc_d_sat_scaled_min
()[source]¶ Calculate the minimum distance to a a galaxy other than the main galaxy, prior to accretion onto the main gal.
Returns: self.data[‘d_sat_scaled_min’][i] = min( d_sat_scaled, prior to first acc for particle i ) Return type: self.data[‘d_sat_scaled_min’] (np.ndarray of shape (n_particles,))
-
calc_dt
()[source]¶ Calc time difference between snapshots.
Returns: self.data[‘dt’][i] = light_travel_time[i+1] - light_travel_time[i] Return type: self.data[‘dt’] (np.ndarray)
-
calc_enriched_metal_mass
()¶ Calculate the metal mass that comes from enrichment for each resolution element, not counting mass that’s at the metallicity floor. Assumes that the there will always be at least one resolution element in the simulation that’s at the metallicity floor.
- Modifies:
- self.data[‘enriched_metal_mass’] (array-like):
- Metal mass from enrichment.
-
calc_ind_star
()[source]¶ Calculate the index at which a particle is first recorded as being a star.
Returns: self.data[‘ind_star’][i] = Index at which particle is first recorded as being a star. Return type: self.data[‘ind_star’] (np.ndarray of shape (n_particles,))
-
calc_is_CGM_EP
()[source]¶ This used to be called satellite wind, until minor issues with the classification scheme were discovered. In particular, merging galaxies that momentarily ended up in the CGM again were being classified as winds.
Returns: If value at [i,j] is True, this is a particle that is “externally processed” and part of the CGM, but has not been “internally processed” and is not part of another galaxy. Return type: array-like, (n_particles, n_snaps)
-
calc_is_CGM_IGM_accretion
()[source]¶ This is “IGM accretion” in Hafen+2018. Note that this is nearly exactly equivalent to “is_CGM_NEP”, but we count unprocessed gas in galaxies (however, this should be nearly negligible).
Returns: If value at [i,j] is True, this is a particle that is part of the CGM and has not been processed. Return type: array-like, (n_particles, n_snaps)
-
calc_is_CGM_IP
()[source]¶ This used to be called wind (from the central galaxy), until minor issues with the classification scheme were discovered. In particular, merging galaxies that momentarily ended up in the CGM again were being classified as winds.
Returns: If value at [i,j] is True, this is a particle that is processed by the main galaxy, but is now in the CGM. Return type: array-like, (n_particles, n_snaps)
-
calc_is_CGM_NEP
()[source]¶ This used to be called IGM accretion, until minor issues with the classification scheme were discovered. In particular, merging galaxies that momentarily ended up in the CGM again were being classified as winds.
Returns: If value at [i,j] is True, this is a particle that is not part of any galaxy and has not been processed. Return type: array-like, (n_particles, n_snaps)
-
calc_is_CGM_accreted
()[source]¶ Material that’s currently in the CGM, and next enters either the main galaxy.
Returns: Array where the value of [i,j]th index indicates if particle i will transfer from the CGM to either the galaxy or galaxy-halo interface after index j. Return type: array-like of booleans, (n_particles, n_snaps)
-
calc_is_CGM_accreted_to_satellite
()[source]¶ Material that’s currently in the CGM, outside a satellite, and next enters a satellite.
Returns: Array where the value of [i,j]th index indicates if particle i will transfer from the CGM to the IGM after index j. Return type: array-like of booleans, (n_particles, n_snaps)
-
calc_is_CGM_ejected
()[source]¶ Material that’s currently in the CGM, and next enters the IGM.
Returns: Array where the value of [i,j]th index indicates if particle i will transfer from the CGM to the IGM after index j. Return type: array-like of booleans, (n_particles, n_snaps)
-
calc_is_CGM_fate_unclassified
()[source]¶ Material that cannot be classified under the current CGM fate classifications.
Returns: Array where the value of [i,j]th index indicates if particle i doesn’t fit within the CGM fate classification scheme Return type: array-like of booleans, (n_particles, n_snaps)
-
calc_is_CGM_halo_transfer
()[source]¶ Material that’s currently in the CGM, and next enters a halo adjacent to the CGM
Returns: Array where the value of [i,j]th index indicates if particle i will transfer from the CGM to another halo after index j. Return type: array-like of booleans, (n_particles, n_snaps)
-
calc_is_CGM_satellite
()[source]¶ This used to be called satellite ISM, until minor issues with the classification scheme were discovered. In particular, merging galaxies that momentarily ended up in the CGM again were being classified as winds.
Returns: If value at [i,j] is True, this is a particle that is “internally processed” and is also part of another galaxy. Return type: array-like, (n_particles, n_snaps)
-
calc_is_CGM_satellite_ISM
()[source]¶ This is “satellite ISM” in Hafen+2018. While called ISM, this doesn’t select only gas particles.
Returns: If value at [i,j] is True, this is a particle that is in a satellite galaxy, in the CGM, and has been externally processed.Return type: array-like, (n_particles, n_snaps)
-
calc_is_CGM_satellite_wind
()[source]¶ This is “satellite wind” in Hafen+2018. Note that under this definition a small fraction of particles may be unclassified: ones that are processed by the main galaxy, land in a satellite galaxy, and then leave the satellite galaxy before spending enough time in it to be externally processed.
Returns: If value at [i,j] is True, this is a particle that is in the CGM, is externally processed, is not in another galaxy, and last left a galaxy other than the main galaxy. Return type: array-like, (n_particles, n_snaps)
-
calc_is_CGM_to_IGM
()[source]¶ Material that’s currently in the CGM, and next enters the IGM.
Returns: Array where the value of [i,j]th index indicates if particle i will transfer from the CGM to the IGM after index j. Return type: array-like of booleans, (n_particles, n_snaps)
-
calc_is_CGM_wind
()[source]¶ This is “wind” (from the central galaxy) in Hafen+2018. Note that under this definition a small fraction of particles may be unclassified: ones that are processed by a galaxy other than the main galaxy, land in the main galaxy, and then leave the main galaxy before spending enough time in it to be internally processed.
Returns: If value at [i,j] is True, this is a particle that is in the CGM, is internally processed, is not in another galaxy, and lasft the main galaxy. Return type: array-like, (n_particles, n_snaps)
-
calc_is_IP
()[source]¶ Calculate internally processed material, defined as all material that has been inside the main galaxy.
-
calc_is_NEP_NYA
()[source]¶ Find material classified as NEP that is not yet accreted (NYA) onto the main galaxy.
Returns: Result Return type: self.data[‘is_mass_transfer_NYA’] ( np.ndarray )
-
calc_is_NEP_wind_recycling
()[source]¶ Find material classified as non-externally-processed wind recycling.
Returns: Result. Return type: self.data[‘is_NEP_wind_recycling’] ( np.ndarray )
-
calc_is_after_enrichment
()[source]¶ Find the snapshots at which the metallicity is different from the prior snapshot.
-
calc_is_before_enrichment
()[source]¶ Find the snapshots at which the metallicity is different from the next snapshot.
-
calc_is_classification_NYA
(classification, tile_classification=True)[source]¶ Find material with the given classification that is not yet accreted (NYA) onto the main galaxy.
Parameters: Returns: The (i,j)th entry is True if particle i is not yet accreted by the jth index.
Return type: is_classification_NYA ( [n_particles, n_snaps] np.ndarray )
-
calc_is_enriched
()[source]¶ Find the snapshots at which the metallicity is different from the either the next snapshot or the previous snapshot.
-
calc_is_enriched_in_mgal
()[source]¶ Find the snapshots at which the metallicity is different from the either the next snapshot or the previous snapshot, and the particle is inside the radius of the main galaxy (note that no density threshold is applied).
-
calc_is_enriched_in_ogal
()[source]¶ Find the snapshots at which the metallicity is different from the either the next snapshot or the previous snapshot, and the particle is inside the radius of another galaxy (note that no density threshold is applied).
-
calc_is_fresh_accretion
()[source]¶ Find material classified as fresh accretion (pristine gas that has not recycled).
Returns: Result. Return type: self.data[‘is_fresh_accretion’] ( np.ndarray )
-
calc_is_hereafter_CGM
()[source]¶ Material that stays in the CGM until z=0.
Returns: Array where the value of the [i,j]th index is True if particle i is in the CGM at j and stays there until z=0 (j=0). Return type: array-like of booleans, (n_particles, n_snaps)
-
calc_is_in_CGM
()[source]¶ Material that is in the CGM.
Returns: If True, the particle is currently in the CGM, as defined in Hafen+18. Return type: self.data[‘is_in_CGM’] (np.ndarray)
-
calc_is_in_CGM_not_sat
()[source]¶ Material that is in the CGM and not in an satellite galaxy
Returns: If True, the particle is currently in the CGM, as defined in Hafen+18. Return type: self.data[‘is_in_CGM_not_sat’] (np.ndarray)
-
calc_is_in_CGM_or_interface
()[source]¶ Material that is in either the CGM (outside a satellite) or the galaxy halo interface.
-
calc_is_in_IGM
()[source]¶ Material that is in the IGM.
Returns: Array where the value of [i,j]th index indicates if particle i is currently in the IGM, as defined in Hafen+19. Return type: array-like of booleans, (n_particles, n_snaps)
-
calc_is_mass_transfer_NYA
()[source]¶ Find material classified as mass transfer that is not yet accreted (NYA) onto the main galaxy.
Returns: Result Return type: self.data[‘is_mass_transfer_NYA’] ( np.ndarray )
-
calc_is_merger_NYA
()[source]¶ Find material classified as merger that is not yet accreted (NYA) onto the main galaxy.
Returns: Result Return type: self.data[‘is_merger_NYA’] ( np.ndarray )
-
calc_is_merger_gas
()[source]¶ Find material classified as a merger, while being gas at time of first accretion. Caution: This is calculated at the snapshot first after accretion. The safer option may be to calculate at the snapshot immediately before first accretion.
Returns: Result. Return type: self.data[‘is_merger_gas’] ( np.ndarray )
-
calc_is_merger_star
()[source]¶ Find material classified as a merger, while being a star particle at time of first accretion. Caution: This is calculated at the snapshot first after accretion. The safer option may be to calculate at the snapshot immediately before first accretion.
Returns: Result. Return type: self.data[‘is_merger_star’] ( np.ndarray )
-
calc_metal_mass
()¶ Calculate the metal mass held by each resolution element.
- Modifies:
- self.data[‘enriched_metal_mass’] (array-like):
- Metal mass from enrichment.
-
calc_n_in
()[source]¶ The number of times a particle has entered the main galaxy.
Returns: result[i,j] number of times that particle i has entered the galaxy prior to index j. Return type: array-like of integers, (n_particles, n_snaps)
-
calc_n_in_CGM
()[source]¶ The number of times a particle has entered the CGM of the main galaxy.
Returns: Value at index [i,j] is the number of times that particle i has entered the CGM prior to index j. Return type: array-like of integers, (n_particles, n_snaps)
-
calc_n_out
()[source]¶ The number of times a particle has left the main galaxy.
Returns: self.data[‘n_out’], where the value of [i,j]th index is number of times that particle i has left the galaxy prior to index j. Return type: array-like of integers, (n_particles, n_snaps)
-
calc_n_out_CGM
()[source]¶ The number of times a particle has entered the CGM of the main galaxy.
Returns: Value at index [i,j] is the number of times that particle i has entered the CGM prior to index j. Return type: array-like of integers, (n_particles, n_snaps)
-
calc_other_gal_event_id
()[source]¶ Indication of when a particle moves in or out of galaxies other than the main galaxy.
Returns: A value of -1 means the particle has left all other galaxies. A value of 1 means the particle has entered any other galaxy. A value of 0 indicates no change. Return type: array-like, (n_particles, n_snaps - 1)
-
calc_phi
(normal_vector='total ang momentum')¶ Calculate the angle (in degrees) from some vector. By default the vector is the total angular momentum.
Parameters: normal_vector (str or array-like) – Vector that represents the vertical.
-
calc_radial_distance
()¶ Calculate the distance from the origin for a given particle.
-
calc_radial_velocity
()¶ Calculate the distance from the origin for a given particle.
-
calc_rho_xy
()¶ Calculate impact parameter in the xy-plane.
-
calc_rho_xz
()¶ Calculate impact parameter in the xz-plane.
-
calc_rho_yz
()¶ Calculate impact parameter in the yz-plane.
-
calc_t_EP
()[source]¶ Calculate the time spent in another galaxy prior to accretion onto the main galaxy of the simulation.
Returns: self.data[‘t_EP’][i] = time particle i spent in another galaxy prior to first accretion. Return type: self.data[‘t_EP’] (np.ndarray)
-
calc_t_cool_lookup
()[source]¶ Calculate the cooling time for a given particle, according to a lookup table.
This makes some assumption about how the filepath informs the what simulation we’re looking at, but it will fail if those don’t fit. (Probably.)
Returns: Value of t_cool for each particle according to a lookup table that uses distance from the central galaxy and redshift. Return type: array-like of floats (n_particles, n_snaps)
-
calc_time
()[source]¶ Calc current time in the simulation.
Returns: The value at index i is the time in the simulation (i.e. the age of the universe) at that index. Return type: self.data[‘time’] (np.ndarray)
-
calc_time_as_classification
(data_key)¶
-
calc_time_since_leaving_main_gal
()[source]¶ Time since a particle has left the main galaxy.
Returns: Value at index [i,j] is the time since particle i left the main galaxy at some index prior to j. Return type: array-like of floats, (n_particles, n_snaps)
-
calc_time_since_leaving_other_gal
()[source]¶ Time since a particle has left all galaxies other than the main galaxy.
Returns: Value at index [i,j] is the time since particle i left a galaxy other than the main galaxy at some index prior to j. Return type: array-like of floats, (n_particles, n_snaps)
-
calc_time_until_not_classification
(data_key)¶
-
calc_velocity_magnitude
()¶ Calculate the velocity relative to an origin velocity for a given particle.
-
center_coords
()¶ Change the location of the origin, if the data isn’t already centered.
- Modifies:
- self.data[‘P’] : Shifts the coordinates to the center.
-
center_vel_coords
()¶ Get velocity coordinates to center on the main halo.
- Modifies:
- self.data[‘V’] : Makes all velocities relative to self.vel_origin
-
classifications
¶ Object for loading and manipulating classifications*.hdf5 data
-
conversion_factor
¶ The ratio necessary to convert to the total mass from the sample mass.
-
count_n_events
(boolean)[source]¶ Counts the number of events that occur up to this point.
Parameters: boolean (array-like, (n_particles, n_snaps)) – If true, the event happens at the given index. Returns: n_events[i,j] number of times that particle i has an event prior to index j. Return type: n_events (array-like)
-
events
¶ Object for loading and manipulating events*.hdf5 data
-
galids
¶ Object for loading and manipulating galids*.hdf5 data
-
get_categories_selected_quantity
(classification_list=['is_fresh_accretion', 'is_NEP_wind_recycling', 'is_mass_transfer', 'is_merger_gas', 'is_merger_star'], selected_quantity_method='get_selected_quantity', *args, **kwargs)[source]¶ Get the total mass in the main galaxy for a particular particle type in each of a number of classification categories. This is only for particles that are tracked! This is not the real mass!
Parameters: - classification_list (list) – What classifications to use.
- selected_quantity_method (str) – Method to use for getting the selected quantity. For example, use ‘get_selected_quantity_radial_bins’ if you want the selected quantity in, well, radial bins.
- **kwargs (*args,) –
Additional arguments to be passed to self.get_selected_data()
Returns: selected_quantity that fits each classification.
Return type: categories_selected_quantity (SmartDict of np.ndarrays)
-
get_categories_selected_quantity_extrapolated
(classification_list=['is_fresh_accretion', 'is_NEP_wind_recycling', 'is_mass_transfer', 'is_merger_gas', 'is_merger_star'], *args, **kwargs)[source]¶ Get the total mass in the main galaxy for a particular particle type in each of a number of classification categories.
Parameters: - classification_list (list) – What classifications to use.
- **kwargs (*args,) –
Additional arguments to be passed to self.get_selected_data()
Returns: selected_quantity that fits each classification.
Return type: categories_selected_quantity (SmartDict of np.ndarrays)
-
get_categories_selected_quantity_fraction
(normalization_category, classification_list=['is_fresh_accretion', 'is_NEP_wind_recycling', 'is_mass_transfer', 'is_merger_gas', 'is_merger_star'], selected_quantity_method='get_selected_quantity', *args, **kwargs)[source]¶ Same as categories_selected_quantity, but as a fraction of the total mass in the main galaxy for a particular particle type.
-
get_data
(data_key, *args, **kwargs)[source]¶ Get data. Usually just get it from ptracks. args and kwargs are passed to self.ptracks.get_data()
Parameters: - data_key (str) – What data to get?
- **kwargs (*args,) –
Additional arguments to pass to other get_data() methods.
Returns: Array of data.
Return type: data (np.ndarray)
-
get_data_at_ind
(data_key, ind_key, ind_shift=0, units=None, units_a_power=1.0, units_h_power=-1.0, return_units_only=False, tile_data=False, *args, **kwargs)[source]¶ Get the data at a specified index for each particle.
Parameters: - data_key (str) – What data to get?
- ind_key (str) – What index to use?
- ind_shift (int) – Relative to the index identified by ind_key, how should the index be shifted?
- units (str) – If given, scale the data by this value, taken from the halo data.
- units_a_power (float) – If using units from the halo data, multiply by a to this power to convert.
- units_h_power (float) – If using units from the halo data, multiply by the hubble param to this power to convert.
- return_units_only (bool) – Return just the units argument. Useful for debugging.
- tile_data (bool) – If True, tile data before getting the data at a specific index.
- **kwargs (*args,) –
Arguments to be passed to self.get_data()
Returns: Array of data, at the specified index.
Return type: data_at_ind (np.ndarray)
-
get_data_first_acc
(data_key, ind_after_first_acc=False, ind_relative_to_first_acc=0, *args, **kwargs)[source]¶ Get data the snapshot immediately before accretion.
Parameters: - data_key (str) – What data to get?
- ind_after_first_acc (bool) – If True, get data the index immediately after first accretion, instead.
- ind_relative_to_first_acc (int) – Move the snapshot index relative to the snapshot before first accretion.
- **kwargs (*args,) –
Arguments to be passed to self.get_data_at_ind()
Returns: Array of data, the index immediately after first accretion.
Return type: data_first_acc (np.ndarray)
-
get_data_ind_star
(data_key, *args, **kwargs)[source]¶ Get data at the snapshot a particle is first identified as a star.
Parameters: - data_key (str) – What data to get?
- **kwargs (*args,) –
Arguments to be passed to self.get_data_at_ind()
Returns: Array of data, at the index a particle is first identified as a star.
Return type: data_ind_star (np.ndarray)
-
get_distance_to_point
(point)¶ This is not unit tested.
Parameters: point (array-like of shape (3,)) – The point you want to find the distance to for each particle.
-
get_event_id
(boolean)[source]¶ Get an “Event ID” for a given boolean, where the particle moves from being in a True state to a False state, or vice versa.
Parameters: boolean (array-like) – If True, the event happens at the given index. Returns: A value of -1 means the particle has switched from True to False. A value of 1 means the particle has switched from False to True. A value of 0 indicates no change. Return type: array-like, same dimensions as boolean minus one column
-
get_fraction_outside
(data_key, data_min, data_max, *args, **kwargs)[source]¶ Get the fraction of data outside a certain range. *args, **kwargs are arguments sent to mask the data.
Parameters: Returns: Fraction outside the range.
Return type: f_outside (float)
-
get_is_A_to_B
(A_to_B_event, A_key)[source]¶ Material that’s currently in classification A, and next enters classification B.
Parameters: A_to_B (array-like of booleans) – Boolean that indicates the particle left A and entered the other category, B. The value of the [i,j]th index should be True if particle i is in B at index j, and was in A at index j+1. Returns: Array where the value of [i,j]th index indicates if particle i will transfer from A to B category after index j. Return type: array-like of booleans, (n_particles, n_snaps)
-
get_is_CGM_to_other
(CGM_to_other_event)[source]¶ Material that’s currently in the CGM, and next enters another category.
Parameters: CGM_to_other_event (array-like of booleans) – Boolean that indicates the particle left the CGM and entered the other category. The value of the [i,j]th index should be True if particle i is in other at index j, and was in the CGM at index j+1. Returns: Array where the value of [i,j]th index indicates if particle i will transfer from the CGM to the other category after index j. Return type: array-like of booleans, (n_particles, n_snaps)
-
get_max_per_event_count
(data_key, n_event_key, flatten=True, verbose=False, max_after_vmax=False, vmax_kwargs={}, *args, **kwargs)[source]¶ Get the maximum value attained by a quantity for each time an event occurs. TODO: This can be greatly updated and sped up using https://docs.scipy.org/doc/scipy/reference/ndimage.html#measurements
Parameters: - data_key (str) – The data to get the maximum for.
- n_event_key (str) – The count of times an event has happened per particle.
- flatten (boolean) – If True, return a flattened array. Else return a list of arrays, the ith index of which is the maximum for n_event=i.
- max_after_vmax (boolean) – If True, get the max per event count, only after the max velocity for that event was reached. Useful when calculating the results of wind kicks.
- vmax_kwargs (dict) – The max velocity per the event is the radial velocity, but by passing additional keyword arguments through this argument that velocity can be scaled by, for example, the circular velocity.
- **kwargs (*arg,) –
Additional args when getting the data out.
Returns: Result, sorted according first to n_event, and second by particle index.
Return type: max_per_event_count (array-like)
-
get_position_data
(data_key)¶ Get position data (assuming the data starts with an ‘R’)
Parameters: data_key (str) – Key in the data dictionary for the key we want to get Returns: Requested data. Return type: data (np.ndarray)
-
get_potential
(point)¶ This is not unit tested.
Parameters: point (array-like of shape (3,)) – The point you want to find the potential at
-
get_processed_data
(data_key, tile_data=False, *args, **kwargs)[source]¶ Get data, handling more complex data keys that indicate doing generic things to the data.
Parameters: Returns: Array of data.
Return type: data (np.ndarray)
-
get_selected_data
(*args, **kwargs)¶ Wrapper for getting masked data.
-
get_selected_data_over_time
(*args, **kwargs)¶ Wrapper for geting masked data as a function of time.
-
get_selected_quantity
(selection_routine='galaxy', ptype='star', quantity='mass', low_memory_mode=False, selected_quantity_data_key='M', *args, **kwargs)[source]¶ Apply a selection routine, and then get out the total mass (or some other quantity) of particles that fulfill that criteria.
Parameters: - selection_routine (str) – What selection routine to run. E.g. ‘galaxy’ selects all particles in the main galaxy.
- ptype (str) – What particle type inside the galaxy to consider.
- quantity (str) – What quantity of the galaxy to retrieve.
- low_memory_mode (bool) – If True, unload the data after getting the quantity (saves memory at the cost of convenience).
- **kwargs (*args,) –
Additional arguments to be passed to self.get_selected_data()
Returns: Total mass for a particular particle type in the main galaxy (satisfying any additional requirements passed via *args and **kwargs) at each specified redshift.
Return type: selected_quantity (np.ndarray)
-
get_selected_quantity_radial_bins
(selection_routine='galaxy', ptype='star', quantity='mass', radial_bins=array([0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1. ]), radial_bin_data_kwargs={'scale_a_power': 1.0, 'scale_h_power': -1.0, 'scale_key': 'Rvir'}, low_memory_mode=False, *args, **kwargs)[source]¶ Apply a selection routine, and then get out the total mass (or some other quantity) of particles that fulfill that criteria, in specified radial bins.
Parameters: - selection_routine (str) – What selection routine to run. E.g. ‘galaxy’ selects all particles in the main galaxy.
- ptype (str) – What particle type inside the galaxy to consider.
- quantity (str) – What quantity to retrieve.
- radial_bins (np.ndarray) – Radial bins to use.
- radial_bin_data_kwargs (dict) – Arguments to change how the data is masked. For example, if you want to scale the data (done by default), use this dictionary to do so. These are arguments that would be passed to self.data_masker.mask_data and in turn self.data_masker.get_processed_data.
- low_memory_mode (bool) – If True, unload the data after getting the quantity (saves memory at the cost of convenience).
- **kwargs (*args,) –
Additional arguments to be passed to self.get_selected_data()
Returns: Total mass for a particular particle type in the main galaxy (satisfying any additional requirements passed via *args and **kwargs) at each specified redshift.
Return type: selected_quantity (np.ndarray)
-
get_time_since_event
(boolean)[source]¶ Calculate the time since an event happened.
Parameters: boolean (array-like, (n_particles, n_snaps)) – If true, the event happens at the given index. Returns: Value at index [i,j] is the time passed since an event prior to j for particle i. Return type: array-like of floats, (n_particles, n_snaps)
-
get_velocity_data
(data_key)¶ Get position data (assuming the data starts with a ‘V’)
Parameters: data_key (str) – Key in the data dictionary for the key we want to get Returns: Requested data. Return type: data (np.ndarray)
-
halo_data
¶ Halo data (e.g. location of galaxy halos)
Todo
Make it easier to get the parameters to use, without loading as much superfluous data.
-
handle_data_key_error
(data_key)[source]¶ If we don’t have a data_key stored, try and create it.
Parameters: data_key (str) – The data key in question. Returns: If successful, stores the data here. Return type: self.data (dict)
-
hubble_param
¶ Hubble parameter used in the simulations, H_0 / 100 km/s / Mpc
-
hubble_z
¶ Property for the hubble function at specified redshift.
-
ids
¶ Object for loading and manipulating ids*.hdf5 data
-
inner_CGM_boundary
¶ Inner edge of the CGM, defined as max( config.INNER_CGM_BOUNDARY * R_vir, ( 1. + config.F_GAP ) * r_gal ) A typical value is max( 0.1 R_vir, 1.2 * r_gal )
-
iterate_over_method
(method_str, iter_arg, iter_values, method_args)¶ Iterate over a specified method, and get the results out.
Parameters: Returns: [ method( **used_args ) for used_args in all_variations_of_used_args ]
Return type: results (list)
-
length_scale
¶ Standard galaxy/halo length scale. Choice of Rvir, Rstar0.5, etc depends on **kwargs passed when constructing the wordline class.
-
m_tot
¶ Total mass of all tracked particles at the last snapshot.
-
mask_data
(*args, **kwargs)¶ Wrapper for masking data.
-
mass_fractions
¶ Get the mass fraction in the last snapshot for the classifications used in Angles-Alcazar+2017.
-
mass_totals
¶ Get the total mass in the sample in the last snapshot for the classifications used in Angles-Alcazar+2017.
-
metallicity_scale
¶ Property for fiducial metallicity scale. By default is z_sun However, a more advanced subclass might set this differently, or this might change in the future.
-
n_particles
¶ The number of particles tracked in the data set.
-
n_particles_presampled
¶ The number of particles selected, prior to sampling.
-
n_particles_snapshot
¶ The number of star and gas particles in the last snapshot tracked. Should be the same throughout the simulation, if there’s conservation of star and gas particles.
-
n_particles_snapshot_gas
¶ The number of gas particles in the last snapshot tracked.
-
n_particles_snapshot_star
¶ The number of star particles in the last snapshot tracked.
-
n_snaps
¶ Number of snapshots, i.e. data points on the time axis.
-
outer_CGM_boundary
¶ Outer edge of the CGM, defined as config.OUTER_CGM_BOUNDARY * R_vir. A typical value is 1.0 * R_vir
-
ptracks
¶ Object for loading and manipulating ptracks*.hdf5 data
-
r_gal
¶ Galaxy radius in pkpc, as defined by galaxy_cut*galaxy_length_scale, the values of which are stored as parameters in galids*hdf5. A typical value is 4*R_star,0.5
-
r_scale
¶ Property for scale radius.
-
r_vir
¶ Property for virial radius.
-
real_mass_totals
¶ Get the total mass (converted from the sample) in the last snapshot for the classifications used in Angles-Alcazar+2017.
-
redshift
¶ Redshift array for each tracked snapshot.
-
retrieve_halo_data
()¶
-
shift
(data, data_key)¶ Shift or multiply the data by some amount. Note that this is applied after logarithms are applied.
data : data to be shifted data_key : Data key for the parameters to be shifted Parameters are a subdictionary of self.kwargs ‘data_key’ : What data key the data is shifted for
-
snums
¶ Each tracked snapshot.
-
v_c
¶ Property for circular velocity.
-
velocity_scale
¶ Property for fiducial simulation velocity scale.