Example #1
0
    def binByPosition(self, rbins, dbins, string):
        '''
        This is not a strictly accurate title. We are binning by position then spitting back ages within those position bins
        '''
        val2bin = self.params[string]
        nr = len(rbins)-1
        nd = len(dbins)-1

        out = []
        eout = []
        for i in range(nr):
            for j in range(nd):
                # pdb.set_trace()
                ind = (self.ra*cosdg(self.d31) > rbins[i]) & (self.ra*cosdg(self.d31) <= rbins[i+1]) & (self.dec > dbins[j]) & (self.dec <= dbins[j+1]) & (self.params['PIXAV'] >= 0)
                z = val2bin[ind]

                if len(z) > 10:
                    out.append(np.mean(z[z == z]))
                    #eout.append(0)
                    eout.append(np.std(z[z == z])/np.sqrt(len(z)))
                else:
                    out.append(np.nan)
                    eout.append(np.nan)
                    
        return np.array(out), np.array(eout)
Example #2
0
def rot_x_matrix( degrees ):
    r = identity( 3, 'd' )
    r[1][1] = cosdg( degrees )
    r[1][2] = -sindg( degrees )
    r[2][1] = sindg( degrees )
    r[2][2] = cosdg( degrees )

    return r
Example #3
0
def v_hel(z, ra, dec, mjd, aband, longitude=keck_long, latitude=keck_lat, altitude=keck_alt, tanplane=False, delim=":"):
    """
    Calculate the heliocentric velocity of stars given their redshift (z), RA and DEC, date of observation (mjd) and A-band correction
    Default longitude and latitude correspond to Keck
    Required arguments:
    - z: redshift
    - ra: right ascension as string or degree
    - dec: declination as string or degree
    - mjd: Julian Date of observation
    - abad: Aband correction
    Optional arguments
    - longitude: longitude of observatory
    - latitude: latitude of observatory
    - altitude: altitude of observatory
    - tanplane: are your positions already in the tangential plane
    - delim: delimiter if your positions are a string

    Note: helcorr.py, and its dependencies, are part of Sergey Koposov's astrolibpy library.
          I am not aware of an astropy equivalent, but there may well be one
          It is being imported here so as to not muck up all the other things that don't need it
    """
    from helcorr import helcorr

    if isinstance(ra, str):
        ra_deg, dec_deg = hms2deg(ra, dec, delim=delim)
    else:
        ra_deg = ra
        dec_deg = dec

    if ~tanplane:
        ra_deg *= cosdg(d31)

    return (z * c) - (aband * c) - helcorr(longitude, latitude, altitude, ra_deg, dec_deg, mjd)[0]
Example #4
0
    def write_xml(self, filename, lat):
        if self.dim != lat.dim:
            ERROR("dimension mismatch between wavevector and lattice")
        with codecs.open(filename, "w", "utf-8") as f:
            f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
            f.write("<WaveVector>\n")
            f.write(tagged("Comment", lat.name))
            f.write(tagged("NumberOfSites", len(lat.sites)))
            f.write(tagged("NumberOfWaveVectors", self.nk))

            f.write(
                "<!-- <RK> [phase(cos)] [phase(sin)] [isite] [kindx] </RK> -->\n"
            )
            for ik in range(self.nk):
                k = self.ks[:, ik]
                for site in lat.sites:
                    sid = site.id
                    coord = site.coord
                    phase = 0
                    for d in range(self.dim):
                        phase += coord[d] * k[d] / float(lat.size[d])
                    c = spsp.cosdg(360 * phase)
                    s = spsp.sindg(360 * phase)
                    f.write(tagged("RK", [c, s, sid, ik]))

            f.write("</WaveVector>\n")
Example #5
0
def keck_constants():
    return {
        "latitude": 19.8283,
        "longitude": 360.0 - 155.478,
        "altitude": 4160.0,
        "declination": 41.269,
        "right_ascension": 10.68 * cosdg(41.269),
    }
Example #6
0
    def rotate( self, degrees ):
        """rotate this vector by given degrees and return as new vector
        """
        # cosine vector is this vector multiplied by cosine of angle
        cosine = self.multiply( cosdg(degrees) )

        # sine vector is cross product of this vector and normalized given
        # vector, multiplied by sine of angle
        sine = self.cross().multiply( sindg(degrees) )

        return cosine.add( sine )
