Ignore:
Timestamp:
06/07/17 10:50:54 (8 years ago)
Author:
Eric.Larour
Message:

CHG: merged branch back to trunk-jpl 21754.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/branches/trunk-larour-NatGeoScience2016/src/m/coordsystems/xy2ll.py

    r17712 r21759  
    1 import numpy as npy
     1import numpy as  np
    22from math import pi
    33
     
    3737                raise StandardError('bad usage: type "help(xy2ll)" for details')
    3838
    39         # if x,y passed as lists, convert to numpy arrays
    40         if type(x) != "numpy.ndarray":
    41                 x=npy.array(x)
    42         if type(y) != "numpy.ndarray":
    43                 y=npy.array(y)
     39        # if x,y passed as lists, convert to np.arrays
     40        if type(x) != "np.ndarray":
     41                x=np.array(x)
     42        if type(y) != "np.ndarray":
     43                y=np.array(y)
    4444
    4545        ## Conversion constant from degrees to radians
     
    5050        ex2 = .006693883
    5151        ## Eccentricity of the Hughes ellipsoid
    52         ex = npy.sqrt(ex2)
     52        ex = np.sqrt(ex2)
    5353       
    5454        sl = slat*pi/180.
    55         rho = npy.sqrt(x**2 + y**2)
    56         cm = npy.cos(sl) / npy.sqrt(1.0 - ex2 * (npy.sin(sl)**2))
    57         T = npy.tan((pi/4.0) - (sl/2.0)) / ((1.0 - ex*npy.sin(sl)) / (1.0 + ex*npy.sin(sl)))**(ex / 2.0)
     55        rho = np.sqrt(x**2 + y**2)
     56        cm = np.cos(sl) / np.sqrt(1.0 - ex2 * (np.sin(sl)**2))
     57        T = np.tan((pi/4.0) - (sl/2.0)) / ((1.0 - ex*np.sin(sl)) / (1.0 + ex*np.sin(sl)))**(ex / 2.0)
    5858       
    5959        if abs(slat-90.) < 1.e-5:
    60                 T = rho*npy.sqrt((1. + ex)**(1. + ex) * (1. - ex)**(1. - ex)) / 2. / re
     60                T = rho*np.sqrt((1. + ex)**(1. + ex) * (1. - ex)**(1. - ex)) / 2. / re
    6161        else:
    6262                T = rho * T / (re * cm)
    6363       
    64         chi = (pi / 2.0) - 2.0 * npy.arctan(T)
     64        chi = (pi / 2.0) - 2.0 * np.arctan(T)
    6565        lat = chi + ((ex2 / 2.0) + (5.0 * ex2**2.0 / 24.0) + (ex2**3.0 / 12.0)) * \
    66                 npy.sin(2 * chi) + ((7.0 * ex2**2.0 / 48.0) + (29.0 * ex2**3 / 240.0)) * \
    67                 npy.sin(4.0 * chi) + (7.0 * ex2**3.0 / 120.0) * npy.sin(6.0 * chi)
     66                np.sin(2 * chi) + ((7.0 * ex2**2.0 / 48.0) + (29.0 * ex2**3 / 240.0)) * \
     67                np.sin(4.0 * chi) + (7.0 * ex2**3.0 / 120.0) * np.sin(6.0 * chi)
    6868       
    6969        lat = sgn * lat
    70         lon = npy.arctan2(sgn * x,-sgn * y)
     70        lon = np.arctan2(sgn * x,-sgn * y)
    7171        lon = sgn * lon
    7272       
    73         res1 = npy.nonzero(rho <= 0.1)[0]
     73        res1 = np.nonzero(rho <= 0.1)[0]
    7474        if len(res1) > 0:
    7575                lat[res1] = 90. * sgn
Note: See TracChangeset for help on using the changeset viewer.