<jupyter_start><jupyter_text><jupyter_code>import pandas as pd

queimadas = pd.read_csv('https://raw.githubusercontent.com/GracielaQuevedo/Repositorio_Python2021/main/historico_pais_bolivia.csv?token=<KEY>')
queimadas
queimadas_2003_2020 = queimadas.iloc[5:23,0:14]
queimadas_2003_2020
import matplotlib.pyplot as plt

queimadas_2003_2020.plot(kind='bar', x='Ano', y='Total', color='gray', figsize=(6.69,4))

# change the default font family
plt.rcParams.update({'font.family':'Times New Roman'})
print(plt.rcParams['font.family'])
plt.rcParams.update({'font.size':9})


plt.xlabel('Ano', fontsize=10)
plt.ylabel('Focos de queimadas', fontsize=10)
#plt.title('Focos de queimadas da Bolívia')
#plt.savefig('Queimadas_bolivia.png', dpi=300)

#Tick Parameters
#plt.tick_params(axis='both',bottom=True, top=True, left=True, right=True, direction='in', which='major', grid_color='blue')


media_anual = queimadas_2003_2020.Total.mean()

media_anual
queimadas_2003_2020['Anomalias'] = ((queimadas_2003_2020['Total'] - media_anual)/media_anual)*100
queimadas_2003_2020
cores = []
for numero in queimadas_2003_2020.Anomalias:
    if numero < 0:
        cores.append('blue')
    else:
        cores.append('red')
    
cores
import matplotlib.pyplot as plt

queimadas_2003_2020.plot(kind='bar', x='Ano', y='Anomalias', color=cores, figsize=(6.69,4))


plt.xlabel('Tempo (Ano)', fontsize=12)
plt.ylabel('Anomalias (%)', fontsize=12)
#plt.title('Focos de queimadas da Bolívia')
#plt.savefig('Queimadas_bolivia.png', dpi=300)
plt.show()
from scipy import signal
import matplotlib.pyplot as plt
from matplotlib import rcParams
%matplotlib inline

Anos = queimadas_2003_2020.iloc[:,0]
QueimadasAnual = queimadas_2003_2020.iloc[:,13]
AnomaliasAnual = queimadas_2003_2020.iloc[:,-1]

# reset the plot configurations to default
plt.rcdefaults()

# change the default font family
plt.rcParams['font.family'] = 'serif'
plt.rcParams['font.serif'] = ['Times New Roman'] + plt.rcParams['font.serif']
print(plt.rcParams['font.serif'])

plt.rcParams.update({'font.size':8})
plt.rcParams['figure.figsize'] = (17/2.54,15/2.54)

cm = 1/2.54  # centimeters in inches
fig, axs = plt.subplots(2, dpi=100)

#fig.suptitle('Focos de queimadas')
axs[0].bar(Anos, QueimadasAnual, color='grey', width = 0.5)
axs[0].set_ylabel('Number of active fires', fontsize=10)
axs[0].set_facecolor('white')
axs[0].tick_params(axis='both',bottom=True, left=True, direction='in', which='major')

axs[1].bar(Anos, AnomaliasAnual, color=cores, width = 0.5)
axs[1].set_ylabel('Anomalies of active fires (%)', fontsize=10)
axs[1].set_facecolor('white')
axs[1].tick_params(axis='both',bottom=True, left=True, direction='in', which='major')

plt.tight_layout()

#fig.set_size_inches(17/2.54, 16/2.54)
from google.colab import files
plt.savefig('Queimadas_Bolivia.png', dpi=300, bbox_inches='tight', papertype='a4')
files.download("Queimadas_Bolivia.png") 

# change the fontsize of axes lables
#plt.rc('axes', labelsize=10)

!pip install bs4
from shapely.geometry import Point, LineString, Polygon
import geopandas as gpd
import contextily
import matplotlib.pyplot as plt
import seaborn as sns

import os
from urllib.request import urlretrieve
import requests
import zipfile
from bs4 import BeautifulSoup
import pandas as pd
import matplotlib.pyplot as plt

