Commit CO2

parent dee46e31
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 40, "execution_count": 1,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 16, "execution_count": 2,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 45, "execution_count": 3,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 46, "execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 47, "execution_count": 5,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -147,7 +147,7 @@ ...@@ -147,7 +147,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 48, "execution_count": 6,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -171,9 +171,21 @@ ...@@ -171,9 +171,21 @@
"The first prot illustrates the raw atmospheric CO2 concentrations over time, showing both seasonal periodic oscillations and a long-term upward trend." "The first prot illustrates the raw atmospheric CO2 concentrations over time, showing both seasonal periodic oscillations and a long-term upward trend."
] ]
}, },
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The graph below demonstrates the measured atmospheric CO2 concentration at Mauna Loa Observatory from 1958 to the present. As a result of quantitative analysis, it has been revealed two key features:\n",
"\n",
"- Upward long-term trend in CO2 level, indicating a continuous increase over the decades.\n",
"- A periodic oscillations, reflecting seasonal variation in CO2 concentration within each year.\n",
"\n",
"These seasonal cycles are caused by natural processes and human acttivities, which dominate global CO2 exchange."
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 49, "execution_count": 7,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -201,22 +213,74 @@ ...@@ -201,22 +213,74 @@
"plt.show()" "plt.show()"
] ]
}, },
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Seasonal oscillation of CO2"
]
},
{
"cell_type": "markdown",
"metadata": {
"hideCode": true,
"hidePrompt": false
},
"source": [
"We performed a seasonal decomposition of the CO2 data in order to separate the peoridic component from the trend and residuals. An additive model was used with frequency of 12 months."
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 19, "execution_count": 8,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"Decomposition=seasonal_decompose(df['CO2'], model='additive', freq=12)\n", "Decomposition=seasonal_decompose(df['CO2'], model='additive', freq=12)\n",
"Seasonal=Decomposition.seasonal.dropna()\n", "#drop missing values to ensure exact quantitative analysis\n",
"Seasonal=Decomposition.seasonal.dropna()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now, we convert the seasonal component to a DataFrame and extract the month from the datetime index for monthly grouping.Furthermore, the average seasonal deviation was computed for each month by grouping the data by month."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"Seasonal_Monthly=Seasonal.to_frame(name='Seasonality')\n", "Seasonal_Monthly=Seasonal.to_frame(name='Seasonality')\n",
"Seasonal_Monthly['Month']=Seasonal_Monthly.index.month\n", "Seasonal_Monthly['Month']=Seasonal_Monthly.index.month\n",
"Monthly_Avg=Seasonal_Monthly.groupby('Month')['Seasonality'].mean()\n" "Monthly_Avg=Seasonal_Monthly.groupby('Month')['Seasonality'].mean()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Plot the average seasonal oscillation og CO2 concentration"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The plot below presents the mean deviation for each month across all years, clearly highlighting the periodic nature of CO2 level.\n",
"\n",
"Moreover, the average seasonal variation in CO2 concentration is observed accros differnt months of the year.\n",
"Notably, CO2 levels peak in May, when plant growth has not yeat removed considerable amount of CO2 from the atmosphere.\n",
"Conversely, the lowes concentration occur in September and October, due to enhanced photosyntetic actrivity during summer, when vegetation actively absorbs CO2.\n",
"After October, CO2 concentrations behin to rise again, mainly because deciduous plants shed their leaves, and photosynthesis slows down, while decomposition process continue, realising CO2 back into the atmosphere. This seasonal CO2 cycle leads to the regular annual fluctuation in its concentration."
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 20, "execution_count": 10,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -247,14 +311,33 @@ ...@@ -247,14 +311,33 @@
"plt.show()" "plt.show()"
] ]
}, },
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Linear Trend Evaluation and Extrapolation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We construct a linear regression model to estimate the long-term trend in CO2 concentration:\n",
"\n",
"- the model was computed manually using the least squares method.\n",
"- The tren was extrapolated to predict CO2 level up to the year 2025."
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 34, "execution_count": 11,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"df_clean = df.dropna(subset = ['CO2', 'DecimalDate']).copy()\n",
"df_clean['CO2']=pd.to_numeric(df_clean['CO2'], errors='coerce')\n", "df_clean['CO2']=pd.to_numeric(df_clean['CO2'], errors='coerce')\n",
"df_clean['DecimalDate']=pd.to_numeric(df_clean['DecimalDate'], errors='coerce')\n", "df_clean['DecimalDate']=pd.to_numeric(df_clean['DecimalDate'], errors='coerce')\n",
"\n",
"df_clean=df_clean.dropna(subset = ['CO2', 'DecimalDate'])\n", "df_clean=df_clean.dropna(subset = ['CO2', 'DecimalDate'])\n",
"x = df_clean['DecimalDate'].values\n", "x = df_clean['DecimalDate'].values\n",
"y = df_clean['CO2'].values\n", "y = df_clean['CO2'].values\n",
...@@ -274,9 +357,30 @@ ...@@ -274,9 +357,30 @@
"y_future_pred = a_tr*x_future + b_tr" "y_future_pred = a_tr*x_future + b_tr"
] ]
}, },
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Plot of the Linear Trend and Extrapolated CO2 Level"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This plot combined three elements:\n",
"\n",
"- Trend line (red dashed) is a linear regression model showing the long-term increase in \n",
" atmospheric CO2.\n",
"- Observed variotion in CO2 concentrations (black lines) is actual monthly measurement.\n",
"- Extrapolated trend (blue dotted) is presicted CO2 values up to the year 2025 based in the model.\n",
"\n",
"In this plot, the observed short-term variability is separated from the long-term systematic rise in CO2 concentrations."
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 38, "execution_count": 12,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -305,8 +409,7 @@ ...@@ -305,8 +409,7 @@
"plt.legend()\n", "plt.legend()\n",
"plt.grid(True)\n", "plt.grid(True)\n",
"plt.tight_layout()\n", "plt.tight_layout()\n",
"plt.show()\n", "plt.show()"
"\n"
] ]
}, },
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment