TimeCourse class¶
Various methods to work with data across a series of snaps (timepoints).
-
class
galaxy.timecourse.TimeCourse(datadir='.', usesql=False)[source]¶ A commection of methods for generating, reading and writing summary data for parameters that change over the timecourse of the simulation.
- These fall into a few groups:
- write_xxx() :
- Methods that loop through the raw data, calculate parameters and write the results to file. Can be slow (hours) to run but Only run once. See the data folder for the resulting files, one line per snap.
- read_xxx_file()` :
- Read in the summary files and return a numpy array. These rely on the generic read_file() method.
- read_xxx_db() :
- Get the summary data from postgres instead of a text file. The returned array should be identical to the read_xxx_file() group.
- write_db_tables() :
- Read a text file, insert the contents to a postgres table.
- get_one_com() :
- Convenience method to return a single CoM position.
-
write_com_ang_mom(galname, start=0, end=801, n=5, show_progress=True)[source]¶ Function that loops over all the desired snapshots to compute the COM pos and vel as a function of time.
- inputs:
- galname (str):
- ‘MW’, ‘M31’ or ‘M33’
- start, end (int):
- first and last snap numbers to include
- n (int):
- stride length for the sequence
- datadir (str):
- path to the input data
- show_progress (bool):
- prints each snap number as it is processed
- returns:
- Two text files saved to disk.
-
write_total_com(start=0, end=801, n=1, show_progress=True)[source]¶ Function that loops over all the desired snapshots to compute the overall COM pos and vel as a function of time. Uses all particles in all galaxies.
- inputs:
- start, end (int):
- first and last snap numbers to include
- n (int):
- stride length for the sequence
- show_progress (bool):
- prints each snap number as it is processed
- output:
- Text file saved to disk.
-
write_total_angmom(start=0, end=801, n=1, show_progress=True)[source]¶ Function that loops over all the desired snapshots to compute the overall angular momentum as a function of time. Uses all particles in all galaxies.
- inputs:
- start, end (int):
- first and last snap numbers to include
- n (int):
- stride length for the sequence
- show_progress (bool):
- prints each snap number as it is processed
- output:
- Text file saved to disk.
-
write_vel_disp(galname, start=0, end=801, n=1, show_progress=True)[source]¶ Function that loops over all the desired snapshots to compute the veocity dispersion sigma as a function of time.
- inputs:
- galname (str):
- ‘MW’, ‘M31’ or ‘M33’
- start, end (int):
- first and last snap numbers to include
- n (int):
- stride length for the sequence
- datadir (str):
- path to the input data
- show_progress (bool):
- prints each snap number as it is processed
- returns:
- Text file saved to disk.
-
write_LG_normal(start=0, end=801)[source]¶ Calculates the normal to a plane containing the three galaxy CoMs.
- Args:
- start, end (int):
- first and last snap numbers to include
- output:
- Text file saved to disk.
-
read_file(fullname)[source]¶ General method for file input. Note that the format is for summary files, (one line per snap), not the raw per-particle files.
-
read_com_file(galaxy, datadir='.')[source]¶ Get CoM summary from file.
- Args:
- galaxy (str):
- ‘MW’, ‘M31’, ‘M33’
- datadir (str):
- path to file
- Returns:
- np.array with 802 rows, one per snap
-
read_angmom_file(galaxy, datadir='.')[source]¶ Get CoM summary from file.
- Args:
- galaxy (str):
- ‘MW’, ‘M31’, ‘M33’
- datadir (str):
- path to file
- Returns:
- np.array with 802 rows, one per snap
-
read_total_com_file(datadir='.')[source]¶ Get CoM summary from file.
- Args:
- datadir (str):
- path to file
- Returns:
- np.array with 802 rows, one per snap
-
read_normals_file(datadir='.')[source]¶ Get normals to plane containing 3 galaxy CoMs from file.
- Args:
- datadir (str):
- path to file
- Returns:
- np.array with 802 rows, one per snap
-
read_relmotion_file(datadir='.')[source]¶ Get relative CoM distances/velocities from file.
- Args:
- datadir (str):
- path to file
- Returns:
- np.array with 802 rows, one per snap
-
write_db_tables(datadir='.', do_com=False, do_angmom=False, do_totalcom=False, do_totalangmom=False, do_normals=False, do_sigmas=False, do_relmotion=False)[source]¶ Adds data to the various tables in the galaxy database
-
read_com_db(galaxy=None, snaprange=(0, 801))[source]¶ Retrieves CoM positions from postgres for a range of snaps.
- Args:
- galaxy (str):
- Optional, defaults to all. Can be ‘MW’, ‘M31’ , ‘M33’
- snaprange (pair of ints):
- Optional, defaults to all. First and last snap to include. This is NOT the [first, last+1] convention of Python.
-
read_angmom_db(galaxy=None, snaprange=(0, 801))[source]¶ Retrieves disk angular momentum from postgres for a range of snaps.
- Args:
- galaxy (str):
- Optional, defaults to all. Can be ‘MW, ‘M31 , ‘M33’
- snaprange (pair of ints):
- Optional, defaults to all. First and last snap to include. This is NOT the [first, last+1] convention of Python.
-
read_total_com_db(snaprange=(0, 801))[source]¶ Retrieves total CoM positions from postgres for a range of snaps.
- Args:
- snaprange (pair of ints):
- Optional, defaults to all. First and last snap to include. This is NOT the [first, last+1] convention of Python.
-
get_one_com(gal, snap)[source]¶ Gets a CoM from postgres for the specified galaxy and snap.
- Args:
- gal (str):
- Can be ‘MW, ‘M31 , ‘M33’
- snap (int):
- The timepoint.
-
read_total_angmom_db(snaprange=(0, 801))[source]¶ Gets the total angular momentum of the 3-galaxy system. In practice, this turns out to be near-zero at all timepoints and can be ignored in future work.
-
read_sigmas_db(galaxy=None, snaprange=(0, 801))[source]¶ Gets the velocity dispersions (km/s) for one galaxy at a range of snaps.