source:
issm/oecreview/Archive/25834-26739/ISSM-26400-26401.diff
Last change on this file was 26740, checked in by , 3 years ago | |
---|---|
File size: 2.3 KB |
-
../trunk-jpl/src/m/coordsystems/ll2xy.py
1 1 import numpy as np 2 2 3 3 4 def ll2xy(lat, lon, sgn =-1, central_meridian=0, standard_parallel=71):4 def ll2xy(lat, lon, sgn, *args): 5 5 """LL2XY - converts lat lon to polar stereographic 6 6 7 7 Converts from geodetic latitude and longitude to Polar … … 15 15 - sgn = Sign of latitude 1 : north latitude (default is mer = 45 lat = 70) 16 16 -1 : south latitude (default is mer = 0 lat = 71) 17 17 """ 18 19 18 assert sgn == 1 or sgn == -1, 'error: sgn should be either 1 or -1' 20 21 #Get central_meridian and standard_parallel depending on hemisphere 22 if sgn == 1: 23 delta = 45 24 slat = 70 25 print(' ll2xy: creating coordinates in north polar stereographic (Std Latitude: 70N Meridian: 45)') 19 20 # Get central_meridian and standard_parallel depending on hemisphere 21 if len(args) == 2: 22 delta = args[0] 23 slat = args[1] 24 elif len(args) == 0: 25 if sgn == 1: 26 delta = 45. 27 slat = 70. 28 print(' ll2xy: creating coordinates in north polar stereographic (Std Latitude: 70degN Meridian: 45deg)') 29 elif sgn == -1: 30 delta = 0. 31 slat = 71. 32 print(' ll2xy: creating coordinates in south polar stereographic (Std Latitude: 71degS Meridian: 0deg)') 33 else: 34 raise ValueError('sgn should be either 1 or -1') 26 35 else: 27 delta = central_meridian 28 slat = standard_parallel 29 print(' ll2xy: creating coordinates in south polar stereographic (Std Latitude: 71S Meridian: 0)') 36 raise Exception('bad usage: type "help(ll2xy)" for details') 30 37 38 # if lat, lon passed as lists, convert to np.arrays 39 if type(lat) != "np.ndarray": 40 lat = np.array(lat) 41 if type(lon) != "np.ndarray": 42 lon = np.array(lon) 43 31 44 # Conversion constant from degrees to radians 32 45 #cde = 57.29577951 33 46 # Radius of the earth in meters … … 57 70 cnt1 = np.nonzero(latitude >= np.pi / 2.)[0] 58 71 59 72 if len(cnt1)>0: 60 x[cnt1, 0] = 0.0 61 y[cnt1, 0] = 0.0 73 x[cnt1] = 0.0 74 y[cnt1] = 0.0 75 62 76 return x, y
Note:
See TracBrowser
for help on using the repository browser.