paicos package
Subpackages
- paicos.cython package
- paicos.derived_variables package
- Submodules
- paicos.derived_variables.derived_variables module
- paicos.derived_variables.derived_variables_gas module
Current()Diameters()Enstrophy()EnstrophyTimesMasses()GFM_MetallicityTimesMasses()MachnumberTimesEnergyDissipation()MagneticCurvature()MagneticFieldSquared()MagneticFieldSquaredTimesVolume()MagneticFieldStrength()MeanMolecularWeight()NumberDensity()Pressure()PressureTimesVolume()Temperatures()TemperaturesTimesMasses()VelocityCurvature()VelocityMagnitude()Volume()
- Module contents
- paicos.histograms package
- paicos.image_creators package
- Submodules
- paicos.image_creators.gpu_ray_projector module
- paicos.image_creators.gpu_sph_projector module
- paicos.image_creators.image_creator module
ImageCreatorImageCreator.__init__()ImageCreator.areaImageCreator.area_per_pixelImageCreator.centerImageCreator.centered_extentImageCreator.depthImageCreator.do_unit_consistency_check()ImageCreator.double_resolution()ImageCreator.extentImageCreator.half_resolution()ImageCreator.heightImageCreator.info()ImageCreator.move_center_along_normal_vector()ImageCreator.move_center_along_perp_vector1()ImageCreator.move_center_along_perp_vector2()ImageCreator.npixImageCreator.npix_heightImageCreator.npix_widthImageCreator.parttypeImageCreator.reset_center()ImageCreator.volumeImageCreator.volume_per_pixelImageCreator.widthImageCreator.width_xImageCreator.width_yImageCreator.width_zImageCreator.widthsImageCreator.x_cImageCreator.y_cImageCreator.z_cImageCreator.zoom()
- paicos.image_creators.image_creator_actions module
ActionsActions.change_snapnum()Actions.create_log()Actions.depth()Actions.double_resolution()Actions.expand_log()Actions.half_resolution()Actions.height()Actions.make_image_creator()Actions.move_center()Actions.move_center_sim_coordinates()Actions.mylogger()Actions.next_actionActions.previous_actionActions.read_log()Actions.reset_center()Actions.resume_from_image()Actions.resume_from_waypoint()Actions.rotate_around_normal_vector()Actions.rotate_around_perp_vector1()Actions.rotate_around_perp_vector2()Actions.step()Actions.width()Actions.zoom()
find_angle_subdivisions()find_zoom_sub_divisions()
- paicos.image_creators.nested_projector module
- paicos.image_creators.projector module
- paicos.image_creators.ray_projector module
- paicos.image_creators.slicer module
- paicos.image_creators.tree_projector module
- Module contents
- paicos.readers package
- Submodules
- paicos.readers.arepo_catalog module
- paicos.readers.arepo_snap module
- paicos.readers.generic_snap module
- paicos.readers.paicos_readers module
Histogram2DReaderImageReaderPaicosReaderPaicosReader.__init__()PaicosReader.aPaicosReader.agePaicosReader.find_unit()PaicosReader.get_adiabiatic_index()PaicosReader.get_age()PaicosReader.get_lookback_time()PaicosReader.get_paicos_quantity()PaicosReader.hPaicosReader.lengthPaicosReader.load_data()PaicosReader.lookback_timePaicosReader.massPaicosReader.rho_crit()PaicosReader.timePaicosReader.unit_quantity()PaicosReader.uq()PaicosReader.velocityPaicosReader.z
- Module contents
- paicos.trees package
- paicos.writers package
Submodules
paicos.misc module
paicos.orientation module
- class paicos.orientation.Orientation(normal_vector=None, perp_vector1=None)
Bases:
objectThe Orientation class is used to define an orientation of e.g. an image. An instance of this class can be passed to an ImageCreator.
- __init__(normal_vector=None, perp_vector1=None)
- Parameters:
normal_vector – a vector which will be normal to the face of the image, i.e. the depth direction. You can e.g. pass the angular momentum vector of a galaxy for a face on projection.
perp_vector1 – a vector which will be parallel to the image plane. This will become the horizontal direction of your image. You can e.g. pass the angular momentum vector here for an edge-on projection.
It’s possible to supply both inputs, which then fully determines the orientation (the vertical direction of the image, perp_vector2, is automatically calculated).
- property cartesian_unit_vectors
The x, y, and z unit vectors in the Orientation given in terms of their components in the original simulation coordinate system.
- property copy
Returns a copy of the current Orientation instance.
- property inverse_rotation_matrix
An inverse rotation matrix, which rotates from the Orientation system into a standard xyz coordinate system. We have the following properties:
np.matmul(inverse_rotation_matrix, perp_vector1) = [1, 0, 0] np.matmul(inverse_rotation_matrix, perp_vector2) = [0, 1, 0] np.matmul(inverse_rotation_matrix, normal_vector) = [0, 0, 1]
The use case for the inverse rotation matrix is to transform Arepo data into a coordinate system where the perp_vector1 direction is in the x-direction, the perp_vector2 direction is in the y-direction and the normal_vector is in the z-direction.
- rotate_around_normal_vector(degrees=None, radians=None)
Rotates the orientation instance around its normal_vector.
For a projection image, this is the depth direction.
- rotate_around_perp_vector1(degrees=None, radians=None)
Rotates the orientation instance around its perp_vector1.
For an image, this is the horizontal axis.
- rotate_around_perp_vector2(degrees=None, radians=None)
Rotates the orientation instance around its perp_vector2.
For an image, this is the vertical axis.
- rotate_around_x(degrees=None, radians=None)
Rotates the orientation instance around the ‘x’-coordinate axis
- rotate_around_y(degrees=None, radians=None)
Rotates the orientation instance around the ‘y’-coordinate axis
- rotate_around_z(degrees=None, radians=None)
Rotates the orientation instance around the ‘z’-coordinate axis
- property rotation_matrix
This rotation matrix rotates the standard cartesian unit vectors:
ex = [1, 0, 0] ey = [0, 1, 0] ez = [0, 0, 1]
into the cartesian coordinate system defined by the three unit vectors:
perp_vector1 perp_vector2 normal_vector
which can also be accessed through the cartesian_unit_vectors method.
That is, the following equality holds:
perp_vector1 = np.matmul(rotation_matrix, [1, 0, 0]) perp_vector2 = np.matmul(rotation_matrix, [0, 1, 0]) normal_vector = np.matmul(rotation_matrix, [0, 0, 1])
paicos.paicos_user_settings_template module
paicos.settings module
paicos.unit_specifications module
paicos.units module
Defines small_a and small_h, conversion to Gauss and eV, and the PaicosQuantity and PaicosTimeSeries classes.
- class paicos.units.PaicosQuantity(value, unit=None, dtype=None, copy=False, order=None, subok=False, ndmin=0, h=None, a=None, comoving_sim=None)
Bases:
QuantityPaicosQuantity is a subclass of the astropy Quantity class which represents a number with some associated unit.
This subclass in addition includes a and h factors used in the definition of comoving variables.
- Parameters:
value (the numeric values of your data (similar to astropy Quantity)) –
a (the cosmological scale factor of your data) –
h (the reduced Hubble parameter, e.g. h = 0.7) –
unit (a string, e.g.
g/cm^3 small_a^-3 small_h^2or an astropy Unit) –The latter can be defined like this:
from paicos import units as pu from astropy import units as u unit = u.g*u.cm**(-3)*small_a**(-3)*small_h**(2)
The naming of small_a and small_h is to avoid conflict with the already existing ‘annum’ (i.e. a year) and ‘h’ (hour) units.
Methods/key properties
- no_small_h
Returns a new comoving quantity where the h-factors have been removed and the numeric value adjusted accordingly.
- to_physical
Returns a new object where both a and h factors have been removed, i.e. we have switched from comoving values to the physical value.
- label
Returns a Latex label for use in plots.
Examples
Here is an example:
units = 'g cm^-3 small_a^-3 small_h^2' A = PaicosQuantity(2, units, h=0.7, a=1/128) # Create a new comoving quantity where the h-factors have been removed B = A.no_small_h # Create a new quantity where both a and h factor have been removed, # i.e. we have switched from a comoving quantity to the physical value C = A.to_physical
- property a
The scale factor.
- adjust_time(a=None, z=None)
Return a PaicosQuantity with its time (i.e. scale factor, a, and redshift, z, set to new values without changing the physical value of the quantity).
Note the difference between this method and the “adjust_time” method!
Use the “adjust_time” method if you want to keep the physical value fixed. Use the “set_time” method if you want to keep the comoving value fixed.
Both are illustrated in the example below:
For instance, we initialize a length of 100 comoving kpc (using a snap object with a = 1)
- In [2]: L = 100 * snap.uq(‘kpc / small_a’)
…: L_fixed_physical = L.adjust_time(a=0.5) …: L_fixed_comoving = L.set_time(a=0.5)
In [3]: L_fixed_physical Out[3]: <PaicosQuantity 50. kpc / small_a>
In [4]: L_fixed_comoving Out[4]: <PaicosQuantity 100. kpc / small_a>
In [5]: L.to_physical Out[5]: <PaicosQuantity 100. kpc>
In [6]: L_fixed_physical.to_physical Out[6]: <PaicosQuantity 100. kpc>
In [7]: L_fixed_comoving.to_physical Out[7]: <PaicosQuantity 200. kpc>
- age(reader_object)
The age of the universe in the simulation.
Requires a reader object as input (e.g. a snap, cat or other instance of Snapshot, Catalog or PaicosReader)
- property arepo
Returns the quantity in Arepo code units.
- property astro
Returns the quantity in typical units used in cosmological simulations
- property astropy_quantity
Returns an astropy Quantity, i.e., the units are retained but we no longer have access to the information about the values of a and h.
- property cgs
Returns a copy of the current PaicosQuantity instance with CGS units. The value of the resulting object will be scaled.
- property comoving_sim
Whether the simulation had ComovingIntegrationOn
- property copy
Returns a copy of the PaicosQuantity.
- property h
The reduced Hubble parameter
- label(variable='')
Return a Latex string for use in plots. The optional input variable could be the Latex symbol for the physical variable, for instance rho or nablatimesvec{v}.
- lookback_time(reader_object)
The lookback time.
Requires a reader object as input (e.g. a snap, cat or other instance of Snapshot, Catalog or PaicosReader)
- property no_small_h
Remove scaling with h, returning a quantity with adjusted values.
- set_time(a=None, z=None)
Return a PaicosQuantity with its time (i.e. scale factor, a, and redshift, z, set to new values while changing the physical value of the quantity).
Note the difference between this method and the “adjust_time” method!
Use the “adjust_time” method if you want to keep the physical value fixed. Use the “set_time” method if you want to keep the comoving value fixed.
Both are illustrated in the example below:
For instance, we initialize a length of 100 comoving kpc (using a snap object with a = 1)
- In [2]: L = 100 * snap.uq(‘kpc / small_a’)
…: L_fixed_physical = L.adjust_time(a=0.5) …: L_fixed_comoving = L.set_time(a=0.5)
In [3]: L_fixed_physical Out[3]: <PaicosQuantity 50. kpc / small_a>
In [4]: L_fixed_comoving Out[4]: <PaicosQuantity 100. kpc / small_a>
In [5]: L.to_physical Out[5]: <PaicosQuantity 100. kpc>
In [6]: L_fixed_physical.to_physical Out[6]: <PaicosQuantity 100. kpc>
In [7]: L_fixed_comoving.to_physical Out[7]: <PaicosQuantity 200. kpc>
- property si
Returns a copy of the current PaicosQuantity instance with SI units. The value of the resulting object will be scaled.
- property time
The time elapsed since the beginning of the simulation.
Only defined for non-comoving simulations.
- to(unit, equivalencies=[], copy=True)
Convert to different units. Similar functionality to the astropy Quantity.to() method.
- to_any(new_unit)
Convert quantity to any (possible) unit.
The .to method only allows converting standard physical units while the .to_comoving only allows modifying the a and h factors. This method allows changing the units in one go.
- to_comoving(unit)
Returns a copy of the current PaicosQuantity instance with the a and h factors given by the input unit.
- property to_physical
Returns a copy of the current PaicosQuantity instance with the a and h factors removed, i.e. transform from comoving to physical. The value of the resulting object is scaled accordingly.
- property unit_quantity
Returns a new PaicosQuantity with the same units as the current PaicosQuantity and a numeric value of 1.
- property uq
A short hand for the ‘unit_quantity’ method.
- property z
The redshift.
- class paicos.units.PaicosTimeSeries(value, unit=None, dtype=None, copy=True, order=None, subok=False, ndmin=0, h=None, a=None, comoving_sim=None)
Bases:
PaicosQuantityPaicosTimeSeries is a subclass of the PaicosQuantity and and shares many of the same methods.
The time series is very similar to the PaicosQuantity but the .a or .time properties now return arrays with same length as the object itself (.shape[0]).
- property copy
Returns a copy of the PaicosTimeSeries.
- to_comoving(unit)
Returns a copy of the current PaicosTimeSeries with the a and h factors given by the input unit.
- property to_physical
Returns a copy of the current PaicosTimeSeries instance with the a and h factors removed, i.e. transform from comoving to physical. The value of the resulting object is scaled accordingly.
- paicos.units.separate_units(unit)
Separates the standard physical units (u_unit) from the units involving a and h (pu_unit). That is:
u_unit, pu_unit = separate_units(unit)
where pu_unit contains small_a and small_h and u_unit contains everything else such that:
unit = u_unit * pu_unit
paicos.util module
Defines a few useful functions and most importantly, the low level hdf5 reader and writer. It also serves as a placeholder for variables that can be changed via user functions.
- paicos.util.conditional_timer(func)
- paicos.util.get_index_of_cubic_region(pos, center, widths, box)
Get a boolean array to the position array, pos, which are inside a cubic region.
- Parameters:
pos (array) – position array with dimensions = (n, 3)
center (array with length 3) – The center of the box (x, y, z).
widths (array with length 3) – The widths of the box.
box (float) – The box size of the simulation (e.g. snap.box).
- paicos.util.get_index_of_cubic_region_plus_thin_layer(pos, center, widths, thickness, box)
Get a boolean array to the position array, pos, which are inside a cubic region plus a thin layer with a cell-dependent thickness
- Parameters:
pos (array) – position array with dimensions = (n, 3)
center (array with length 3) – The center of the box (x, y, z).
widths (array with length 3) – The widths of the box.
thickness (array) – Array with same length as the position array.
box (float) – The box size of the simulation (e.g. snap.box).
- paicos.util.get_index_of_radial_range(pos, center, r_min, r_max)
Get a boolean array of positions, pos, which are inside the spherical shell with inner radius r_min and outer radius r_max, centered at center.
- paicos.util.get_index_of_radial_range_plus_thin_layer(pos, center, r_min, r_max, thickness)
Get a boolean array for the positions, pos, which are inside the spherical shell with inner radius r_min and outer radius r_max, centered at center. The thickness array argument adds a variable thickness, e.g., the cell diameters, so that point close to the selection are also included.
- paicos.util.get_index_of_rotated_cubic_region(pos, center, widths, box, orientation)
Get a boolean array to the position array, pos, which are inside a cubic region
- Parameters:
pos (array) – position array with dimensions = (n, 3)
center (array with length 3) – The center of the box (x, y, z).
widths (array with length 3) – The widths of the box.
thickness (array) – Array with same length as the position array.
box (float) – The box size of the simulation (e.g. snap.box).
- paicos.util.get_index_of_rotated_cubic_region_plus_thin_layer(pos, center, widths, thickness, box, orientation)
Get a boolean array to the position array, pos, which are inside a cubic region plus a thin layer with a cell-dependent thickness
- Parameters:
pos (array) – position array with dimensions = (n, 3)
center (array with length 3) – The center of the box (x, y, z).
widths (array with length 3) – The widths of the box.
thickness (array) – Array with same length as the position array.
box (float) – The box size of the simulation (e.g. snap.box).
- paicos.util.get_project_root_dir()
Returns the root directory of the local Paicos copy.
- paicos.util.load_dataset(hdf5file, name, group=None)
Load dataset, returning a paicos quantity if the attributes contain units and units are enabled.
- paicos.util.remove_astro_units(func)
This is a decorator function that takes in a function and returns a new function that removes any astro units from the function’s arguments and keyword arguments before calling the original function. The decorator checks if the argument or keyword argument has a ‘unit’ attribute and, if so, replaces it with its ‘value’ attribute. This is useful for functions that do not support astro units or need to work with raw values.
- paicos.util.save_dataset(hdf5file, name, data=None, data_attrs={}, group=None, group_attrs={})
Create dataset in open hdf5file ( hdf5file = h5py.File(filename, ‘w’) ) If the data has units then they are saved as an attribute.