{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 생육일수(Growing Degree Days)\n", "\n", "이 노트북은 CSV 파일에 저장된 온도 데이터를 불러와 분석합니다. 온도를 그래프로 표시하고, 각 날짜의 최고 및 최저 값을 보여주며, 생육일수(GDD)를 계산합니다.\n", "\n", "이 노트북을 사용하려면:\n", "\n", "* `temperature.csv` 파일을 이 노트북과 동일한 폴더에 복사하세요.\n", "* 위의 **▶︎ 실행** 버튼을 사용하여 모든 셀을 실행하세요. 선택한 셀이 실행된 후 다음 셀로 이동합니다.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "셀 아래에서 `base_temperature`를 식물의 기준 온도로 설정하세요.\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "base_temperature = 10" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "CSV 파일은 이제 pandas를 사용하여 로드해야 합니다\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "\n", "# Read the temperature CSV file\n", "df = pd.read_csv('temperature.csv')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.figure(figsize=(20, 10))\n", "plt.plot(df['date'], df['temperature'])\n", "plt.xticks(rotation='vertical');" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "데이터를 읽은 후 `date` 열로 그룹화할 수 있으며, 각 날짜에 대한 최저 및 최고 기온을 추출할 수 있습니다.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Convert datetimes to pure dates so we can group by the date\n", "df['date'] = pd.to_datetime(df['date']).dt.date\n", "\n", "# Group the data by date so it can be analyzed by date\n", "data_by_date = df.groupby('date')\n", "\n", "# Get the minimum and maximum temperatures for each date\n", "min_by_date = data_by_date.min()\n", "max_by_date = data_by_date.max()\n", "\n", "# Join the min and max temperatures into one dataframe and flatten it\n", "min_max_by_date = min_by_date.join(max_by_date, on='date', lsuffix='_min', rsuffix='_max')\n", "min_max_by_date = min_max_by_date.reset_index()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "GDD는 표준 GDD 방정식을 사용하여 계산할 수 있습니다\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def calculate_gdd(row):\n", " return ((row['temperature_max'] + row['temperature_min']) / 2) - base_temperature\n", "\n", "# Calculate the GDD for each row\n", "min_max_by_date['gdd'] = min_max_by_date.apply (lambda row: calculate_gdd(row), axis=1)\n", "\n", "# Print the results\n", "print(min_max_by_date[['date', 'gdd']].to_string(index=False))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n---\n\n**면책 조항**: \n이 문서는 AI 번역 서비스 [Co-op Translator](https://github.com/Azure/co-op-translator)를 사용하여 번역되었습니다. 정확성을 위해 최선을 다하고 있으나, 자동 번역에는 오류나 부정확성이 포함될 수 있습니다. 원본 문서의 원어 버전을 신뢰할 수 있는 권위 있는 자료로 간주해야 합니다. 중요한 정보의 경우, 전문적인 인간 번역을 권장합니다. 이 번역 사용으로 인해 발생하는 오해나 잘못된 해석에 대해 책임을 지지 않습니다.\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.1" }, "metadata": { "interpreter": { "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49" } }, "coopTranslator": { "original_hash": "8fcf954f6042f0bf3601a2c836a09574", "translation_date": "2025-08-26T15:58:55+00:00", "source_file": "2-farm/lessons/1-predict-plant-growth/code-notebook/gdd.ipynb", "language_code": "ko" } }, "nbformat": 4, "nbformat_minor": 2 }