<commit_before># encoding: utf-8
# filename: _lm10_acceleration.pyx

from __future__ import division

import sys
import numpy as np
cimport numpy as np

import cython
cimport cython

cdef extern from "math.h":
    double sqrt(double x)
    double atan2(double x, double x)
    double acos(double x)
    double sin(double x)
    double cos(double x)
    double log(double x)
    double abs(double x)

def _gc_to_hel(np.ndarray[double, ndim=2] X not None):
    """ Assumes Galactic units: kpc, Myr, radian, M_sun """

    cdef int nparticles = X.shape[0]
    cdef double Rsun = 8.
    cdef double Vcirc = 0.224996676312
    cdef double[:,:] O = np.empty((nparticles, 6))

    cdef double x, y, z, vx, vy, vz, d_xy
    cdef double l,b,d,mul,mub,vr

    for ii in range(nparticles):
        # transform to heliocentric cartesian
        x = X[ii,0] + Rsun
        y = X[ii,1]
        z = X[ii,2]
        vx = X[ii,3]
        vy = X[ii,4] - Vcirc
        vz = X[ii,5]

        # transform from cartesian to spherical
        d = sqrt(x**2 + y**2 + z**2)
        l = atan2(y, x)
        b = 1.5707963267948966 - acos(z/d)

        # transform cartesian velocity to spherical
        d_xy = sqrt(x**2 + y**2)
        vr = (vx*x + vy*y + vz*z) / d # kpc/Myr
        mul = -(vx*y - x*vy) / d_xy**2 # rad / Myr
        mub = -(z*(x*vx + y*vy) - d_xy**2*vz) / (d**2 * d_xy) # rad / Myr

        O[ii,0] = l
        O[ii,1] = b
        O[ii,2] = d
        O[ii,3] = mul
        O[ii,4] = mub
        O[ii,5] = vr

    return np.array(O)

def _hel_to_gc(np.ndarray[double, ndim=2] O not None):
    """ Assumes Galactic units: kpc, Myr, radian, M_sun """

    cdef int nparticles = O.shape[0]
    cdef double Rsun = 8.
    cdef double Vcirc = 0.224996676312<commit_msg>0 to 360 not -180 to 180<commit_after># encoding: utf-8
# filename: _lm10_acceleration.pyx

from __future__ import division

import sys
import numpy as np
cimport numpy as np

import cython
cimport cython

cdef extern from "math.h":
    double sqrt(double x)
    double atan2(double x, double x)
    double acos(double x)
    double sin(double x)
    double cos(double x)
    double log(double x)
    double abs(double x)

def _gc_to_hel(np.ndarray[double, ndim=2] X not None):
    """ Assumes Galactic units: kpc, Myr, radian, M_sun """

    cdef int nparticles = X.shape[0]
    cdef double Rsun = 8.
    cdef double Vcirc = 0.224996676312
    cdef double[:,:] O = np.empty((nparticles, 6))

    cdef double x, y, z, vx, vy, vz, d_xy
    cdef double l,b,d,mul,mub,vr
    cdef double twopi = np.pi*2

    for ii in range(nparticles):
        # transform to heliocentric cartesian
        x = X[ii,0] + Rsun
        y = X[ii,1]
        z = X[ii,2]
        vx = X[ii,3]
        vy = X[ii,4] - Vcirc
        vz = X[ii,5]

        # transform from cartesian to spherical
        d = sqrt(x**2 + y**2 + z**2)
        l = atan2(y, x)
        b = 1.5707963267948966 - acos(z/d)

        if l < 0:
            l = l+twopi

        # transform cartesian velocity to spherical
        d_xy = sqrt(x**2 + y**2)
        vr = (vx*x + vy*y + vz*z) / d # kpc/Myr
        mul = -(vx*y - x*vy) / d_xy**2 # rad / Myr
        mub = -(z*(x*vx + y*vy) - d_xy**2*vz) / (d**2 * d_xy) # rad / Myr

        O[ii,0] = l
        O[ii,1] = b
        O[ii,2] = d
        O[ii,3] = mul
        O[ii,4] = mub
        O[ii,5] = vr

    return np.array(O)

def _hel_to_gc(np.ndarray[double, ndim=2] O not None):
    """ Assumes Galactic units: kpc, Myr, radian, M_sun """

    cdef int nparticles = O.shape[0]
    cdef double Rsun = 8.
    cdef double Vcirc = 0.224996676312
{'fraction_non_alphanumeric': 0.13348164627363737, 'fraction_numerical': 0.04505005561735261, 'mean_word_length': 2.1608084358523727, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4869335', 'n_tokens_mistral': 1554, 'n_tokens_neox': 1433, 'n_words': 406}