linefinder.analyze_data.ptracks module

Tools for reading worldline data

@author: Zach Hafen @contact: zachary.h.hafen@gmail.com @status: Development

class linefinder.analyze_data.ptracks.PTracks(data_dir, tag, ahf_index=None, *args, **kwargs)[source]

Bases: galaxy_dive.analyze_data.simulation_data.TimeData

Loads and analyzes data created by galaxy_link.py

add_hubble_flow()

Correct for hubble flow movement.

Modifies:
self.data[‘V’] : Accounts for hubble flow, relative to origin
base_data_shape

Property for simulation redshift.

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_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_metal_mass()

Calculate the metal mass held by each resolution element.

Modifies:
self.data[‘enriched_metal_mass’] (array-like):
Metal mass from enrichment.
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_time_as_classification(data_key)
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
get_data(data_key, sl=None)

Get the data from within the class. Only for getting the data. No post-processing or changing the data (putting it in particular units, etc.) The idea is to calculate necessary quantities as the need arises, hence a whole function for getting the data.

Parameters:
  • data_key (str) – Key in the data dictionary for the key we want to get
  • sl (slice) – Slice of the data, if requested.
Returns:

Requested data.

Return type:

data (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_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, sl=None, smooth_data=False, smoothing_window_length=9, smoothing_polyorder=3, a_power=None, scale_key=None, scale_a_power=None, scale_h_power=None, tile_data=False, tile_dim='auto', *args, **kwargs)

Modified method for getting processed method. For the most part is equivalent to calling the method of the parent class, but is also capable of scaling the retrieved data by a column from the halo data.

Parameters:
  • data_key (str) – What to get out?
  • sl (slice) – Slice of the data, if requested.
  • smooth_data (bool) – If True, smooth the data.
  • smoothing_polyorder (smoothing_window_length,) – Arguments for how to smooth the data.
  • scale_key (str) – Halo data entry by which to divide the data by.
  • scale_a_power (float) – The halo data that we are scaling processed_data by will be multiplied by a to this power. Useful for data in cosmological units (as is often normal).
  • scale_h_power (float) – The halo data that we are scaling processed_data by will be multiplied by the hubble parameter to this power. Useful for data in cosmological units (as is often normal).
  • tile_data (bool) – If True, tile data along a given direction. This is usually for data formatting purposes.
  • tile_dim (str) –

    If the data is tiled, what dimension of the data should match? Options:

    ’auto’ :
    Tiles according to data size.
    ’match_snaps’ :
    The data is tiled such that the new shape is (self.n_snaps, data_size).
    ’match_particles’ :
    The data is tiled such that the new shape is (data_size, self.n_particles).
  • **kwargs (*args,) –

    Passed to SimulationData.get_processed_data.

Returns:

Requested data array.

Return type:

processed_data (array-like)

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_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 used.

handle_data_key_error(data_key)

When get_data() fails to data_key in self.data, it passes the data_key to try and generate that data.

Parameters:data_key (str) – Key to try and generate data for
Modifies:
self.data[data_key] (np.array) : If it finds a function to generate the data, it will do so
hubble_param
hubble_z

Property for the hubble function at specified redshift.

iterate_over_method(method_str, iter_arg, iter_values, method_args)

Iterate over a specified method, and get the results out.

Parameters:
  • method_str (str) – Which method to use.
  • iter_arg (str) – Which argument of the method to iterate over.
  • iter_values (list of values) – Which values to change.
  • method_args (dict) – Default args to pass to the method
Returns:

[ method( **used_args ) for used_args in all_variations_of_used_args ]

Return type:

results (list)

length_scale

Property for fiducial simulation length scale.

mask_data(*args, **kwargs)

Wrapper for masking data.

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

Number of snapshots, i.e. data points on the time axis.

n_snaps

Number of snapshots, i.e. data points on the time axis.

r_scale

Property for scale radius.

r_vir

Property for virial radius.

redshift

Property for simulation redshift.

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

snum
snums
v_c

Property for circular velocity.

velocity_scale

Property for fiducial simulation velocity scale.