Skip to content

Commit

Permalink
add input-function, instead of input field
Browse files Browse the repository at this point in the history
  • Loading branch information
torave committed Apr 13, 2025
1 parent f47456f commit 599339c
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 56 deletions.
54 changes: 41 additions & 13 deletions notebooks/notebook_compare_one_day_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
16 changes: 6 additions & 10 deletions notebooks/notebook_compare_one_week_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down Expand Up @@ -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)"
Expand Down
16 changes: 6 additions & 10 deletions notebooks/notebook_compare_statistic_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
Expand Down Expand Up @@ -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)"
]
Expand Down
8 changes: 3 additions & 5 deletions notebooks/notebook_current_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
13 changes: 5 additions & 8 deletions notebooks/notebook_one_day_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down Expand Up @@ -685,7 +682,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.6"
"version": "3.12.5"
}
},
"nbformat": 4,
Expand Down
8 changes: 3 additions & 5 deletions notebooks/notebook_one_week_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 3 additions & 5 deletions notebooks/notebook_statistic_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
Expand Down
5 changes: 5 additions & 0 deletions src/my_package/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 599339c

Please sign in to comment.