def convert_rain_code(rain_code):
    """
    Convert rain code into the following code

    SKY Code: refer to weather station API document
        0: No rain
        1: Rainy
        2: Rainy and Snowy
        3: Snowy

    Weather Code: Own implementation
        1: sunny (not handled by this function)
        2: rainy
        3: cloudy (not handled by this function)
        4: snowy

    :param rain_code: PTY(rain) code from open API
    :return: weather code
    """

    weather_code = 0  # error

    if rain_code == 1 or rain_code == 2:
        weather_code = 2
    elif rain_code == 3:
        weather_code = 4

    return weather_code