repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
varlink/python
varlink/server.py
Server.server_bind
def server_bind(self): """Called by constructor to bind the socket. May be overridden. """ if self.allow_reuse_address: self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.socket.setblocking(True) if not self.listen_fd: self.s...
python
def server_bind(self): """Called by constructor to bind the socket. May be overridden. """ if self.allow_reuse_address: self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.socket.setblocking(True) if not self.listen_fd: self.s...
Called by constructor to bind the socket. May be overridden.
https://github.com/varlink/python/blob/b021a29dd9def06b03416d20e8b37be39c3edd33/varlink/server.py#L443-L463
varlink/python
varlink/server.py
Server.server_close
def server_close(self): """Called to clean-up the server. May be overridden. """ if self.remove_file: try: os.remove(self.remove_file) except: pass self.socket.close()
python
def server_close(self): """Called to clean-up the server. May be overridden. """ if self.remove_file: try: os.remove(self.remove_file) except: pass self.socket.close()
Called to clean-up the server. May be overridden.
https://github.com/varlink/python/blob/b021a29dd9def06b03416d20e8b37be39c3edd33/varlink/server.py#L473-L484
varlink/python
varlink/server.py
Server.shutdown_request
def shutdown_request(self, request): """Called to shutdown and close an individual request.""" try: # explicitly shutdown. socket.close() merely releases # the socket and waits for GC to perform the actual close. request.shutdown(socket.SHUT_RDWR) except: ...
python
def shutdown_request(self, request): """Called to shutdown and close an individual request.""" try: # explicitly shutdown. socket.close() merely releases # the socket and waits for GC to perform the actual close. request.shutdown(socket.SHUT_RDWR) except: ...
Called to shutdown and close an individual request.
https://github.com/varlink/python/blob/b021a29dd9def06b03416d20e8b37be39c3edd33/varlink/server.py#L502-L511
varlink/python
varlink/client.py
Client.open
def open(self, interface_name, namespaced=False, connection=None): """Open a new connection and get a client interface handle with the varlink methods installed. :param interface_name: an interface name, which the service this client object is connected to, provides. ...
python
def open(self, interface_name, namespaced=False, connection=None): """Open a new connection and get a client interface handle with the varlink methods installed. :param interface_name: an interface name, which the service this client object is connected to, provides. ...
Open a new connection and get a client interface handle with the varlink methods installed. :param interface_name: an interface name, which the service this client object is connected to, provides. :param namespaced: If arguments and return values are instances of SimpleN...
https://github.com/varlink/python/blob/b021a29dd9def06b03416d20e8b37be39c3edd33/varlink/client.py#L585-L606
varlink/python
varlink/client.py
Client.get_interfaces
def get_interfaces(self, socket_connection=None): """Returns the a list of Interface objects the service implements.""" if not socket_connection: socket_connection = self.open_connection() close_socket = True else: close_socket = False # noinspection ...
python
def get_interfaces(self, socket_connection=None): """Returns the a list of Interface objects the service implements.""" if not socket_connection: socket_connection = self.open_connection() close_socket = True else: close_socket = False # noinspection ...
Returns the a list of Interface objects the service implements.
https://github.com/varlink/python/blob/b021a29dd9def06b03416d20e8b37be39c3edd33/varlink/client.py#L615-L630
varlink/python
varlink/client.py
Client.add_interface
def add_interface(self, interface): """Manually add or overwrite an interface definition from an Interface object. :param interface: an Interface() object """ if not isinstance(interface, Interface): raise TypeError self._interfaces[interface.name] = interface
python
def add_interface(self, interface): """Manually add or overwrite an interface definition from an Interface object. :param interface: an Interface() object """ if not isinstance(interface, Interface): raise TypeError self._interfaces[interface.name] = interface
Manually add or overwrite an interface definition from an Interface object. :param interface: an Interface() object
https://github.com/varlink/python/blob/b021a29dd9def06b03416d20e8b37be39c3edd33/varlink/client.py#L650-L659
SINGROUP/SOAPLite
utilities/rematch_example.py
rematch_entry
def rematch_entry(envkernel, gamma = 0.1, threshold = 1e-6): """ Compute the global similarity between two structures A and B. It uses the Sinkhorn algorithm as reported in: Phys. Chem. Chem. Phys., 2016, 18, p. 13768 Args: envkernel: NxM matrix of structure A with N and structu...
python
def rematch_entry(envkernel, gamma = 0.1, threshold = 1e-6): """ Compute the global similarity between two structures A and B. It uses the Sinkhorn algorithm as reported in: Phys. Chem. Chem. Phys., 2016, 18, p. 13768 Args: envkernel: NxM matrix of structure A with N and structu...
Compute the global similarity between two structures A and B. It uses the Sinkhorn algorithm as reported in: Phys. Chem. Chem. Phys., 2016, 18, p. 13768 Args: envkernel: NxM matrix of structure A with N and structure B with M atoms gamma: parameter to control between best match ...
https://github.com/SINGROUP/SOAPLite/blob/80e27cc8d5b4c887011542c5a799583bfc6ff643/utilities/rematch_example.py#L15-L59
SINGROUP/SOAPLite
utilities/batchSoapPy.py
create
def create(atoms_list,N, L, cutoff = 0, all_atomtypes=[]): """Takes a trajectory xyz file and writes soap features """ myAlphas, myBetas = genBasis.getBasisFunc(cutoff, N) # get information about feature length n_datapoints = len(atoms_list) atoms = atoms_list[0] x = get_lastatom_soap(atoms,...
python
def create(atoms_list,N, L, cutoff = 0, all_atomtypes=[]): """Takes a trajectory xyz file and writes soap features """ myAlphas, myBetas = genBasis.getBasisFunc(cutoff, N) # get information about feature length n_datapoints = len(atoms_list) atoms = atoms_list[0] x = get_lastatom_soap(atoms,...
Takes a trajectory xyz file and writes soap features
https://github.com/SINGROUP/SOAPLite/blob/80e27cc8d5b4c887011542c5a799583bfc6ff643/utilities/batchSoapPy.py#L21-L44
SINGROUP/SOAPLite
soaplite/getBasis.py
getPoly
def getPoly(rCut, nMax): """Used to calculate discrete vectors for the polynomial basis functions. Args: rCut(float): Radial cutoff nMax(int): Number of polynomial radial functions """ rCutVeryHard = rCut+5.0 rx = 0.5*rCutVeryHard*(x + 1) basisFunctions = [] for i in range(...
python
def getPoly(rCut, nMax): """Used to calculate discrete vectors for the polynomial basis functions. Args: rCut(float): Radial cutoff nMax(int): Number of polynomial radial functions """ rCutVeryHard = rCut+5.0 rx = 0.5*rCutVeryHard*(x + 1) basisFunctions = [] for i in range(...
Used to calculate discrete vectors for the polynomial basis functions. Args: rCut(float): Radial cutoff nMax(int): Number of polynomial radial functions
https://github.com/SINGROUP/SOAPLite/blob/80e27cc8d5b4c887011542c5a799583bfc6ff643/soaplite/getBasis.py#L303-L342
SINGROUP/SOAPLite
soaplite/core.py
_format_ase2clusgeo
def _format_ase2clusgeo(obj, all_atomtypes=None): """ Takes an ase Atoms object and returns numpy arrays and integers which are read by the internal clusgeo. Apos is currently a flattened out numpy array Args: obj(): all_atomtypes(): sort(): """ #atoms metadata total...
python
def _format_ase2clusgeo(obj, all_atomtypes=None): """ Takes an ase Atoms object and returns numpy arrays and integers which are read by the internal clusgeo. Apos is currently a flattened out numpy array Args: obj(): all_atomtypes(): sort(): """ #atoms metadata total...
Takes an ase Atoms object and returns numpy arrays and integers which are read by the internal clusgeo. Apos is currently a flattened out numpy array Args: obj(): all_atomtypes(): sort():
https://github.com/SINGROUP/SOAPLite/blob/80e27cc8d5b4c887011542c5a799583bfc6ff643/soaplite/core.py#L11-L44
SINGROUP/SOAPLite
soaplite/core.py
_get_supercell
def _get_supercell(obj, rCut=5.0): rCutHard = rCut + 5 # Giving extra space for hard cutOff """ Takes atoms object (with a defined cell) and a radial cutoff. Returns a supercell centered around the original cell generously extended to contain all spheres with the given radial cutoff centered around...
python
def _get_supercell(obj, rCut=5.0): rCutHard = rCut + 5 # Giving extra space for hard cutOff """ Takes atoms object (with a defined cell) and a radial cutoff. Returns a supercell centered around the original cell generously extended to contain all spheres with the given radial cutoff centered around...
Takes atoms object (with a defined cell) and a radial cutoff. Returns a supercell centered around the original cell generously extended to contain all spheres with the given radial cutoff centered around the original atoms.
https://github.com/SINGROUP/SOAPLite/blob/80e27cc8d5b4c887011542c5a799583bfc6ff643/soaplite/core.py#L47-L77
SINGROUP/SOAPLite
soaplite/core.py
get_soap_locals
def get_soap_locals(obj, Hpos, alp, bet, rCut=5.0, nMax=5, Lmax=5, crossOver=True, all_atomtypes=None, eta=1.0): """Get the RBF basis SOAP output for the given positions in a finite system. Args: obj(ase.Atoms): Atomic structure for which the SOAP output is calculated. Hpos: Positio...
python
def get_soap_locals(obj, Hpos, alp, bet, rCut=5.0, nMax=5, Lmax=5, crossOver=True, all_atomtypes=None, eta=1.0): """Get the RBF basis SOAP output for the given positions in a finite system. Args: obj(ase.Atoms): Atomic structure for which the SOAP output is calculated. Hpos: Positio...
Get the RBF basis SOAP output for the given positions in a finite system. Args: obj(ase.Atoms): Atomic structure for which the SOAP output is calculated. Hpos: Positions at which to calculate SOAP alp: Alphas bet: Betas rCut: Radial cutoff. nMax: Maximum ...
https://github.com/SINGROUP/SOAPLite/blob/80e27cc8d5b4c887011542c5a799583bfc6ff643/soaplite/core.py#L80-L169
SINGROUP/SOAPLite
soaplite/core.py
get_soap_structure
def get_soap_structure(obj, alp, bet, rCut=5.0, nMax=5, Lmax=5, crossOver=True, all_atomtypes=None, eta=1.0): """Get the RBF basis SOAP output for atoms in a finite structure. Args: obj(ase.Atoms): Atomic structure for which the SOAP output is calculated. alp: Alphas bet: Be...
python
def get_soap_structure(obj, alp, bet, rCut=5.0, nMax=5, Lmax=5, crossOver=True, all_atomtypes=None, eta=1.0): """Get the RBF basis SOAP output for atoms in a finite structure. Args: obj(ase.Atoms): Atomic structure for which the SOAP output is calculated. alp: Alphas bet: Be...
Get the RBF basis SOAP output for atoms in a finite structure. Args: obj(ase.Atoms): Atomic structure for which the SOAP output is calculated. alp: Alphas bet: Betas rCut: Radial cutoff. nMax: Maximum nmber of radial basis functions Lmax: Maximum spherica...
https://github.com/SINGROUP/SOAPLite/blob/80e27cc8d5b4c887011542c5a799583bfc6ff643/soaplite/core.py#L172-L195
SINGROUP/SOAPLite
soaplite/core.py
get_periodic_soap_locals
def get_periodic_soap_locals(obj, Hpos, alp, bet, rCut=5.0, nMax=5, Lmax=5, crossOver=True, all_atomtypes=None, eta=1.0): """Get the RBF basis SOAP output for the given position in a periodic system. Args: obj(ase.Atoms): Atomic structure for which the SOAP output is calculated. alp...
python
def get_periodic_soap_locals(obj, Hpos, alp, bet, rCut=5.0, nMax=5, Lmax=5, crossOver=True, all_atomtypes=None, eta=1.0): """Get the RBF basis SOAP output for the given position in a periodic system. Args: obj(ase.Atoms): Atomic structure for which the SOAP output is calculated. alp...
Get the RBF basis SOAP output for the given position in a periodic system. Args: obj(ase.Atoms): Atomic structure for which the SOAP output is calculated. alp: Alphas bet: Betas rCut: Radial cutoff. nMax: Maximum nmber of radial basis functions Lmax: Maxi...
https://github.com/SINGROUP/SOAPLite/blob/80e27cc8d5b4c887011542c5a799583bfc6ff643/soaplite/core.py#L198-L221
SINGROUP/SOAPLite
utilities/get_sitecenteredsoap_from_structures.py
get_nnsoap
def get_nnsoap(obj, first_shell, alphas, betas, rcut=6, nmax=10, lmax=9, all_atomtypes=[]): """Takes cluster structure and nearest neighbour information of a datapoint, Returns concatenated soap vectors for each nearest neighbour (up to 3). Top, bridge, hollow fill the initial zero soap vector from left...
python
def get_nnsoap(obj, first_shell, alphas, betas, rcut=6, nmax=10, lmax=9, all_atomtypes=[]): """Takes cluster structure and nearest neighbour information of a datapoint, Returns concatenated soap vectors for each nearest neighbour (up to 3). Top, bridge, hollow fill the initial zero soap vector from left...
Takes cluster structure and nearest neighbour information of a datapoint, Returns concatenated soap vectors for each nearest neighbour (up to 3). Top, bridge, hollow fill the initial zero soap vector from left to right.
https://github.com/SINGROUP/SOAPLite/blob/80e27cc8d5b4c887011542c5a799583bfc6ff643/utilities/get_sitecenteredsoap_from_structures.py#L57-L82
SINGROUP/SOAPLite
utilities/get_sitecenteredsoap_from_structures.py
get_sitecenteredsoap
def get_sitecenteredsoap(obj, first_shell, alphas, betas, rcut=6, nmax=10, lmax=9, all_atomtypes=[]): """Takes cluster structure and nearest neighbour information of a datapoint, Returns concatenated soap vectors for each nearest neighbour (up to 3). Top, bridge, hollow fill the initial zero soap vector...
python
def get_sitecenteredsoap(obj, first_shell, alphas, betas, rcut=6, nmax=10, lmax=9, all_atomtypes=[]): """Takes cluster structure and nearest neighbour information of a datapoint, Returns concatenated soap vectors for each nearest neighbour (up to 3). Top, bridge, hollow fill the initial zero soap vector...
Takes cluster structure and nearest neighbour information of a datapoint, Returns concatenated soap vectors for each nearest neighbour (up to 3). Top, bridge, hollow fill the initial zero soap vector from left to right.
https://github.com/SINGROUP/SOAPLite/blob/80e27cc8d5b4c887011542c5a799583bfc6ff643/utilities/get_sitecenteredsoap_from_structures.py#L84-L99
adrn/gala
gala/dynamics/orbit.py
Orbit.w
def w(self, units=None): """ This returns a single array containing the phase-space positions. Parameters ---------- units : `~gala.units.UnitSystem` (optional) The unit system to represent the position and velocity in before combining into the full array...
python
def w(self, units=None): """ This returns a single array containing the phase-space positions. Parameters ---------- units : `~gala.units.UnitSystem` (optional) The unit system to represent the position and velocity in before combining into the full array...
This returns a single array containing the phase-space positions. Parameters ---------- units : `~gala.units.UnitSystem` (optional) The unit system to represent the position and velocity in before combining into the full array. Returns ------- w ...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/orbit.py#L142-L166
adrn/gala
gala/dynamics/orbit.py
Orbit.represent_as
def represent_as(self, new_pos, new_vel=None): """ Represent the position and velocity of the orbit in an alternate coordinate system. Supports any of the Astropy coordinates representation classes. Parameters ---------- new_pos : :class:`~astropy.coordinates.Bas...
python
def represent_as(self, new_pos, new_vel=None): """ Represent the position and velocity of the orbit in an alternate coordinate system. Supports any of the Astropy coordinates representation classes. Parameters ---------- new_pos : :class:`~astropy.coordinates.Bas...
Represent the position and velocity of the orbit in an alternate coordinate system. Supports any of the Astropy coordinates representation classes. Parameters ---------- new_pos : :class:`~astropy.coordinates.BaseRepresentation` The type of representation to generate...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/orbit.py#L171-L195
adrn/gala
gala/dynamics/orbit.py
Orbit.to_hdf5
def to_hdf5(self, f): """ Serialize this object to an HDF5 file. Requires ``h5py``. Parameters ---------- f : str, :class:`h5py.File` Either the filename or an open HDF5 file. """ f = super(Orbit, self).to_hdf5(f) if self.potential ...
python
def to_hdf5(self, f): """ Serialize this object to an HDF5 file. Requires ``h5py``. Parameters ---------- f : str, :class:`h5py.File` Either the filename or an open HDF5 file. """ f = super(Orbit, self).to_hdf5(f) if self.potential ...
Serialize this object to an HDF5 file. Requires ``h5py``. Parameters ---------- f : str, :class:`h5py.File` Either the filename or an open HDF5 file.
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/orbit.py#L214-L236
adrn/gala
gala/dynamics/orbit.py
Orbit.from_hdf5
def from_hdf5(cls, f): """ Load an object from an HDF5 file. Requires ``h5py``. Parameters ---------- f : str, :class:`h5py.File` Either the filename or an open HDF5 file. """ # TODO: this is duplicated code from PhaseSpacePosition if...
python
def from_hdf5(cls, f): """ Load an object from an HDF5 file. Requires ``h5py``. Parameters ---------- f : str, :class:`h5py.File` Either the filename or an open HDF5 file. """ # TODO: this is duplicated code from PhaseSpacePosition if...
Load an object from an HDF5 file. Requires ``h5py``. Parameters ---------- f : str, :class:`h5py.File` Either the filename or an open HDF5 file.
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/orbit.py#L239-L292
adrn/gala
gala/dynamics/orbit.py
Orbit.orbit_gen
def orbit_gen(self): """ Generator for iterating over each orbit. """ if self.norbits == 1: yield self else: for i in range(self.norbits): yield self[:, i]
python
def orbit_gen(self): """ Generator for iterating over each orbit. """ if self.norbits == 1: yield self else: for i in range(self.norbits): yield self[:, i]
Generator for iterating over each orbit.
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/orbit.py#L294-L303
adrn/gala
gala/dynamics/orbit.py
Orbit.potential_energy
def potential_energy(self, potential=None): r""" The potential energy *per unit mass*: .. math:: E_\Phi = \Phi(\boldsymbol{q}) Returns ------- E : :class:`~astropy.units.Quantity` The potential energy. """ if self.hamiltonian is ...
python
def potential_energy(self, potential=None): r""" The potential energy *per unit mass*: .. math:: E_\Phi = \Phi(\boldsymbol{q}) Returns ------- E : :class:`~astropy.units.Quantity` The potential energy. """ if self.hamiltonian is ...
r""" The potential energy *per unit mass*: .. math:: E_\Phi = \Phi(\boldsymbol{q}) Returns ------- E : :class:`~astropy.units.Quantity` The potential energy.
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/orbit.py#L309-L328
adrn/gala
gala/dynamics/orbit.py
Orbit.energy
def energy(self, hamiltonian=None): r""" The total energy *per unit mass*: Returns ------- E : :class:`~astropy.units.Quantity` The total energy. """ if self.hamiltonian is None and hamiltonian is None: raise ValueError("To compute the to...
python
def energy(self, hamiltonian=None): r""" The total energy *per unit mass*: Returns ------- E : :class:`~astropy.units.Quantity` The total energy. """ if self.hamiltonian is None and hamiltonian is None: raise ValueError("To compute the to...
r""" The total energy *per unit mass*: Returns ------- E : :class:`~astropy.units.Quantity` The total energy.
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/orbit.py#L330-L360
adrn/gala
gala/dynamics/orbit.py
Orbit._max_helper
def _max_helper(self, arr, approximate=False, interp_kwargs=None, minimize_kwargs=None): """ Helper function for computing extrema (apocenter, pericenter, z_height) and times of extrema. Parameters ---------- arr : `numpy.ndarray` """ ...
python
def _max_helper(self, arr, approximate=False, interp_kwargs=None, minimize_kwargs=None): """ Helper function for computing extrema (apocenter, pericenter, z_height) and times of extrema. Parameters ---------- arr : `numpy.ndarray` """ ...
Helper function for computing extrema (apocenter, pericenter, z_height) and times of extrema. Parameters ---------- arr : `numpy.ndarray`
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/orbit.py#L362-L407
adrn/gala
gala/dynamics/orbit.py
Orbit.pericenter
def pericenter(self, return_times=False, func=np.mean, interp_kwargs=None, minimize_kwargs=None, approximate=False): """ Estimate the pericenter(s) of the orbit by identifying local minima in the spherical radius and interpolating between timesteps near the ...
python
def pericenter(self, return_times=False, func=np.mean, interp_kwargs=None, minimize_kwargs=None, approximate=False): """ Estimate the pericenter(s) of the orbit by identifying local minima in the spherical radius and interpolating between timesteps near the ...
Estimate the pericenter(s) of the orbit by identifying local minima in the spherical radius and interpolating between timesteps near the minima. By default, this returns the mean of all local minima (pericenters). To get, e.g., the minimum pericenter, pass in ``func=np.min``. To get ...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/orbit.py#L422-L484
adrn/gala
gala/dynamics/orbit.py
Orbit.zmax
def zmax(self, return_times=False, func=np.mean, interp_kwargs=None, minimize_kwargs=None, approximate=False): """ Estimate the maximum ``z`` height of the orbit by identifying local maxima in the absolute value of the ``z`` position and interpolating between ti...
python
def zmax(self, return_times=False, func=np.mean, interp_kwargs=None, minimize_kwargs=None, approximate=False): """ Estimate the maximum ``z`` height of the orbit by identifying local maxima in the absolute value of the ``z`` position and interpolating between ti...
Estimate the maximum ``z`` height of the orbit by identifying local maxima in the absolute value of the ``z`` position and interpolating between timesteps near the maxima. By default, this returns the mean of all local maxima. To get, e.g., the largest ``z`` excursion, pass in ``func=np...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/orbit.py#L550-L612
adrn/gala
gala/dynamics/orbit.py
Orbit.eccentricity
def eccentricity(self, **kw): r""" Returns the eccentricity computed from the mean apocenter and mean pericenter. .. math:: e = \frac{r_{\rm apo} - r_{\rm per}}{r_{\rm apo} + r_{\rm per}} Parameters ---------- **kw Any keyword arguments ...
python
def eccentricity(self, **kw): r""" Returns the eccentricity computed from the mean apocenter and mean pericenter. .. math:: e = \frac{r_{\rm apo} - r_{\rm per}}{r_{\rm apo} + r_{\rm per}} Parameters ---------- **kw Any keyword arguments ...
r""" Returns the eccentricity computed from the mean apocenter and mean pericenter. .. math:: e = \frac{r_{\rm apo} - r_{\rm per}}{r_{\rm apo} + r_{\rm per}} Parameters ---------- **kw Any keyword arguments passed to ``apocenter()`` and ...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/orbit.py#L614-L637
adrn/gala
gala/dynamics/orbit.py
Orbit.estimate_period
def estimate_period(self, radial=True): """ Estimate the period of the orbit. By default, computes the radial period. If ``radial==False``, this returns period estimates for each dimension of the orbit. Parameters ---------- radial : bool (optional) W...
python
def estimate_period(self, radial=True): """ Estimate the period of the orbit. By default, computes the radial period. If ``radial==False``, this returns period estimates for each dimension of the orbit. Parameters ---------- radial : bool (optional) W...
Estimate the period of the orbit. By default, computes the radial period. If ``radial==False``, this returns period estimates for each dimension of the orbit. Parameters ---------- radial : bool (optional) What period to estimate. If ``True``, estimates the radial ...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/orbit.py#L639-L675
adrn/gala
gala/dynamics/orbit.py
Orbit.circulation
def circulation(self): """ Determine which axes the Orbit circulates around by checking whether there is a change of sign of the angular momentum about an axis. Returns a 2D array with ``ndim`` integers per orbit point. If a box orbit, all integers will be 0. A 1 indicates ...
python
def circulation(self): """ Determine which axes the Orbit circulates around by checking whether there is a change of sign of the angular momentum about an axis. Returns a 2D array with ``ndim`` integers per orbit point. If a box orbit, all integers will be 0. A 1 indicates ...
Determine which axes the Orbit circulates around by checking whether there is a change of sign of the angular momentum about an axis. Returns a 2D array with ``ndim`` integers per orbit point. If a box orbit, all integers will be 0. A 1 indicates circulation about the corresponding axis....
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/orbit.py#L680-L731
adrn/gala
gala/dynamics/orbit.py
Orbit.align_circulation_with_z
def align_circulation_with_z(self, circulation=None): """ If the input orbit is a tube orbit, this function aligns the circulation axis with the z axis and returns a copy. Parameters ---------- circulation : array_like (optional) Array of bits that specify th...
python
def align_circulation_with_z(self, circulation=None): """ If the input orbit is a tube orbit, this function aligns the circulation axis with the z axis and returns a copy. Parameters ---------- circulation : array_like (optional) Array of bits that specify th...
If the input orbit is a tube orbit, this function aligns the circulation axis with the z axis and returns a copy. Parameters ---------- circulation : array_like (optional) Array of bits that specify the axis about which the orbit circulates. If not provided, will...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/orbit.py#L733-L800
adrn/gala
gala/dynamics/orbit.py
Orbit.to_frame
def to_frame(self, frame, current_frame=None, **kwargs): """ TODO: Parameters ---------- frame : `gala.potential.CFrameBase` The frame to transform to. current_frame : `gala.potential.CFrameBase` (optional) If the Orbit has no associated Hamiltoni...
python
def to_frame(self, frame, current_frame=None, **kwargs): """ TODO: Parameters ---------- frame : `gala.potential.CFrameBase` The frame to transform to. current_frame : `gala.potential.CFrameBase` (optional) If the Orbit has no associated Hamiltoni...
TODO: Parameters ---------- frame : `gala.potential.CFrameBase` The frame to transform to. current_frame : `gala.potential.CFrameBase` (optional) If the Orbit has no associated Hamiltonian, this specifies the current frame of the orbit. Retur...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/orbit.py#L885-L916
adrn/gala
gala/coordinates/greatcircle.py
greatcircle_to_greatcircle
def greatcircle_to_greatcircle(from_greatcircle_coord, to_greatcircle_frame): """Transform between two greatcircle frames.""" # This transform goes through the parent frames on each side. # from_frame -> from_frame.origin -> to_frame.origin -> to_frame intermediate_from =...
python
def greatcircle_to_greatcircle(from_greatcircle_coord, to_greatcircle_frame): """Transform between two greatcircle frames.""" # This transform goes through the parent frames on each side. # from_frame -> from_frame.origin -> to_frame.origin -> to_frame intermediate_from =...
Transform between two greatcircle frames.
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/coordinates/greatcircle.py#L21-L31
adrn/gala
gala/coordinates/greatcircle.py
reference_to_greatcircle
def reference_to_greatcircle(reference_frame, greatcircle_frame): """Convert a reference coordinate to a great circle frame.""" # Define rotation matrices along the position angle vector, and # relative to the origin. pole = greatcircle_frame.pole.transform_to(coord.ICRS) ra0 = greatcircle_frame.ra...
python
def reference_to_greatcircle(reference_frame, greatcircle_frame): """Convert a reference coordinate to a great circle frame.""" # Define rotation matrices along the position angle vector, and # relative to the origin. pole = greatcircle_frame.pole.transform_to(coord.ICRS) ra0 = greatcircle_frame.ra...
Convert a reference coordinate to a great circle frame.
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/coordinates/greatcircle.py#L34-L70
adrn/gala
gala/coordinates/greatcircle.py
pole_from_endpoints
def pole_from_endpoints(coord1, coord2): """Compute the pole from a great circle that connects the two specified coordinates. This assumes a right-handed rule from coord1 to coord2: the pole is the north pole under that assumption. Parameters ---------- coord1 : `~astropy.coordinates.SkyCo...
python
def pole_from_endpoints(coord1, coord2): """Compute the pole from a great circle that connects the two specified coordinates. This assumes a right-handed rule from coord1 to coord2: the pole is the north pole under that assumption. Parameters ---------- coord1 : `~astropy.coordinates.SkyCo...
Compute the pole from a great circle that connects the two specified coordinates. This assumes a right-handed rule from coord1 to coord2: the pole is the north pole under that assumption. Parameters ---------- coord1 : `~astropy.coordinates.SkyCoord` Coordinate of one point on a great ...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/coordinates/greatcircle.py#L270-L296
adrn/gala
gala/coordinates/greatcircle.py
sph_midpoint
def sph_midpoint(coord1, coord2): """Compute the midpoint between two points on the sphere. Parameters ---------- coord1 : `~astropy.coordinates.SkyCoord` Coordinate of one point on a great circle. coord2 : `~astropy.coordinates.SkyCoord` Coordinate of the other point on a great cir...
python
def sph_midpoint(coord1, coord2): """Compute the midpoint between two points on the sphere. Parameters ---------- coord1 : `~astropy.coordinates.SkyCoord` Coordinate of one point on a great circle. coord2 : `~astropy.coordinates.SkyCoord` Coordinate of the other point on a great cir...
Compute the midpoint between two points on the sphere. Parameters ---------- coord1 : `~astropy.coordinates.SkyCoord` Coordinate of one point on a great circle. coord2 : `~astropy.coordinates.SkyCoord` Coordinate of the other point on a great circle. Returns ------- midpt :...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/coordinates/greatcircle.py#L299-L322
adrn/gala
gala/coordinates/pm_cov_transform.py
get_uv_tan
def get_uv_tan(c): """Get tangent plane basis vectors on the unit sphere at the given spherical coordinates. """ l = c.spherical.lon b = c.spherical.lat p = np.array([-np.sin(l), np.cos(l), np.zeros_like(l.value)]).T q = np.array([-np.cos(l)*np.sin(b), -np.sin(l)*np.sin(b), np.cos(b)]).T ...
python
def get_uv_tan(c): """Get tangent plane basis vectors on the unit sphere at the given spherical coordinates. """ l = c.spherical.lon b = c.spherical.lat p = np.array([-np.sin(l), np.cos(l), np.zeros_like(l.value)]).T q = np.array([-np.cos(l)*np.sin(b), -np.sin(l)*np.sin(b), np.cos(b)]).T ...
Get tangent plane basis vectors on the unit sphere at the given spherical coordinates.
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/coordinates/pm_cov_transform.py#L8-L18
adrn/gala
gala/coordinates/pm_cov_transform.py
get_transform_matrix
def get_transform_matrix(from_frame, to_frame): """Compose sequential matrix transformations (static or dynamic) to get a single transformation matrix from a given path through the Astropy transformation machinery. Parameters ---------- from_frame : `~astropy.coordinates.BaseCoordinateFrame` su...
python
def get_transform_matrix(from_frame, to_frame): """Compose sequential matrix transformations (static or dynamic) to get a single transformation matrix from a given path through the Astropy transformation machinery. Parameters ---------- from_frame : `~astropy.coordinates.BaseCoordinateFrame` su...
Compose sequential matrix transformations (static or dynamic) to get a single transformation matrix from a given path through the Astropy transformation machinery. Parameters ---------- from_frame : `~astropy.coordinates.BaseCoordinateFrame` subclass The *class* of the frame you're transfor...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/coordinates/pm_cov_transform.py#L21-L59
adrn/gala
gala/coordinates/pm_cov_transform.py
transform_pm_cov
def transform_pm_cov(c, cov, to_frame): """Transform a proper motion covariance matrix to a new frame. Parameters ---------- c : `~astropy.coordinates.SkyCoord` The sky coordinates of the sources in the initial coordinate frame. cov : array_like The covariance matrix of the proper m...
python
def transform_pm_cov(c, cov, to_frame): """Transform a proper motion covariance matrix to a new frame. Parameters ---------- c : `~astropy.coordinates.SkyCoord` The sky coordinates of the sources in the initial coordinate frame. cov : array_like The covariance matrix of the proper m...
Transform a proper motion covariance matrix to a new frame. Parameters ---------- c : `~astropy.coordinates.SkyCoord` The sky coordinates of the sources in the initial coordinate frame. cov : array_like The covariance matrix of the proper motions. Must have same length as the in...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/coordinates/pm_cov_transform.py#L62-L121
adrn/gala
gala/potential/frame/builtin/transformations.py
rodrigues_axis_angle_rotate
def rodrigues_axis_angle_rotate(x, vec, theta): """ Rotated the input vector or set of vectors `x` around the axis `vec` by the angle `theta`. Parameters ---------- x : array_like The vector or array of vectors to transform. Must have shape """ x = np.array(x).T vec = np.a...
python
def rodrigues_axis_angle_rotate(x, vec, theta): """ Rotated the input vector or set of vectors `x` around the axis `vec` by the angle `theta`. Parameters ---------- x : array_like The vector or array of vectors to transform. Must have shape """ x = np.array(x).T vec = np.a...
Rotated the input vector or set of vectors `x` around the axis `vec` by the angle `theta`. Parameters ---------- x : array_like The vector or array of vectors to transform. Must have shape
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/potential/frame/builtin/transformations.py#L10-L29
adrn/gala
gala/potential/frame/builtin/transformations.py
z_angle_rotate
def z_angle_rotate(xy, theta): """ Rotated the input vector or set of vectors `xy` by the angle `theta`. Parameters ---------- xy : array_like The vector or array of vectors to transform. Must have shape """ xy = np.array(xy).T theta = np.array(theta).T out = np.zeros_lik...
python
def z_angle_rotate(xy, theta): """ Rotated the input vector or set of vectors `xy` by the angle `theta`. Parameters ---------- xy : array_like The vector or array of vectors to transform. Must have shape """ xy = np.array(xy).T theta = np.array(theta).T out = np.zeros_lik...
Rotated the input vector or set of vectors `xy` by the angle `theta`. Parameters ---------- xy : array_like The vector or array of vectors to transform. Must have shape
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/potential/frame/builtin/transformations.py#L31-L49
adrn/gala
gala/potential/frame/builtin/transformations.py
static_to_constantrotating
def static_to_constantrotating(frame_i, frame_r, w, t=None): """ Transform from an inertial static frame to a rotating frame. Parameters ---------- frame_i : `~gala.potential.StaticFrame` frame_r : `~gala.potential.ConstantRotatingFrame` w : `~gala.dynamics.PhaseSpacePosition`, `~gala.dynam...
python
def static_to_constantrotating(frame_i, frame_r, w, t=None): """ Transform from an inertial static frame to a rotating frame. Parameters ---------- frame_i : `~gala.potential.StaticFrame` frame_r : `~gala.potential.ConstantRotatingFrame` w : `~gala.dynamics.PhaseSpacePosition`, `~gala.dynam...
Transform from an inertial static frame to a rotating frame. Parameters ---------- frame_i : `~gala.potential.StaticFrame` frame_r : `~gala.potential.ConstantRotatingFrame` w : `~gala.dynamics.PhaseSpacePosition`, `~gala.dynamics.Orbit` t : quantity_like (optional) Required if input coo...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/potential/frame/builtin/transformations.py#L100-L120
adrn/gala
gala/potential/frame/builtin/transformations.py
constantrotating_to_static
def constantrotating_to_static(frame_r, frame_i, w, t=None): """ Transform from a constantly rotating frame to a static, inertial frame. Parameters ---------- frame_i : `~gala.potential.StaticFrame` frame_r : `~gala.potential.ConstantRotatingFrame` w : `~gala.dynamics.PhaseSpacePosition`, `...
python
def constantrotating_to_static(frame_r, frame_i, w, t=None): """ Transform from a constantly rotating frame to a static, inertial frame. Parameters ---------- frame_i : `~gala.potential.StaticFrame` frame_r : `~gala.potential.ConstantRotatingFrame` w : `~gala.dynamics.PhaseSpacePosition`, `...
Transform from a constantly rotating frame to a static, inertial frame. Parameters ---------- frame_i : `~gala.potential.StaticFrame` frame_r : `~gala.potential.ConstantRotatingFrame` w : `~gala.dynamics.PhaseSpacePosition`, `~gala.dynamics.Orbit` t : quantity_like (optional) Required i...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/potential/frame/builtin/transformations.py#L122-L142
adrn/gala
gala/potential/potential/io.py
from_dict
def from_dict(d, module=None): """ Convert a dictionary potential specification into a :class:`~gala.potential.PotentialBase` subclass object. Parameters ---------- d : dict Dictionary specification of a potential. module : namespace (optional) """ # need this here for circ...
python
def from_dict(d, module=None): """ Convert a dictionary potential specification into a :class:`~gala.potential.PotentialBase` subclass object. Parameters ---------- d : dict Dictionary specification of a potential. module : namespace (optional) """ # need this here for circ...
Convert a dictionary potential specification into a :class:`~gala.potential.PotentialBase` subclass object. Parameters ---------- d : dict Dictionary specification of a potential. module : namespace (optional)
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/potential/potential/io.py#L70-L117
adrn/gala
gala/potential/potential/io.py
to_dict
def to_dict(potential): """ Turn a potential object into a dictionary that fully specifies the state of the object. Parameters ---------- potential : :class:`~gala.potential.PotentialBase` The instantiated :class:`~gala.potential.PotentialBase` object. """ from .. import potent...
python
def to_dict(potential): """ Turn a potential object into a dictionary that fully specifies the state of the object. Parameters ---------- potential : :class:`~gala.potential.PotentialBase` The instantiated :class:`~gala.potential.PotentialBase` object. """ from .. import potent...
Turn a potential object into a dictionary that fully specifies the state of the object. Parameters ---------- potential : :class:`~gala.potential.PotentialBase` The instantiated :class:`~gala.potential.PotentialBase` object.
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/potential/potential/io.py#L148-L179
adrn/gala
gala/potential/potential/io.py
load
def load(f, module=None): """ Read a potential specification file and return a :class:`~gala.potential.PotentialBase` object instantiated with parameters specified in the spec file. Parameters ---------- f : str, file_like A block of text, filename, or file-like object to parse and ...
python
def load(f, module=None): """ Read a potential specification file and return a :class:`~gala.potential.PotentialBase` object instantiated with parameters specified in the spec file. Parameters ---------- f : str, file_like A block of text, filename, or file-like object to parse and ...
Read a potential specification file and return a :class:`~gala.potential.PotentialBase` object instantiated with parameters specified in the spec file. Parameters ---------- f : str, file_like A block of text, filename, or file-like object to parse and read a potential from. mod...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/potential/potential/io.py#L183-L203
adrn/gala
gala/potential/potential/io.py
save
def save(potential, f): """ Write a :class:`~gala.potential.PotentialBase` object out to a text (YAML) file. Parameters ---------- potential : :class:`~gala.potential.PotentialBase` The instantiated :class:`~gala.potential.PotentialBase` object. f : str, file_like A filename...
python
def save(potential, f): """ Write a :class:`~gala.potential.PotentialBase` object out to a text (YAML) file. Parameters ---------- potential : :class:`~gala.potential.PotentialBase` The instantiated :class:`~gala.potential.PotentialBase` object. f : str, file_like A filename...
Write a :class:`~gala.potential.PotentialBase` object out to a text (YAML) file. Parameters ---------- potential : :class:`~gala.potential.PotentialBase` The instantiated :class:`~gala.potential.PotentialBase` object. f : str, file_like A filename or file-like object to write the in...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/potential/potential/io.py#L205-L224
adrn/gala
gala/integrate/core.py
Integrator._prepare_ws
def _prepare_ws(self, w0, mmap, n_steps): """ Decide how to make the return array. If mmap is False, this returns a full array of zeros, but with the correct shape as the output. If mmap is True, return a pointer to a memory-mapped array. The latter is particularly useful for int...
python
def _prepare_ws(self, w0, mmap, n_steps): """ Decide how to make the return array. If mmap is False, this returns a full array of zeros, but with the correct shape as the output. If mmap is True, return a pointer to a memory-mapped array. The latter is particularly useful for int...
Decide how to make the return array. If mmap is False, this returns a full array of zeros, but with the correct shape as the output. If mmap is True, return a pointer to a memory-mapped array. The latter is particularly useful for integrating a large number of orbits or integrating a lar...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/integrate/core.py#L44-L78
adrn/gala
gala/dynamics/nonlinear.py
fast_lyapunov_max
def fast_lyapunov_max(w0, hamiltonian, dt, n_steps, d0=1e-5, n_steps_per_pullback=10, noffset_orbits=2, t1=0., atol=1E-10, rtol=1E-10, nmax=0, return_orbit=True): """ Compute the maximum Lyapunov exponent using a C-implemented estimator that uses the DOPRI853 inte...
python
def fast_lyapunov_max(w0, hamiltonian, dt, n_steps, d0=1e-5, n_steps_per_pullback=10, noffset_orbits=2, t1=0., atol=1E-10, rtol=1E-10, nmax=0, return_orbit=True): """ Compute the maximum Lyapunov exponent using a C-implemented estimator that uses the DOPRI853 inte...
Compute the maximum Lyapunov exponent using a C-implemented estimator that uses the DOPRI853 integrator. Parameters ---------- w0 : `~gala.dynamics.PhaseSpacePosition`, array_like Initial conditions. hamiltonian : `~gala.potential.Hamiltonian` dt : numeric Timestep. n_steps ...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/nonlinear.py#L12-L95
adrn/gala
gala/dynamics/nonlinear.py
surface_of_section
def surface_of_section(orbit, plane_ix, interpolate=False): """ Generate and return a surface of section from the given orbit. .. warning:: This is an experimental function and the API may change. Parameters ---------- orbit : `~gala.dynamics.Orbit` plane_ix : int Integer ...
python
def surface_of_section(orbit, plane_ix, interpolate=False): """ Generate and return a surface of section from the given orbit. .. warning:: This is an experimental function and the API may change. Parameters ---------- orbit : `~gala.dynamics.Orbit` plane_ix : int Integer ...
Generate and return a surface of section from the given orbit. .. warning:: This is an experimental function and the API may change. Parameters ---------- orbit : `~gala.dynamics.Orbit` plane_ix : int Integer that represents the coordinate to record crossings in. For examp...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/nonlinear.py#L207-L263
adrn/gala
gala/potential/potential/core.py
PotentialBase._remove_units
def _remove_units(self, x): """ Always returns an array. If a Quantity is passed in, it converts to the units associated with this object and returns the value. """ if hasattr(x, 'unit'): x = x.decompose(self.units).value else: x = np.array(x) ...
python
def _remove_units(self, x): """ Always returns an array. If a Quantity is passed in, it converts to the units associated with this object and returns the value. """ if hasattr(x, 'unit'): x = x.decompose(self.units).value else: x = np.array(x) ...
Always returns an array. If a Quantity is passed in, it converts to the units associated with this object and returns the value.
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/potential/potential/core.py#L96-L107
adrn/gala
gala/potential/potential/core.py
PotentialBase.energy
def energy(self, q, t=0.): """ Compute the potential energy at the given position(s). Parameters ---------- q : `~gala.dynamics.PhaseSpacePosition`, `~astropy.units.Quantity`, array_like The position to compute the value of the potential. If the input pos...
python
def energy(self, q, t=0.): """ Compute the potential energy at the given position(s). Parameters ---------- q : `~gala.dynamics.PhaseSpacePosition`, `~astropy.units.Quantity`, array_like The position to compute the value of the potential. If the input pos...
Compute the potential energy at the given position(s). Parameters ---------- q : `~gala.dynamics.PhaseSpacePosition`, `~astropy.units.Quantity`, array_like The position to compute the value of the potential. If the input position object has no units (i.e. is an `~numpy.n...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/potential/potential/core.py#L126-L147
adrn/gala
gala/potential/potential/core.py
PotentialBase.gradient
def gradient(self, q, t=0.): """ Compute the gradient of the potential at the given position(s). Parameters ---------- q : `~gala.dynamics.PhaseSpacePosition`, `~astropy.units.Quantity`, array_like The position to compute the value of the potential. If the ...
python
def gradient(self, q, t=0.): """ Compute the gradient of the potential at the given position(s). Parameters ---------- q : `~gala.dynamics.PhaseSpacePosition`, `~astropy.units.Quantity`, array_like The position to compute the value of the potential. If the ...
Compute the gradient of the potential at the given position(s). Parameters ---------- q : `~gala.dynamics.PhaseSpacePosition`, `~astropy.units.Quantity`, array_like The position to compute the value of the potential. If the input position object has no units (i.e. is an ...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/potential/potential/core.py#L149-L170
adrn/gala
gala/potential/potential/core.py
PotentialBase.density
def density(self, q, t=0.): """ Compute the density value at the given position(s). Parameters ---------- q : `~gala.dynamics.PhaseSpacePosition`, `~astropy.units.Quantity`, array_like The position to compute the value of the potential. If the input posit...
python
def density(self, q, t=0.): """ Compute the density value at the given position(s). Parameters ---------- q : `~gala.dynamics.PhaseSpacePosition`, `~astropy.units.Quantity`, array_like The position to compute the value of the potential. If the input posit...
Compute the density value at the given position(s). Parameters ---------- q : `~gala.dynamics.PhaseSpacePosition`, `~astropy.units.Quantity`, array_like The position to compute the value of the potential. If the input position object has no units (i.e. is an `~numpy.ndar...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/potential/potential/core.py#L172-L194
adrn/gala
gala/potential/potential/core.py
PotentialBase.hessian
def hessian(self, q, t=0.): """ Compute the Hessian of the potential at the given position(s). Parameters ---------- q : `~gala.dynamics.PhaseSpacePosition`, `~astropy.units.Quantity`, array_like The position to compute the value of the potential. If the ...
python
def hessian(self, q, t=0.): """ Compute the Hessian of the potential at the given position(s). Parameters ---------- q : `~gala.dynamics.PhaseSpacePosition`, `~astropy.units.Quantity`, array_like The position to compute the value of the potential. If the ...
Compute the Hessian of the potential at the given position(s). Parameters ---------- q : `~gala.dynamics.PhaseSpacePosition`, `~astropy.units.Quantity`, array_like The position to compute the value of the potential. If the input position object has no units (i.e. is an `...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/potential/potential/core.py#L196-L224
adrn/gala
gala/potential/potential/core.py
PotentialBase.mass_enclosed
def mass_enclosed(self, q, t=0.): """ Estimate the mass enclosed within the given position by assuming the potential is spherical. Parameters ---------- q : `~gala.dynamics.PhaseSpacePosition`, `~astropy.units.Quantity`, array_like Position(s) to estimate the...
python
def mass_enclosed(self, q, t=0.): """ Estimate the mass enclosed within the given position by assuming the potential is spherical. Parameters ---------- q : `~gala.dynamics.PhaseSpacePosition`, `~astropy.units.Quantity`, array_like Position(s) to estimate the...
Estimate the mass enclosed within the given position by assuming the potential is spherical. Parameters ---------- q : `~gala.dynamics.PhaseSpacePosition`, `~astropy.units.Quantity`, array_like Position(s) to estimate the enclossed mass. Returns ------- ...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/potential/potential/core.py#L246-L291
adrn/gala
gala/potential/potential/core.py
PotentialBase.circular_velocity
def circular_velocity(self, q, t=0.): """ Estimate the circular velocity at the given position assuming the potential is spherical. Parameters ---------- q : array_like, numeric Position(s) to estimate the circular velocity. Returns ------- ...
python
def circular_velocity(self, q, t=0.): """ Estimate the circular velocity at the given position assuming the potential is spherical. Parameters ---------- q : array_like, numeric Position(s) to estimate the circular velocity. Returns ------- ...
Estimate the circular velocity at the given position assuming the potential is spherical. Parameters ---------- q : array_like, numeric Position(s) to estimate the circular velocity. Returns ------- vcirc : `~astropy.units.Quantity` Circu...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/potential/potential/core.py#L293-L318
adrn/gala
gala/potential/potential/core.py
PotentialBase.plot_contours
def plot_contours(self, grid, filled=True, ax=None, labels=None, subplots_kw=dict(), **kwargs): """ Plot equipotentials contours. Computes the potential energy on a grid (specified by the array `grid`). .. warning:: Right now the grid input must be arrays and must ...
python
def plot_contours(self, grid, filled=True, ax=None, labels=None, subplots_kw=dict(), **kwargs): """ Plot equipotentials contours. Computes the potential energy on a grid (specified by the array `grid`). .. warning:: Right now the grid input must be arrays and must ...
Plot equipotentials contours. Computes the potential energy on a grid (specified by the array `grid`). .. warning:: Right now the grid input must be arrays and must already be in the unit system of the potential. Quantity support is coming... Parameters ---------- g...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/potential/potential/core.py#L396-L497
adrn/gala
gala/potential/potential/core.py
PotentialBase.total_energy
def total_energy(self, x, v): """ Compute the total energy (per unit mass) of a point in phase-space in this potential. Assumes the last axis of the input position / velocity is the dimension axis, e.g., for 100 points in 3-space, the arrays should have shape (100,3). Pa...
python
def total_energy(self, x, v): """ Compute the total energy (per unit mass) of a point in phase-space in this potential. Assumes the last axis of the input position / velocity is the dimension axis, e.g., for 100 points in 3-space, the arrays should have shape (100,3). Pa...
Compute the total energy (per unit mass) of a point in phase-space in this potential. Assumes the last axis of the input position / velocity is the dimension axis, e.g., for 100 points in 3-space, the arrays should have shape (100,3). Parameters ---------- x : array_like...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/potential/potential/core.py#L649-L667
adrn/gala
gala/potential/potential/core.py
PotentialBase.replace_units
def replace_units(self, units, copy=True): """Change the unit system of this potential. Parameters ---------- units : `~gala.units.UnitSystem` Set of non-reducable units that specify (at minimum) the length, mass, time, and angle units. copy : bool (optio...
python
def replace_units(self, units, copy=True): """Change the unit system of this potential. Parameters ---------- units : `~gala.units.UnitSystem` Set of non-reducable units that specify (at minimum) the length, mass, time, and angle units. copy : bool (optio...
Change the unit system of this potential. Parameters ---------- units : `~gala.units.UnitSystem` Set of non-reducable units that specify (at minimum) the length, mass, time, and angle units. copy : bool (optional) If True, returns a copy, if False, ch...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/potential/potential/core.py#L691-L714
adrn/gala
gala/potential/potential/core.py
CompositePotential.replace_units
def replace_units(self, units, copy=True): """Change the unit system of this potential. Parameters ---------- units : `~gala.units.UnitSystem` Set of non-reducable units that specify (at minimum) the length, mass, time, and angle units. copy : bool (optio...
python
def replace_units(self, units, copy=True): """Change the unit system of this potential. Parameters ---------- units : `~gala.units.UnitSystem` Set of non-reducable units that specify (at minimum) the length, mass, time, and angle units. copy : bool (optio...
Change the unit system of this potential. Parameters ---------- units : `~gala.units.UnitSystem` Set of non-reducable units that specify (at minimum) the length, mass, time, and angle units. copy : bool (optional) If True, returns a copy, if False, ch...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/potential/potential/core.py#L810-L834
adrn/gala
gala/potential/potential/util.py
from_equation
def from_equation(expr, vars, pars, name=None, hessian=False): r""" Create a potential class from an expression for the potential. .. note:: This utility requires having `Sympy <http://www.sympy.org/>`_ installed. .. warning:: These potentials are *not* pickle-able and cannot be writ...
python
def from_equation(expr, vars, pars, name=None, hessian=False): r""" Create a potential class from an expression for the potential. .. note:: This utility requires having `Sympy <http://www.sympy.org/>`_ installed. .. warning:: These potentials are *not* pickle-able and cannot be writ...
r""" Create a potential class from an expression for the potential. .. note:: This utility requires having `Sympy <http://www.sympy.org/>`_ installed. .. warning:: These potentials are *not* pickle-able and cannot be written out to YAML files (using `~gala.potential.PotentialBase...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/potential/potential/util.py#L18-L162
adrn/gala
gala/potential/potential/util.py
format_doc
def format_doc(*args, **kwargs): """ Replaces the docstring of the decorated object and then formats it. Modeled after astropy.utils.decorators.format_doc """ def set_docstring(obj): # None means: use the objects __doc__ doc = obj.__doc__ # Delete documentation in this case...
python
def format_doc(*args, **kwargs): """ Replaces the docstring of the decorated object and then formats it. Modeled after astropy.utils.decorators.format_doc """ def set_docstring(obj): # None means: use the objects __doc__ doc = obj.__doc__ # Delete documentation in this case...
Replaces the docstring of the decorated object and then formats it. Modeled after astropy.utils.decorators.format_doc
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/potential/potential/util.py#L165-L184
adrn/gala
gala/io.py
quantity_from_hdf5
def quantity_from_hdf5(dset): """ Return an Astropy Quantity object from a key in an HDF5 file, group, or dataset. This checks to see if the input file/group/dataset contains a ``'unit'`` attribute (e.g., in `f.attrs`). Parameters ---------- dset : :class:`h5py.DataSet` Returns ---...
python
def quantity_from_hdf5(dset): """ Return an Astropy Quantity object from a key in an HDF5 file, group, or dataset. This checks to see if the input file/group/dataset contains a ``'unit'`` attribute (e.g., in `f.attrs`). Parameters ---------- dset : :class:`h5py.DataSet` Returns ---...
Return an Astropy Quantity object from a key in an HDF5 file, group, or dataset. This checks to see if the input file/group/dataset contains a ``'unit'`` attribute (e.g., in `f.attrs`). Parameters ---------- dset : :class:`h5py.DataSet` Returns ------- q : `astropy.units.Quantity`, `nu...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/io.py#L4-L25
adrn/gala
gala/io.py
quantity_to_hdf5
def quantity_to_hdf5(f, key, q): """ Turn an Astropy Quantity object into something we can write out to an HDF5 file. Parameters ---------- f : :class:`h5py.File`, :class:`h5py.Group`, :class:`h5py.DataSet` key : str The name. q : float, `astropy.units.Quantity` The quan...
python
def quantity_to_hdf5(f, key, q): """ Turn an Astropy Quantity object into something we can write out to an HDF5 file. Parameters ---------- f : :class:`h5py.File`, :class:`h5py.Group`, :class:`h5py.DataSet` key : str The name. q : float, `astropy.units.Quantity` The quan...
Turn an Astropy Quantity object into something we can write out to an HDF5 file. Parameters ---------- f : :class:`h5py.File`, :class:`h5py.Group`, :class:`h5py.DataSet` key : str The name. q : float, `astropy.units.Quantity` The quantity.
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/io.py#L27-L48
adrn/gala
gala/units.py
UnitSystem.decompose
def decompose(self, q): """ A thin wrapper around :meth:`astropy.units.Quantity.decompose` that knows how to handle Quantities with physical types with non-default representations. Parameters ---------- q : :class:`~astropy.units.Quantity` An instance...
python
def decompose(self, q): """ A thin wrapper around :meth:`astropy.units.Quantity.decompose` that knows how to handle Quantities with physical types with non-default representations. Parameters ---------- q : :class:`~astropy.units.Quantity` An instance...
A thin wrapper around :meth:`astropy.units.Quantity.decompose` that knows how to handle Quantities with physical types with non-default representations. Parameters ---------- q : :class:`~astropy.units.Quantity` An instance of an astropy Quantity object. Ret...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/units.py#L133-L158
adrn/gala
gala/units.py
UnitSystem.get_constant
def get_constant(self, name): """ Retrieve a constant with specified name in this unit system. Parameters ---------- name : str The name of the constant, e.g., G. Returns ------- const : float The value of the constant represented...
python
def get_constant(self, name): """ Retrieve a constant with specified name in this unit system. Parameters ---------- name : str The name of the constant, e.g., G. Returns ------- const : float The value of the constant represented...
Retrieve a constant with specified name in this unit system. Parameters ---------- name : str The name of the constant, e.g., G. Returns ------- const : float The value of the constant represented in this unit system. Examples --...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/units.py#L160-L187
adrn/gala
gala/util.py
rolling_window
def rolling_window(arr, window_size, stride=1, return_idx=False): """ There is an example of an iterator for pure-Python objects in: http://stackoverflow.com/questions/6822725/rolling-or-sliding-window-iterator-in-python This is a rolling-window iterator Numpy arrays, with window size and stride con...
python
def rolling_window(arr, window_size, stride=1, return_idx=False): """ There is an example of an iterator for pure-Python objects in: http://stackoverflow.com/questions/6822725/rolling-or-sliding-window-iterator-in-python This is a rolling-window iterator Numpy arrays, with window size and stride con...
There is an example of an iterator for pure-Python objects in: http://stackoverflow.com/questions/6822725/rolling-or-sliding-window-iterator-in-python This is a rolling-window iterator Numpy arrays, with window size and stride control. See examples below for demos. Parameters ---------- arr : a...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/util.py#L48-L111
adrn/gala
gala/util.py
atleast_2d
def atleast_2d(*arys, **kwargs): """ View inputs as arrays with at least two dimensions. Parameters ---------- arys1, arys2, ... : array_like One or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have two or more dimensions are pre...
python
def atleast_2d(*arys, **kwargs): """ View inputs as arrays with at least two dimensions. Parameters ---------- arys1, arys2, ... : array_like One or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have two or more dimensions are pre...
View inputs as arrays with at least two dimensions. Parameters ---------- arys1, arys2, ... : array_like One or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have two or more dimensions are preserved. insert_axis : int (optional) ...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/util.py#L113-L170
adrn/gala
gala/util.py
assert_angles_allclose
def assert_angles_allclose(x, y, **kwargs): """ Like numpy's assert_allclose, but for angles (in radians). """ c2 = (np.sin(x)-np.sin(y))**2 + (np.cos(x)-np.cos(y))**2 diff = np.arccos((2.0 - c2)/2.0) # a = b = 1 assert np.allclose(diff, 0.0, **kwargs)
python
def assert_angles_allclose(x, y, **kwargs): """ Like numpy's assert_allclose, but for angles (in radians). """ c2 = (np.sin(x)-np.sin(y))**2 + (np.cos(x)-np.cos(y))**2 diff = np.arccos((2.0 - c2)/2.0) # a = b = 1 assert np.allclose(diff, 0.0, **kwargs)
Like numpy's assert_allclose, but for angles (in radians).
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/util.py#L176-L182
adrn/gala
gala/coordinates/quaternion.py
Quaternion.from_v_theta
def from_v_theta(cls, v, theta): """ Create a quaternion from unit vector v and rotation angle theta. Returns ------- q : :class:`gala.coordinates.Quaternion` A ``Quaternion`` instance. """ theta = np.asarray(theta) v = np.asarray(v) ...
python
def from_v_theta(cls, v, theta): """ Create a quaternion from unit vector v and rotation angle theta. Returns ------- q : :class:`gala.coordinates.Quaternion` A ``Quaternion`` instance. """ theta = np.asarray(theta) v = np.asarray(v) ...
Create a quaternion from unit vector v and rotation angle theta. Returns ------- q : :class:`gala.coordinates.Quaternion` A ``Quaternion`` instance.
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/coordinates/quaternion.py#L27-L45
adrn/gala
gala/coordinates/quaternion.py
Quaternion.v_theta
def v_theta(self): """ Return the ``(v, theta)`` equivalent of the (normalized) quaternion. Returns ------- v : float theta : float """ # compute theta norm = np.sqrt(np.sum(self.wxyz**2)) theta = 2 * np.arccos(self.wxyz[0] / norm) ...
python
def v_theta(self): """ Return the ``(v, theta)`` equivalent of the (normalized) quaternion. Returns ------- v : float theta : float """ # compute theta norm = np.sqrt(np.sum(self.wxyz**2)) theta = 2 * np.arccos(self.wxyz[0] / norm) ...
Return the ``(v, theta)`` equivalent of the (normalized) quaternion. Returns ------- v : float theta : float
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/coordinates/quaternion.py#L66-L84
adrn/gala
gala/coordinates/quaternion.py
Quaternion.rotation_matrix
def rotation_matrix(self): """ Compute the rotation matrix of the (normalized) quaternion. Returns ------- R : :class:`~numpy.ndarray` A 3 by 3 rotation matrix (has shape ``(3,3)``). """ v, theta = self.v_theta c = np.cos(theta) s = n...
python
def rotation_matrix(self): """ Compute the rotation matrix of the (normalized) quaternion. Returns ------- R : :class:`~numpy.ndarray` A 3 by 3 rotation matrix (has shape ``(3,3)``). """ v, theta = self.v_theta c = np.cos(theta) s = n...
Compute the rotation matrix of the (normalized) quaternion. Returns ------- R : :class:`~numpy.ndarray` A 3 by 3 rotation matrix (has shape ``(3,3)``).
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/coordinates/quaternion.py#L87-L109
adrn/gala
gala/coordinates/quaternion.py
Quaternion.random
def random(cls): """ Randomly sample a Quaternion from a distribution uniform in 3D rotation angles. https://www-preview.ri.cmu.edu/pub_files/pub4/kuffner_james_2004_1/kuffner_james_2004_1.pdf Returns ------- q : :class:`gala.coordinates.Quaternion` ...
python
def random(cls): """ Randomly sample a Quaternion from a distribution uniform in 3D rotation angles. https://www-preview.ri.cmu.edu/pub_files/pub4/kuffner_james_2004_1/kuffner_james_2004_1.pdf Returns ------- q : :class:`gala.coordinates.Quaternion` ...
Randomly sample a Quaternion from a distribution uniform in 3D rotation angles. https://www-preview.ri.cmu.edu/pub_files/pub4/kuffner_james_2004_1/kuffner_james_2004_1.pdf Returns ------- q : :class:`gala.coordinates.Quaternion` A randomly sampled ``Quaternion`` ins...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/coordinates/quaternion.py#L112-L137
adrn/gala
gala/integrate/pyintegrators/leapfrog.py
LeapfrogIntegrator.step
def step(self, t, x_im1, v_im1_2, dt): """ Step forward the positions and velocities by the given timestep. Parameters ---------- dt : numeric The timestep to move forward. """ x_i = x_im1 + v_im1_2 * dt F_i = self.F(t, np.vstack((x_i, v_im1_...
python
def step(self, t, x_im1, v_im1_2, dt): """ Step forward the positions and velocities by the given timestep. Parameters ---------- dt : numeric The timestep to move forward. """ x_i = x_im1 + v_im1_2 * dt F_i = self.F(t, np.vstack((x_i, v_im1_...
Step forward the positions and velocities by the given timestep. Parameters ---------- dt : numeric The timestep to move forward.
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/integrate/pyintegrators/leapfrog.py#L93-L110
adrn/gala
gala/integrate/pyintegrators/leapfrog.py
LeapfrogIntegrator._init_v
def _init_v(self, t, w0, dt): """ Leapfrog updates the velocities offset a half-step from the position updates. If we're given initial conditions aligned in time, e.g. the positions and velocities at the same 0th step, then we have to initially scoot the velocities forward by a h...
python
def _init_v(self, t, w0, dt): """ Leapfrog updates the velocities offset a half-step from the position updates. If we're given initial conditions aligned in time, e.g. the positions and velocities at the same 0th step, then we have to initially scoot the velocities forward by a h...
Leapfrog updates the velocities offset a half-step from the position updates. If we're given initial conditions aligned in time, e.g. the positions and velocities at the same 0th step, then we have to initially scoot the velocities forward by a half step to prime the integrator. ...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/integrate/pyintegrators/leapfrog.py#L112-L131
adrn/gala
gala/dynamics/actionangle.py
generate_n_vectors
def generate_n_vectors(N_max, dx=1, dy=1, dz=1, half_lattice=True): r""" Generate integer vectors, :math:`\boldsymbol{n}`, with :math:`|\boldsymbol{n}| < N_{\rm max}`. If ``half_lattice=True``, only return half of the three-dimensional lattice. If the set N = {(i,j,k)} defines the lattice, we restr...
python
def generate_n_vectors(N_max, dx=1, dy=1, dz=1, half_lattice=True): r""" Generate integer vectors, :math:`\boldsymbol{n}`, with :math:`|\boldsymbol{n}| < N_{\rm max}`. If ``half_lattice=True``, only return half of the three-dimensional lattice. If the set N = {(i,j,k)} defines the lattice, we restr...
r""" Generate integer vectors, :math:`\boldsymbol{n}`, with :math:`|\boldsymbol{n}| < N_{\rm max}`. If ``half_lattice=True``, only return half of the three-dimensional lattice. If the set N = {(i,j,k)} defines the lattice, we restrict to the cases such that ``(k > 0)``, ``(k = 0, j > 0)``, and ...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/actionangle.py#L23-L76
adrn/gala
gala/dynamics/actionangle.py
fit_isochrone
def fit_isochrone(orbit, m0=2E11, b0=1., minimize_kwargs=None): r""" Fit the toy Isochrone potential to the sum of the energy residuals relative to the mean energy by minimizing the function .. math:: f(m,b) = \sum_i (\frac{1}{2}v_i^2 + \Phi_{\rm iso}(x_i\,|\,m,b) - <E>)^2 TODO: This shou...
python
def fit_isochrone(orbit, m0=2E11, b0=1., minimize_kwargs=None): r""" Fit the toy Isochrone potential to the sum of the energy residuals relative to the mean energy by minimizing the function .. math:: f(m,b) = \sum_i (\frac{1}{2}v_i^2 + \Phi_{\rm iso}(x_i\,|\,m,b) - <E>)^2 TODO: This shou...
r""" Fit the toy Isochrone potential to the sum of the energy residuals relative to the mean energy by minimizing the function .. math:: f(m,b) = \sum_i (\frac{1}{2}v_i^2 + \Phi_{\rm iso}(x_i\,|\,m,b) - <E>)^2 TODO: This should fail if the Hamiltonian associated with the orbit has a...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/actionangle.py#L78-L140
adrn/gala
gala/dynamics/actionangle.py
fit_harmonic_oscillator
def fit_harmonic_oscillator(orbit, omega0=[1., 1, 1], minimize_kwargs=None): r""" Fit the toy harmonic oscillator potential to the sum of the energy residuals relative to the mean energy by minimizing the function .. math:: f(\boldsymbol{\omega}) = \sum_i (\frac{1}{2}v_i^2 + \Phi_{\rm sho}(x_i...
python
def fit_harmonic_oscillator(orbit, omega0=[1., 1, 1], minimize_kwargs=None): r""" Fit the toy harmonic oscillator potential to the sum of the energy residuals relative to the mean energy by minimizing the function .. math:: f(\boldsymbol{\omega}) = \sum_i (\frac{1}{2}v_i^2 + \Phi_{\rm sho}(x_i...
r""" Fit the toy harmonic oscillator potential to the sum of the energy residuals relative to the mean energy by minimizing the function .. math:: f(\boldsymbol{\omega}) = \sum_i (\frac{1}{2}v_i^2 + \Phi_{\rm sho}(x_i\,|\,\boldsymbol{\omega}) - <E>)^2 TODO: This should fail if the Hamiltonian...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/actionangle.py#L142-L194
adrn/gala
gala/dynamics/actionangle.py
fit_toy_potential
def fit_toy_potential(orbit, force_harmonic_oscillator=False): """ Fit a best fitting toy potential to the orbit provided. If the orbit is a tube (loop) orbit, use the Isochrone potential. If the orbit is a box potential, use the harmonic oscillator potential. An option is available to force using t...
python
def fit_toy_potential(orbit, force_harmonic_oscillator=False): """ Fit a best fitting toy potential to the orbit provided. If the orbit is a tube (loop) orbit, use the Isochrone potential. If the orbit is a box potential, use the harmonic oscillator potential. An option is available to force using t...
Fit a best fitting toy potential to the orbit provided. If the orbit is a tube (loop) orbit, use the Isochrone potential. If the orbit is a box potential, use the harmonic oscillator potential. An option is available to force using the harmonic oscillator (`force_harmonic_oscillator`). See the docstrin...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/actionangle.py#L196-L235
adrn/gala
gala/dynamics/actionangle.py
check_angle_sampling
def check_angle_sampling(nvecs, angles): """ Returns a list of the index of elements of n which do not have adequate toy angle coverage. The criterion is that we must have at least one sample in each Nyquist box when we project the toy angles along the vector n. Parameters ---------- nvecs ...
python
def check_angle_sampling(nvecs, angles): """ Returns a list of the index of elements of n which do not have adequate toy angle coverage. The criterion is that we must have at least one sample in each Nyquist box when we project the toy angles along the vector n. Parameters ---------- nvecs ...
Returns a list of the index of elements of n which do not have adequate toy angle coverage. The criterion is that we must have at least one sample in each Nyquist box when we project the toy angles along the vector n. Parameters ---------- nvecs : array_like Array of integer vectors. an...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/actionangle.py#L237-L283
adrn/gala
gala/dynamics/actionangle.py
_action_prepare
def _action_prepare(aa, N_max, dx, dy, dz, sign=1., throw_out_modes=False): """ Given toy actions and angles, `aa`, compute the matrix `A` and vector `b` to solve for the vector of "true" actions and generating function values, `x` (see Equations 12-14 in Sanders & Binney (2014)). .. todo:: ...
python
def _action_prepare(aa, N_max, dx, dy, dz, sign=1., throw_out_modes=False): """ Given toy actions and angles, `aa`, compute the matrix `A` and vector `b` to solve for the vector of "true" actions and generating function values, `x` (see Equations 12-14 in Sanders & Binney (2014)). .. todo:: ...
Given toy actions and angles, `aa`, compute the matrix `A` and vector `b` to solve for the vector of "true" actions and generating function values, `x` (see Equations 12-14 in Sanders & Binney (2014)). .. todo:: Wrong shape for aa -- should be (6,n) as usual... Parameters ---------- a...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/actionangle.py#L285-L353
adrn/gala
gala/dynamics/actionangle.py
_angle_prepare
def _angle_prepare(aa, t, N_max, dx, dy, dz, sign=1.): """ Given toy actions and angles, `aa`, compute the matrix `A` and vector `b` to solve for the vector of "true" angles, frequencies, and generating function derivatives, `x` (see Appendix of Sanders & Binney (2014)). .. todo:: Wron...
python
def _angle_prepare(aa, t, N_max, dx, dy, dz, sign=1.): """ Given toy actions and angles, `aa`, compute the matrix `A` and vector `b` to solve for the vector of "true" angles, frequencies, and generating function derivatives, `x` (see Appendix of Sanders & Binney (2014)). .. todo:: Wron...
Given toy actions and angles, `aa`, compute the matrix `A` and vector `b` to solve for the vector of "true" angles, frequencies, and generating function derivatives, `x` (see Appendix of Sanders & Binney (2014)). .. todo:: Wrong shape for aa -- should be (6,n) as usual... Parameters -...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/actionangle.py#L355-L441
adrn/gala
gala/dynamics/actionangle.py
_single_orbit_find_actions
def _single_orbit_find_actions(orbit, N_max, toy_potential=None, force_harmonic_oscillator=False): """ Find approximate actions and angles for samples of a phase-space orbit, `w`, at times `t`. Uses toy potentials with known, analytic action-angle transformations to approx...
python
def _single_orbit_find_actions(orbit, N_max, toy_potential=None, force_harmonic_oscillator=False): """ Find approximate actions and angles for samples of a phase-space orbit, `w`, at times `t`. Uses toy potentials with known, analytic action-angle transformations to approx...
Find approximate actions and angles for samples of a phase-space orbit, `w`, at times `t`. Uses toy potentials with known, analytic action-angle transformations to approximate the true coordinates as a Fourier sum. This code is adapted from Jason Sanders' `genfunc <https://github.com/jlsanders/genfunc>...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/actionangle.py#L443-L537
adrn/gala
gala/dynamics/actionangle.py
find_actions
def find_actions(orbit, N_max, force_harmonic_oscillator=False, toy_potential=None): r""" Find approximate actions and angles for samples of a phase-space orbit. Uses toy potentials with known, analytic action-angle transformations to approximate the true coordinates as a Fourier sum. This code is ...
python
def find_actions(orbit, N_max, force_harmonic_oscillator=False, toy_potential=None): r""" Find approximate actions and angles for samples of a phase-space orbit. Uses toy potentials with known, analytic action-angle transformations to approximate the true coordinates as a Fourier sum. This code is ...
r""" Find approximate actions and angles for samples of a phase-space orbit. Uses toy potentials with known, analytic action-angle transformations to approximate the true coordinates as a Fourier sum. This code is adapted from Jason Sanders' `genfunc <https://github.com/jlsanders/genfunc>`_ Pa...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/actionangle.py#L539-L591
adrn/gala
gala/integrate/timespec.py
parse_time_specification
def parse_time_specification(units, dt=None, n_steps=None, nsteps=None, t1=None, t2=None, t=None): """ Return an array of times given a few combinations of kwargs that are accepted -- see below. Parameters ---------- dt, n_steps[, t1] : (numeric, int[, numeric]) A fixed timestep dt and ...
python
def parse_time_specification(units, dt=None, n_steps=None, nsteps=None, t1=None, t2=None, t=None): """ Return an array of times given a few combinations of kwargs that are accepted -- see below. Parameters ---------- dt, n_steps[, t1] : (numeric, int[, numeric]) A fixed timestep dt and ...
Return an array of times given a few combinations of kwargs that are accepted -- see below. Parameters ---------- dt, n_steps[, t1] : (numeric, int[, numeric]) A fixed timestep dt and a number of steps to run for. dt, t1, t2 : (numeric, numeric, numeric) A fixed timestep dt, an init...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/integrate/timespec.py#L13-L110
adrn/gala
gala/dynamics/_genfunc/toy_potentials.py
angact_ho
def angact_ho(x,omega): """ Calculate angle and action variable in sho potential with parameter omega """ action = (x[3:]**2+(omega*x[:3])**2)/(2.*omega) angle = np.array([np.arctan(-x[3+i]/omega[i]/x[i]) if x[i]!=0. else -np.sign(x[3+i])*np.pi/2. for i in range(3)]) for i in range(3): if(x[...
python
def angact_ho(x,omega): """ Calculate angle and action variable in sho potential with parameter omega """ action = (x[3:]**2+(omega*x[:3])**2)/(2.*omega) angle = np.array([np.arctan(-x[3+i]/omega[i]/x[i]) if x[i]!=0. else -np.sign(x[3+i])*np.pi/2. for i in range(3)]) for i in range(3): if(x[...
Calculate angle and action variable in sho potential with parameter omega
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/_genfunc/toy_potentials.py#L18-L26
adrn/gala
gala/dynamics/_genfunc/toy_potentials.py
findbestparams_ho
def findbestparams_ho(xsamples): """ Minimize sum of square differences of H_sho-<H_sho> for timesamples """ return np.abs(leastsq(deltaH_ho,np.array([10.,10.,10.]), Dfun = Jac_deltaH_ho, args=(xsamples,))[0])[:3]
python
def findbestparams_ho(xsamples): """ Minimize sum of square differences of H_sho-<H_sho> for timesamples """ return np.abs(leastsq(deltaH_ho,np.array([10.,10.,10.]), Dfun = Jac_deltaH_ho, args=(xsamples,))[0])[:3]
Minimize sum of square differences of H_sho-<H_sho> for timesamples
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/_genfunc/toy_potentials.py#L39-L41
adrn/gala
gala/dynamics/_genfunc/toy_potentials.py
cart2spol
def cart2spol(X): """ Performs coordinate transformation from cartesian to spherical polar coordinates with (r,phi,theta) having usual meanings. """ x,y,z,vx,vy,vz=X r=np.sqrt(x*x+y*y+z*z) p=np.arctan2(y,x) t=np.arccos(z/r) vr=(vx*np.cos(p)+vy*np.sin(p))*np.sin(t)+np.cos(t)*vz vp=-vx...
python
def cart2spol(X): """ Performs coordinate transformation from cartesian to spherical polar coordinates with (r,phi,theta) having usual meanings. """ x,y,z,vx,vy,vz=X r=np.sqrt(x*x+y*y+z*z) p=np.arctan2(y,x) t=np.arccos(z/r) vr=(vx*np.cos(p)+vy*np.sin(p))*np.sin(t)+np.cos(t)*vz vp=-vx...
Performs coordinate transformation from cartesian to spherical polar coordinates with (r,phi,theta) having usual meanings.
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/_genfunc/toy_potentials.py#L46-L57
adrn/gala
gala/dynamics/_genfunc/toy_potentials.py
H_iso
def H_iso(x,params): """ Isochrone Hamiltonian = -GM/(b+sqrt(b**2+(r-r0)**2))""" #r = (np.sqrt(np.sum(x[:3]**2))-params[2])**2 r = np.sum(x[:3]**2) return 0.5*np.sum(x[3:]**2)-Grav*params[0]/(params[1]+np.sqrt(params[1]**2+r))
python
def H_iso(x,params): """ Isochrone Hamiltonian = -GM/(b+sqrt(b**2+(r-r0)**2))""" #r = (np.sqrt(np.sum(x[:3]**2))-params[2])**2 r = np.sum(x[:3]**2) return 0.5*np.sum(x[3:]**2)-Grav*params[0]/(params[1]+np.sqrt(params[1]**2+r))
Isochrone Hamiltonian = -GM/(b+sqrt(b**2+(r-r0)**2))
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/_genfunc/toy_potentials.py#L60-L64
adrn/gala
gala/dynamics/_genfunc/toy_potentials.py
angact_iso
def angact_iso(x,params): """ Calculate angle and action variable in isochrone potential with parameters params = (M,b) """ GM = Grav*params[0] E = H_iso(x,params) r,p,t,vr,vphi,vt=cart2spol(x) st=np.sin(t) Lz=r*vphi*st L=np.sqrt(r*r*vt*vt+Lz*Lz/st/st) if(E>0.): # Unbound re...
python
def angact_iso(x,params): """ Calculate angle and action variable in isochrone potential with parameters params = (M,b) """ GM = Grav*params[0] E = H_iso(x,params) r,p,t,vr,vphi,vt=cart2spol(x) st=np.sin(t) Lz=r*vphi*st L=np.sqrt(r*r*vt*vt+Lz*Lz/st/st) if(E>0.): # Unbound re...
Calculate angle and action variable in isochrone potential with parameters params = (M,b)
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/_genfunc/toy_potentials.py#L67-L113
adrn/gala
gala/dynamics/_genfunc/toy_potentials.py
findbestparams_iso
def findbestparams_iso(xsamples): """ Minimize sum of square differences of H_iso-<H_iso> for timesamples""" p = 0.5*np.sum(xsamples.T[3:]**2,axis=0) r = np.sum(xsamples.T[:3]**2,axis=0) return np.abs(leastsq(deltaH_iso,np.array([10.,10.]), Dfun = None , col_deriv=1,args=(p,r,))[0])
python
def findbestparams_iso(xsamples): """ Minimize sum of square differences of H_iso-<H_iso> for timesamples""" p = 0.5*np.sum(xsamples.T[3:]**2,axis=0) r = np.sum(xsamples.T[:3]**2,axis=0) return np.abs(leastsq(deltaH_iso,np.array([10.,10.]), Dfun = None , col_deriv=1,args=(p,r,))[0])
Minimize sum of square differences of H_iso-<H_iso> for timesamples
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/_genfunc/toy_potentials.py#L130-L134
adrn/gala
gala/dynamics/util.py
peak_to_peak_period
def peak_to_peak_period(t, f, amplitude_threshold=1E-2): """ Estimate the period of the input time series by measuring the average peak-to-peak time. Parameters ---------- t : array_like Time grid aligned with the input time series. f : array_like A periodic time series. ...
python
def peak_to_peak_period(t, f, amplitude_threshold=1E-2): """ Estimate the period of the input time series by measuring the average peak-to-peak time. Parameters ---------- t : array_like Time grid aligned with the input time series. f : array_like A periodic time series. ...
Estimate the period of the input time series by measuring the average peak-to-peak time. Parameters ---------- t : array_like Time grid aligned with the input time series. f : array_like A periodic time series. amplitude_threshold : numeric (optional) A tolerance paramet...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/util.py#L17-L68
adrn/gala
gala/dynamics/util.py
estimate_dt_n_steps
def estimate_dt_n_steps(w0, hamiltonian, n_periods, n_steps_per_period, dE_threshold=1E-9, func=np.nanmax, **integrate_kwargs): """ Estimate the timestep and number of steps to integrate an orbit for given its initial conditions and a potential object. Pa...
python
def estimate_dt_n_steps(w0, hamiltonian, n_periods, n_steps_per_period, dE_threshold=1E-9, func=np.nanmax, **integrate_kwargs): """ Estimate the timestep and number of steps to integrate an orbit for given its initial conditions and a potential object. Pa...
Estimate the timestep and number of steps to integrate an orbit for given its initial conditions and a potential object. Parameters ---------- w0 : `~gala.dynamics.PhaseSpacePosition`, array_like Initial conditions. potential : :class:`~gala.potential.PotentialBase` The potential to...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/util.py#L94-L169
adrn/gala
gala/dynamics/util.py
combine
def combine(objs): """Combine the specified `~gala.dynamics.PhaseSpacePosition` or `~gala.dynamics.Orbit` objects. Parameters ---------- objs : iterable An iterable of either `~gala.dynamics.PhaseSpacePosition` or `~gala.dynamics.Orbit` objects. """ from .orbit import Orbit ...
python
def combine(objs): """Combine the specified `~gala.dynamics.PhaseSpacePosition` or `~gala.dynamics.Orbit` objects. Parameters ---------- objs : iterable An iterable of either `~gala.dynamics.PhaseSpacePosition` or `~gala.dynamics.Orbit` objects. """ from .orbit import Orbit ...
Combine the specified `~gala.dynamics.PhaseSpacePosition` or `~gala.dynamics.Orbit` objects. Parameters ---------- objs : iterable An iterable of either `~gala.dynamics.PhaseSpacePosition` or `~gala.dynamics.Orbit` objects.
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/util.py#L171-L277
adrn/gala
gala/coordinates/reflex.py
reflex_correct
def reflex_correct(coords, galactocentric_frame=None): """Correct the input Astropy coordinate object for solar reflex motion. The input coordinate instance must have distance and radial velocity information. If the radial velocity is not known, fill the Parameters ---------- coords : `~astropy.co...
python
def reflex_correct(coords, galactocentric_frame=None): """Correct the input Astropy coordinate object for solar reflex motion. The input coordinate instance must have distance and radial velocity information. If the radial velocity is not known, fill the Parameters ---------- coords : `~astropy.co...
Correct the input Astropy coordinate object for solar reflex motion. The input coordinate instance must have distance and radial velocity information. If the radial velocity is not known, fill the Parameters ---------- coords : `~astropy.coordinates.SkyCoord` The Astropy coordinate object with...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/coordinates/reflex.py#L5-L40
adrn/gala
gala/dynamics/plot.py
_get_axes
def _get_axes(dim, subplots_kwargs=dict()): """ Parameters ---------- dim : int Dimensionality of the orbit. subplots_kwargs : dict (optional) Dictionary of kwargs passed to :func:`~matplotlib.pyplot.subplots`. """ import matplotlib.pyplot as plt if dim > 1: n_p...
python
def _get_axes(dim, subplots_kwargs=dict()): """ Parameters ---------- dim : int Dimensionality of the orbit. subplots_kwargs : dict (optional) Dictionary of kwargs passed to :func:`~matplotlib.pyplot.subplots`. """ import matplotlib.pyplot as plt if dim > 1: n_p...
Parameters ---------- dim : int Dimensionality of the orbit. subplots_kwargs : dict (optional) Dictionary of kwargs passed to :func:`~matplotlib.pyplot.subplots`.
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/plot.py#L6-L32
adrn/gala
gala/dynamics/plot.py
plot_projections
def plot_projections(x, relative_to=None, autolim=True, axes=None, subplots_kwargs=dict(), labels=None, plot_function=None, **kwargs): """ Given N-dimensional quantity, ``x``, make a figure containing 2D projections of all combinations of the axes. Parameters ...
python
def plot_projections(x, relative_to=None, autolim=True, axes=None, subplots_kwargs=dict(), labels=None, plot_function=None, **kwargs): """ Given N-dimensional quantity, ``x``, make a figure containing 2D projections of all combinations of the axes. Parameters ...
Given N-dimensional quantity, ``x``, make a figure containing 2D projections of all combinations of the axes. Parameters ---------- x : array_like Array of values. ``axis=0`` is assumed to be the dimensionality, ``axis=1`` is the time axis. See :ref:`shape-conventions` for more ...
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/plot.py#L34-L120
adrn/gala
gala/dynamics/_genfunc/genfunc_3d.py
check_angle_solution
def check_angle_solution(ang,n_vec,toy_aa,timeseries): """ Plots the toy angle solution against the toy angles --- Takes true angles and frequencies ang, the Fourier vectors n_vec, the toy action-angles toy_aa and the timeseries """ f,a=plt.subplots(3,1) for i in range(3): ...
python
def check_angle_solution(ang,n_vec,toy_aa,timeseries): """ Plots the toy angle solution against the toy angles --- Takes true angles and frequencies ang, the Fourier vectors n_vec, the toy action-angles toy_aa and the timeseries """ f,a=plt.subplots(3,1) for i in range(3): ...
Plots the toy angle solution against the toy angles --- Takes true angles and frequencies ang, the Fourier vectors n_vec, the toy action-angles toy_aa and the timeseries
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/_genfunc/genfunc_3d.py#L30-L44
adrn/gala
gala/dynamics/_genfunc/genfunc_3d.py
eval_mean_error_functions
def eval_mean_error_functions(act,ang,n_vec,toy_aa,timeseries,withplot=False): """ Calculates sqrt(mean(E)) and sqrt(mean(F)) """ Err = np.zeros(6) NT = len(timeseries) size = len(ang[6:])/3 UA = ua(toy_aa.T[3:].T,np.ones(3)) fig,axis=None,None if(withplot): fig,axis=plt.subplots(3,...
python
def eval_mean_error_functions(act,ang,n_vec,toy_aa,timeseries,withplot=False): """ Calculates sqrt(mean(E)) and sqrt(mean(F)) """ Err = np.zeros(6) NT = len(timeseries) size = len(ang[6:])/3 UA = ua(toy_aa.T[3:].T,np.ones(3)) fig,axis=None,None if(withplot): fig,axis=plt.subplots(3,...
Calculates sqrt(mean(E)) and sqrt(mean(F))
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/_genfunc/genfunc_3d.py#L63-L94
adrn/gala
gala/dynamics/_genfunc/genfunc_3d.py
box_actions
def box_actions(results, times, N_matrix, ifprint): """ Finds actions, angles and frequencies for box orbit. Takes a series of phase-space points from an orbit integration at times t and returns L = (act,ang,n_vec,toy_aa, pars) -- explained in find_actions() below. """ if(ifprint): ...
python
def box_actions(results, times, N_matrix, ifprint): """ Finds actions, angles and frequencies for box orbit. Takes a series of phase-space points from an orbit integration at times t and returns L = (act,ang,n_vec,toy_aa, pars) -- explained in find_actions() below. """ if(ifprint): ...
Finds actions, angles and frequencies for box orbit. Takes a series of phase-space points from an orbit integration at times t and returns L = (act,ang,n_vec,toy_aa, pars) -- explained in find_actions() below.
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/_genfunc/genfunc_3d.py#L96-L135