Skip to content

Instantly share code, notes, and snippets.

@aletelecom
aletelecom / .py
Created July 19, 2022 00:47
Importing
# Make all the imports needed
import pandas as pd
from itertools import product
from random import randint, choice
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.DataFrame(data=[[1,2,3,'model_A'],[5,6,7,'model_B']], columns=[['slot', 'port', 'client_qty', 'model']])
df
@aletelecom
aletelecom / .py
Created July 19, 2022 00:51
Checking class
olt = OLT()
df = olt.create_olt_and_populate(max_client_qty=64)
df
@aletelecom
aletelecom / .py
Created July 19, 2022 00:53
Creating the olt population
olt_qty = 150
max_client_qty = 64
concat_df = pd.concat([OLT().create_olt_and_populate(max_client_qty) for olt in range(olt_qty)])
concat_df
@aletelecom
aletelecom / .py
Created July 19, 2022 00:59
Creating the viz
plt.rcParams.update({'font.size':14, 'figure.figsize': (25,20)})
grouped_olts = concat_df.groupby(['port', 'slot', 'model'])['client_qty'].mean().reset_index()
grouped_olts.sort_values(by='model', inplace=True)
models = list(concat_df['model'].unique())
olts = []
for model in models:
o = grouped_olts[grouped_olts['model']==model]
olts.append(o)
@aletelecom
aletelecom / .py
Created July 19, 2022 01:01
Creating olt class
class OLT:
""" Define a class OLT that have the following attributes:
- An "int" Board quantity (slot_qty) which represent the maximun slot count that the OLT has.
- An "int" Port quantity per slot (port_per_slot) which represent the maximun port count per slot that the OLT has.
- An "int" Maximun client quantity per pon port (max_client_qty) which represent the maximun client count per port per slot that the OLT has. """
def __init__(self, slot_qty=16, port_per_slot=16):
self.slot_qty = slot_qty
self.port_per_slot = port_per_slot
@aletelecom
aletelecom / .py
Created July 23, 2022 02:22
New OLT class for viz 2
class OLT:
""" Define a class OLT that have the following attributes:
- An "int" Board quantity (slot_qty) which represent the maximun slot count that the OLT has.
- An "int" Port quantity per slot (port_per_slot) which represent the maximun port count per slot that the OLT has.
- An "int" Maximun client quantity per pon port (max_client_qty) which represent the maximun client count per port per slot that the OLT has. """
def __init__(self, slot_qty=16, port_per_slot=16):
self.slot_qty = slot_qty
self.port_per_slot = port_per_slot
@aletelecom
aletelecom / .py
Created July 23, 2022 02:24
Create synthetical viz 2
olt_qty = 350
max_client_qty = 64
speeds = np.arange(10, 20, 0.1)
concat_df = pd.concat([OLT().create_olt_and_populate(max_client_qty, speeds) for olt in range(olt_qty)])
concat_df
@aletelecom
aletelecom / .py
Created July 23, 2022 02:27
Viz 2
#from matplotlib.pyplot import annotate
plt.rcParams.update({'font.size':25, 'figure.figsize': (30,10)})
# Calculate the mean of ocupation, and the x axis of the text
mean = concat_df['ocupation_%'].mean()
text_x = concat_df['client_qty'].max() / 10
# Create the scatter plot, the horizontal line, and the text
ax = concat_df.plot(kind='scatter', x='client_qty', y='ocupation_%', color='blue')
ax.axhline(mean, lw=8, color='green', label='Mean')
@aletelecom
aletelecom / .py
Created July 29, 2022 13:31
All imports viz 3
# Make all the imports needed
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import skewnorm, norm
@aletelecom
aletelecom / .py
Created July 29, 2022 13:33
Viz 3 create clients
a = 3
loc = 4500
scale = 6500
size = 350
client_qty = skewnorm.rvs(a, loc, scale, size, random_state=28)
plt.hist(np.sort(client_qty))
plt.show()