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
  • ../trunk-jpl/src/m/coordsystems/ll2xy.py

     
    11import numpy as np
    22
    33
    4 def ll2xy(lat, lon, sgn=-1, central_meridian=0, standard_parallel=71):
     4def ll2xy(lat, lon, sgn, *args):
    55    """LL2XY - converts lat lon to polar stereographic
    66
    77    Converts from geodetic latitude and longitude to Polar
     
    1515    - sgn = Sign of latitude    1 : north latitude (default is mer = 45 lat = 70)
    1616                                                   -1 : south latitude (default is mer = 0  lat = 71)
    1717    """
    18 
    1918    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')
    2635    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')
    3037
     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
    3144    # Conversion constant from degrees to radians
    3245    #cde = 57.29577951
    3346    # Radius of the earth in meters
     
    5770    cnt1 = np.nonzero(latitude >= np.pi / 2.)[0]
    5871
    5972    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
    6276    return x, y
Note: See TracBrowser for help on using the repository browser.