Пример #1
0
            anomaly_in_file = bool(anomaly_index)
                        
            if anomaly_in_file:
            
                # Aliasing for brevity.
                x  = previous_dataset.index.size + anomaly_index[0]
                dx = LOOKUP_RANGE

                surrounding_data = dataset.iloc[x - dx: x + dx + 1]
                
                latitudes  = surrounding_data.latitude
                longitudes = surrounding_data.longitude
                points     = list(zip(latitudes, longitudes))
                reference  = (latitudes.iloc[dx], longitudes.iloc[dx])
                
                distances = np.array(list(map(lambda p: lambert(reference, p), points)))
                distances[:LOOKUP_RANGE] *= -1

                modis_cloud_top_height = surrounding_data["modis_cloud_top_height"].values
                cal_cloud_top_height   = surrounding_data["cal_cloud_top_height"].values

                nan_mask = np.isnan(distances) | np.isnan(modis_cloud_top_height) | np.isnan(cal_cloud_top_height)                
                
                latitude_envelope_series[i]      = latitudes
                longitude_envelope_series[i]     = longitudes
                distance_series[i]               = distances
                modis_cloud_top_height_series[i] = modis_cloud_top_height
                cal_cloud_top_height_series[i]   = cal_cloud_top_height
                
            else:
Пример #2
0
def calculate_azimuthal_angle(latitude_1: float, longitude_1: float,
                              latitude_2: float, longitude_2: float) -> float:
    '''
    Computes the azimuthal angle for a vector described by two points,
    going from point (latitude_1, longitude_1) to point (latitude_2, longitude_2)

    Parameters:

        * latitude_1 (float) :
          - Latiutde position for starting point of the vector

        * longitude_1 (float) :
          - Longitude position for starting point of the vector

        * latitude_2 (float) :
          - Latiutde position for end point of the vector

        * longitude_2 (float) :
          - Longitude position for end point of the vector

    Return values:

        * angle (float) :
          - Units: degrees
          - Azimuthal angle for the vector

    '''

    latitude_diff = latitude_2 - latitude_1
    longitude_diff = longitude_2 - longitude_1

    # if satellite is moving E or W along cadinal axes
    if latitude_diff == 0:

        # if satellite is moving E
        if longitude_2 > longitude_1:
            angle = 90

        # if satellite is moving W
        else:
            angle = 270

        return angle

    # if satellite is moving N or S along cadinal axes
    if longitude_diff == 0:

        # if satellite is moving N
        if latitude_2 > latitude_1:
            angle = 0

        # if satellite is moving S
        else:
            angle = 180

        return angle

    # if satellite is not moving along cardinal axes find the x and y component
    # of the displacement vector between these two points calculated along the
    # cardinal axes

    point_start = np.array([(latitude_1, longitude_1)])
    point_mid = np.array([(latitude_1, longitude_2)])
    point_end = np.array([(latitude_2, longitude_2)])

    # Lambert formula calculates distance between first and second point given
    distance_x = lambert(point_start[0], point_mid[0])
    distance_y = lambert(point_mid[0], point_end[0])

    angle = np.degrees(np.arctan(distance_x / distance_y))

    # Determine azimuthal angle based on whether latitude and longtitude decrease
    # between the previous and next point for the anomaly

    if latitude_diff < 0 and longitude_diff < 0:
        angle = 180 + angle

    elif longitude_diff < 0:
        angle = 360 - angle

    elif latitude_diff < 0:
        angle = 180 - angle

    return angle
Пример #3
0
            if anomaly_in_file:

                # Aliasing for brevity.
                x = previous_dataset.index.size + anomaly_index[0]
                dx = LOOKUP_RANGE

                surrounding_data = dataset.iloc[x - dx:x + dx + 1]

                latitudes = surrounding_data.latitude
                longitudes = surrounding_data.longitude
                points = list(zip(latitudes, longitudes))
                reference = (latitudes.iloc[dx], longitudes.iloc[dx])

                distances = np.array(
                    list(map(lambda p: lambert(reference, p), points)))
                distances[:LOOKUP_RANGE] *= -1

                modis_cloud_top_height = surrounding_data[
                    "modis_cloud_top_height"].values
                cal_cloud_top_height = surrounding_data[
                    "cal_cloud_top_height"].values
                layer_type = surrounding_data["layer_type"]

                # convert CAL layer top height data to CALIPSO cloud top height data
                for i in range(len(layer_type)):

                    # call on function from other script to identify layer type
                    vfm = vertical_feature_mask.classify_vfm(layer_type[i])
                    if vfm[0][0] != 2:
                        cal_cloud_top_height[i] = np.nan
Пример #4
0
        # Calculate sign of dot product of the 2d vectors
        sign_2d = dot_product_sign(displacement_azimuthal_angle, SAA)
        #print("2D Sign: ", sign_2d)

        # Determine which point to use in the slope calculation based on the sign

        # If positive, use point before anomaly
        if sign_2d > 0:
            # Calculate azimuthal angle for the satellite displacement vector
            slope_azimuthal_angle = calculate_azimuthal_angle(
                prev_latitude, prev_longitude, anomaly_latitude,
                anomaly_longitude)

            distance_bween_points = lambert(
                (anomaly_latitude, anomaly_longitude),
                (prev_latitude, prev_longitude))

            #read in cloud top height for the previous point
            point_height = ncin["calipso_cloud_top_height"][i][prevIndex]

            # find height in meters
            height_diff_bween_points = (anomaly_height - point_height) * 1000

            # Append 'True' to the prevPointUsed array, since the previous point was the one used to calculate slope
            prevPointUsed = 1

        # If negative, use point after anomaly
        if sign_2d < 0:

            # Calculate azimuthal angle for the satellite displacement vector