Example #7
0
def generate(param):
    dim = 2
    L = get_as_list(param, "L", extendto=dim)
    bc = get_as_list(param, "bc", default=True, extendto=dim)
    basis = np.array([[1.0, 0.0], [cosdg(120), sindg(120)]])

    sites = [
            {"siteid": 0, "type": 0, "coord": [0.0, 0.0]},
            {"siteid": 1, "type": 0, "coord": [0.5, 0.0]},
            {"siteid": 1, "type": 0, "coord": [0.5, 0.5]},
            ]
    bonds = [
        {
            "bondid": 0,
            "type": 0,
            "source": {"siteid": 0},
            "target": {"siteid": 1, "offset": [0, 0]},
        },
        {
            "bondid": 1,
            "type": 0,
            "source": {"siteid": 0},
            "target": {"siteid": 2, "offset": [0, 0]},
        },
        {
            "bondid": 2,
            "type": 0,
            "source": {"siteid": 1},
            "target": {"siteid": 2, "offset": [0, 0]},
        },
        {
            "bondid": 3,
            "type": 0,
            "source": {"siteid": 1},
            "target": {"siteid": 0, "offset": [1, 0]},
        },
        {
            "bondid": 4,
            "type": 0,
            "source": {"siteid": 2},
            "target": {"siteid": 1, "offset": [0, 1]},
        },
        {
            "bondid": 5,
            "type": 0,
            "source": {"siteid": 2},
            "target": {"siteid": 0, "offset": [1, 1]},
        },
    ]

    parameter = {"name": "kagome", "dim": dim, "L": L, "bc": bc, "basis": basis}
    unitcell = {"sites": sites, "bonds": bonds}

    return {"parameter": parameter, "unitcell": unitcell}
Example #8
0
def dist_from_m31(*args, **kwargs):
    """
    Formerly computeDist
    Computes distance from M31 center in kpc, designed for stars within the disk
    Default PA of M31 away from vertical is 50 degrees, computed through trial and error off of a Galex image
    
    Required arguments:
    - ra: right ascension
    - dec: declination
    Optional arguments
    - tanplane: are your input positions already in the tangent plane
    - tilt: tilt of M31
    - i: inclination of M31
    """

    if len(args) == 2:
        ra, dec = args
    else:
        print 'Proper syntax is "computeDist(ra, dec, tanplane= T/F)'
        return

    tanplane = kwargs.get("tanplane", False)
    tilt = kwargs.get("tilt", 50)
    i = kwargs.get("i", 74)

    d31 = 41.269
    r31 = 10.68 * cosdg(d31)
    if tanplane:
        # If RA is already in the tangent plane
        x = (ra - r31) * 13.67
    else:
        # If it isn't
        ra_new = ra * cosdg(d31)
        x = (ra_new - r31) * 13.67

    y = (dec - d31) * 13.67
    xr = x * cosdg(tilt) + y * sindg(tilt)
    yr = -x * sindg(tilt) + y * cosdg(tilt)
    r = np.sqrt(xr ** 2 + yr ** 2)
    alpha = np.arctan2(yr, xr * cosdg(i)) * 180.0 / np.pi
    dist = r / (np.sqrt(cosdg(alpha) ** 2 + (sindg(alpha) * cosdg(i)) ** 2))

    return dist

fun1 = special.kelvin(15)
print(fun1)


fun2 = special.xlogy(2, 10)
print(fun2)

fun3 = special.exp10(50)
print(fun3)

fun4 = special.sindg(60)
print(fun4)

fun5 = special.cosdg(60)
print(fun5)

print('---------------------')


def var1(x): return x**3


fun6 = integrate.quad(var1, 0, 6)
print(fun6)


def var2(y, x): return x * y**4

import pdb
import pyfits
import matplotlib
import CM_MASTER
import show_galex

import numpy as np
import matplotlib.pyplot as py

from scipy.special import cosdg


cmbase = CM_MASTER.CM_Master()

dr = 0.24*cosdg(cmbase.d31)
dd = 0.24 

