- Timestamp:
- 06/07/17 10:50:54 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/branches/trunk-larour-NatGeoScience2016/src/m/coordsystems/xy2ll.py
r17712 r21759 1 import numpy as npy1 import numpy as np 2 2 from math import pi 3 3 … … 37 37 raise StandardError('bad usage: type "help(xy2ll)" for details') 38 38 39 # if x,y passed as lists, convert to n umpyarrays40 if type(x) != "n umpy.ndarray":41 x=np y.array(x)42 if type(y) != "n umpy.ndarray":43 y=np y.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) 44 44 45 45 ## Conversion constant from degrees to radians … … 50 50 ex2 = .006693883 51 51 ## Eccentricity of the Hughes ellipsoid 52 ex = np y.sqrt(ex2)52 ex = np.sqrt(ex2) 53 53 54 54 sl = slat*pi/180. 55 rho = np y.sqrt(x**2 + y**2)56 cm = np y.cos(sl) / npy.sqrt(1.0 - ex2 * (npy.sin(sl)**2))57 T = np y.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) 58 58 59 59 if abs(slat-90.) < 1.e-5: 60 T = rho*np y.sqrt((1. + ex)**(1. + ex) * (1. - ex)**(1. - ex)) / 2. / re60 T = rho*np.sqrt((1. + ex)**(1. + ex) * (1. - ex)**(1. - ex)) / 2. / re 61 61 else: 62 62 T = rho * T / (re * cm) 63 63 64 chi = (pi / 2.0) - 2.0 * np y.arctan(T)64 chi = (pi / 2.0) - 2.0 * np.arctan(T) 65 65 lat = chi + ((ex2 / 2.0) + (5.0 * ex2**2.0 / 24.0) + (ex2**3.0 / 12.0)) * \ 66 np y.sin(2 * chi) + ((7.0 * ex2**2.0 / 48.0) + (29.0 * ex2**3 / 240.0)) * \67 np y.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) 68 68 69 69 lat = sgn * lat 70 lon = np y.arctan2(sgn * x,-sgn * y)70 lon = np.arctan2(sgn * x,-sgn * y) 71 71 lon = sgn * lon 72 72 73 res1 = np y.nonzero(rho <= 0.1)[0]73 res1 = np.nonzero(rho <= 0.1)[0] 74 74 if len(res1) > 0: 75 75 lat[res1] = 90. * sgn
Note:
See TracChangeset
for help on using the changeset viewer.