Esempio n. 1
0
import matplotlib.pyplot as plt

AUSTRALIAN_CITIES = [
    "Sydney",
    "Melbourne",
    "Brisbane",
    "Perth",
    "Adelaide",
]
FOREIGN_CITIES = [
    "Auckland", "Hong Kong", "Singapore", "Kuala Lumpur", "Tokyo"
]

if __name__ == "__main__":
    # Load Data
    combined = util.load_cdf("Visualization/international.nc")

    # Setup the graph
    fig, axes = plt.subplots(nrows=len(AUSTRALIAN_CITIES),
                             ncols=len(FOREIGN_CITIES))
    plt.rcParams.update({"font.size": 14})

    # Plot each incoming/outgoing pair
    for xx, incoming in enumerate(AUSTRALIAN_CITIES):
        for yy, outgoing in enumerate(FOREIGN_CITIES):
            test = combined.sel(AustralianPort=incoming,
                                ForeignPort=outgoing)[["PaxIn", "PaxOut"]]

            test.to_dataframe().plot(ax=axes[xx, yy], legend=False)
            axes[xx, yy].legend(loc="upper right", fontsize=10)
Esempio n. 2
0
import util
import numpy as np
import datetime
import matplotlib.pyplot as plt
import calendar

AUSTRALIAN_CITIES = ["SYD", "MEL", "BNE", "PER", "ADL", "DRW"]

if __name__ == "__main__":
    combined = util.load_cdf("Visualization/domestic.nc")
    years = [x for x in range(2004, 2020)]
    months = [x for x in range(1, 13)]

    # We need the format of the data to be in a 2D-array format
    # Each column is a month, while each row is a year
    data = [
        np.zeros(shape=(len(years), len(months)))
        for i in range(len(AUSTRALIAN_CITIES))
    ]

    # Generate the dataset
    # Each city gets one array
    for i, city in enumerate(AUSTRALIAN_CITIES):
        city_data_origin = combined.sel(Origin=city)
        try:
            city_data_destination = combined.sel(Destination=city)
            for xx, year in enumerate(years):
                for yy, month in enumerate(months):
                    date = datetime.datetime(year, month, 1)
                    monthly_total1 = city_data_origin.sel(Month=date).sum(
                        ["Destination"])