rbins = np.arange(min(cmbase.ra*cosdg(cmbase.d31)),max(cmbase.ra*cosdg(cmbase.d31)),dr)
dbins = np.arange(min(cmbase.dec), max(cmbase.dec),dd)

rabins = (rbins - cmbase.r31*cosdg(cmbase.d31))*-13.67
decbins = (dbins - cmbase.d31)*13.67


allRA = (cmbase.ra-cmbase.r31)*cosdg(cmbase.d31)*-13.67
allDEC = (cmbase.dec - cmbase.d31)*13.67

agbra = allRA[cmbase.params['EVSTAGE'] == 'AGB']
agbdec = allDEC[cmbase.params['EVSTAGE'] == 'AGB']

cra = allRA[cmbase.c]
Example #11
0
import scipy
from scipy import cluster
from scipy import special
from scipy import integrate

a = special.exp10(2)
print(a)

b = special.exp2(2)
print(b)

c = special.sindg(90)
print(c)

print(special.cosdg(0))

print(scipy.integrate.quad(lambda x: special.exp10(x), 0, 1))
Example #12
0
from scipy import special

# for computing 10^x
a = special.exp10(2)
print(a)

# for computing 2^x
a = special.exp2(3)
print(a)

# sin function
s = special.sindg(90)
print(s)

# cos function
c = special.cosdg(90)
print(c)
#    v_guess = term1/term2

    
                  

hdu = pyfits.open('/Users/khamren/M31_Research/splash_data/subMasterSPLASH_zerr.fits')
data = hdu[1].data
cstars = data[(data.CID == 'c') & (data.FIELDTYPE == 'disk') & (data.RA != '00:00:00')]
agb = data[((data.EVSTAGE == 'AGB') | (data.EVSTAGE == 'agb')) & (data.FIELDTYPE == 'disk') & (data.RA != '00:00:00')]
agb_noc = data[((data.EVSTAGE == 'AGB') | (data.EVSTAGE == 'agb')) & (data.FIELDTYPE == 'disk') & (data.RA != '00:00:00') & (data.CID != 'c')]


#cvel = (cstars.Z*c) - (cstars.ABAND*c) - helcorr(keck_long,keck_lat,keck_alt,cra, cdec,cstars.MJD)[0]

cra = np.array([hms2deg(r,d)[0] for r,d in zip(cstars.RA, cstars.DEC)])
cra2 = cra*cosdg(d31)
cdec = np.array([hms2deg(r,d)[1] for r,d in zip(cstars.RA, cstars.DEC)])

cdist = computeDist(cra, cdec)

ara = np.array([hms2deg(r,d)[0] for r,d in zip(agb_noc.RA, agb_noc.DEC)])
ara2 = ara*cosdg(d31)
adec = np.array([hms2deg(r,d)[1] for r,d in zip(agb_noc.RA, agb_noc.DEC)])

ara_all = np.array([hms2deg(r,d)[0] for r,d in zip(agb.RA, agb.DEC)])
ara2_all = ara_all*cosdg(d31)
adec_all = np.array([hms2deg(r,d)[1] for r,d in zip(agb.RA, agb.DEC)])

cvel = np.array([((z*c) - (aband*c) - helcorr(keck_long,keck_lat,keck_alt,r,d, mjd)[0]) for z, aband, r, d, mjd in zip(cstars.Z, cstars.ABAND, cra, cdec, cstars.MJD)])
avel = np.array([((z*c) - (aband*c) - helcorr(keck_long, keck_lat,keck_alt, r,d, mjd)[0]) for z, aband, r, d, mjd in zip(agb_noc.Z, agb_noc.ABAND, ara, adec, agb_noc.MJD)])
averr = agb_noc.Z_ERR*c 
# Python Full Course - Learn Python in 12 Hours | Python Tutorial For Beginners | Edureka
# This lesson looks at some of the special mathematical functions in SciPy such as
# exponential and trigonometric functions.

# We need to import special the function
# from the scipy library
from scipy import special

# Exponential Functions

# Calculates 10 to the power of 2
a = special.exp10(2)
# Outputs 10 squared
print("10 squared =", a)

b = special.exp2(3)
print("2 cubed =", b)

# Trigonometric Functions

