coastalimagelib/supportfunctions.py
def localTransformPoints(origin, x_in, y_in, flag):
    """
    Transforms points either in geographical coordinates to local,
    or in local to geographical.
    This requires the local origin in geographical coordinates, as well as the
    angle between coordinate systems in CIRN angle convention.
    See the WAMFlow user manual for more information on CIRN angle convention.

    Args:
        origin (xo, yo, angle): local origin (0,0) in Geographical coordinates.
                Typically xo is E and yo is N coordinate.
                The angle should be the relative angle
                between the new (local) X axis  and old (Geo)
                X axis, positive counter-clockwise from the old (Geo) X.
        flag = 1 or 0 to indicate transform direction
              Geo-->local (1) or
              local-->Geo (0)
        x_in - Local (X) or Geo (E) coord depending on transform direction
        y_in = Local (Y) or Geo (N) coord depending on direction

    Returns:
        x_out - Local (X) or Geo (E) coord depending on direction
        y_out - Local (Y) or Geo (N) coord depending on direction

    """

    if flag == 1:
        # Geo to Local

        # Translate first
        easp = x_in - origin[0]
        norp = y_in - origin[1]

        # Rotate
        x_out = easp * np.cos(origin[2]) + norp * np.sin(origin[2])
        y_out = norp * np.cos(origin[2]) - easp * np.sin(origin[2])

    if flag == 0:
        # Local to Geo

        # Rotate first
        x_out = x_in * np.cos(origin[2]) - y_in * np.sin(origin[2])
        y_out = y_in * np.cos(origin[2]) + x_in * np.sin(origin[2])

        # Translate
        x_out = x_out + origin[0]
        y_out = y_out + origin[1]

    return x_out, y_out

    Transforms points either in geographical coordinates to local,
    or in local to geographical.
    This requires the local origin in geographical coordinates, as well as the
    angle between coordinate systems in CIRN angle convention.
    See the WAMFlow user manual for more information on CIRN angle convention.

    Args:
        origin (xo, yo, angle): local origin (0,0) in Geographical coordinates.
                Typically xo is E and yo is N coordinate.
                The angle should be the relative angle
                between the new (local) X axis  and old (Geo)
                X axis, positive counter-clockwise from the old (Geo) X.
        flag = 1 or 0 to indicate transform direction
              Geo-->local (1) or
              local-->Geo (0)
        x_in - Local (X) or Geo (E) coord depending on transform direction
        y_in = Local (Y) or Geo (N) coord depending on direction

    Returns:
        x_out - Local (X) or Geo (E) coord depending on direction
        y_out - Local (Y) or Geo (N) coord depending on direction

    
Transforms points either in geographical coordinates to local,
or in local to geographical.
This requires the local origin in geographical coordinates, as well as the
angle between coordinate systems in CIRN angle convention.
See the WAMFlow user manual for more information on CIRN angle convention.

origin (xo, yo, angle): local origin (0,0) in Geographical coordinates.
Typically xo is E and yo is N coordinate.
The angle should be the relative angle
between the new (local) X axis  and old (Geo)
X axis, positive counter-clockwise from the old (Geo) X.

Local (X) or Geo (E) coord depending on direction
y_out - Local (Y) or Geo (N) coord depending on direction
Transforms points either in geographical coordinates to local or in local to geographical . This requires the local origin in geographical coordinates as well as the angle between coordinate systems in CIRN angle convention . See the WAMFlow user manual for more information on CIRN angle convention . origin ( xo yo angle ) : local origin ( 0 0 ) in Geographical coordinates . Typically xo is E and yo is N coordinate . The angle should be the relative angle between the new ( local ) X axis and old ( Geo ) X axis positive counter - clockwise from the old ( Geo ) X . Local ( X ) or Geo ( E ) coord depending on direction y_out - Local ( Y ) or Geo ( N ) coord depending on direction
def localTransformPoints(origin, x_in, y_in, flag):
    if flag == 1:
        easp = x_in - origin[0]
        norp = y_in - origin[1]
        x_out = easp * np.cos(origin[2]) + norp * np.sin(origin[2])
        y_out = norp * np.cos(origin[2]) - easp * np.sin(origin[2])
    if flag == 0:
         first
        x_out = x_in * np.cos(origin[2]) - y_in * np.sin(origin[2])
        y_out = y_in * np.cos(origin[2]) + x_in * np.sin(origin[2])
        x_out = x_out + origin[0]
        y_out = y_out + origin[1]
    return x_out, y_out
def localTransformPoints ( origin , x_in , y_in , flag ) : if flag == 1 : easp = x_in - origin [ 0 ] norp = y_in - origin [ 1 ] x_out = easp * np . cos ( origin [ 2 ] ) + norp * np . sin ( origin [ 2 ] ) y_out = norp * np . cos ( origin [ 2 ] ) - easp * np . sin ( origin [ 2 ] ) if flag == 0 : x_out = x_in * np . cos ( origin [ 2 ] ) - y_in * np . sin ( origin [ 2 ] ) y_out = y_in * np . cos ( origin [ 2 ] ) + x_in * np . sin ( origin [ 2 ] ) x_out = x_out + origin [ 0 ] y_out = y_out + origin [ 1 ] return x_out , y_out
Transforms points either in geographical coordinates to local,
or in local to geographical.
Transforms points either in geographical coordinates to local or in local to geographical .
"""
    Transforms points either in geographical coordinates to local,
    or in local to geographical.
    This requires the local origin in geographical coordinates, as well as the
    angle between coordinate systems in CIRN angle convention.
    See the WAMFlow user manual for more information on CIRN angle convention.

    Args:
        origin (xo, yo, angle): local origin (0,0) in Geographical coordinates.
                Typically xo is E and yo is N coordinate.
                The angle should be the relative angle
                between the new (local) X axis  and old (Geo)
                X axis, positive counter-clockwise from the old (Geo) X.
        flag = 1 or 0 to indicate transform direction
              Geo-->local (1) or
              local-->Geo (0)
        x_in - Local (X) or Geo (E) coord depending on transform direction
        y_in = Local (Y) or Geo (N) coord depending on direction

    Returns:
        x_out - Local (X) or Geo (E) coord depending on direction
        y_out - Local (Y) or Geo (N) coord depending on direction

    """ # Geo to Local # Translate first # Rotate # Local to Geo # Rotate first # Translate
origin
x_in
y_in
flag