How to use the vortexasdk.Geographies function in vortexasdk

To help you get started, we’ve selected a few vortexasdk 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 V0RT3X4 / python-sdk / tests / endpoints / test_vessel_movements_real.py View on Github external
def test_age_flag_scrubbers_filters(self):
        panama = [
            g.id
            for g in Geographies().search("panama").to_list()
            if "country" in g.layer
        ]

        df = (
            VesselMovements()
            .search(
                filter_vessel_scrubbers="inc",
                filter_vessel_age_min=2,
                filter_vessel_age_max=15,
                filter_vessel_flags=panama,
                filter_time_min=datetime(2017, 10, 1),
                filter_time_max=datetime(2017, 10, 1),
            )
            .to_df()
            .head(2)
        )
github V0RT3X4 / python-sdk / tests / endpoints / test_geographies_real.py View on Github external
def test_search(self):
        geographies = Geographies().search(term=["Liverpool", "Southampton"])
        names = [g["name"] for g in geographies]

        assert "Liverpool [GB]" in names
github V0RT3X4 / python-sdk / tests / endpoints / test_cargo_movements_real.py View on Github external
def test_search_single_filter_waypoint_name(self):
        df = (
            CargoMovements()
            .search(
                filter_activity="any_activity",
                filter_waypoints=[
                    g.id for g in Geographies().search(term="suez").to_list()
                ],
                filter_time_min=datetime(2019, 8, 29),
                filter_time_max=datetime(2019, 8, 29, 0, 10),
            )
            .to_df()
            .head(2)
        )

        assert len(df) == 2
github V0RT3X4 / python-sdk / tests / endpoints / test_vessel_movements_real.py View on Github external
def test_search(self):
        rotterdam = [
            g.id
            for g in Geographies().search("rotterdam").to_list()
            if "port" in g.layer
        ]
        v = VesselMovements().search(
            filter_time_min=datetime(2017, 10, 1, 0, 0),
            filter_time_max=datetime(2017, 10, 1, 0, 10),
            filter_origins=rotterdam,
        )

        assert len(v) > 10
github V0RT3X4 / python-sdk / tests / endpoints / test_cargo_time_series_real.py View on Github external
def test_filter_geographies_and_products(self):
        start = datetime(2019, 1, 1)
        end = datetime(2019, 11, 1)

        rotterdam = [
            g.id
            for g in Geographies().search(term="rotterdam").to_list()
            if "port" in g.layer
        ]
        crude = [
            p.id
            for p in Products().search("crude").to_list()
            if "Crude" == p.name
        ]

        rotterdam_crude_timeseries = (
            CargoTimeSeries()
            .search(
                filter_activity="loading_state",
                timeseries_unit="bpd",
                timeseries_frequency="month",
                filter_time_min=start,
                filter_time_max=end,
github V0RT3X4 / python-sdk / tests / endpoints / test_vessel_movements_real.py View on Github external
def test_exclusion_filter(self):
        meg = [
            g.id
            for g in Geographies().search("MEG/AG").to_list()
            if "trading_region" in g.layer
        ]
        iraq = [
            g.id
            for g in Geographies().search("Iraq").to_list()
            if "country" in g.layer
        ]
        bahri = [c.id for c in Corporations().search("BAHRI").to_list()]

        cols = [
            "vessel_movement_id",
            "vessel.name",
            "start_timestamp",
            "end_timestamp",
            "origin.location.country.id",
            "origin.location.country.label",
            "destination.location.country.id",
            "destination.location.country.label",
            "cargoes.0.product.group.label",
            "vessel.corporate_entities.charterer.id",
            "vessel.corporate_entities.charterer.label",
github V0RT3X4 / python-sdk / tests / endpoints / test_vessel_movements_real.py View on Github external
def test_to_df_all_columns(self):
        rotterdam = [
            g.id
            for g in Geographies().search("rotterdam").to_list()
            if "port" in g.layer
        ]
        df = (
            VesselMovements()
            .search(
                filter_time_min=datetime(2017, 10, 1, 0, 0),
                filter_time_max=datetime(2017, 10, 1, 0, 10),
                filter_origins=rotterdam,
            )
            .to_df(columns="all")
            .head(2)
        )

        assert len(df) == 2
github V0RT3X4 / python-sdk / docs / examples / 1_china.py View on Github external
|  0 | 2019-10-08T00:41:00+0000                           | Crude                 | Djeno                 |     123457 | AROME            |
|  1 | 2019-11-08T00:41:52+0000                           | Crude                 | Arab Medium           |      99898 | SCOOBYDOO        |
|  2 | 2019-09-30T23:49:41+0000                           | Crude                 | Arab Heavy            |    9879878 | DAVID            |
|  3 | 2019-12-01T01:40:00+0000                           | Crude                 | Usan                  |     999999 | DUCK             |


"""
from datetime import datetime

from vortexasdk import CargoMovements, Geographies, Vessels

if __name__ == "__main__":
    # Find china ID
    china = [
        g.id
        for g in Geographies().search(term="china").to_list()
        if "country" in g.layer
    ]

    # Find the ID of all VLCCs
    vlccs = [
        v.id for v in Vessels().search(vessel_classes="vlcc_plus").to_list()
    ]

    # Query API
    search_result = CargoMovements().search(
        filter_activity="loading_start",
        filter_vessels=vlccs,
        filter_destinations=china,
        filter_time_min=datetime(2019, 8, 29),
        filter_time_max=datetime(2019, 10, 30),
    )
github V0RT3X4 / python-sdk / docs / examples / 3_crude_from_saudi_arabia_to_india.py View on Github external
one_month_ago = now - relativedelta(months=1)

    # First we find the ID for the country India. Note that when searching geographies with the term 'india', we'll
    # retrieve all geographies with india in the name, ie Indiana, British Indian Ocean Territory...
    all_geogs_with_india_in_the_name = Geographies().search("india").to_list()

    # We're only interested in the country India here
    india = [
        g.id for g in all_geogs_with_india_in_the_name if g.name == "India"
    ]
    # Check we've only got one ID for India
    assert len(india) == 1

    saudi_arabia = [
        g.id
        for g in Geographies().search("saudi arabia").to_list()
        if "country" in g.layer
    ]
    # Check we've only got one ID for Saudi Arabia
    assert len(saudi_arabia) == 1

    # Let's find the Crude ID
    crude = [
        p.id for p in Products().search("crude").to_list() if p.name == "Crude"
    ]
    # Check we've only got one Crude ID
    assert len(crude) == 1

    # Query the API.
    search_result = CargoMovements().search(
        filter_activity="loading_end",
        filter_origins=saudi_arabia,
github V0RT3X4 / python-sdk / vortexasdk / check_setup.py View on Github external
def check_can_retrieve_geographies():
    global all_tests_pass

    # noinspection PyBroadException
    try:
        from vortexasdk import Geographies

        europe = (
            "f39d455f5d38907394d6da3a91da4e391f9a34bd6a17e826d6042761067e88f4"
        )
        geography = Geographies().reference(europe)
        assert geography["id"] == europe
        print(
            "βœ… Python successfully retrieved a sample piece of reference data"
        )
    except Exception:
        all_tests_pass = False
        print("❌ Python unable to retrieve a sample piece of reference data")