How to use the meteomatics.binary_reader.BinaryReader function in meteomatics

To help you get started, we’ve selected a few meteomatics examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github meteomatics / python-connector-api / meteomatics / api.py View on Github external
def convert_grid_binary_response_to_df(input, parameter_grid):
    binary_reader = BinaryReader(input)

    header = binary_reader.get_string(length=4)

    if header != "MBG_":
        raise WeatherApiException("No MBG received, instead: {}".format(header))

    version = binary_reader.get_int()
    precision = binary_reader.get_int()
    num_payloads_per_forecast = binary_reader.get_int()
    payload_meta = binary_reader.get_int()
    num_forecasts = binary_reader.get_int()
    forecast_dates_ux = [binary_reader.get_unsigned_long() for _ in range(num_forecasts)]

    # precision in bytes
    DOUBLE = 8
    FLOAT = 4
github meteomatics / python-connector-api / meteomatics / api.py View on Github external
def convert_time_series_binary_response_to_df(input, latlon_tuple_list, parameters, station=False):
    binary_reader = BinaryReader(input)

    parameters_ts = parameters[:]

    if station:
        # add station_id in the list of parameters
        parameters_ts.extend(["station_id"])
    else:
        # add lat, lon in the list of parameters
        parameters_ts.extend(["lat", "lon"])
    dfs = []
    # parse response
    num_of_coords = binary_reader.get_int() if len(latlon_tuple_list) > 1 else 1

    for i in range(num_of_coords):
        dict_data = {}
        num_of_dates = binary_reader.get_int()