Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Moncora
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
halleyUIS
Moncora
Commits
4c06c900
Commit
4c06c900
authored
1 year ago
by
Laura Marcela Becerra
Browse files
Options
Downloads
Patches
Plain Diff
change figure
parent
064a937b
Branches
main
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Book/Racimo/data2023.md
+55
-74
55 additions, 74 deletions
Book/Racimo/data2023.md
with
55 additions
and
74 deletions
Book/Racimo/data2023.md
+
55
−
74
View file @
4c06c900
...
...
@@ -162,6 +162,9 @@ display(bucaramanga_map)
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import plotly.express as px
import plotly.graph_objects as go
...
...
@@ -176,6 +179,9 @@ Estaciones = [('E2_00023','Grupo Halley',7.1393716,-73.1210968),
('mE1_00012','I.E. Café Madrid',7.1631654, -73.14033300)
]
fecha_inicio = "2023-02-24 00:00:00"
fecha_fin = "2023-12-20 00:00:00"
Nest=len(Estaciones)
data=[[] for i in range(Nest)]
...
...
@@ -204,86 +210,60 @@ for i in range(1,Nest):
data[i]['Estacion'] = est[1]
data[i]['id_est'] = int(i)
for i in range(1,Nest):
data[i] = data[i].assign(row_number=range(len(data[i])))
data[i]['ts'] = data[i].index
data[i].set_index(['row_number'], inplace=True)
dat[i] = dat[i].assign(row_number=range(len(dat[i])))
dat[i]['ts'] = dat[i].index
dat[i].set_index(['row_number'], inplace=True)
data_all = data[1].copy()
dat_all = dat[1].copy()
for i in range(2,Nest):
data_all = data_all.merge(data[i], how='outer')
dat_all = dat_all.merge(dat[i], how='outer')
fig = plt.subplots(figsize=(20,20))
col = 2
row = int( (Nest-1)/col )
i=0; j=0
for ii in range(1,Nest):
ax = plt.subplot2grid((row,col), (j,i) )
# Crear gráfico
data[ii].pm25.plot(ax=ax,label=' ' , marker='o',ls="", markersize=0.5, alpha=0.2)
dat[ii].pm25_r.plot(ax=ax,label=' Promedio PM 25 ', ls="-", color="navy")
fig = px.scatter(data_all, x="ts", y="pm25",
color="Estacion", hover_name="Estacion"
)
ax.axhline(y=37, color='r', linestyle='--', label='Nivel Máximo Permisible 24 horas (37 $\mu g /m^3$)')
ax.axhline(y=12, color='orange', linestyle='--', label='Nivel Aceptable Permisible 24 horas (12 $\mu g /m^3$)')
Ndat= dat[ii].shape[0]
ax.text(dat[ii].index[int(0.5*Ndat)], 50, Estaciones[ii][1], ha="center", va="bottom", fontsize=25, fontweight="bold")
fig2 = px.line(dat_all, x="ts", y="pm25_r",
color="Estacion",
hover_name="Estacion" )
fig.update_traces(marker={'size': 2, 'opacity':0.3 })
fig3 = go.Figure(data=fig.data + fig2.data)
fig3.add_hline(y=12, line_dash="dot", row="all", col="all",
annotation_text="<b>Nivel Aceptable Permisible 24 horas</b> <br> (12 \mu g /m^3)",
annotation_position="bottom right",
line_color="yellow",
annotation=dict(font_size=12, font_family="Times New Roman"),)
fig3.add_hline(y=37, line_dash="dot", row="all", col="all",
annotation_text="<b>Nivel Máximo Permisible 24 horas</b> <br> (37 \mu g /m^3)",
annotation_position="bottom right",
line_color="red",
annotation=dict(font_size=12, font_family="Times New Roman"),)
fig3.update_layout ( xaxis_title="Fecha",
yaxis_title="PM 25 [ \mu g / m^3 ]",
autosize=True,
#width=790,
#height=500,
margin=dict(
l=50,
r=50,
b=50,
t=50,
pad=4),
font=dict(
family="Rockwell",
size=12,
#color="RebeccaPurple"
),
legend=dict(
title=None, orientation="h", y=1.05, yanchor="bottom", x=0.5, xanchor="center"
),
plot_bgcolor='rgba(0,0,0,0)'
)
fig3.update_xaxes( ticks='outside',
showline=True,
linecolor='black',
#mirror=True,
#range=[1600,2020],
)
fig3.update_yaxes( #ticks='outside',
#showline=True,
#linecolor='black',
#mirror=True,
range=[-2,75],
)
fig3.show()
if i==0:
ax.set_ylabel("PM 25 $[\, \mu g / m^3\, ]$", fontsize=25, fontweight="bold")
ax.tick_params(which='major', pad=1, length=8, labelsize=15, direction="inout", width=1.5)
if j==0:
ax.legend(loc="upper left")
else:
ax.axes.yaxis.set_visible(False)
if j==(row-1):
ax.xaxis.set_major_formatter(mdates.DateFormatter('%b'))
plt.xticks(rotation=0)
ax.set_xlabel("")
#ax.xaxis.set_major_locator(mdates.DayLocator(interval=32))
ax.tick_params(which='minor', labelsize=18, length=8)
else:
ax.axes.xaxis.set_visible(False)
ax.set_ylim(-2., 75)
ax.set_xlim(fecha_inicio, fecha_fin)
i+=1
if i > (col-1):
i=0
j+=1
plt.subplots_adjust(left=0.06, bottom=0.1, right=0.99, top=0.99, wspace=0.01, hspace=0)
plt.show()
```
...
...
@@ -315,6 +295,7 @@ Estaciones = [('E2_00023','Grupo Halley',7.1393716,-73.1210968),
('mE1_00012','I.E. Café Madrid',7.1631654, -73.14033300)
]
Nest=len(Estaciones)
data=[[] for i in range(Nest)]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment