コード例 #1
0
ファイル: citi_bike_dashboard.py プロジェクト: ntoand/maro
def render_inter_view(source_path: str, epoch_num: int):
    """Render the cross-epoch infomartion chart of Citi Bike data.

    This part would be displayed only if epoch_num > 1.

    Args:
        source_path (str): The root path of the dumped snapshots data for the corresponding experiment.
        epoch_num (int): Total number of epoches,
            i.e. the total number of data folders since there is a folder per epoch.
    """
    helper.render_h1_title("Citi Bike Inter Epoch Data")
    sample_ratio = helper.get_sample_ratio_selection_list(epoch_num)
    # Get epoch sample number.
    down_pooling_range = helper._get_sampled_epoch_range(epoch_num, sample_ratio)
    attribute_option_candidates = (
        CITIBIKEItemOption.quick_info + CITIBIKEItemOption.requirement_info + CITIBIKEItemOption.station_info
    )
    # Generate data.
    data_summary = helper.read_detail_csv(
        os.path.join(source_path, GlobalFileNames.stations_sum)
    ).iloc[down_pooling_range]
    # Get formula and selected data.
    data_formula = helper.get_filtered_formula_and_data(
        GlobalScenarios.CITI_BIKE, data_summary, attribute_option_candidates
    )
    _generate_inter_view_panel(
        data_formula["data"][data_formula["attribute_option"]],
        down_pooling_range
    )
コード例 #2
0
ファイル: cim_dashboard.py プロジェクト: ntoand/maro
def render_inter_view(source_path: str, epoch_num: int):
    """Show CIM inter-view plot.

    Args:
        source_path (str): The root path of the dumped snapshots data for the corresponding experiment.
        epoch_num (int): Total number of epoches,
            i.e. the total number of data folders since there is a folder per epoch.
    """
    helper.render_h1_title("CIM Inter Epoch Data")
    sample_ratio = helper.get_sample_ratio_selection_list(epoch_num)
    # Get epoch sample list.
    down_pooling_range = helper._get_sampled_epoch_range(epoch_num, sample_ratio)
    attribute_option_candidates = (
        CIMItemOption.quick_info + CIMItemOption.port_info + CIMItemOption.booking_info
    )

    # Generate data.
    data = helper.read_detail_csv(os.path.join(source_path, GlobalFileNames.ports_sum)).iloc[down_pooling_range]
    data["remaining_space"] = list(
        map(
            lambda x, y, z: x - y - z,
            data["capacity"],
            data["full"],
            data["empty"]
        )
    )
    # Get formula and selected data.
    data_formula = helper.get_filtered_formula_and_data(GlobalScenarios.CIM, data, attribute_option_candidates)
    _generate_inter_view_panel(
        data_formula["data"][data_formula["attribute_option"]],
        down_pooling_range
    )
コード例 #3
0
ファイル: citi_bike_dashboard.py プロジェクト: ntoand/maro
def render_intra_view(source_path: str, epoch_num: int, prefix: str):
    """Show Citi Bike intra-view plot.

    Args:
        source_path (str): The root path of the dumped snapshots data for the corresponding experiment.
        epoch_num (int): Total number of epoches,
            i.e. the total number of data folders since there is a folder per epoch.
        prefix (str): Prefix of data folders.
    """
    selected_epoch = 0
    if epoch_num > 1:
        selected_epoch = st.sidebar.select_slider(
            label="Choose an Epoch:",
            options=list(range(0, epoch_num))
        )
    helper.render_h1_title("Citi Bike Intra Epoch Data")
    data_stations = pd.read_csv(os.path.join(source_path, f"{prefix}{selected_epoch}", "stations.csv"))
    view_option = st.sidebar.selectbox(
        label="By station/snapshot:",
        options=CitiBikeIntraViewChoice._member_names_
    )
    stations_num = len(data_stations["id"].unique())
    stations_index = np.arange(stations_num).tolist()
    snapshot_num = len(data_stations["frame_index"].unique())
    snapshots_index = np.arange(snapshot_num).tolist()

    index_name_conversion = helper.read_detail_csv(
        os.path.join(
            source_path,
            GlobalFileNames.name_convert
        )
    )
    attribute_option_candidates = (
        CITIBIKEItemOption.quick_info + CITIBIKEItemOption.requirement_info + CITIBIKEItemOption.station_info
    )
    st.sidebar.markdown("***")

    # Filter by station index.
    # Display the change of snapshot within 1 station.
    render_top_k_summary(source_path, prefix, selected_epoch)
    if view_option == CitiBikeIntraViewChoice.by_station.name:
        _generate_intra_view_by_station(
            data_stations, index_name_conversion, attribute_option_candidates, stations_index, snapshot_num
        )

    # Filter by snapshot index.
    # Display all station information within 1 snapshot.
    elif view_option == CitiBikeIntraViewChoice.by_snapshot.name:
        _generate_intra_view_by_snapshot(
            data_stations, index_name_conversion, attribute_option_candidates,
            snapshots_index, snapshot_num, stations_num
        )
