From 599339c7e05734a11d41d1072e1d59468e94c9dc Mon Sep 17 00:00:00 2001 From: toravest Date: Sun, 13 Apr 2025 15:05:02 +0200 Subject: [PATCH] add input-function, instead of input field --- notebooks/notebook_compare_one_day_data.ipynb | 54 ++++++++++++++----- .../notebook_compare_one_week_data.ipynb | 16 +++--- .../notebook_compare_statistic_data.ipynb | 16 +++--- notebooks/notebook_current_data.ipynb | 8 ++- notebooks/notebook_one_day_data.ipynb | 13 ++--- notebooks/notebook_one_week_data.ipynb | 8 ++- notebooks/notebook_statistic_data.ipynb | 8 ++- src/my_package/util.py | 5 ++ 8 files changed, 72 insertions(+), 56 deletions(-) diff --git a/notebooks/notebook_compare_one_day_data.ipynb b/notebooks/notebook_compare_one_day_data.ipynb index e0e5fd4..863c459 100644 --- a/notebooks/notebook_compare_one_day_data.ipynb +++ b/notebooks/notebook_compare_one_day_data.ipynb @@ -31,7 +31,39 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Selected date: 12-03\n", + "Unix Timestamp: 1764716400 -> 12-03 00:00:00\n", + "Unix Timestamp: 1764720000 -> 12-03 01:00:00\n", + "Unix Timestamp: 1764723600 -> 12-03 02:00:00\n", + "Unix Timestamp: 1764727200 -> 12-03 03:00:00\n", + "Unix Timestamp: 1764730800 -> 12-03 04:00:00\n", + "Unix Timestamp: 1764734400 -> 12-03 05:00:00\n", + "Unix Timestamp: 1764738000 -> 12-03 06:00:00\n", + "Unix Timestamp: 1764741600 -> 12-03 07:00:00\n", + "Unix Timestamp: 1764745200 -> 12-03 08:00:00\n", + "Unix Timestamp: 1764748800 -> 12-03 09:00:00\n", + "Unix Timestamp: 1764752400 -> 12-03 10:00:00\n", + "Unix Timestamp: 1764756000 -> 12-03 11:00:00\n", + "Unix Timestamp: 1764759600 -> 12-03 12:00:00\n", + "Unix Timestamp: 1764763200 -> 12-03 13:00:00\n", + "Unix Timestamp: 1764766800 -> 12-03 14:00:00\n", + "Unix Timestamp: 1764770400 -> 12-03 15:00:00\n", + "Unix Timestamp: 1764774000 -> 12-03 16:00:00\n", + "Unix Timestamp: 1764777600 -> 12-03 17:00:00\n", + "Unix Timestamp: 1764781200 -> 12-03 18:00:00\n", + "Unix Timestamp: 1764784800 -> 12-03 19:00:00\n", + "Unix Timestamp: 1764788400 -> 12-03 20:00:00\n", + "Unix Timestamp: 1764792000 -> 12-03 21:00:00\n", + "Unix Timestamp: 1764795600 -> 12-03 22:00:00\n", + "Unix Timestamp: 1764799200 -> 12-03 23:00:00\n" + ] + } + ], "source": [ "import datetime\n", "import time\n", @@ -95,13 +127,11 @@ "# Now we can import the fucntion from the module\n", "from my_package.fetch_data import fetch_data\n", "\n", - "# Import function to replace nordic (æøå)\n", - "from my_package.util import replace_nordic\n", - "\n", - "# User choose a city they want the weather data from\n", - "city_1 = input(\"Enter first city name: \")\n", + "# Import function to for input_place, replace æøå\n", + "from my_package.util import input_place\n", "\n", - "city_1 = replace_nordic(city_1)\n", + "# User input the city, for the weather\n", + "city_1 = input_place()\n", "\n", "# Start_date is the first timestamp, end_date is the last\n", "start_date, end_date = timestamps[0], timestamps[-1]\n", @@ -133,13 +163,11 @@ "# Now we can import the fucntion from the module\n", "from my_package.fetch_data import fetch_data\n", "\n", - "# Import function to replace nordic (æøå)\n", - "from my_package.util import replace_nordic\n", - "\n", - "# User choose a city they want the weather data from\n", - "city_2 = input(\"Enter first city name: \")\n", + "# Import function to for input_place, replace æøå\n", + "from my_package.util import input_place\n", "\n", - "city_2 = replace_nordic(city_2)\n", + "# User input the city, for the weather\n", + "city_2 = input_place()\n", "\n", "# Start_date is the first timestamp, end_date is the last\n", "start_date, end_date = timestamps[0], timestamps[-1]\n", diff --git a/notebooks/notebook_compare_one_week_data.ipynb b/notebooks/notebook_compare_one_week_data.ipynb index 186f61a..5afaee5 100644 --- a/notebooks/notebook_compare_one_week_data.ipynb +++ b/notebooks/notebook_compare_one_week_data.ipynb @@ -88,13 +88,11 @@ "# Now we can import the fucntion from the module\n", "from my_package.fetch_data import fetch_data\n", "\n", - "# Import function to replace nordic (æøå)\n", - "from my_package.util import replace_nordic\n", + "# Import function to for input_place, replace æøå\n", + "from my_package.util import input_place\n", "\n", "# User input the city, for the weather\n", - "city_1 = input(\"Enter a city in Norway: \")\n", - "\n", - "city_1 = replace_nordic(city_1)\n", + "city_1 = input_place()\n", "\n", "# Stores the values in the variables\n", "data_city_1, folder = fetch_data(unix_start_date, unix_end_date, city_1)" @@ -125,13 +123,11 @@ "# Now we can import the fucntion from the module\n", "from my_package.fetch_data import fetch_data\n", "\n", - "# Import function to replace nordic (æøå)\n", - "from my_package.util import replace_nordic\n", + "# Import function to for input_place, replace æøå\n", + "from my_package.util import input_place\n", "\n", "# User input the city, for the weather\n", - "city_2 = input(\"Enter a city in Norway: \")\n", - "\n", - "city_2 = replace_nordic(city_2)\n", + "city_2 = input_place()\n", "\n", "# Stores the values in the variables\n", "data_city_2, folder = fetch_data(unix_start_date, unix_end_date, city_2)" diff --git a/notebooks/notebook_compare_statistic_data.ipynb b/notebooks/notebook_compare_statistic_data.ipynb index 5985dfc..d91d393 100644 --- a/notebooks/notebook_compare_statistic_data.ipynb +++ b/notebooks/notebook_compare_statistic_data.ipynb @@ -40,13 +40,11 @@ "# Now we can import the fucntion from the module\n", "from my_package.year_data import fetch_data\n", "\n", - "# Import function to replace nordic (æøå)\n", - "from my_package.util import replace_nordic\n", + "# Import function to for input_place, replace æøå\n", + "from my_package.util import input_place\n", "\n", "# User input the city, for the weather\n", - "city_1 = input(\"Enter a city in Norway: \")\n", - "\n", - "city_1 = replace_nordic(city_1)\n", + "city_1 = input_place()\n", "\n", "data_city_1, folder = fetch_data(city_1)" ] @@ -75,13 +73,11 @@ "# Now we can import the fucntion from the module\n", "from my_package.year_data import fetch_data\n", "\n", - "# Import function to replace nordic (æøå)\n", - "from my_package.util import replace_nordic\n", + "# Import function to for input_place, replace æøå\n", + "from my_package.util import input_place\n", "\n", "# User input the city, for the weather\n", - "city_2 = input(\"Enter a city in Norway: \")\n", - "\n", - "city_2 = replace_nordic(city_2)\n", + "city_2 = input_place()\n", "\n", "data_city_2, folder = fetch_data(city_2)" ] diff --git a/notebooks/notebook_current_data.ipynb b/notebooks/notebook_current_data.ipynb index c99efdd..b020d0f 100644 --- a/notebooks/notebook_current_data.ipynb +++ b/notebooks/notebook_current_data.ipynb @@ -32,13 +32,11 @@ "# Now we can import the fucntion from the module\n", "from my_package.fetch_current_data import fetch_current_data\n", "\n", - "# Import function to replace nordic (æøå)\n", - "from my_package.util import replace_nordic\n", + "# Import function to for input_place, replace æøå\n", + "from my_package.util import input_place\n", "\n", "# User input the city, for the weather\n", - "city_name = input(\"Enter a city in Norway: \")\n", - "\n", - "city_name = replace_nordic(city_name)\n", + "city_name = input_place()\n", "\n", "# Stores the return of the function\n", "data, folder = fetch_current_data(city_name)" diff --git a/notebooks/notebook_one_day_data.ipynb b/notebooks/notebook_one_day_data.ipynb index 5f861d0..d8b62b1 100644 --- a/notebooks/notebook_one_day_data.ipynb +++ b/notebooks/notebook_one_day_data.ipynb @@ -98,18 +98,15 @@ "# Now we can import the fucntion from the module\n", "from my_package.fetch_data import fetch_data\n", "\n", - "# Import function to replace nordic (æøå)\n", - "from my_package.util import replace_nordic\n", + "# Import function to for input_place, replace æøå\n", + "from my_package.util import input_place\n", "\n", - "# User choose a city they want the weather data from\n", - "city_name = input(\"Enter city name: \")\n", - "\n", - "city_name = replace_nordic(city_name)\n", + "# User input the city, for the weather\n", + "city_name = input_place()\n", "\n", "# Start_date is the first timestamp, end_date is the last\n", "start_date, end_date = timestamps[0], timestamps[-1]\n", "\n", - "city_name = replace_nordic(city_name)\n", "\n", "# Stores the values in the variables\n", "weather_data, folder = fetch_data(start_date, end_date, city_name)" @@ -685,7 +682,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.6" + "version": "3.12.5" } }, "nbformat": 4, diff --git a/notebooks/notebook_one_week_data.ipynb b/notebooks/notebook_one_week_data.ipynb index a714766..d2c49c5 100644 --- a/notebooks/notebook_one_week_data.ipynb +++ b/notebooks/notebook_one_week_data.ipynb @@ -86,13 +86,11 @@ "# Now we can import the fucntion from the module\n", "from my_package.fetch_data import fetch_data\n", "\n", - "# Import function to replace nordic (æøå)\n", - "from my_package.util import replace_nordic\n", + "# Import function to for input_place, replace æøå\n", + "from my_package.util import input_place\n", "\n", "# User input the city, for the weather\n", - "city_name = input(\"Enter a city in Norway: \")\n", - "\n", - "city_name = replace_nordic(city_name)\n", + "city_name = input_place()\n", "\n", "# Stores the values in the variables\n", "data, folder = fetch_data(unix_start_date, unix_end_date, city_name)\n" diff --git a/notebooks/notebook_statistic_data.ipynb b/notebooks/notebook_statistic_data.ipynb index cdd8ca1..7d943d9 100644 --- a/notebooks/notebook_statistic_data.ipynb +++ b/notebooks/notebook_statistic_data.ipynb @@ -34,13 +34,11 @@ "# Now we can import the fucntion from the module\n", "from my_package.year_data import fetch_data\n", "\n", - "# Import function to replace nordic (æøå)\n", - "from my_package.util import replace_nordic\n", + "# Import function to for input_place, replace æøå\n", + "from my_package.util import input_place\n", "\n", "# User input the city, for the weather\n", - "city_name = input(\"Enter a city in Norway: \")\n", - "\n", - "city_name = replace_nordic(city_name)\n", + "city_name = input_place()\n", "\n", "data, folder = fetch_data(city_name)" ] diff --git a/src/my_package/util.py b/src/my_package/util.py index 0c01171..c667960 100644 --- a/src/my_package/util.py +++ b/src/my_package/util.py @@ -10,6 +10,11 @@ def replace_nordic(city_name): city_name = city_name.replace('å', 'aa') return city_name +def input_place(): + city_name = input("Enter city name: ") + city_name = replace_nordic(city_name) + return city_name + # Function to convert from kelvin to celsius temp def kelvin_to_celsius(temp_in_kelvin): temp_in_celsius = temp_in_kelvin - 273.15