source: issm/oecreview/Archive/25834-26739/ISSM-26400-26401.diff@ 26740

Last change on this file since 26740 was 26740, checked in by Mathieu Morlighem, 3 years ago

CHG: added 25834-26739

File size: 2.3 KB
RevLine 
[26740]1Index: ../trunk-jpl/src/m/coordsystems/ll2xy.py
2===================================================================
3--- ../trunk-jpl/src/m/coordsystems/ll2xy.py (revision 26400)
4+++ ../trunk-jpl/src/m/coordsystems/ll2xy.py (revision 26401)
5@@ -1,7 +1,7 @@
6 import numpy as np
7
8
9-def ll2xy(lat, lon, sgn=-1, central_meridian=0, standard_parallel=71):
10+def ll2xy(lat, lon, sgn, *args):
11 """LL2XY - converts lat lon to polar stereographic
12
13 Converts from geodetic latitude and longitude to Polar
14@@ -15,19 +15,32 @@
15 - sgn = Sign of latitude 1 : north latitude (default is mer = 45 lat = 70)
16 -1 : south latitude (default is mer = 0 lat = 71)
17 """
18-
19 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)')
26+
27+ # Get central_meridian and standard_parallel depending on hemisphere
28+ if len(args) == 2:
29+ delta = args[0]
30+ slat = args[1]
31+ elif len(args) == 0:
32+ if sgn == 1:
33+ delta = 45.
34+ slat = 70.
35+ print(' ll2xy: creating coordinates in north polar stereographic (Std Latitude: 70degN Meridian: 45deg)')
36+ elif sgn == -1:
37+ delta = 0.
38+ slat = 71.
39+ print(' ll2xy: creating coordinates in south polar stereographic (Std Latitude: 71degS Meridian: 0deg)')
40+ else:
41+ raise ValueError('sgn should be either 1 or -1')
42 else:
43- delta = central_meridian
44- slat = standard_parallel
45- print(' ll2xy: creating coordinates in south polar stereographic (Std Latitude: 71S Meridian: 0)')
46+ raise Exception('bad usage: type "help(ll2xy)" for details')
47
48+ # if lat, lon passed as lists, convert to np.arrays
49+ if type(lat) != "np.ndarray":
50+ lat = np.array(lat)
51+ if type(lon) != "np.ndarray":
52+ lon = np.array(lon)
53+
54 # Conversion constant from degrees to radians
55 #cde = 57.29577951
56 # Radius of the earth in meters
57@@ -57,6 +70,7 @@
58 cnt1 = np.nonzero(latitude >= np.pi / 2.)[0]
59
60 if len(cnt1)>0:
61- x[cnt1, 0] = 0.0
62- y[cnt1, 0] = 0.0
63+ x[cnt1] = 0.0
64+ y[cnt1] = 0.0
65+
66 return x, y
Note: See TracBrowser for help on using the repository browser.