<jupyter_start><jupyter_text>Libraries<jupyter_code>from _ctypes import LoadLibrary as _dlopen
_dlopen("D:\\Sangwons_Room\\00_SoftWares\\Anaconda\\envs\\torch\\Library\\bin\\geos.dll", 0)

# nuscenes-devkit
from nuscenes.nuscenes import NuScenes

# nuscenes-map expansion
from utils.custom_map_api_expansion import CustomNuScenesMap

# nuscenes-devkit-utils
from nuscenes.utils.data_classes import LidarPointCloud, RadarPointCloud, Box
from nuscenes.utils.geometry_utils import view_points, transform_matrix

from pyquaternion import Quaternion


from functools import reduce
import os

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import plotly.express as px
from tqdm.notebook import tqdm

from torch.utils.data import Dataset, DataLoader
%matplotlib inline<jupyter_output><empty_output><jupyter_text>Set  Parameters<jupyter_code>locations = ['singapore-onenorth', 'singapore-hollandvillage', 'singapore-queenstown', 'boston-seaport']
version = 'v1.0-mini'
dataroot = './data/sets/nuscenes'<jupyter_output><empty_output><jupyter_text>Load Informations<jupyter_code>nusc = NuScenes(version=version, dataroot=dataroot, verbose=True)
nusc_location = dict()
for loc in locations:
    nusc_location[loc] = CustomNuScenesMap(dataroot=dataroot, map_name=loc)<jupyter_output>======
Loading NuScenes tables for version v1.0-mini...
Loading nuScenes-lidarseg...
32 category,
8 attribute,
4 visibility,
911 instance,
12 sensor,
120 calibrated_sensor,
31206 ego_pose,
8 log,
10 scene,
404 sample,
31206 sample_data,
18538 sample_annotation,
4 map,
404 lidarseg,
Done loading in 0.659 seconds.
======
Reverse indexing ...
Done reverse indexing in 0.1 seconds.
======<jupyter_text>Check Maps<jupyter_code># for location in locations:
#     nusc_map = nusc_location[location]
#     fig, ax = nusc_map.render_layers(nusc_map.non_geometric_layers, figsize=1)
#     ax.set_title(f"{location}, {nusc_map.get_size()}")
# plt.show()
# nusc_map = nusc_location['singapore-hollandvillage']

# nusc_map = nusc_location['singapore-onenorth']

# nusc_map.get_closest_layers(nusc_map.non_geometric_layers, (700.0, 1900.0))<jupyter_output><empty_output><jupyter_text>Data Analysis  Total Map Analysis<jupyter_code>info = []

for location in tqdm(locations, position = 0):
    nusc_map = nusc_location[location]
    map_size = nusc_map.get_size()
    
    for x in tqdm(np.arange(100, map_size[0] + 200, 200), position = 1, leave = False, ):
        for y in tqdm(np.arange(100, map_size[0] + 200, 200), position = 2, leave = False):
            objects_list = nusc_map.get_closest_layers(nusc_map.non_geometric_layers, (x, y))
            for layer in nusc_map.non_geometric_layers:
                objects = objects_list[layer]
                for object_ in objects:
                    info.append([location, layer, x, y, object_.shape[0]])
                    
df = pd.DataFrame(info, columns = ['location', 'layer', 'map_x', 'map_y', 'number_of_points'])
nusc_map.non_geometric_layers
print(df.shape)
df.head()
df['location'].value_counts()
layer_portion = df['layer'].value_counts() / df.shape[0] * 100
layer_portion
df.groupby('location')['layer'].value_counts()
df.groupby('layer')['number_of_points'].mean()
df.groupby('layer')['number_of_points'].min()
df.groupby('layer')['number_of_points'].max()
info = []

for location in tqdm(locations, position = 0):
    nusc_map = nusc_location[location]
    map_size = nusc_map.get_size()
    
    objects_list = nusc_map.get_closest_layers(nusc_map.non_geometric_layers, (0, 0), map_size)
    for layer in nusc_map.non_geometric_layers:
        objects = objects_list[layer]
        print(layer, len(objects))
                    
df = pd.DataFrame(info, columns = ['location', 'layer', 'map_x', 'map_y', 'number_of_points'])
nusc_map.non_geometric_layers<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12245961438249088, 'fraction_numerical': 0.023710265763418448, 'mean_word_length': 5.103338632750398, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '436034', 'license': 'MIT', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1353, 'n_words': 270, 'path': 'Research/nuScenes/.ipynb_checkpoints/Nuscenes_EDA_for_map-checkpoint.ipynb', 'repo_name': 'leeh8911/BeSuperRepo', 'size': '3838'}