Queimadas_Departamentos = pd.read_csv('https://raw.githubusercontent.com/GracielaQuevedo/Repositorio_Python2021/main/Queimadas_Dept_Bolivia.csv?token=<KEY>')
Queimadas_Departamentos
Anos = Queimadas_Departamentos.iloc[:,0]
Santa_Cruz = Queimadas_Departamentos.iloc[:,2]
Beni = Queimadas_Departamentos.iloc[:,1]
Cochabamba = Queimadas_Departamentos.iloc[:,3]
Pando = Queimadas_Departamentos.iloc[:,4]
La_Paz = Queimadas_Departamentos.iloc[:,5]
Tarija = Queimadas_Departamentos.iloc[:,6]
Chuquisaca = Queimadas_Departamentos.iloc[:,7]
Oruro = Queimadas_Departamentos.iloc[:,8]
Potosi = Queimadas_Departamentos.iloc[:,9]


fig, axs = plt.subplots(5, 2, figsize=(9,10), sharex=True)

axs[0, 0].bar(Anos, Santa_Cruz, color='grey', width = 0.5)
axs[0, 0].set_ylabel('Número de Focos', fontsize=10)
#axs[SC].set_facecolor('white')
axs[0, 1].bar(Anos, Beni, color='grey', width = 0.5)

axs[1, 0].bar(Anos, Cochabamba, color='grey', width = 0.5)

axs[1, 1].bar(Anos, Pando, color='grey', width = 0.5)

axs[2, 0].bar(Anos, La_Paz, color='grey', width = 0.5)

axs[2, 1].bar(Anos, Tarija, color='grey', width = 0.5)

axs[3, 0].bar(Anos, Chuquisaca, color='grey', width = 0.5)

axs[3, 1].bar(Anos, Oruro, color='grey', width = 0.5)

axs[4, 0].bar(Anos, Potosi, color='grey', width = 0.5)

axs[4, 1].axis('off')


import matplotlib.pyplot as plt
from matplotlib import rcParams

fig, ((ax1, ax2), (ax3, ax4), (ax5, ax6), (ax7, ax8), (ax9, ax10)) = plt.subplots(nrows=5, ncols=2, sharex=False, sharey=False, dpi=100)

# reset the plot configurations to default
plt.rcdefaults()

# change the default font family
plt.rcParams['font.family'] = 'serif'
plt.rcParams['font.serif'] = ['Times New Roman'] + plt.rcParams['font.serif']
print(plt.rcParams['font.serif'])

plt.rcParams.update({'font.size':8})
plt.rcParams['figure.figsize'] = (17/2.54,22/2.54)

ax1.bar(Anos, Santa_Cruz, color='grey')
ax1.set_xticks(Anos[::5])
ax1.set_xticklabels(Anos[::5])
ax1.set_title('Santa Cruz', fontsize=10)
ax1.set_ylabel('Number of\n active fire', fontsize=10)
ax1.tick_params(axis='both',bottom=True, left=True, direction='in', which='major')

ax2.bar(Anos, Beni, color='grey')
ax2.set_xticks(Anos[::5])
ax2.set_xticklabels(Anos[::5])
ax2.set_title('Beni', fontsize=10)
#ax2.set_ylabel('Number of\n active fire')
ax2.tick_params(axis='both',bottom=True, left=True, direction='in', which='major')

ax3.bar(Anos, Cochabamba, color='grey')
ax3.set_xticks(Anos[::5])
ax3.set_xticklabels(Anos[::5])
ax3.set_title('Cochabamba', fontsize=10)
ax3.set_ylabel('Number of\n active fire', fontsize=10)
ax3.tick_params(axis='both',bottom=True, left=True, direction='in', which='major')

ax4.bar(Anos, Pando, color='grey')
ax4.set_xticks(Anos[::5])
ax4.set_xticklabels(Anos[::5])
ax4.set_title('Pando', fontsize=10)
#ax4.set_ylabel('Number of\n active fire')
ax4.tick_params(axis='both',bottom=True, left=True, direction='in', which='major')

ax5.bar(Anos, La_Paz, color='grey')
ax5.set_xticks(Anos[::5])
ax5.set_xticklabels(Anos[::5])
ax5.set_title('La Paz', fontsize=10)
ax5.set_ylabel('Number of\n active fire', fontsize=10)
ax5.tick_params(axis='both',bottom=True, left=True, direction='in', which='major')

ax6.bar(Anos, Tarija, color='grey')
ax6.set_xticks(Anos[::5])
ax6.set_xticklabels(Anos[::5])
ax6.set_title('Tarija', fontsize=10)
#ax6.set_ylabel('Number of\n active fire')
ax6.tick_params(axis='both',bottom=True, left=True, direction='in', which='major')

