Add application file
Browse files- .gitattributes +2 -35
- .streamlit/config.toml +2 -0
- __pycache__/cpc_iri_web.cpython-38.pyc +0 -0
- __pycache__/plot.cpython-38.pyc +0 -0
- app.py +276 -0
- cpc_iri_web.py +58 -0
- estilos/style.css +76 -0
- imgs/logo.png +0 -0
- packages.txt +1 -0
- plot.py +706 -0
- requirements.txt +10 -0
.gitattributes
CHANGED
@@ -1,35 +1,2 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
1 |
+
# Auto detect text files and perform LF normalization
|
2 |
+
* text=auto
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.streamlit/config.toml
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
[theme]
|
2 |
+
base="light"
|
__pycache__/cpc_iri_web.cpython-38.pyc
ADDED
Binary file (1.81 kB). View file
|
|
__pycache__/plot.cpython-38.pyc
ADDED
Binary file (16.9 kB). View file
|
|
app.py
ADDED
@@ -0,0 +1,276 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from streamlit_echarts import st_pyecharts
|
3 |
+
from plot import *
|
4 |
+
from cpc_iri_web import header
|
5 |
+
from st_on_hover_tabs import on_hover_tabs
|
6 |
+
from datetime import datetime, timedelta
|
7 |
+
import requests
|
8 |
+
from PIL import Image
|
9 |
+
import warnings
|
10 |
+
warnings.simplefilter(action='ignore', category=FutureWarning)
|
11 |
+
|
12 |
+
# Configurando a página
|
13 |
+
st.set_page_config(layout='wide')
|
14 |
+
|
15 |
+
# Estilos
|
16 |
+
streamlit_style = """
|
17 |
+
<style>
|
18 |
+
footer {visibility: hidden;}
|
19 |
+
iframe[title="streamlit_echarts.st_echarts"]{ height: 500px;}
|
20 |
+
ul.streamlit-expander {border-top: 0;}
|
21 |
+
ul.streamlit-expander {border-left: 0;}
|
22 |
+
ul.streamlit-expander {border-right: 0;}
|
23 |
+
ul.streamlit-expander {border-bottom: solid 2px;}
|
24 |
+
ul.streamlit-expander {border-radius: 0px;}
|
25 |
+
.css-11qx4gg {display: none;}
|
26 |
+
</style>
|
27 |
+
"""
|
28 |
+
st.markdown(streamlit_style, unsafe_allow_html=True)
|
29 |
+
st.markdown('<style>' + open('estilos/style.css').read() + '</style>', unsafe_allow_html=True)
|
30 |
+
|
31 |
+
# Sidebar
|
32 |
+
with st.sidebar:
|
33 |
+
|
34 |
+
logo = Image.open('imgs/logo.png')
|
35 |
+
st.image(logo)
|
36 |
+
st.divider()
|
37 |
+
|
38 |
+
component = on_hover_tabs(
|
39 |
+
tabName=['Índices oceânicos', 'Índice atmosférico', 'Mapas e índices diários', 'Previsão POAMA', 'Previsão CPC/IRI'],
|
40 |
+
iconName=['storm', 'cloud', 'maps', 'public', 'public'],
|
41 |
+
styles = {'navtab': {'background-color':'#111','color': '#818181','font-size': '15px',
|
42 |
+
'transition': '0.5s',
|
43 |
+
'white-space': 'nowrap',
|
44 |
+
'text-transform': 'uppercase'},
|
45 |
+
'tabOptionsStyle': {':hover :hover': {'color': 'white','cursor': 'pointer'}},
|
46 |
+
'iconStyle':{'position':'fixed','left':'7.5px', 'text-align': 'left'},
|
47 |
+
'tabStyle' : {'list-style-type': 'none', 'margin-bottom': '30px', 'padding-left': '30px'}},
|
48 |
+
default_choice=0)
|
49 |
+
|
50 |
+
# #st.header('Menu')
|
51 |
+
# component = sac.menu(
|
52 |
+
|
53 |
+
# items=[
|
54 |
+
# sac.MenuItem('Monitoramento', type='group', children=['Índices oceânicos', 'Índice atmosféricos', 'Mapas']),
|
55 |
+
# sac.MenuItem('Previsão', type='group', children=['CPC/IRI']),
|
56 |
+
# #sac.MenuItem('Estudo de casos', type='group', children=['ENA', 'Precipitação'])
|
57 |
+
# ],
|
58 |
+
# index=1
|
59 |
+
# )
|
60 |
+
|
61 |
+
if component == 'Índices oceânicos':
|
62 |
+
|
63 |
+
st.title('Evolução dos Índices ENSO por região do Oceano Pacíficio', anchor=False)
|
64 |
+
|
65 |
+
descricao = '''
|
66 |
+
O índice ONI é calculado a partir da região 3.4 do Oceano Pacífico e pode ser utilizado para a caracterização dos episódios de <span style="color: red">aquecimento da TSM equatorial do oceano Pacífico</span> e <span style="color: blue">resfriamento da TSM equatorial do oceano Pacífico</span>. A duração de pelo menos cinco médias móveis consecutivas de três meses <span style="color: red">acima de 0.5°C</span> classifica um episódio de <span style="color: red">El Niño</span>, enquanto que <span style="color: blue">abaixo de -0.5°C</span> classifica um episódio de <span style="color: blue">La Ninã</span>. Além da região 3.4, as demais regiões do pacíficio equatorial (Nino3, Nino4, Nino1+2) também possuem influência nos padrões de teleconexão e devem ser monitorados. O Índice ONI e as anomalias de TSM são calculados a partir do conjunto de dados <i><a href='https://www.ncei.noaa.gov/products/extended-reconstructed-sst'>Extended Reconstructed Sea Surface Temperature (ERSSTv5).</i></a>
|
67 |
+
'''
|
68 |
+
|
69 |
+
st.write(descricao, unsafe_allow_html=True)
|
70 |
+
|
71 |
+
col1, col2 = st.columns(2)
|
72 |
+
|
73 |
+
with col1:
|
74 |
+
st.header('Sazonal')
|
75 |
+
tab1, tab2, tab3, tab4, tab5 = st.tabs(['Índice ONI','Niño 1+2', 'Niño 3', 'Niño 3.4', 'Niño 4'])
|
76 |
+
with tab1:
|
77 |
+
plot = plot_oni_season()
|
78 |
+
st_pyecharts(plot_oni_season(), height="500px", width="100%")
|
79 |
+
with tab2:
|
80 |
+
plot = plot_sst_indexes_season('nino12')
|
81 |
+
st_pyecharts(plot, height="500px", width="100%")
|
82 |
+
with tab3:
|
83 |
+
plot = plot_sst_indexes_season('nino3')
|
84 |
+
st_pyecharts(plot, height="500px", width="100%")
|
85 |
+
with tab4:
|
86 |
+
plot = plot_sst_indexes_season('nino34')
|
87 |
+
st_pyecharts(plot, height="500px", width="100%")
|
88 |
+
with tab5:
|
89 |
+
plot = plot_sst_indexes_season('nino4')
|
90 |
+
st_pyecharts(plot, height="500px", width="100%")
|
91 |
+
|
92 |
+
with col2:
|
93 |
+
st.header('Mensal')
|
94 |
+
tab1, tab2, tab3, tab4, tab5 = st.tabs(['Índice ONI','Niño 1+2', 'Niño 3', 'Niño 3.4', 'Niño 4'])
|
95 |
+
with tab1:
|
96 |
+
plot = plot_oni()
|
97 |
+
st_pyecharts(plot, height="500px", width="100%")
|
98 |
+
with tab2:
|
99 |
+
plot = plot_sst_indexes('nino12')
|
100 |
+
st_pyecharts(plot, height="500px", width="100%")
|
101 |
+
with tab3:
|
102 |
+
plot = plot_sst_indexes('nino3')
|
103 |
+
st_pyecharts(plot, height="500px", width="100%")
|
104 |
+
with tab4:
|
105 |
+
plot = plot_sst_indexes('nino34')
|
106 |
+
st_pyecharts(plot, height="500px", width="100%")
|
107 |
+
with tab5:
|
108 |
+
plot = plot_sst_indexes('nino4')
|
109 |
+
st_pyecharts(plot, height="500px", width="100%")
|
110 |
+
|
111 |
+
with st.expander('**Clique para ver a distribuição geográfica das regiões**'):
|
112 |
+
ex1, ex2, ex3 = st.columns(3)
|
113 |
+
with ex2:
|
114 |
+
st.image('https://www.ncei.noaa.gov/monitoring-content/teleconnections/nino-regions.gif', use_column_width=True)
|
115 |
+
st.markdown('<strong>Fonte: NOAA/NCEI</strong>', unsafe_allow_html=True)
|
116 |
+
|
117 |
+
if component == 'Índice atmosférico':
|
118 |
+
|
119 |
+
st.title('Evolução do Índice SOI', anchor=False)
|
120 |
+
descricao = '''
|
121 |
+
|
122 |
+
O Índice de Oscilação Sul (Southern Oscillation Index - SOI) é um índice baseado nas diferenças observadas de pressão ao nível do mar (PNM) entre Tahti e Darwin, na Austrália, e pode ser um indicador das flutuações de larga escala durante as fases do fenômeno ENSO. Durante episódios de <span style="color: red">El Niño</span>, espera-se um um <span style="color: blue">Índice SOI negativo</span>. Para episódios de <span style="color: blue">La Niña</span>, espera-se um um <span style="color: red">Índice SOI positivo</span>. <a href="https://www.cpc.ncep.noaa.gov/products/analysis_monitoring/ensocycle/soi.shtml">Mais informações sobre o Índice SOI.</a><br>
|
123 |
+
'''
|
124 |
+
st.write(descricao, unsafe_allow_html=True)
|
125 |
+
col1, col2 = st.columns(2)
|
126 |
+
with col1:
|
127 |
+
st.header('Sazonal')
|
128 |
+
plot = plot_soi_season()
|
129 |
+
st_pyecharts(plot, height="500px", width="100%")
|
130 |
+
with col2:
|
131 |
+
st.header('Mensal')
|
132 |
+
plot = plot_soi()
|
133 |
+
st_pyecharts(plot, height="500px", width="100%")
|
134 |
+
|
135 |
+
# Mapas
|
136 |
+
|
137 |
+
if component == 'Mapas e índices diários':
|
138 |
+
|
139 |
+
st.title('Mapas de diários de temperatura da superífice do mar (TSM), anomalia da temperatura da superífice do mar e tendência da TSM nos últimos 7 dias')
|
140 |
+
descricao = '''
|
141 |
+
<a href="https://coralreefwatch.noaa.gov/product/5km/">Fonte: Coral Reef Watch.</a><br>
|
142 |
+
'''
|
143 |
+
st.write(descricao, unsafe_allow_html=True)
|
144 |
+
st.info('Clique ao lado da figura para ampliar seu tamanho')
|
145 |
+
fmt = '%Y%m%d'
|
146 |
+
now = datetime.now()
|
147 |
+
|
148 |
+
now_1day = now - timedelta(days=1)
|
149 |
+
now_1day_fmt = now_1day.strftime(fmt)
|
150 |
+
now_2day = now - timedelta(days=2)
|
151 |
+
now_2day_fmt = now_2day.strftime(fmt)
|
152 |
+
|
153 |
+
data_escolhida_tsm = st.date_input('Escolha ou digite a data desejada', now_1day, max_value=now_1day, key='tsm')
|
154 |
+
data_escolhida_tsm_fmt = data_escolhida_tsm.strftime(fmt)
|
155 |
+
data_escolhida_tsm_year_fmt = data_escolhida_tsm.year
|
156 |
+
|
157 |
+
col1, col2, col3 = st.columns(3)
|
158 |
+
with col1:
|
159 |
+
st.header('Temperatura')
|
160 |
+
url = f'https://www.star.nesdis.noaa.gov/pub/sod/mecb/crw/data/5km/v3.1_op/image_browse/daily/sst/png/{data_escolhida_tsm_year_fmt}/coraltemp_v3.1_global_{data_escolhida_tsm_fmt}.png'
|
161 |
+
response = requests.get(url)
|
162 |
+
if response.status_code == 200:
|
163 |
+
st.image(f'https://www.star.nesdis.noaa.gov/pub/sod/mecb/crw/data/5km/v3.1_op/image_browse/daily/sst/png/{data_escolhida_tsm_year_fmt}/coraltemp_v3.1_global_{data_escolhida_tsm_fmt}.png')
|
164 |
+
else:
|
165 |
+
st.image(f'https://www.star.nesdis.noaa.gov/pub/sod/mecb/crw/data/5km/v3.1_op/image_browse/daily/sst/png/{data_escolhida_tsm_year_fmt}/coraltemp_v3.1_global_{now_2day_fmt}.png')
|
166 |
+
with col2:
|
167 |
+
st.header('Anomalia')
|
168 |
+
url = f'https://www.star.nesdis.noaa.gov/pub/sod/mecb/crw/data/5km/v3.1_op/image_browse/daily/ssta/png/{data_escolhida_tsm_year_fmt}/ct5km_ssta_v3.1_global_{data_escolhida_tsm_fmt}.png'
|
169 |
+
response = requests.get(url)
|
170 |
+
if response.status_code == 200:
|
171 |
+
st.image(f'https://www.star.nesdis.noaa.gov/pub/sod/mecb/crw/data/5km/v3.1_op/image_browse/daily/ssta/png/{data_escolhida_tsm_year_fmt}/ct5km_ssta_v3.1_global_{data_escolhida_tsm_fmt}.png')
|
172 |
+
else:
|
173 |
+
st.image(f'https://www.star.nesdis.noaa.gov/pub/sod/mecb/crw/data/5km/v3.1_op/image_browse/daily/ssta/png/{data_escolhida_tsm_year_fmt}/ct5km_ssta_v3.1_global_{now_2day_fmt}.png')
|
174 |
+
with col3:
|
175 |
+
st.header('Tendência')
|
176 |
+
url = f'https://www.star.nesdis.noaa.gov/pub/sod/mecb/crw/data/5km/v3.1_op/image_browse/daily/sst-trend-7d/png/{data_escolhida_tsm_year_fmt}/ct5km_sst-trend-7d_v3.1_global_{data_escolhida_tsm_fmt}.png'
|
177 |
+
response = requests.get(url)
|
178 |
+
if response.status_code == 200:
|
179 |
+
st.image(f'https://www.star.nesdis.noaa.gov/pub/sod/mecb/crw/data/5km/v3.1_op/image_browse/daily/sst-trend-7d/png/{data_escolhida_tsm_year_fmt}/ct5km_sst-trend-7d_v3.1_global_{data_escolhida_tsm_fmt}.png')
|
180 |
+
else:
|
181 |
+
st.image(f'https://www.star.nesdis.noaa.gov/pub/sod/mecb/crw/data/5km/v3.1_op/image_browse/daily/sst-trend-7d/png/{data_escolhida_tsm_year_fmt}/ct5km_sst-trend-7d_v3.1_global_{now_2day_fmt}.png')
|
182 |
+
|
183 |
+
st.title('Índices diários da anomalia de temperatura da superífice do mar para regiões do ENSO.')
|
184 |
+
days = 1800
|
185 |
+
tab1, tab2, tab3, tab4 = st.tabs(['Niño 1+2', 'Niño 3', 'Niño 3.4', 'Niño 4'])
|
186 |
+
with tab1:
|
187 |
+
plot = plot_daily_ssta('nino12', days)
|
188 |
+
st_pyecharts(plot, height="500px", width="100%")
|
189 |
+
with tab2:
|
190 |
+
plot = plot_daily_ssta('nino3', days)
|
191 |
+
st_pyecharts(plot, height="500px", width="100%")
|
192 |
+
with tab3:
|
193 |
+
plot = plot_daily_ssta('nino34', days)
|
194 |
+
st_pyecharts(plot, height="500px", width="100%")
|
195 |
+
with tab4:
|
196 |
+
plot = plot_daily_ssta('nino4', days)
|
197 |
+
st_pyecharts(plot, height="500px", width="100%")
|
198 |
+
|
199 |
+
# if component == 'NOAA/CPC/NCEP':
|
200 |
+
# st.title('Apresentação da NOAA/CPC/NCEP a respeito das condições de ENSO observadas semanalmente')
|
201 |
+
# components.iframe('https://docs.google.com/presentation/d/e/2PACX-1vRTlPQuAwEDdVyjkwCwYabSuqL30Xfir6RVdYURyhlxd6-5fVhfEccAc-dXWmG2JA/embed?start=false&loop=false&delayms=3000', height=500)
|
202 |
+
|
203 |
+
if component == 'Previsão POAMA':
|
204 |
+
|
205 |
+
# Figuras de previsão
|
206 |
+
|
207 |
+
st.title('Previsão dos modelos para de anomalia a TSM na região 3.4')
|
208 |
+
descricao = '''
|
209 |
+
<a href="http://www.bom.gov.au/climate/enso/">Fonte: Poama</a><br>
|
210 |
+
'''
|
211 |
+
st.write(descricao, unsafe_allow_html=True)
|
212 |
+
st.write('Última inicialização: <strong>01 Agosto 2023</strong>', unsafe_allow_html=True)
|
213 |
+
|
214 |
+
tab1, tab2, tab3, tab4, tab5 = st.tabs(['Mês 1', 'Mês 2', 'Mês 3', 'Mês 4', 'Mês 5'])
|
215 |
+
|
216 |
+
with tab1:
|
217 |
+
st.image('https://github.com/josepaulo1233/enso-assets/blob/main/imgs/poama_model_lead1.png?raw=true')
|
218 |
+
with tab2:
|
219 |
+
st.image('https://github.com/josepaulo1233/enso-assets/blob/main/imgs/poama_model_lead2.png?raw=true')
|
220 |
+
with tab3:
|
221 |
+
st.image('https://github.com/josepaulo1233/enso-assets/blob/main/imgs/poama_model_lead3.png?raw=true')
|
222 |
+
with tab4:
|
223 |
+
st.image('https://github.com/josepaulo1233/enso-assets/blob/main/imgs/poama_model_lead4.png?raw=true')
|
224 |
+
with tab5:
|
225 |
+
st.image('https://github.com/josepaulo1233/enso-assets/blob/main/imgs/poama_model_lead5.png?raw=true')
|
226 |
+
|
227 |
+
# Gráfico
|
228 |
+
|
229 |
+
import pandas as pd
|
230 |
+
|
231 |
+
st.title('Anomalia de TSM e probabilidade do ENSO')
|
232 |
+
descricao = '''
|
233 |
+
Previsão de anomalia de TSM e probabilidades da temperatura estar acima de +0.8°C (vermelho), em condições de neutralidade (verde), e abaixo de -0.8°C (azul) na região do Niño 3.4. <a href="http://www.bom.gov.au/climate/ocean/outlooks/#region=NINO34">Mais informações sobre a previsão do centro Australiano (POAMA).</a><br>
|
234 |
+
'''
|
235 |
+
st.write(descricao, unsafe_allow_html=True)
|
236 |
+
|
237 |
+
url = 'http://www.bom.gov.au/climate/ocean/outlooks/archive/20230729//plumes/sstOutlooks.nino34.hr.png'
|
238 |
+
last_update = pd.to_datetime(url.split('/')[7], format='%Y%m%d')
|
239 |
+
last_update = last_update.strftime('%B %d, %Y')
|
240 |
+
st.write(f'Última atualização: <strong>{last_update}</strong>', unsafe_allow_html=True)
|
241 |
+
plot = plot_poama()
|
242 |
+
st_pyecharts(plot, height="300px", width="100%")
|
243 |
+
|
244 |
+
if component == 'Previsão CPC/IRI':
|
245 |
+
|
246 |
+
st.title('Previsão do CPC/IRI para a anomalia de TSM na região do Niño 3.4', anchor=False)
|
247 |
+
descricao = '''
|
248 |
+
Dados fornecidos por <a href='https://iri.columbia.edu/ENSO'> The International Research Institute for Climate and Society, Columbia University Climate School </a><br>
|
249 |
+
'''
|
250 |
+
st.write(descricao, unsafe_allow_html=True)
|
251 |
+
st.write(f'Última atualização: <strong>{header}</strong>', unsafe_allow_html=True)
|
252 |
+
dicas = '''
|
253 |
+
Dicas: Passe o mouse sobre a legenda para destacar a previsão de determinado modelo ou clique para remover.
|
254 |
+
'''
|
255 |
+
tab1, tab2, tab3, tab4 = st.tabs(['Modelos dinâmicos', 'Modelos estatisticos', 'Todos modelos', 'Previsão de concenso'])
|
256 |
+
with tab1:
|
257 |
+
plot = plot_cpc_iri_dinamico()
|
258 |
+
st_pyecharts(plot, height="500px", width="100%", key='dinamico')
|
259 |
+
st.info(dicas, icon="ℹ️")
|
260 |
+
with tab2:
|
261 |
+
plot = plot_cpc_iri_estatistico()
|
262 |
+
st_pyecharts(plot, height="500px", width="100%", key='estatistico')
|
263 |
+
st.info(dicas, icon="ℹ️")
|
264 |
+
with tab3:
|
265 |
+
plot = plot_cpc_iri_todos()
|
266 |
+
st_pyecharts(plot, height="500px", width="100%", key='todos')
|
267 |
+
st.info(dicas, icon="ℹ️")
|
268 |
+
with tab4:
|
269 |
+
plot = plot_iri_concenso()
|
270 |
+
st_pyecharts(plot, height="500px", width="100%", key='concenso')
|
271 |
+
st.info('Dicas: Clique na legenda para remover alguma barra', icon="ℹ️")
|
272 |
+
|
273 |
+
|
274 |
+
|
275 |
+
|
276 |
+
|
cpc_iri_web.py
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from selenium import webdriver
|
2 |
+
from selenium.webdriver.chrome.options import Options
|
3 |
+
from selenium.webdriver.chrome.service import Service
|
4 |
+
from webdriver_manager.chrome import ChromeDriverManager
|
5 |
+
from bs4 import BeautifulSoup
|
6 |
+
import pandas as pd
|
7 |
+
import streamlit as st
|
8 |
+
|
9 |
+
#st.set_page_config(layout='wide')
|
10 |
+
|
11 |
+
options = Options()
|
12 |
+
options.add_argument('--headless')
|
13 |
+
#@st.cache_resource
|
14 |
+
def get_driver():
|
15 |
+
return webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
|
16 |
+
|
17 |
+
driver = get_driver()
|
18 |
+
driver.get("https://iri.columbia.edu/our-expertise/climate/forecasts/enso/current/?enso_tab=enso-sst_table")
|
19 |
+
page = driver.page_source
|
20 |
+
soup = BeautifulSoup(page, 'lxml')
|
21 |
+
|
22 |
+
#cabeçalho
|
23 |
+
header = soup.find('h4')
|
24 |
+
header = header.text.split(':')[1]
|
25 |
+
|
26 |
+
# table
|
27 |
+
table = soup.find('table')
|
28 |
+
df_table = pd.read_html(str(table))[0]
|
29 |
+
df_table = pd.DataFrame(df_table.to_records())
|
30 |
+
df_table = df_table[df_table.columns[1:]]
|
31 |
+
df_table.set_index('Season', inplace=True)
|
32 |
+
|
33 |
+
# Divs
|
34 |
+
div = soup.find('div', {"id": "ENSO-Plume-Models-Table"})
|
35 |
+
df = pd.read_html(str(div))[0]
|
36 |
+
df = pd.DataFrame(df.to_records())
|
37 |
+
df = df[df.columns[1:]]
|
38 |
+
colunas = [x.split(',')[1].split(')')[0] for x in df.columns]
|
39 |
+
colunas = [x.replace(' ', '').replace("'", "") for x in colunas]
|
40 |
+
df.columns = colunas
|
41 |
+
|
42 |
+
# modelos dinamicos
|
43 |
+
modelos_dinamicos = df[1:18]
|
44 |
+
modelos_dinamicos.set_index('Model', inplace=True)
|
45 |
+
modelos_dinamicos = modelos_dinamicos.astype(float)
|
46 |
+
modelos_dinamicos = modelos_dinamicos.T
|
47 |
+
modelos_dinamicos['Média'] = modelos_dinamicos.mean(axis=1)
|
48 |
+
|
49 |
+
# modelos estatisticos
|
50 |
+
modelos_estatisticos = df[20:36]
|
51 |
+
modelos_estatisticos.set_index('Model', inplace=True)
|
52 |
+
modelos_estatisticos = modelos_estatisticos.astype(float)
|
53 |
+
modelos_estatisticos = modelos_estatisticos.T
|
54 |
+
modelos_estatisticos['Média'] = modelos_estatisticos.mean(axis=1)
|
55 |
+
|
56 |
+
|
57 |
+
|
58 |
+
|
estilos/style.css
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
section[data-testid='stSidebar'] {
|
2 |
+
background-color: #111;
|
3 |
+
flex-shrink: unset !important;
|
4 |
+
|
5 |
+
}
|
6 |
+
|
7 |
+
@media(hover:hover) and (min-width: 600px) and (max-width: 769px){
|
8 |
+
|
9 |
+
header[data-testid="stHeader"] {
|
10 |
+
display:none;
|
11 |
+
}
|
12 |
+
|
13 |
+
section[data-testid='stSidebar'] {
|
14 |
+
height: 100%;
|
15 |
+
min-width:95px !important;
|
16 |
+
width: 95px !important;
|
17 |
+
margin-left: 305px;
|
18 |
+
position: relative;
|
19 |
+
z-index: 1;
|
20 |
+
top: 0;
|
21 |
+
left: 0;
|
22 |
+
background-color: #111;
|
23 |
+
overflow-x: hidden;
|
24 |
+
transition: 0.5s ease;
|
25 |
+
padding-top: 60px;
|
26 |
+
white-space: nowrap;
|
27 |
+
}
|
28 |
+
|
29 |
+
section[data-testid='stSidebar']:hover{
|
30 |
+
min-width: 330px !important;
|
31 |
+
}
|
32 |
+
|
33 |
+
button[kind="header"] {
|
34 |
+
display: none;
|
35 |
+
}
|
36 |
+
|
37 |
+
div[data-testid="collapsedControl"]{
|
38 |
+
display: none;
|
39 |
+
}
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
@media(hover: hover) and (min-width: 769px){
|
44 |
+
|
45 |
+
header[data-testid="stHeader"] {
|
46 |
+
display:none;
|
47 |
+
}
|
48 |
+
|
49 |
+
section[data-testid='stSidebar'] {
|
50 |
+
height: 100%;
|
51 |
+
min-width:95px !important;
|
52 |
+
width: 95px !important;
|
53 |
+
transform:translateX(0px);
|
54 |
+
position: relative;
|
55 |
+
z-index: 1;
|
56 |
+
top: 0;
|
57 |
+
left: 0;
|
58 |
+
background-color: #111;
|
59 |
+
overflow-x: hidden;
|
60 |
+
transition: 0.5s ease;
|
61 |
+
padding-top: 60px;
|
62 |
+
white-space: nowrap;
|
63 |
+
}
|
64 |
+
|
65 |
+
section[data-testid='stSidebar']:hover{
|
66 |
+
min-width: 330px !important;
|
67 |
+
}
|
68 |
+
|
69 |
+
button[kind="header"] {
|
70 |
+
display: none;
|
71 |
+
}
|
72 |
+
|
73 |
+
div[data-testid="collapsedControl"]{
|
74 |
+
display: none;
|
75 |
+
}
|
76 |
+
}
|
imgs/logo.png
ADDED
packages.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
chromium
|
plot.py
ADDED
@@ -0,0 +1,706 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
from pyecharts import options as opts
|
4 |
+
from pyecharts.charts import Bar, Line
|
5 |
+
from pyecharts.commons.utils import JsCode
|
6 |
+
import numpy as np
|
7 |
+
from cpc_iri_web import modelos_dinamicos, modelos_estatisticos, df_table
|
8 |
+
|
9 |
+
#@st.cache_data
|
10 |
+
def plot_oni():
|
11 |
+
|
12 |
+
df = pd.read_table('https://origin.cpc.ncep.noaa.gov/products/analysis_monitoring/ensostuff/detrend.nino34.ascii.txt', delim_whitespace=True)
|
13 |
+
|
14 |
+
data_inicial = str(df['MON'].values[0]) + '/' + str(df['YR'].values[0])
|
15 |
+
data_final = str(df['MON'].values[-1]) + '/' + str(df['YR'].values[-1])
|
16 |
+
daterange = pd.date_range(*(pd.to_datetime([data_inicial, data_final], format='%m/%Y') + pd.offsets.MonthEnd()), freq='M')
|
17 |
+
index = daterange.strftime('%b/%Y').tolist()
|
18 |
+
data = df['ANOM'].values.tolist()
|
19 |
+
|
20 |
+
color_function = """
|
21 |
+
function (params) {
|
22 |
+
if (params.value > 0) {
|
23 |
+
return 'red';
|
24 |
+
} else {
|
25 |
+
return 'blue';
|
26 |
+
}
|
27 |
+
}
|
28 |
+
"""
|
29 |
+
|
30 |
+
oni_plot = (
|
31 |
+
Bar()
|
32 |
+
.add_xaxis(index)
|
33 |
+
.add_yaxis("Indice ONI", data, itemstyle_opts=opts.ItemStyleOpts(color=JsCode(color_function)))
|
34 |
+
.set_global_opts(title_opts=opts.TitleOpts(title="Índice ONI", subtitle="Fonte: NOAA/CPC", subtitle_link='https://origin.cpc.ncep.noaa.gov/products/analysis_monitoring/ensostuff/ONI_v5.php'),
|
35 |
+
tooltip_opts=opts.TooltipOpts(is_show=True, trigger="axis", axis_pointer_type="cross"),
|
36 |
+
legend_opts=opts.LegendOpts(is_show=False),
|
37 |
+
yaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(formatter="{value} °C")),
|
38 |
+
xaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(is_show=False)),
|
39 |
+
datazoom_opts=[opts.DataZoomOpts(range_start=0, range_end=len(index)), opts.DataZoomOpts(type_="inside")]
|
40 |
+
)
|
41 |
+
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
|
42 |
+
)
|
43 |
+
|
44 |
+
return oni_plot
|
45 |
+
|
46 |
+
###############################################################################################################
|
47 |
+
|
48 |
+
#@st.cache_data
|
49 |
+
def plot_oni_season():
|
50 |
+
|
51 |
+
df = pd.read_table('https://origin.cpc.ncep.noaa.gov/products/analysis_monitoring/ensostuff/detrend.nino34.ascii.txt', delim_whitespace=True)
|
52 |
+
|
53 |
+
data_inicial = str(df['MON'].values[0]) + '/' + str(df['YR'].values[0])
|
54 |
+
data_final = str(df['MON'].values[-1]) + '/' + str(df['YR'].values[-1])
|
55 |
+
daterange = pd.date_range(*(pd.to_datetime([data_inicial, data_final], format='%m/%Y') + pd.offsets.MonthEnd()), freq='M')
|
56 |
+
index = daterange.strftime('%b/%Y').tolist()
|
57 |
+
data = df['ANOM'].values.tolist()
|
58 |
+
|
59 |
+
dff = df.copy()
|
60 |
+
dff.index = index
|
61 |
+
dff_resample = dff['ANOM'].rolling(3).mean().dropna()
|
62 |
+
|
63 |
+
new_index = []
|
64 |
+
for i in range(len(index)):
|
65 |
+
if i+2 < len(index) and i+1 < len(index):
|
66 |
+
new_index.append(index[i][0] + index[i+1][0] + index[i+2][0] + index[i+2][3:])
|
67 |
+
dff_resample.index = new_index
|
68 |
+
|
69 |
+
data = dff_resample.round(2).values.tolist()
|
70 |
+
|
71 |
+
color_function = """
|
72 |
+
function (params) {
|
73 |
+
if (params.value > 0) {
|
74 |
+
return 'red';
|
75 |
+
} else {
|
76 |
+
return 'blue';
|
77 |
+
}
|
78 |
+
}
|
79 |
+
"""
|
80 |
+
|
81 |
+
oni_plot = (
|
82 |
+
Bar()
|
83 |
+
.add_xaxis(new_index)
|
84 |
+
.add_yaxis("Indice ONI", data, itemstyle_opts=opts.ItemStyleOpts(color=JsCode(color_function)))
|
85 |
+
.set_global_opts(title_opts=opts.TitleOpts(title="Índice ONI", subtitle="Fonte: NOAA/CPC", subtitle_link='https://origin.cpc.ncep.noaa.gov/products/analysis_monitoring/ensostuff/ONI_v5.php'),
|
86 |
+
tooltip_opts=opts.TooltipOpts(is_show=True, trigger="axis", axis_pointer_type="cross"),
|
87 |
+
legend_opts=opts.LegendOpts(is_show=False),
|
88 |
+
yaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(formatter="{value} °C")),
|
89 |
+
xaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(is_show=False)),
|
90 |
+
datazoom_opts=[opts.DataZoomOpts(range_start=0, range_end=len(index)), opts.DataZoomOpts(type_="inside")]
|
91 |
+
)
|
92 |
+
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
|
93 |
+
)
|
94 |
+
|
95 |
+
return oni_plot
|
96 |
+
|
97 |
+
###############################################################################################################
|
98 |
+
|
99 |
+
#@st.cache_data
|
100 |
+
def plot_sst_indexes(nino):
|
101 |
+
|
102 |
+
df = pd.read_table('https://www.cpc.ncep.noaa.gov/data/indices/sstoi.indices', delim_whitespace=True)
|
103 |
+
data_inicial = str(df['MON'].values[0]) + '/' + str(df['YR'].values[0])
|
104 |
+
data_final = str(df['MON'].values[-1]) + '/' + str(df['YR'].values[-1])
|
105 |
+
daterange = pd.date_range(*(pd.to_datetime([data_inicial, data_final], format='%m/%Y') + pd.offsets.MonthEnd()), freq='M')
|
106 |
+
index = daterange.strftime('%b/%Y').tolist()
|
107 |
+
|
108 |
+
if nino == 'nino12':
|
109 |
+
data = df['ANOM'].values.tolist()
|
110 |
+
title = 'Anomalia TSM Niño 1+2 Index'
|
111 |
+
elif nino == 'nino3':
|
112 |
+
data = df['ANOM.1'].values.tolist()
|
113 |
+
title = 'Anomalia TSM Niño 3 Index'
|
114 |
+
elif nino == 'nino34':
|
115 |
+
data = df['ANOM.2'].values.tolist()
|
116 |
+
title = 'Anomalia TSM Niño 3+4 Index'
|
117 |
+
elif nino == 'nino4':
|
118 |
+
data = df['ANOM.3'].values.tolist()
|
119 |
+
title = 'Anomalia TSM Niño 4 Index'
|
120 |
+
|
121 |
+
color_function = """
|
122 |
+
function (params) {
|
123 |
+
if (params.value > 0) {
|
124 |
+
return 'red';
|
125 |
+
} else {
|
126 |
+
return 'blue';
|
127 |
+
}
|
128 |
+
}
|
129 |
+
"""
|
130 |
+
|
131 |
+
oni_plot = (
|
132 |
+
|
133 |
+
Bar()
|
134 |
+
.add_xaxis(index)
|
135 |
+
.add_yaxis("Indice SST", data, itemstyle_opts=opts.ItemStyleOpts(color=JsCode(color_function)))
|
136 |
+
.set_global_opts(title_opts=opts.TitleOpts(title=title, subtitle="Fonte: NCEI/NOAA", subtitle_link='https://www.ncei.noaa.gov/access/monitoring/enso/sst'),
|
137 |
+
tooltip_opts=opts.TooltipOpts(is_show=True, trigger="axis", axis_pointer_type="cross"),
|
138 |
+
legend_opts=opts.LegendOpts(is_show=False),
|
139 |
+
yaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(formatter="{value} °C")),
|
140 |
+
xaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(is_show=False)),
|
141 |
+
datazoom_opts=[opts.DataZoomOpts(range_start=0, range_end=len(index)), opts.DataZoomOpts(type_="inside")]
|
142 |
+
)
|
143 |
+
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
|
144 |
+
)
|
145 |
+
|
146 |
+
return oni_plot
|
147 |
+
|
148 |
+
|
149 |
+
###############################################################################################################
|
150 |
+
|
151 |
+
#@st.cache_data
|
152 |
+
def plot_sst_indexes_season(nino):
|
153 |
+
|
154 |
+
df = pd.read_table('https://www.cpc.ncep.noaa.gov/data/indices/sstoi.indices', delim_whitespace=True)
|
155 |
+
data_inicial = str(df['MON'].values[0]) + '/' + str(df['YR'].values[0])
|
156 |
+
data_final = str(df['MON'].values[-1]) + '/' + str(df['YR'].values[-1])
|
157 |
+
daterange = pd.date_range(*(pd.to_datetime([data_inicial, data_final], format='%m/%Y') + pd.offsets.MonthEnd()), freq='M')
|
158 |
+
index = daterange.strftime('%b/%Y').tolist()
|
159 |
+
dff = df.copy()
|
160 |
+
dff.index = index
|
161 |
+
|
162 |
+
if nino == 'nino12':
|
163 |
+
data = dff['ANOM']
|
164 |
+
title = 'Anomalia TSM Niño 1+2 Index'
|
165 |
+
elif nino == 'nino3':
|
166 |
+
data = dff['ANOM.1']
|
167 |
+
title = 'Anomalia TSM Niño 3 Index'
|
168 |
+
elif nino == 'nino34':
|
169 |
+
data = dff['ANOM.2']
|
170 |
+
title = 'Anomalia TSM Niño 3+4 Index'
|
171 |
+
elif nino == 'nino4':
|
172 |
+
data = dff['ANOM.3']
|
173 |
+
title = 'Anomalia TSM Niño 4 Index'
|
174 |
+
|
175 |
+
dff_resample = data.rolling(3).mean().dropna()
|
176 |
+
|
177 |
+
new_index = []
|
178 |
+
for i in range(len(index)):
|
179 |
+
if i+2 < len(index) and i+1 < len(index):
|
180 |
+
new_index.append(index[i][0] + index[i+1][0] + index[i+2][0] + index[i+2][3:])
|
181 |
+
dff_resample.index = new_index
|
182 |
+
|
183 |
+
data = dff_resample.round(2).values.tolist()
|
184 |
+
|
185 |
+
color_function = """
|
186 |
+
function (params) {
|
187 |
+
if (params.value > 0) {
|
188 |
+
return 'red';
|
189 |
+
} else {
|
190 |
+
return 'blue';
|
191 |
+
}
|
192 |
+
}
|
193 |
+
"""
|
194 |
+
|
195 |
+
oni_plot = (
|
196 |
+
|
197 |
+
Bar()
|
198 |
+
.add_xaxis(new_index)
|
199 |
+
.add_yaxis("Indice SST", data, itemstyle_opts=opts.ItemStyleOpts(color=JsCode(color_function)))
|
200 |
+
.set_global_opts(title_opts=opts.TitleOpts(title=title, subtitle="Fonte: NCEI/NOAA", subtitle_link='https://www.ncei.noaa.gov/access/monitoring/enso/sst'),
|
201 |
+
tooltip_opts=opts.TooltipOpts(is_show=True, trigger="axis", axis_pointer_type="cross"),
|
202 |
+
legend_opts=opts.LegendOpts(is_show=False),
|
203 |
+
yaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(formatter="{value} °C")),
|
204 |
+
xaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(is_show=False)),
|
205 |
+
datazoom_opts=[opts.DataZoomOpts(range_start=0, range_end=len(index)), opts.DataZoomOpts(type_="inside")]
|
206 |
+
)
|
207 |
+
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
|
208 |
+
)
|
209 |
+
|
210 |
+
return oni_plot
|
211 |
+
|
212 |
+
###############################################################################################################
|
213 |
+
|
214 |
+
#@st.cache_data
|
215 |
+
def plot_soi():
|
216 |
+
|
217 |
+
soi = pd.read_table('https://www.cpc.ncep.noaa.gov/data/indices/soi', delim_whitespace=True, skiprows=87, index_col=0)
|
218 |
+
soi = soi[0:72]
|
219 |
+
soi.loc['2023'] = [1.4, 1.4, 0.2, 0.2, 1.0, 0.3, -0.3, np.NaN, np.NaN, np.NaN, np.NaN, np.NaN] # INSERINDO MANUALMENTE OS VALORES
|
220 |
+
t = soi.loc[soi.index[0]]
|
221 |
+
for h in soi.index[1:]:
|
222 |
+
if h == soi.index[1]:
|
223 |
+
r = pd.concat([t, soi.loc[h]])
|
224 |
+
else:
|
225 |
+
r = pd.concat([r, soi.loc[h]])
|
226 |
+
df_soi = pd.DataFrame(r).astype(float)
|
227 |
+
date_range2 = pd.date_range(start='1/1/1951', end='1/1/2024', freq='M')
|
228 |
+
df_soi.index = date_range2
|
229 |
+
df_soi.columns = ['Índice SOI']
|
230 |
+
index = df_soi.index.strftime('%b/%Y').tolist()
|
231 |
+
data = df_soi['Índice SOI'].tolist()
|
232 |
+
title = 'Índice SOI'
|
233 |
+
|
234 |
+
color_function = """
|
235 |
+
function (params) {
|
236 |
+
if (params.value > 0) {
|
237 |
+
return 'red';
|
238 |
+
} else {
|
239 |
+
return 'blue';
|
240 |
+
}
|
241 |
+
}
|
242 |
+
"""
|
243 |
+
|
244 |
+
soi_plot = (
|
245 |
+
|
246 |
+
Bar()
|
247 |
+
.add_xaxis(index)
|
248 |
+
.add_yaxis("Indice SOI", data, itemstyle_opts=opts.ItemStyleOpts(color=JsCode(color_function)))
|
249 |
+
.set_global_opts(title_opts=opts.TitleOpts(title=title, subtitle="Fonte: NCEI/NOAA", subtitle_link='https://www.ncei.noaa.gov/access/monitoring/enso/soi'),
|
250 |
+
tooltip_opts=opts.TooltipOpts(is_show=True, trigger="axis", axis_pointer_type="cross"),
|
251 |
+
legend_opts=opts.LegendOpts(is_show=False),
|
252 |
+
#yaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(formatter="{value} °C")),
|
253 |
+
xaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(is_show=False)),
|
254 |
+
datazoom_opts=[opts.DataZoomOpts(range_start=0, range_end=len(index)), opts.DataZoomOpts(type_="inside")]
|
255 |
+
)
|
256 |
+
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
|
257 |
+
)
|
258 |
+
|
259 |
+
return soi_plot
|
260 |
+
|
261 |
+
###############################################################################################################
|
262 |
+
|
263 |
+
#@st.cache_data
|
264 |
+
def plot_soi_season():
|
265 |
+
|
266 |
+
soi = pd.read_table('https://www.cpc.ncep.noaa.gov/data/indices/soi', delim_whitespace=True, skiprows=87, index_col=0)
|
267 |
+
soi = soi[0:72]
|
268 |
+
soi.loc['2023'] = [1.4, 1.4, 0.2, 0.2, 1.0, 0.3, -0.3, np.NaN, np.NaN, np.NaN, np.NaN, np.NaN] # INSERINDO MANUALMENTE OS VALORES
|
269 |
+
t = soi.loc[soi.index[0]]
|
270 |
+
for h in soi.index[1:]:
|
271 |
+
if h == soi.index[1]:
|
272 |
+
r = pd.concat([t, soi.loc[h]])
|
273 |
+
else:
|
274 |
+
r = pd.concat([r, soi.loc[h]])
|
275 |
+
df_soi = pd.DataFrame(r).astype(float)
|
276 |
+
date_range2 = pd.date_range(start='1/1/1951', end='1/1/2024', freq='M')
|
277 |
+
df_soi.index = date_range2
|
278 |
+
df_soi.columns = ['Índice SOI']
|
279 |
+
index = df_soi.index.strftime('%b/%Y').tolist()
|
280 |
+
data = df_soi['Índice SOI'].tolist()
|
281 |
+
title = 'Índice SOI'
|
282 |
+
|
283 |
+
dff = df_soi.copy()
|
284 |
+
dff.index = index
|
285 |
+
dff_resample = dff.rolling(3).mean()
|
286 |
+
dff_resample = dff[2:]
|
287 |
+
|
288 |
+
new_index = []
|
289 |
+
for i in range(len(dff.index)):
|
290 |
+
if i+2 < len(dff.index) and i+1 < len(dff.index):
|
291 |
+
new_index.append(dff.index[i][0] + dff.index[i+1][0] + dff.index[i+2][0] + dff.index[i+2][3:])
|
292 |
+
|
293 |
+
dff_resample.index = new_index
|
294 |
+
data = dff_resample['Índice SOI'].dropna().values.tolist()
|
295 |
+
|
296 |
+
color_function = """
|
297 |
+
function (params) {
|
298 |
+
if (params.value > 0) {
|
299 |
+
return 'red';
|
300 |
+
} else {
|
301 |
+
return 'blue';
|
302 |
+
}
|
303 |
+
}
|
304 |
+
"""
|
305 |
+
|
306 |
+
soi_plot = (
|
307 |
+
|
308 |
+
Bar()
|
309 |
+
.add_xaxis(new_index)
|
310 |
+
.add_yaxis("Indice SOI", data, itemstyle_opts=opts.ItemStyleOpts(color=JsCode(color_function)))
|
311 |
+
.set_global_opts(title_opts=opts.TitleOpts(title=title, subtitle="Fonte: NCEI/NOAA", subtitle_link='https://www.ncei.noaa.gov/access/monitoring/enso/soi'),
|
312 |
+
tooltip_opts=opts.TooltipOpts(is_show=True, trigger="axis", axis_pointer_type="cross"),
|
313 |
+
legend_opts=opts.LegendOpts(is_show=False),
|
314 |
+
#yaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(formatter="{value} °C")),
|
315 |
+
xaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(is_show=False)),
|
316 |
+
datazoom_opts=[opts.DataZoomOpts(range_start=0, range_end=len(index)), opts.DataZoomOpts(type_="inside")]
|
317 |
+
)
|
318 |
+
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
|
319 |
+
)
|
320 |
+
|
321 |
+
return soi_plot
|
322 |
+
|
323 |
+
###############################################################################################################
|
324 |
+
|
325 |
+
def plot_poama():
|
326 |
+
|
327 |
+
csv = 'https://raw.githubusercontent.com/josepaulo1233/enso-assets/main/xlsx/poama.csv'
|
328 |
+
df = pd.read_csv(csv, sep=';')
|
329 |
+
df.columns = ['Mês', 'Anomalia região 3.4', 'Abaixo', 'Neutro', 'Acima']
|
330 |
+
|
331 |
+
index = df['Mês'].values.tolist()
|
332 |
+
title = 'Previsão POAMA'
|
333 |
+
data_anomalia = df['Anomalia região 3.4'].values.tolist()
|
334 |
+
data_abaixo = (df['Abaixo']*100).values.tolist()
|
335 |
+
data_neutro = (df['Neutro']*100).values.tolist()
|
336 |
+
data_acima = (df['Acima']*100).values.tolist()
|
337 |
+
|
338 |
+
poama_plot_bar = (
|
339 |
+
|
340 |
+
Bar()
|
341 |
+
.add_xaxis(index)
|
342 |
+
.add_yaxis("La Niña", data_abaixo, color='blue')
|
343 |
+
.add_yaxis("Neutro", data_neutro, color='green')
|
344 |
+
.add_yaxis("El Niño", data_acima, color='red')
|
345 |
+
.set_global_opts(title_opts=opts.TitleOpts(
|
346 |
+
#title=title,
|
347 |
+
# subtitle="Fonte: POAMA", subtitle_link='http://www.bom.gov.au/climate/ocean/outlooks/'
|
348 |
+
),
|
349 |
+
tooltip_opts=opts.TooltipOpts(is_show=True, trigger="axis", axis_pointer_type="cross"),
|
350 |
+
legend_opts=opts.LegendOpts(orient='horizontal', type_='scroll', pos_top='bottom', item_gap=23, border_width=0),
|
351 |
+
xaxis_opts=opts.AxisOpts(axispointer_opts=opts.AxisPointerOpts(is_show=True, type_="shadow"), splitline_opts=opts.SplitLineOpts(is_show=False)),
|
352 |
+
yaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(formatter="{value} %"),
|
353 |
+
name='Probabilidade',
|
354 |
+
name_location='middle',
|
355 |
+
name_gap=100,
|
356 |
+
name_textstyle_opts=opts.TextStyleOpts(font_size=13, font_weight='bold')
|
357 |
+
),
|
358 |
+
)
|
359 |
+
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
|
360 |
+
.extend_axis(yaxis=opts.AxisOpts(
|
361 |
+
type_="value",
|
362 |
+
min_=-1.5,
|
363 |
+
max_=3.5,
|
364 |
+
interval=1,
|
365 |
+
axislabel_opts=opts.LabelOpts(formatter="{value} °C"),
|
366 |
+
)
|
367 |
+
)
|
368 |
+
|
369 |
+
)
|
370 |
+
|
371 |
+
poama_plot_line = (
|
372 |
+
|
373 |
+
Line()
|
374 |
+
.add_xaxis(index)
|
375 |
+
.add_yaxis("Anomalia de TSM",
|
376 |
+
data_anomalia,
|
377 |
+
color='black',
|
378 |
+
linestyle_opts=opts.LineStyleOpts(width=5), symbol_size=10,
|
379 |
+
#color=JsCode(color_function),
|
380 |
+
#itemstyle_opts=opts.ItemStyleOpts(color=JsCode(color_function)),
|
381 |
+
yaxis_index=1,
|
382 |
+
)
|
383 |
+
|
384 |
+
)
|
385 |
+
|
386 |
+
poama_plot_bar.overlap(poama_plot_line)
|
387 |
+
|
388 |
+
return poama_plot_bar
|
389 |
+
|
390 |
+
###############################################################################################################
|
391 |
+
|
392 |
+
def plot_cpc_iri_dinamico():
|
393 |
+
|
394 |
+
data1 = modelos_dinamicos['GFDL SPEAR'].values.tolist()
|
395 |
+
data2 = modelos_dinamicos['AUS-ACCESS'].values.tolist()
|
396 |
+
data3 = modelos_dinamicos['BCC_CSM11m'].values.tolist()
|
397 |
+
data4 = modelos_dinamicos['COLA CCSM4'].values.tolist()
|
398 |
+
data5 = modelos_dinamicos['CS-IRI-MM'].values.tolist()
|
399 |
+
data6 = modelos_dinamicos['DWD'].values.tolist()
|
400 |
+
data7 = modelos_dinamicos['ECMWF'].values.tolist()
|
401 |
+
data8 = modelos_dinamicos['IOCAS ICM'].values.tolist()
|
402 |
+
data9 = modelos_dinamicos['JMA'].values.tolist()
|
403 |
+
data10 = modelos_dinamicos['KMA'].values.tolist()
|
404 |
+
data11 = modelos_dinamicos['LDEO'].values.tolist()
|
405 |
+
data12 = modelos_dinamicos['MetFRANCE'].values.tolist()
|
406 |
+
data13 = modelos_dinamicos['NASA GMAO'].values.tolist()
|
407 |
+
data14 = modelos_dinamicos['NCEP CFSv2'].values.tolist()
|
408 |
+
data15 = modelos_dinamicos['SINTEX-F'].values.tolist()
|
409 |
+
data16 = modelos_dinamicos['UKMO'].values.tolist()
|
410 |
+
data17 = modelos_dinamicos['Média'].round(2).values.tolist()
|
411 |
+
|
412 |
+
index = modelos_dinamicos.index.values.tolist()
|
413 |
+
|
414 |
+
cpc_plot = (
|
415 |
+
|
416 |
+
Line()
|
417 |
+
.add_xaxis(index)
|
418 |
+
.add_yaxis("GFDL SPEAR", data1, itemstyle_opts={"emphasis": {"focus": "series"}})
|
419 |
+
.add_yaxis("AUS-ACCESS", data2, itemstyle_opts={"emphasis": {"focus": "series"}})
|
420 |
+
.add_yaxis("BCC_CSM11m", data3, itemstyle_opts={"emphasis": {"focus": "series"}})
|
421 |
+
.add_yaxis("COLA CCSM4", data4, itemstyle_opts={"emphasis": {"focus": "series"}})
|
422 |
+
.add_yaxis("CS-IRI-MM", data5, itemstyle_opts={"emphasis": {"focus": "series"}})
|
423 |
+
.add_yaxis("DWD", data6, itemstyle_opts={"emphasis": {"focus": "series"}})
|
424 |
+
.add_yaxis("ECMWF", data7, itemstyle_opts={"emphasis": {"focus": "series"}})
|
425 |
+
.add_yaxis("IOCAS ICM", data8, itemstyle_opts={"emphasis": {"focus": "series"}})
|
426 |
+
.add_yaxis("JMA", data9, itemstyle_opts={"emphasis": {"focus": "series"}})
|
427 |
+
.add_yaxis("KMA", data10, itemstyle_opts={"emphasis": {"focus": "series"}})
|
428 |
+
.add_yaxis("LDEO", data11, itemstyle_opts={"emphasis": {"focus": "series"}})
|
429 |
+
.add_yaxis("MetFRANCE", data12, itemstyle_opts={"emphasis": {"focus": "series"}})
|
430 |
+
.add_yaxis("NASA GMAO", data13, itemstyle_opts={"emphasis": {"focus": "series"}})
|
431 |
+
.add_yaxis("NCEP CFSv2", data14, itemstyle_opts={"emphasis": {"focus": "series"}})
|
432 |
+
.add_yaxis("SINTEX-F", data15, itemstyle_opts={"emphasis": {"focus": "series"}})
|
433 |
+
.add_yaxis("UKMO", data16, itemstyle_opts={"emphasis": {"focus": "series"}})
|
434 |
+
.add_yaxis("Média Dinâmicos", data17, linestyle_opts=opts.LineStyleOpts(width=5), symbol_size=10, itemstyle_opts={"emphasis": {"focus": "series"}})
|
435 |
+
.set_global_opts(title_opts=opts.TitleOpts(
|
436 |
+
title='Modelos dinâmicos',
|
437 |
+
#subtitle="Fonte: NCEI/NOAA", subtitle_link='https://www.ncei.noaa.gov/access/monitoring/enso/soi'
|
438 |
+
),
|
439 |
+
tooltip_opts=opts.TooltipOpts(is_show=True,
|
440 |
+
trigger="item",
|
441 |
+
#axis_pointer_type="cross",
|
442 |
+
#trigger="item",
|
443 |
+
#trigger_on="mousemove"
|
444 |
+
),
|
445 |
+
legend_opts=opts.LegendOpts(orient='horizontal', type_='scroll', pos_top='bottom', item_gap=23, border_width=0),
|
446 |
+
yaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(formatter="{value} °C"),
|
447 |
+
name='Anomalia de TSM (°C) na região do Niño 3.4',
|
448 |
+
name_location='middle',
|
449 |
+
name_gap=100,
|
450 |
+
name_textstyle_opts=opts.TextStyleOpts(font_size=13, font_weight='bold')
|
451 |
+
),
|
452 |
+
xaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(is_show=False)),
|
453 |
+
#datazoom_opts=[opts.DataZoomOpts(range_start=0, range_end=len(index)), opts.DataZoomOpts(type_="inside")]
|
454 |
+
)
|
455 |
+
.set_series_opts(label_opts=opts.LabelOpts(is_show=False), )
|
456 |
+
)
|
457 |
+
|
458 |
+
return cpc_plot
|
459 |
+
|
460 |
+
###############################################################################################################
|
461 |
+
|
462 |
+
def plot_cpc_iri_estatistico():
|
463 |
+
|
464 |
+
data1 = modelos_estatisticos['BCC_RZDM'].values.tolist()
|
465 |
+
data2 = modelos_estatisticos['CDC LIM'].values.tolist()
|
466 |
+
data3 = modelos_estatisticos['CPC CA'].values.tolist()
|
467 |
+
data4 = modelos_estatisticos['CPC CCA'].values.tolist()
|
468 |
+
data5 = modelos_estatisticos['CPC MRKOV'].values.tolist()
|
469 |
+
data6 = modelos_estatisticos['CSU CLIPR'].values.tolist()
|
470 |
+
data7 = modelos_estatisticos['FSU REGR'].values.tolist()
|
471 |
+
data8 = modelos_estatisticos['IAP-NN'].values.tolist()
|
472 |
+
data9 = modelos_estatisticos['NTU CODA'].values.tolist()
|
473 |
+
data10 = modelos_estatisticos['PSD-CU LIM'].values.tolist()
|
474 |
+
data11 = modelos_estatisticos['UBC NNET'].values.tolist()
|
475 |
+
data12 = modelos_estatisticos['UNB/CWC'].values.tolist()
|
476 |
+
data13 = modelos_estatisticos['UCLA'].values.tolist()
|
477 |
+
data14 = modelos_estatisticos['UCLA-TCD'].values.tolist()
|
478 |
+
data15 = modelos_estatisticos['UW PSL-CSLIM'].values.tolist()
|
479 |
+
data16 = modelos_estatisticos['UW PSL-LIM'].values.tolist()
|
480 |
+
data17 = modelos_estatisticos['Média'].round(2).values.tolist()
|
481 |
+
|
482 |
+
index = modelos_estatisticos.index.values.tolist()
|
483 |
+
|
484 |
+
cpc_plot = (
|
485 |
+
|
486 |
+
Line()
|
487 |
+
.add_xaxis(index)
|
488 |
+
.add_yaxis("BCC_RZDM", data1, itemstyle_opts={"emphasis": {"focus": "series"}})
|
489 |
+
#.add_yaxis("CDC LIM", data2)
|
490 |
+
.add_yaxis("CPC CA", data3, itemstyle_opts={"emphasis": {"focus": "series"}})
|
491 |
+
#.add_yaxis("CPC CCA", data4)
|
492 |
+
.add_yaxis("CPC MRKOV", data5, itemstyle_opts={"emphasis": {"focus": "series"}})
|
493 |
+
.add_yaxis("CSU CLIPR", data6, itemstyle_opts={"emphasis": {"focus": "series"}})
|
494 |
+
#.add_yaxis("FSU REGR", data7)
|
495 |
+
.add_yaxis("IAP-NN", data8, itemstyle_opts={"emphasis": {"focus": "series"}})
|
496 |
+
.add_yaxis("NTU CODA", data9, itemstyle_opts={"emphasis": {"focus": "series"}})
|
497 |
+
#.add_yaxis("PSD-CU LIM", data10)
|
498 |
+
#.add_yaxis("UBC NNET", data11)
|
499 |
+
#.add_yaxis("UNB/CWC", data12)
|
500 |
+
#.add_yaxis("UCLA", data13)
|
501 |
+
.add_yaxis("UCLA-TCD", data14, itemstyle_opts={"emphasis": {"focus": "series"}})
|
502 |
+
.add_yaxis("UW PSL-CSLIM", data15, itemstyle_opts={"emphasis": {"focus": "series"}})
|
503 |
+
.add_yaxis("UW PSL-LIM", data16, itemstyle_opts={"emphasis": {"focus": "series"}})
|
504 |
+
.add_yaxis("Média Estatisticos", data17, linestyle_opts=opts.LineStyleOpts(width=5), symbol_size=10, itemstyle_opts={"emphasis": {"focus": "series"}})
|
505 |
+
.set_global_opts(title_opts=opts.TitleOpts(title='Modelos estatísticos',
|
506 |
+
),
|
507 |
+
tooltip_opts=opts.TooltipOpts(is_show=True,
|
508 |
+
trigger="item",
|
509 |
+
),
|
510 |
+
legend_opts=opts.LegendOpts(orient='horizontal', type_='scroll', pos_top='bottom', item_gap=23, border_width=0),
|
511 |
+
yaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(formatter="{value} °C"),
|
512 |
+
name='Anomalia de TSM (°C) na região do Niño 3.4',
|
513 |
+
name_location='middle',
|
514 |
+
name_gap=100,
|
515 |
+
name_textstyle_opts=opts.TextStyleOpts(font_size=13, font_weight='bold')
|
516 |
+
),
|
517 |
+
xaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(is_show=False)),
|
518 |
+
)
|
519 |
+
.set_series_opts(label_opts=opts.LabelOpts(is_show=False), )
|
520 |
+
)
|
521 |
+
|
522 |
+
return cpc_plot
|
523 |
+
|
524 |
+
###############################################################################################################
|
525 |
+
|
526 |
+
def plot_cpc_iri_todos():
|
527 |
+
|
528 |
+
data1 = modelos_estatisticos['BCC_RZDM'].values.tolist()
|
529 |
+
data2 = modelos_estatisticos['CDC LIM'].values.tolist()
|
530 |
+
data3 = modelos_estatisticos['CPC CA'].values.tolist()
|
531 |
+
data4 = modelos_estatisticos['CPC CCA'].values.tolist()
|
532 |
+
data5 = modelos_estatisticos['CPC MRKOV'].values.tolist()
|
533 |
+
data6 = modelos_estatisticos['CSU CLIPR'].values.tolist()
|
534 |
+
data7 = modelos_estatisticos['FSU REGR'].values.tolist()
|
535 |
+
data8 = modelos_estatisticos['IAP-NN'].values.tolist()
|
536 |
+
data9 = modelos_estatisticos['NTU CODA'].values.tolist()
|
537 |
+
data10 = modelos_estatisticos['PSD-CU LIM'].values.tolist()
|
538 |
+
data11 = modelos_estatisticos['UBC NNET'].values.tolist()
|
539 |
+
data12 = modelos_estatisticos['UNB/CWC'].values.tolist()
|
540 |
+
data13 = modelos_estatisticos['UCLA'].values.tolist()
|
541 |
+
data14 = modelos_estatisticos['UCLA-TCD'].values.tolist()
|
542 |
+
data15 = modelos_estatisticos['UW PSL-CSLIM'].values.tolist()
|
543 |
+
data16 = modelos_estatisticos['UW PSL-LIM'].values.tolist()
|
544 |
+
data17 = modelos_estatisticos['Média'].round(2).values.tolist()
|
545 |
+
|
546 |
+
data18 = modelos_dinamicos['GFDL SPEAR'].values.tolist()
|
547 |
+
data19 = modelos_dinamicos['AUS-ACCESS'].values.tolist()
|
548 |
+
data20 = modelos_dinamicos['BCC_CSM11m'].values.tolist()
|
549 |
+
data21 = modelos_dinamicos['COLA CCSM4'].values.tolist()
|
550 |
+
data22 = modelos_dinamicos['CS-IRI-MM'].values.tolist()
|
551 |
+
data23 = modelos_dinamicos['DWD'].values.tolist()
|
552 |
+
data24 = modelos_dinamicos['ECMWF'].values.tolist()
|
553 |
+
data25 = modelos_dinamicos['IOCAS ICM'].values.tolist()
|
554 |
+
data26 = modelos_dinamicos['JMA'].values.tolist()
|
555 |
+
data27 = modelos_dinamicos['KMA'].values.tolist()
|
556 |
+
data28 = modelos_dinamicos['LDEO'].values.tolist()
|
557 |
+
data29 = modelos_dinamicos['MetFRANCE'].values.tolist()
|
558 |
+
data30 = modelos_dinamicos['NASA GMAO'].values.tolist()
|
559 |
+
data31 = modelos_dinamicos['NCEP CFSv2'].values.tolist()
|
560 |
+
data32 = modelos_dinamicos['SINTEX-F'].values.tolist()
|
561 |
+
data33 = modelos_dinamicos['UKMO'].values.tolist()
|
562 |
+
data34 = modelos_dinamicos['Média'].round(2).values.tolist()
|
563 |
+
|
564 |
+
|
565 |
+
index = modelos_estatisticos.index.values.tolist()
|
566 |
+
|
567 |
+
cpc_plot = (
|
568 |
+
|
569 |
+
Line()
|
570 |
+
.add_xaxis(index)
|
571 |
+
.add_yaxis("BCC_RZDM", data1, itemstyle_opts={"emphasis": {"focus": "series"}})
|
572 |
+
#.add_yaxis("CDC LIM", data2)
|
573 |
+
.add_yaxis("CPC CA", data3, itemstyle_opts={"emphasis": {"focus": "series"}})
|
574 |
+
#.add_yaxis("CPC CCA", data4)
|
575 |
+
.add_yaxis("CPC MRKOV", data5, itemstyle_opts={"emphasis": {"focus": "series"}})
|
576 |
+
.add_yaxis("CSU CLIPR", data6, itemstyle_opts={"emphasis": {"focus": "series"}})
|
577 |
+
#.add_yaxis("FSU REGR", data7)
|
578 |
+
.add_yaxis("IAP-NN", data8, itemstyle_opts={"emphasis": {"focus": "series"}})
|
579 |
+
.add_yaxis("NTU CODA", data9, itemstyle_opts={"emphasis": {"focus": "series"}})
|
580 |
+
#.add_yaxis("PSD-CU LIM", data10)
|
581 |
+
#.add_yaxis("UBC NNET", data11)
|
582 |
+
#.add_yaxis("UNB/CWC", data12)
|
583 |
+
#.add_yaxis("UCLA", data13)
|
584 |
+
.add_yaxis("UCLA-TCD", data14, itemstyle_opts={"emphasis": {"focus": "series"}})
|
585 |
+
.add_yaxis("UW PSL-CSLIM", data15, itemstyle_opts={"emphasis": {"focus": "series"}})
|
586 |
+
.add_yaxis("UW PSL-LIM", data16, itemstyle_opts={"emphasis": {"focus": "series"}})
|
587 |
+
.add_yaxis("M.Estatistica", data17, linestyle_opts=opts.LineStyleOpts(width=5), symbol_size=13, symbol='triangle', itemstyle_opts={"emphasis": {"focus": "series"}})
|
588 |
+
.add_yaxis("GFDL SPEAR", data18, itemstyle_opts={"emphasis": {"focus": "series"}})
|
589 |
+
.add_yaxis("AUS-ACCESS", data19, itemstyle_opts={"emphasis": {"focus": "series"}})
|
590 |
+
.add_yaxis("BCC_CSM11m", data20, itemstyle_opts={"emphasis": {"focus": "series"}})
|
591 |
+
.add_yaxis("COLA CCSM4", data21, itemstyle_opts={"emphasis": {"focus": "series"}})
|
592 |
+
.add_yaxis("CS-IRI-MM", data22, itemstyle_opts={"emphasis": {"focus": "series"}})
|
593 |
+
.add_yaxis("DWD", data23, itemstyle_opts={"emphasis": {"focus": "series"}})
|
594 |
+
.add_yaxis("ECMWF", data24, itemstyle_opts={"emphasis": {"focus": "series"}})
|
595 |
+
.add_yaxis("IOCAS ICM", data25, itemstyle_opts={"emphasis": {"focus": "series"}})
|
596 |
+
.add_yaxis("JMA", data26, itemstyle_opts={"emphasis": {"focus": "series"}})
|
597 |
+
.add_yaxis("KMA", data27, itemstyle_opts={"emphasis": {"focus": "series"}})
|
598 |
+
.add_yaxis("LDEO", data28, itemstyle_opts={"emphasis": {"focus": "series"}})
|
599 |
+
.add_yaxis("MetFRANCE", data29, itemstyle_opts={"emphasis": {"focus": "series"}})
|
600 |
+
.add_yaxis("NASA GMAO", data30, itemstyle_opts={"emphasis": {"focus": "series"}})
|
601 |
+
.add_yaxis("NCEP CFSv2", data31, itemstyle_opts={"emphasis": {"focus": "series"}})
|
602 |
+
.add_yaxis("SINTEX-F", data32, itemstyle_opts={"emphasis": {"focus": "series"}})
|
603 |
+
.add_yaxis("UKMO", data33, itemstyle_opts={"emphasis": {"focus": "series"}})
|
604 |
+
.add_yaxis("M.Dinamica", data34, linestyle_opts=opts.LineStyleOpts(width=5), symbol_size=13, symbol='rect', itemstyle_opts={"emphasis": {"focus": "series"}})
|
605 |
+
.set_global_opts(title_opts=opts.TitleOpts(title='Todos modelos',
|
606 |
+
),
|
607 |
+
tooltip_opts=opts.TooltipOpts(is_show=True,
|
608 |
+
trigger="item",
|
609 |
+
position='bottom'
|
610 |
+
),
|
611 |
+
legend_opts=opts.LegendOpts(orient='horizontal', type_='scroll', pos_top='bottom', item_gap=23, border_width=0),
|
612 |
+
yaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(formatter="{value} °C"),
|
613 |
+
name='Anomalia de TSM (°C) na região do Niño 3.4',
|
614 |
+
name_location='middle',
|
615 |
+
name_gap=100,
|
616 |
+
name_textstyle_opts=opts.TextStyleOpts(font_size=13, font_weight='bold')
|
617 |
+
),
|
618 |
+
xaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(is_show=False)),
|
619 |
+
)
|
620 |
+
.set_series_opts(label_opts=opts.LabelOpts(is_show=False), )
|
621 |
+
)
|
622 |
+
|
623 |
+
return cpc_plot
|
624 |
+
|
625 |
+
###############################################################################################################
|
626 |
+
|
627 |
+
def plot_iri_concenso():
|
628 |
+
|
629 |
+
data_nina = df_table['La Niña'].values.tolist()
|
630 |
+
data_neutro = df_table['Neutral'].values.tolist()
|
631 |
+
data_nino = df_table['El Niño'].values.tolist()
|
632 |
+
index = df_table.index.to_list()
|
633 |
+
title = 'Previsão por consenso'
|
634 |
+
|
635 |
+
cpc_bar = (
|
636 |
+
|
637 |
+
Bar()
|
638 |
+
.add_xaxis(index)
|
639 |
+
.add_yaxis("La Niña", data_nina, color='blue')
|
640 |
+
.add_yaxis("Neutro", data_neutro, color='green')
|
641 |
+
.add_yaxis("El Niño", data_nino, color='red')
|
642 |
+
.set_global_opts(title_opts=opts.TitleOpts(title=title),
|
643 |
+
tooltip_opts=opts.TooltipOpts(is_show=True),
|
644 |
+
legend_opts=opts.LegendOpts(orient='horizontal', type_='scroll', pos_top='bottom', item_gap=23, border_width=0),
|
645 |
+
xaxis_opts=opts.AxisOpts(axispointer_opts=opts.AxisPointerOpts(is_show=True, type_="shadow"), splitline_opts=opts.SplitLineOpts(is_show=False)),
|
646 |
+
yaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(formatter="{value} %"),
|
647 |
+
name='Probabilidade',
|
648 |
+
name_location='middle',
|
649 |
+
name_gap=100,
|
650 |
+
name_textstyle_opts=opts.TextStyleOpts(font_size=14, font_weight='bold')
|
651 |
+
),
|
652 |
+
)
|
653 |
+
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
|
654 |
+
|
655 |
+
)
|
656 |
+
|
657 |
+
return cpc_bar
|
658 |
+
|
659 |
+
###############################################################################################################
|
660 |
+
#@st.cache_data
|
661 |
+
def plot_daily_ssta(nino, days):
|
662 |
+
|
663 |
+
df = pd.read_table('https://conmet.com.br/public/txt_enso/sst_nino_daily.txt', delim_whitespace=True, index_col=0, parse_dates=True)
|
664 |
+
|
665 |
+
df = df[-int(days):]
|
666 |
+
index = df.index.strftime('%d/%b/%Y').tolist()
|
667 |
+
|
668 |
+
if nino == 'nino12':
|
669 |
+
data = df['anom12'].round(2).values.tolist()
|
670 |
+
title = 'Anomalia TSM Niño 1+2'
|
671 |
+
elif nino == 'nino3':
|
672 |
+
data = df['anom3'].round(2).values.tolist()
|
673 |
+
title = 'Anomalia TSM Niño 3'
|
674 |
+
elif nino == 'nino34':
|
675 |
+
data = df['anom34'].round(2).values.tolist()
|
676 |
+
title = 'Anomalia TSM Niño 3+4'
|
677 |
+
elif nino == 'nino4':
|
678 |
+
data = df['anom4'].round(2).values.tolist()
|
679 |
+
title = 'Anomalia TSM Niño 4'
|
680 |
+
|
681 |
+
color_function = """
|
682 |
+
function (params) {
|
683 |
+
if (params.value > 0) {
|
684 |
+
return 'red';
|
685 |
+
} else {
|
686 |
+
return 'blue';
|
687 |
+
}
|
688 |
+
}
|
689 |
+
"""
|
690 |
+
|
691 |
+
oni_plot = (
|
692 |
+
|
693 |
+
Bar()
|
694 |
+
.add_xaxis(index)
|
695 |
+
.add_yaxis("Indice SST", data, itemstyle_opts=opts.ItemStyleOpts(color=JsCode(color_function)))
|
696 |
+
.set_global_opts(title_opts=opts.TitleOpts(title=title, subtitle="Fonte: NCEI/NOAA", subtitle_link='https://www.ncei.noaa.gov/products/extended-reconstructed-sst'),
|
697 |
+
tooltip_opts=opts.TooltipOpts(is_show=True, trigger="axis", axis_pointer_type="cross"),
|
698 |
+
legend_opts=opts.LegendOpts(is_show=False),
|
699 |
+
yaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(formatter="{value} °C")),
|
700 |
+
xaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(is_show=False)),
|
701 |
+
datazoom_opts=[opts.DataZoomOpts(range_start=0, range_end=len(index)), opts.DataZoomOpts(type_="inside")]
|
702 |
+
)
|
703 |
+
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
|
704 |
+
)
|
705 |
+
|
706 |
+
return oni_plot
|
requirements.txt
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
pyecharts
|
3 |
+
pandas
|
4 |
+
numpy
|
5 |
+
streamlit_echarts
|
6 |
+
streamlit-on-Hover-tabs
|
7 |
+
selenium
|
8 |
+
webdriver-manager
|
9 |
+
beautifulsoup4
|
10 |
+
lxml
|