Changeset 26401


Ignore:
Timestamp:
08/18/21 15:12:36 (4 years ago)
Author:
schlegel
Message:

CHG: ll2xy python should check for arguments and not default to Antarctica

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/coordsystems/ll2xy.py

    r26398 r26401  
    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
     
    1616                                                   -1 : south latitude (default is mer = 0  lat = 71)
    1717    """
     18    assert sgn == 1 or sgn == -1, 'error: sgn should be either 1 or -1'
     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')
     35    else:
     36       raise Exception('bad usage: type "help(ll2xy)" for details')
    1837
    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     else:
    27         delta = central_meridian
    28         slat = standard_parallel
    29         print('        ll2xy: creating coordinates in south polar stereographic (Std Latitude: 71S Meridian: 0)')
     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)
    3043
    3144    # Conversion constant from degrees to radians
     
    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 TracChangeset for help on using the changeset viewer.