ax7.bar(Anos, Chuquisaca, color='grey')
ax7.set_xticks(Anos[::5])
ax7.set_xticklabels(Anos[::5])
ax7.set_title('Chuquisaca', fontsize=10)
ax7.set_ylabel('Number of\n active fire', fontsize=10)
ax7.tick_params(axis='both',bottom=True, left=True, direction='in', which='major')

ax8.bar(Anos, Oruro, color='grey')
ax8.set_xticks(Anos[::5])
ax8.set_xticklabels(Anos[::5])
ax8.set_title('Oruro', fontsize=10)
#ax8.set_ylabel('Number of\n active fire')
ax8.tick_params(axis='both',bottom=True, left=True, direction='in', which='major')

ax9.bar(Anos, Potosi, color='grey')
ax9.set_xticks(Anos[::5])
ax9.set_xticklabels(Anos[::5])
ax9.set_title('Potosi', fontsize=10)
ax9.set_ylabel('Number of\n active fire', fontsize=10)
ax9.tick_params(axis='both',bottom=True, left=True, direction='in', which='major')

ax10.axis('off')

fig.tight_layout()


#fig.set_size_inches(17/2.54, 16/2.54)
from google.colab import files
plt.savefig('Queimadas_Departamentos.png', dpi=300, bbox_inches='tight', papertype='a4')
files.download("Queimadas_Departamentos.png")

plt.show()

import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(8,17), dpi=100, facecolor=None)

# reset the plot configurations to default
plt.rcdefaults()
# change the default font family
plt.rcParams.update({'font.family':'Times New Roman'})
print(plt.rcParams['font.family'])
plt.rcParams.update({'font.size':8})
plt.rcParams['figure.figsize'] = (17/2.54,15/2.54)

plt.subplot(5, 2, 1)
plt.bar(Anos, Santa_Cruz, color='grey', width=0.5)
plt.title('Santa Cruz')

plt.subplot(5, 2, 2)
plt.bar(Anos, Beni)
plt.title('Beni')

plt.subplot(5, 2, 3)
plt.bar(Anos, Cochabamba)
plt.title('Cochabamba')

plt.subplot(5, 2, 4)
plt.bar(Anos, Pando)
plt.title('Pando')

plt.subplot(5, 2, 5)
plt.bar(Anos, La_Paz)
plt.title('La Paz')

plt.subplot(5, 2, 6)
plt.bar(Anos, Tarija)
plt.title('Tarija')

plt.subplot(5, 2, 7)
plt.bar(Anos, Chuquisaca)
plt.title('chuquisaca')

plt.subplot(5, 2, 8)
plt.bar(Anos, Oruro)
plt.title('Oruro')

plt.subplot(5, 2, 9)
plt.bar(Anos, Potosi)
plt.title('Potosi')


plt.show()

'''
from google.colab import files
plt.savefig('Queimadas_Bolivia.png', dpi=300, bbox_inches='tight', papertype='a4')
files.download("Queimadas_Bolivia.png") 
'''
import matplotlib.pyplot as plt 
import seaborn as sns
import pandas as pd

fig = plt.figure(figsize=(8,12))

plt.subplot(521)
plt.title('Santa Cruz')
sns.barplot(data = Queimadas_Departamentos, x= 'YEAR', y = 'SANTA CRUZ')

ax_2=fig.add_subplot(522)
plt.title('Beni')
sns.barplot(data = Queimadas_Departamentos, x= 'YEAR', y = 'EL BENI')

ax_3=fig.add_subplot(523)
plt.title('Cochabamba')
sns.barplot(data = Queimadas_Departamentos, x= 'YEAR', y = 'COCHABAMBA')

ax_4=fig.add_subplot(524)
plt.title('Pando')
sns.barplot(data = Queimadas_Departamentos, x= 'YEAR', y = 'PANDO')

ax_5=fig.add_subplot(525)
plt.title('La Paz')
sns.barplot(data = Queimadas_Departamentos, x= 'YEAR', y = 'LA PAZ')


ax_6=fig.add_subplot(526)
plt.title('Tarija')
sns.barplot(data = Queimadas_Departamentos, x= 'YEAR', y = 'TARIJA')

ax_7=fig.add_subplot(527)
plt.title('Chuquisaca')
sns.barplot(data = Queimadas_Departamentos, x= 'YEAR', y = 'CHUQUISACA')

ax_8=fig.add_subplot(528)
plt.title('Oruro')
sns.barplot(data = Queimadas_Departamentos, x= 'YEAR', y = 'ORURO')

ax_9=fig.add_subplot(529)
plt.title('Potosi')
sns.barplot(data = Queimadas_Departamentos, x= 'YEAR', y = 'POTOSI')

#fig.suptitle("Figure with multiple Subplots")


plt.show()

mean_SC = Santa_Cruz.mean()
mean_BN = Beni.mean()
mean_CB = Cochabamba.mean()
mean_PD = Pando.mean()
mean_LP = La_Paz.mean()
mean_CH = Chuquisaca.mean()
mean_TJ = Tarija.mean()
mean_OR = Oruro.mean()
mean_PT = Potosi.mean()

Anomalias_Dpto = pd.DataFrame(Queimadas_Departamentos, columns = ['YEAR'])

print(Anomalias_Dpto)
Anomalias_Dpto['Santa Cruz'] = ((Queimadas_Departamentos['SANTA CRUZ'] - mean_SC)/mean_SC)*100
Anomalias_Dpto['Beni'] = ((Queimadas_Departamentos['EL BENI'] - mean_BN)/mean_BN)*100
Anomalias_Dpto['Cochabamba'] = ((Queimadas_Departamentos['COCHABAMBA'] - mean_CB)/mean_CB)*100
Anomalias_Dpto['Pando'] = ((Queimadas_Departamentos['PANDO'] - mean_PD)/mean_PD)*100
Anomalias_Dpto['La Paz'] = ((Queimadas_Departamentos['LA PAZ'] - mean_LP)/mean_LP)*100
Anomalias_Dpto['Chuquisaca'] = ((Queimadas_Departamentos['CHUQUISACA'] - mean_CH)/mean_CH)*100
Anomalias_Dpto['Tarija'] = ((Queimadas_Departamentos['TARIJA'] - mean_TJ)/mean_TJ)*100
Anomalias_Dpto['Oruro'] = ((Queimadas_Departamentos['ORURO'] - mean_OR)/mean_OR)*100
Anomalias_Dpto['Potosi'] = ((Queimadas_Departamentos['POTOSI'] - mean_PT)/mean_PT)*100
Anomalias_Dpto
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import rcParams

# reset the plot configurations to default
plt.rcdefaults()

# change the default font family
plt.rcParams['font.family'] = 'serif'
plt.rcParams['font.serif'] = ['Times New Roman'] + plt.rcParams['font.serif']
print(plt.rcParams['font.serif'])

plt.rcParams.update({'font.size':8})
plt.rcParams['figure.figsize'] = (17/2.54,10/2.54)

ax = plt.gca()
#fig, (ax1, ax2) = plt.subplots(nrows=2, ncols=, sharex=False, sharey=False, dpi=100)

ax.set_xticks(Anos[::1])
ax.tick_params(axis='both',bottom=True, left=True, direction='in', which='major')

Anomalias_Dpto.plot(ax=ax, kind='line', x='YEAR', y='Santa Cruz', marker='o')
Anomalias_Dpto.plot(ax=ax, kind='line', x='YEAR', y='Beni', color='red', marker='o')
Anomalias_Dpto.plot(ax=ax, kind='line', x='YEAR', y='Cochabamba', color='g', marker='o')
Anomalias_Dpto.plot(ax=ax, kind='line', x='YEAR', y='Pando', color='y', marker='o')
Anomalias_Dpto.plot(ax=ax, kind='line', x='YEAR', y='La Paz', color='c', marker='o')

plt.ylabel('Anomalies of active fires', fontsize=10)
plt.tight_layout()
plt.show()
import pandas as pd

Queimadas_mensal = pd.read_csv('https://raw.githubusercontent.com/GracielaQuevedo/Repositorio_Python2021/main/Queimadas_Mensal.csv?token=<KEY>')


Queimadas_mensal.head()
Valor_Sasonal = [58.5, 37.0, 2.5, 1.9]
Labels =['Spring', 'Winter', 'Autumn', 'Summer']

type(Valor_Sasonal)
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import rcParams

# reset the plot configurations to default
plt.rcdefaults()

# change the default font family
plt.rcParams['font.family'] = 'serif'
plt.rcParams['font.serif'] = ['Times New Roman'] + plt.rcParams['font.serif']
print(plt.rcParams['font.serif'])

plt.rcParams.update({'font.size':8})
plt.rcParams['figure.figsize'] = (17/2.54,8/2.54)

plt.subplot(1, 2, 1)
ax = Queimadas_mensal.boxplot(column=['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], color='black', grid=False, widths=0.5)
plt.ylabel('Number of active fires', fontsize=10)
plt.xticks(rotation = 90)
ax.tick_params(axis='both',bottom=True, left=True, direction='in', which='major')
plt.text(.8, 1000, 'D')
plt.text(1.8, 1300, 'D')
plt.text(2.8, 1400, 'D')
plt.text(3.8, 1800, 'D')
plt.text(4.8, 2500, 'D')
plt.text(5.8, 3900, 'D')
plt.text(6.5, 7000, 'C;D')
plt.text(7.5, 17500, 'A;B')
plt.text(8.8, 31100, 'A')
plt.text(9.5, 12900, 'B;C')
plt.text(10.8, 7000, 'D')
plt.text(11.8, 2400, 'D')
plt.tight_layout()

plt.subplot(1, 2, 2)
ax = plt.bar(Labels, Valor_Sasonal, color='gray', width=0.5)
plt.ylabel('Frequency (%)', fontsize=10)
plt.tick_params(axis='both',bottom=True, left=True, direction='in', which='major')
plt.text(-0.26, 59, '58.5%')
plt.text(0.75, 37.5, '37.0%')
plt.text(1.77, 3, '2.5%')
plt.text(2.77, 2.4, '1.9%')
plt.tight_layout()

#fig.set_size_inches(17/2.54, 16/2.54)
from google.colab import files
plt.savefig('Fig5.png', dpi=300, bbox_inches='tight', papertype='a4')
files.download("Fig5.png")


plt.show()


import pandas as pd 

Densidade = pd.read_csv('https://raw.githubusercontent.com/GracielaQuevedo/Repositorio_Python2021/main/Densidade_Dep.csv?token=<KEY>')

Densidade.head()
Densidade.dtypes
Departamentos = 
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import rcParams
import seaborn as sns

# reset the plot configurations to default
plt.rcdefaults()

# change the default font family
plt.rcParams['font.family'] = 'serif'
plt.rcParams['font.serif'] = ['Times New Roman'] + plt.rcParams['font.serif']
print(plt.rcParams['font.serif'])

plt.rcParams.update({'font.size':8})
plt.rcParams['figure.figsize'] = (8.5/2.54,14/2.54)

plt.subplot(2, 1, 1)
sns.barplot(data=Densidade, x='Departamentos', y='Total', color='gray')
plt.ylabel('Total distribution\n of active fires', fontsize=10)
plt.xlabel('')

plt.subplot(2, 1, 2)
sns.barplot(data=Densidade, x='Departamentos', y='Densidade', color='gray')
plt.ylabel('Density of active\n fires/area (km$^2$)', fontsize=10)
plt.xlabel('Bolivia Departments', fontsize=10)

plt.tight_layout()

#fig.set_size_inches(17/2.54, 16/2.54)
from google.colab import files
plt.savefig('Fig6.png', dpi=300, bbox_inches='tight', papertype='a4')
files.download("Fig6.png")

plt.show()<jupyter_output>['Times New Roman', 'DejaVu Serif', 'Bitstream Vera Serif', 'Computer Modern Roman', 'New Century Schoolbook', 'Century Schoolbook L', 'Utopia', 'ITC Bookman', 'Bookman', 'Nimbus Roman No9 L', 'Times New Roman', 'Times', 'Palatino', 'Charter', 'serif']
{'fraction_non_alphanumeric': 0.18413258554414266, 'fraction_numerical': 0.0463797340727204, 'mean_word_length': 7.043588443993918, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 8, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '297480', 'license': 'MIT', 'n_tokens_mistral': 7168, 'n_tokens_neox': 6596, 'n_words': 1156, 'path': 'Queimadas_bolivia.ipynb', 'repo_name': 'GracielaQuevedo/Ocean_CienciaDados_24_02_2021', 'size': '15968'}