# Gets the sine value of an angle in degrees
c = special.sindg(90)
print("The sine value of 90 degrees is:", c)

# Gets the cosine value of of an angle in degrees
d = special.cosdg(0)
print("The cosine value of 0 degrees is:", d)
Example #15
0
def rotate(input_arr,
           angle,
           axes=(1, 0),
           reshape=True,
           output=None,
           order=1,
           mode='constant',
           cval=0.0,
           prefilter=False,
           output_chunks=None,
           output_shape=None):
    """
    
    Rotate an array using Dask. Chunkwise processing is performed
    using dask_image.ndinterp.affine_transform

    The array is rotated in the plane defined by the two axes given by the
    `axes` parameter using spline interpolation of the requested order.

    Parameters
    ----------
    %(input)s
    angle : float
        The rotation angle in degrees.
    axes : tuple of 2 ints, optional
        The two axes that define the plane of rotation. Default is the first
        two axes.
    reshape : bool, optional
        If `reshape` is true, the output shape is adapted so that the input
        array is contained completely in the output. Default is True.
    %(output)s
    order : int, optional
        The order of the spline interpolation, default is 3.
        The order has to be in the range 0-5.
    %(mode_interp_constant)s
    %(cval)s
    %(prefilter)s

    Returns
    -------
    rotate : ndarray
        The rotated input.

    Notes
    -----
        Differences to `ndimage.affine_transformation`:
        - currently, prefiltering is not supported
          (affecting the output in case of interpolation `order > 1`)
        - default order is 1
        - modes 'reflect', 'mirror' and 'wrap' are not supported
        
        Arguments equal to `ndimage.affine_rotate`,
        except for `output_chunks`.

    .. versionadded:: 1.6.0


    Examples
    --------
    >>> from scipy import ndimage, misc
    >>> import matplotlib.pyplot as plt
    >>> import dask.array as da
    >>> fig = plt.figure(figsize=(10, 3))
    >>> ax1, ax2, ax3 = fig.subplots(1, 3)
    >>> img = da.from_array(misc.ascent(),chunks=(64,64))
    >>> img_45 = dask_image.ndinterp.rotate(img, 45, reshape=False)
    >>> full_img_45 = dask_image.ndinterp.rotate(img, 45, reshape=True)
    >>> ax1.imshow(img, cmap='gray')
    >>> ax1.set_axis_off()
    >>> ax2.imshow(img_45, cmap='gray')
    >>> ax2.set_axis_off()
    >>> ax3.imshow(full_img_45, cmap='gray')
    >>> ax3.set_axis_off()
    >>> fig.set_tight_layout(True)
    >>> plt.show()
    >>> print(img.shape)
    (512, 512)
    >>> print(img_45.shape)
    (512, 512)
    >>> print(full_img_45.shape)
    (724, 724)

    """
    #  input_arr = input#np.asarray(input)

    if not type(input_arr) == da.core.Array:
        input_arr = da.from_array(input_arr)

    if output_shape is None:
        output_shape = input_arr.shape

    ndim = input_arr.ndim

    if reshape & (output_shape != None):
        warnings.warn(
            'Both reshaping desired and output_shape provided.'
            'Will use the explicit output_shape.', UserWarning)

    if ndim < 2:
        raise ValueError('input array should be at least 2D')

    axes = list(axes)

    if len(axes) != 2:
        raise ValueError('axes should contain exactly two values')

    if not all([float(ax).is_integer() for ax in axes]):
        raise ValueError('axes should contain only integer values')

    if axes[0] < 0:
        axes[0] += ndim
    if axes[1] < 0:
        axes[1] += ndim
    if axes[0] < 0 or axes[1] < 0 or axes[0] >= ndim or axes[1] >= ndim:
        raise ValueError('invalid rotation plane specified')

    axes.sort()

    c, s = special.cosdg(angle), special.sindg(angle)

    rot_matrix = np.array([[c, s], [-s, c]])

    img_shape = np.asarray(input_arr.shape)
    in_plane_shape = img_shape[axes]

    if reshape:
        # Compute transformed input bounds
        iy, ix = in_plane_shape
        out_bounds = rot_matrix @ [[0, 0, iy, iy], [0, ix, 0, ix]]
        # Compute the shape of the transformed input plane
        out_plane_shape = (out_bounds.ptp(axis=1) + 0.5).astype(int)
    else:
        out_plane_shape = img_shape[axes]

    if output_shape is None:
        output_shape = img_shape
        output_shape[axes] = out_plane_shape
    else:
        out_plane_shape = np.asarray(output_shape)[axes]

    out_center = rot_matrix @ ((out_plane_shape - 1) / 2)
    in_center = (in_plane_shape - 1) / 2
    offset = in_center - out_center
    output_shape = tuple(output_shape)

    if ndim <= 2:

        output = affine_transform(input_arr,
                                  rot_matrix,
                                  offset=offset,
                                  output_shape=tuple(output_shape),
                                  order=order,
                                  mode=mode,
                                  cval=cval,
                                  prefilter=prefilter,
                                  output_chunks=output_chunks)

    elif ndim >= 3:
        rotmat_nd = np.eye(ndim)
        offset_nd = np.zeros(ndim)

        for o_x, idx in enumerate(axes):

            rotmat_nd[idx, axes[0]] = rot_matrix[o_x, 0]
            rotmat_nd[idx, axes[1]] = rot_matrix[o_x, 1]

            offset_nd[idx] = offset[o_x]

        output = affine_transform(input_arr,
                                  rotmat_nd,
                                  offset=offset_nd,
                                  output_shape=tuple(output_shape),
                                  order=order,
                                  mode=mode,
                                  cval=cval,
                                  prefilter=prefilter,
                                  output_chunks=output_chunks)

    return output
