<jupyter_start><jupyter_text>**Colaboratory**<jupyter_code>#from google.colab import drive
#drive.mount('/content/drive/', force_remount=True)
#import os
#os.chdir('./drive/My Drive/3D-CLoST/Notebook')<jupyter_output><empty_output><jupyter_text>**Import modules**<jupyter_code>from CLOST.imports import pd, np, dt, timedelta
from CLOST.utils import remove_incomplete_days
from CLOST.volumes import *<jupyter_output><empty_output><jupyter_text>**Beijing Volume and Mask Creation**  **Import data**<jupyter_code>city = 'BJ'
step = 2
data = np.load('../data/' + city + '/data.npy')
timestamps = np.load('../data/' + city + '/timestamps.npy').astype(str)
data, timestamps = remove_incomplete_days(data, timestamps)
hour_dict = {'01': '0000',
             '02': '0030',
             '03': '0100',
             '04': '0130',
             '05': '0200',
             '06': '0230',
             '07': '0300',
             '08': '0330',
             '09': '0400',
             '10': '0430',
             '11': '0500',
             '12': '0530',
             '13': '0600',
             '14': '0630',
             '15': '0700',
             '16': '0730',
             '17': '0800',
             '18': '0830',
             '19': '0900',
             '20': '0930',
             '21': '1000',
             '22': '1030',
             '23': '1100',
             '24': '1130',
             '25': '1200',
             '26': '1230',
             '27': '1300',
             '28': '1330',
             '29': '1400',
             '30': '1430',
             '31': '1500',
             '32': '1530',
             '33': '1600',
             '34': '1630',
             '35': '1700',
             '36': '1730',
             '37': '1800',
             '38': '1830',
             '39': '1900',
             '40': '1930',
             '41': '2000',
             '42': '2030',
             '43': '2100',
             '44': '2130',
             '45': '2200',
             '46': '2230',
             '47': '2300',
             '48': '2330'}

timestamps = np.array([date[:-2] + hour_dict[date[-2:]] for date in timestamps])<jupyter_output><empty_output><jupyter_text>**Volumes creation**<jupyter_code>city_dict = create_dict(data, timestamps)
timestamps = pd.Series(list(city_dict.keys())).apply(lambda x: x.split('_')[0]).unique()
X_date, y_date = set_volume_date(city, timestamps, step = step, add_day_before=True, add_half=True)
X = [[[city_dict[date_h + '_' + typ] for typ in ('Inflow', 'Outflow')] for date_h in list_date_h] for list_date_h in X_date] 
y = [[city_dict[d_h + '_' + typ] for typ in ('Inflow', 'Outflow')] for d_h in y_date]

np.save('../data/' + city + '/volumes/X.npy', X)
np.save('../data/' + city + '/volumes/y.npy', y)<jupyter_output><empty_output><jupyter_text>**Mask creation**<jupyter_code>mask = create_mask(city, city_dict)
np.save('../data/' + city + '/mask.npy', mask)<jupyter_output><empty_output><jupyter_text>**New York Volume and Mask Creation**  **Import data**<jupyter_code>city = 'NY'
step = 2
data = np.load('../data/' + city + '/data.npy')
timestamps = np.load('../data/' + city + '/timestamps.npy').astype(str)<jupyter_output><empty_output><jupyter_text>**Volumes creation**<jupyter_code>city_dict = create_dict(data, timestamps)
X_date, y_date = set_volume_date(city, timestamps, step = step, add_week_before=True)
X = [[[city_dict[date_h + '_' + typ] for typ in ('Inflow', 'Outflow')] for date_h in list_date_h] for list_date_h in X_date] 
y = [[city_dict[d_h + '_' + typ] for typ in ('Inflow', 'Outflow')] for d_h in y_date]

np.save('../data/' + city + '/volumes/X.npy', X)
np.save('../data/' + city + '/volumes/y.npy', y)<jupyter_output><empty_output><jupyter_text>**Mask creation**<jupyter_code>mask = create_mask(city, city_dict)
np.save('../data/' + city + '/mask.npy', mask)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup