Beispiel #1
0
def test_load_wind_uv():
    # gulf st lawrence
    #south =  46
    #north =  52
    #west  = -70
    #east  = -56
    result = kadlu.load(source='wwiii', var='wind_uv', south=south-1, west=west-1, north=north, east=east, start=start, end=end)
    print(result)
Beispiel #2
0
def test_wwiii_load_wind_u():
    try:
        #wave, lat, lon, time = Wwiii().load_wind_uv(south=south, west=west, north=north, east=east, start=start, end=end)
        result = kadlu.load(source='wwiii', var='wind_u', south=south, west=west, north=north, east=east, start=start, end=end)
    except AssertionError as err:
        logging.info(f'CAUGHT EXCEPTION: {str(err)}')
    except Exception as err:
        raise err
Beispiel #3
0
def test_era5_load_wind():
    ns_offset = 1
    ew_offset = 1

    uval, lat, lon, epoch = kadlu.load(source='era5',
                                       var='wind_u',
                                       start=datetime(2016, 3, 9),
                                       end=datetime(2016, 3, 11),
                                       south=44.5541333 - ns_offset,
                                       west=-64.17682 - ew_offset,
                                       north=44.5541333 + ns_offset,
                                       east=-64.17682 + ew_offset,
                                       top=0,
                                       bottom=0)

    vval, lat, lon, epoch = kadlu.load(source='era5',
                                       var='wind_v',
                                       start=datetime(2016, 3, 9),
                                       end=datetime(2016, 3, 11),
                                       south=44.5541333 - ns_offset,
                                       west=-64.17682 - ew_offset,
                                       north=44.5541333 + ns_offset,
                                       east=-64.17682 + ew_offset,
                                       top=0,
                                       bottom=0)

    uvval, lat, lon, epoch = kadlu.load(source='era5',
                                        var='wind_uv',
                                        start=datetime(2016, 3, 9),
                                        end=datetime(2016, 3, 11),
                                        south=44.5541333 - ns_offset,
                                        west=-64.17682 - ew_offset,
                                        north=44.5541333 + ns_offset,
                                        east=-64.17682 + ew_offset,
                                        top=0,
                                        bottom=0)
Beispiel #4
0
def add_kadlu_env_data(bounds, sources, detection_df):
    """
    Fetches the requested environmental data for the given region & time. The data is interpolated
    across space (2D or 3D) and time before being merged into a new version of detection_df.

    :param bounds: Dictionary containing the boundaries (space & time) which will be used to fetch
                   data from kadlu. Must include `north`, `south`, `east`, `west`, `start`, `end`,
                   `top`, and `bottom`.
    :type bounds: dict

    :param sources: Dictionary containing a variable -> source mapping.
    :type sources: dict.

    :param detection_df: Dataframe containing detection data.
    :type detection_df: pandas.DataFrame

    :return: - **detection_df_env** (`pandas.DataFrame`) - A copy of detection_df where interpolated
               environment data has been added.
             - **kadlu_result** (`numpy.array`) - The raw result from kadlu (not interpolated)
    """
    detection_df_copy = copy.copy(detection_df)

    axes_to_interpolate = [detection_df_copy['Receiver.lat'],
                           detection_df_copy['Receiver.lon'],
                           [d.timestamp() for d in detection_df_copy['datetime']],
                           detection_df_copy['Receiver.depth']]

    for load_func, source in sources.items():
        col_name = '_'.join(load_func.split('_')[1:])
        kadlu_result = kadlu.load(source=source, var=col_name, **bounds)
        interpolations = interpolate(kadlu_result, axes_to_interpolate)

        detection_df_copy[col_name] = interpolations

    # TODO: kadlu_result is currently only the last result. Should probably be a list of results
    return detection_df_copy, kadlu_result
Beispiel #5
0
def test_wwiii_load_waveperiod():
    #wave, lat, lon, time = Wwiii().load_waveperiod(south=south, west=west, north=north, east=east, start=start, end=end)
    result = kadlu.load(source='wwiii', var='waveperiod', south=south, west=west, north=north, east=east, start=start, end=end)