Example #16
0
def find_hit_position(angle, pos, track_map, dl=1.0):
    """
    This function returns the point at which
        a beam coming from point pos at angle given by angle variable
         for the first time crosses a non zero point on the map
         Timing at Marcin computer: dl = 5.0 -> about max 0.4 ms;
         It is roughly valid: dl/n -> time*n
     :param angle: angle (deg) in which the beam is going, e.g the body angle of the car
     :param pos: point ((x,y) in pixels) where the beam starts, e.g. position of the car
     :param track_map: a SPECIAL map which is non-zero in sand region and zero on track. Use map_lidar for it.
     :param dl: determines the precision of the collision point determination
                - the algorithm moves along the beam and checks every dl pixels (does not need to be integer)
                if it left the track
     :return the point on the track boundary which the beam first hits ((x,y) in pixels)
                    (e.g. which the car would hit if it would go on a straight line)
    """
    (h, w) = track_map.shape
    found = False

    # x = meters2pixels(pos[0])
    # y = meters2pixels(pos[1])

    x = pos[0]
    y = pos[1]

    # Depending on direction we take y = ax+b or x = ay+b
    if (45.0 < angle < 135.0) or (225.0 < angle < 315.0):
        # x = ay+b

        dy = dl * sindg(angle)
        # dy = dl
        a = cotdg(angle)
        b = x - a * y

        while 0 < x < w and 0 < y < h:
            if track_map[int(y), int(x)] > 0:
                found = True
                break
            else:
                y = y + dy
                x = a * y + b


    else:
        # dx = dl
        dx = dl * cosdg(angle)
        a = tandg(angle)
        b = y - a * x

        while 0 < x < w and 0 < y < h:
            if track_map[int(y), int(x)] > 0:
                found = True
                break
            else:
                x = x + dx
                y = a * x + b

    if found:
        hit_pos = (x, y)
    else:
        hit_pos = None

    return hit_pos
Example #17
0
#oh_out = np.column_stack((ra_matched, dec_matched, dist_oh, obj_oh, obj_eoh))
#np.savetxt('HII_OH_all.txt', oh_out, fmt = ('%10.8f','%10.8f','%6.4f','%4.3f','%4.3f'))
#pdb.set_trace()
#pOH = np.polyfit(dist_oh, obj_oh[inds],1)

#-----------Get SPLASH data-----------------------------
cmbase = CM_MASTER.CM_Master()

#dr = 0.24*cosdg(cmbase.d31)
#dd = 0.24 
#rbins = np.arange(min(cmbase.ra*cosdg(cmbase.d31)),max(cmbase.ra*cosdg(cmbase.d31)),dr)
#dbins = np.arange(min(cmbase.dec), max(cmbase.dec),dd)