コード例 #4
0
ファイル: cim_dashboard.py プロジェクト: yourmoonlight/maro
def _render_intra_view_by_snapshot(source_path: str, option_epoch: int,
                                   data_ports: pd.DataFrame,
                                   snapshots_index: List[int],
                                   index_name_conversion: pd.DataFrame,
                                   attribute_option_candidates: List[str],
                                   ports_num: int, prefix: str):
    """ Show intra-view data by snapshot.

    Args:
        source_path (str): The root path of the dumped snapshots data for the corresponding experiment.
        option_epoch (int): Index of selected epoch.
        data_ports (pd.Dataframe): Filtered port data.
        snapshots_index (List[int]): Index of selected snapshot.
        index_name_conversion (pd.Dataframe): Relationship between index and name.
        attribute_option_candidates (List[str]): All options for users to choose.
        ports_num (int): Number of ports in current snapshot.
        prefix (str): Prefix of data folders.
    """
    selected_snapshot = st.sidebar.select_slider(label="snapshot index",
                                                 options=snapshots_index)
    # Get sample ratio.
    sample_ratio = helper.get_sample_ratio_selection_list(ports_num)
    selected_port_sample_ratio = st.sidebar.select_slider(
        label="Ports Sampling Ratio:", options=sample_ratio)
    # Accumulated data.
    helper.render_h1_title("Accumulated Data")
    _render_intra_heat_map(source_path, GlobalScenarios.CIM, option_epoch,
                           selected_snapshot, prefix)

    helper.render_h3_title(
        f"SnapShot-{selected_snapshot}: Port Accumulated Attributes")
    _generate_intra_panel_accumulated_by_snapshot(data_ports,
                                                  selected_snapshot, ports_num,
                                                  index_name_conversion,
                                                  selected_port_sample_ratio)
    _generate_top_k_summary(data_ports, selected_snapshot,
                            index_name_conversion)
    # Detailed data.
    helper.render_h1_title("Detail Data")
    _render_intra_panel_vessel(source_path, prefix, option_epoch,
                               selected_snapshot)

    helper.render_h3_title(
        f"Snapshot-{selected_snapshot}: Port Detail Attributes")
    data_formula = helper.get_filtered_formula_and_data(
        GlobalScenarios.CIM, data_ports, attribute_option_candidates)
    _generate_intra_panel_by_snapshot(data_formula["data"], selected_snapshot,
                                      ports_num, index_name_conversion,
                                      selected_port_sample_ratio,
                                      data_formula["attribute_option"])
コード例 #5
0
ファイル: cim_dashboard.py プロジェクト: ntoand/maro
def _render_intra_view_by_ports(
    data_ports: pd.DataFrame, ports_index: int,
    index_name_conversion: pd.DataFrame, attribute_option_candidates: List[str], snapshot_num: int
):
    """ Show intra-view data by ports.

    Args:
        data_ports (pd.Dataframe): Filtered port data.
        ports_index (int):Index of port of current data.
        index_name_conversion (pd.Dataframe): Relationship of index and name.
        attribute_option_candidates (List[str]): All options for users to choose.
        snapshot_num (int): Number of snapshots on a port.
    """
    selected_port = st.sidebar.select_slider(
        label="Choose a Port:",
        options=ports_index
    )
    sample_ratio = helper.get_sample_ratio_selection_list(snapshot_num)
    selected_snapshot_sample_ratio = st.sidebar.select_slider(
        label="Snapshot Sampling Ratio:",
        options=sample_ratio
    )
    # Accumulated data.
    helper.render_h1_title("CIM Accumulated Data")
    helper.render_h3_title(
        f"Port Accumulated Attributes: {selected_port} - {index_name_conversion.loc[int(selected_port)][0]}"
    )
    _generate_intra_panel_accumulated_by_ports(
        data_ports, f"ports_{selected_port}", snapshot_num, selected_snapshot_sample_ratio
    )
    # Detailed data.
    helper.render_h1_title("CIM Detail Data")
    data_formula = helper.get_filtered_formula_and_data(
        GlobalScenarios.CIM, data_ports, attribute_option_candidates
    )

    helper.render_h3_title(
        f"Port Detail Attributes: {selected_port} - {index_name_conversion.loc[int(selected_port)][0]}"
    )
    _generate_intra_panel_by_ports(
        data_formula["data"], f"ports_{selected_port}",
        snapshot_num, selected_snapshot_sample_ratio, data_formula["attribute_option"]
    )