radbins = np.arange(3, 25, 5)

cra = cmbase.ra[cmbase.c]*cosdg(cmbase.d31)
cdec = cmbase.dec[cmbase.c]
cdist = computeDist(cra, cdec, tanplane = True)

hC, bins = np.histogram(cdist, bins = radbins)
hC *= 1.0

raB95 = cmbase.ra[cmbase.brewer]*cosdg(cmbase.d31)
decB95 = cmbase.dec[cmbase.brewer]
distB95 = computeDist(raB95, decB95, tanplane = True)

hB95, bins = np.histogram(distB95, bins = radbins)

cmB95 = hC/hB95
cmB95e = cmB95*np.sqrt((hC+hB95)/(hC*hB95))
Example #18
0
def matchDUSTiNGS(type, ra, dec, masks):

    if type == 'dsph':
        table = np.genfromtxt('/Users/khamren/M31_Research/splash_data/DUSTiNGS/dsph_goodcat.tsv', delimiter=';', dtype=str, filling_values='9999')
    elif type == 'de':
        table =  np.genfromtxt('/Users/khamren/M31_Research/splash_data/DUSTiNGS/ngc_goodcat.tsv', delimiter=';', dtype=str, filling_values='9999')
    else:
        raise AttributeError('Input type should be dsph or de')

    dust_fields = np.array([convert_to_mask(m) for m in table[:,0]])
    dust_ra = np.array([hms2deg(':'.join(r.strip().split()),':'.join(d.strip().split()))[0]
                        for r,d in zip(table[:,1],table[:,2])])
    dust_dec = np.array([hms2deg(':'.join(r.strip().split()),':'.join(d.strip().split()))[1]
                         for r,d in zip(table[:,1],table[:,2])])

    n = len(ra)
    m36 = np.empty(n)
    em36 = np.empty(n)
    m45 = np.empty(n)
    em45 = np.empty(n)

    splash_fields = np.array([re.split('_',m)[0].lower() for m in masks])
    
    for i,r,d,m in zip(range(n),ra, dec,splash_fields):

        if m == 'd7bi':
            m = 'd7'
            
        dist = np.array([3600*np.sqrt(((r-rv)*cosdg(d))**2 + (d-dv)**2)
                         for rv, dv in zip(dust_ra[dust_fields == m], dust_dec[dust_fields == m])])

        try:
            if (len(dist) == 0) or (min(dist) > 0.5):
                m36[i] = np.nan
                em36[i] = np.nan
                m45[i] = np.nan
                em45[i] = np.nan
            
            else:
                j = np.argwhere(dist == min(dist))[0][0]

                try:
                    m36[i] =(table[j,3].astype(float))
                    em36[i] =(table[j,4].astype(float))
                    m45[i] =(table[j,9].astype(float))
                    em45[i] =(table[j,10].astype(float))
                except:
                    try:
                        m36[i] =(table[j,5].astype(float))
                        em36[i] =(table[j,6].astype(float)) 
                        m45[i] =(table[j,11].astype(float))
                        em45[i] =(table[j,12].astype(float))
                    except:
                        try:
                            m36[i] =(table[j,7].astype(float))
                            em36[i] =(table[j,8].astype(float))
                            m45[i] =(table[j,13].astype(float))
                            em45[i] =(table[j,14].astype(float))
                        except:
                            m36[i] = np.nan
                            em36[i] = np.nan
                            m45[i] = np.nan
                            em45[i] = np.nan    
        except:
            pdb.set_trace()
            

    return np.array(m36), np.array(em36), np.array(m45), np.array(em45)
Example #19
0
def rotate(input, angle, axes=(1, 0), reshape=True, output=None, order=3,
           mode='constant', cval=0.0, prefilter=True):
    """
    Rotate an array.

    The array is rotated in the plane defined by the two axes given by the
    `axes` parameter using spline interpolation of the requested order.

    Parameters
    ----------
    %(input)s
    angle : float
        The rotation angle in degrees.
    axes : tuple of 2 ints, optional
        The two axes that define the plane of rotation. Default is the first
        two axes.
    reshape : bool, optional
        If `reshape` is true, the output shape is adapted so that the input
        array is contained completely in the output. Default is True.
    %(output)s
    order : int, optional
        The order of the spline interpolation, default is 3.
        The order has to be in the range 0-5.
    %(mode_interp_constant)s
    %(cval)s
    %(prefilter)s

    Returns
    -------
    rotate : ndarray
        The rotated input.

    Notes
    -----
    For complex-valued `input`, this function rotates the real and imaginary
    components independently.

    .. versionadded:: 1.6.0
        Complex-valued support added.

    Examples
    --------
    >>> from scipy import ndimage, misc
    >>> import matplotlib.pyplot as plt
    >>> fig = plt.figure(figsize=(10, 3))
    >>> ax1, ax2, ax3 = fig.subplots(1, 3)
    >>> img = misc.ascent()
    >>> img_45 = ndimage.rotate(img, 45, reshape=False)
    >>> full_img_45 = ndimage.rotate(img, 45, reshape=True)
    >>> ax1.imshow(img, cmap='gray')
    >>> ax1.set_axis_off()
    >>> ax2.imshow(img_45, cmap='gray')
    >>> ax2.set_axis_off()
    >>> ax3.imshow(full_img_45, cmap='gray')
    >>> ax3.set_axis_off()
    >>> fig.set_tight_layout(True)
    >>> plt.show()
    >>> print(img.shape)
    (512, 512)
    >>> print(img_45.shape)
    (512, 512)
    >>> print(full_img_45.shape)
    (724, 724)

    """
    input_arr = numpy.asarray(input)
    ndim = input_arr.ndim

    if ndim < 2:
        raise ValueError('input array should be at least 2D')

    axes = list(axes)

    if len(axes) != 2:
        raise ValueError('axes should contain exactly two values')

    if not all([float(ax).is_integer() for ax in axes]):
        raise ValueError('axes should contain only integer values')

    if axes[0] < 0:
        axes[0] += ndim
    if axes[1] < 0:
        axes[1] += ndim
    if axes[0] < 0 or axes[1] < 0 or axes[0] >= ndim or axes[1] >= ndim:
        raise ValueError('invalid rotation plane specified')

    axes.sort()

    c, s = special.cosdg(angle), special.sindg(angle)

    rot_matrix = numpy.array([[c, s],
                              [-s, c]])

    img_shape = numpy.asarray(input_arr.shape)
    in_plane_shape = img_shape[axes]
    if reshape:
        # Compute transformed input bounds
        iy, ix = in_plane_shape
        out_bounds = rot_matrix @ [[0, 0, iy, iy],
                                   [0, ix, 0, ix]]
        # Compute the shape of the transformed input plane
        out_plane_shape = (out_bounds.ptp(axis=1) + 0.5).astype(int)
    else:
        out_plane_shape = img_shape[axes]

    out_center = rot_matrix @ ((out_plane_shape - 1) / 2)
    in_center = (in_plane_shape - 1) / 2
    offset = in_center - out_center

    output_shape = img_shape
    output_shape[axes] = out_plane_shape
    output_shape = tuple(output_shape)

    complex_output = numpy.iscomplexobj(input_arr)
    output = _ni_support._get_output(output, input_arr, shape=output_shape,
                                     complex_output=complex_output)

    if ndim <= 2:
        affine_transform(input_arr, rot_matrix, offset, output_shape, output,
                         order, mode, cval, prefilter)
    else:
        # If ndim > 2, the rotation is applied over all the planes
        # parallel to axes
        planes_coord = itertools.product(
            *[[slice(None)] if ax in axes else range(img_shape[ax])
              for ax in range(ndim)])

        out_plane_shape = tuple(out_plane_shape)

        for coordinates in planes_coord:
            ia = input_arr[coordinates]
            oa = output[coordinates]
            affine_transform(ia, rot_matrix, offset, out_plane_shape,
                             oa, order, mode, cval, prefilter)

    return output
import scipy as sp
from scipy import special

fun1 = special.kelvin(15)
print(fun1)

fun2 = special.xlogy(2, 10)
print(fun2)

fun3 = special.exp10(50)
print(fun3)

fun4 = special.sindg(30)
print(fun4)

fun5 = special.cosdg(90)
print(fun5)