Skip to content

Commit

Permalink
chore(examples): Automatic commit of example files in Markdown and Ju…
Browse files Browse the repository at this point in the history
…pyter Notebook format.
  • Loading branch information
[email protected] authored and [email protected] committed Dec 23, 2024
1 parent b083665 commit e831ebf
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "import logging\nlogging.basicConfig(level=\"DEBUG\")\n"
"source": "import logging\n\nlogging.basicConfig(level=\"DEBUG\")\n"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Choose the project class according to the desired weather data origin.\nCheck the project classes file or the API documentation to see which classes are available.\n"
"source": "Choose the project class according to the desired weather data origin.\nCheck the project_class.py file or the API documentation to see which classes are available.\n[project classes](https://rwth-ebc.github.io/AixWeather//4-joss_paper//docs/code/aixweather.html#module-aixweather.project_class)\n"
},
{
"cell_type": "code",
Expand All @@ -44,7 +44,7 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "import datetime as dt\nDWD_pull_project = ProjectClassDWDHistorical(\n start=dt.datetime(2022, 1, 1),\n end=dt.datetime(2023, 1, 1),\n station=15000,\n # specify whether nan-values should be filled when exporting\n fillna=True,\n # define results path if desired\n abs_result_folder_path=None,\n)\n"
"source": "import datetime as dt\n\nproject = ProjectClassDWDHistorical(\n start=dt.datetime(2022, 1, 1),\n end=dt.datetime(2023, 1, 1),\n station=15000,\n # specify whether nan-values should be filled when exporting\n fillna=True,\n # define results path if desired\n abs_result_folder_path=None,\n)\n"
},
{
"cell_type": "markdown",
Expand All @@ -56,7 +56,7 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "DWD_pull_project.import_data()\nprint(\n f\"\\nHow the imported data looks like:\\n{DWD_pull_project.imported_data.head()}\\n\"\n)\n"
"source": "project.import_data()\nprint(f\"\\nHow the imported data looks like:\\n{project.imported_data.head()}\\n\")\n"
},
{
"cell_type": "markdown",
Expand All @@ -68,7 +68,7 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "DWD_pull_project.data_2_core_data()\nprint(f\"\\nHow the core data looks like:\\n{DWD_pull_project.core_data.head()}\\n\")\n"
"source": "project.data_2_core_data()\nprint(f\"\\nHow the core data looks like:\\n{project.core_data.head()}\\n\")\n"
},
{
"cell_type": "markdown",
Expand All @@ -92,7 +92,7 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "plot = plot_heatmap_missing_values(DWD_pull_project.core_data)\nplot.show()\n"
"source": "plot = plot_heatmap_missing_values(project.core_data)\nplot.show()\n"
},
{
"cell_type": "markdown",
Expand All @@ -104,7 +104,60 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "DWD_pull_project.core_2_csv()\nDWD_pull_project.core_2_json()\nDWD_pull_project.core_2_pickle()\nDWD_pull_project.core_2_mos()\nDWD_pull_project.core_2_epw()\n"
"source": "project.core_2_csv()\nproject.core_2_json()\nproject.core_2_pickle()\nproject.core_2_mos()\nproject.core_2_epw()\n"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "By the way, if you want to run this with some other weather data source, here are some copy-paste snippets to get you started:\n"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "For DWD Forecast data\n"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "from aixweather.project_class import ProjectClassDWDForecast\n\nproject = ProjectClassDWDForecast(\n station=\"06710\", # Example station: Lausanne\n abs_result_folder_path=None, # Optional: specify result path\n)\n"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "For EPW and TRY we need to import the .epw or .dat file\nThese imports are just to create the path to the file stored in the tests folder\n"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "import os\nfrom aixweather import definitions\n"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "For EPW files\n"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "from aixweather.project_class import ProjectClassEPW\n\nproject = ProjectClassEPW(\n path=os.path.join(\n definitions.ROOT_DIR,\n \"tests/test_files/regular_tests/EPW/test_EPW_Essen_Ladybug/input/DEU_NW_Essen_104100_TRY2035_05_Wint_BBSR.epw\",\n ), # Example: EPW weather file for Essen\n abs_result_folder_path=None,\n)\n"
},
{
"cell_type": "markdown",
"metadata": {},
"source": "For TRY (Test Reference Year) data\n"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": "from aixweather.project_class import ProjectClassTRY\n\nproject = ProjectClassTRY(\n path=os.path.join(\n definitions.ROOT_DIR,\n \"tests/test_files/regular_tests/TRY/test_TRY2015/input/TRY2015_507931060546_Jahr.dat\"\n ),\n)\n"
}
],
"metadata": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ Enable logging, this is just to get more feedback through the terminal

```python
import logging

logging.basicConfig(level="DEBUG")
```

Choose the project class according to the desired weather data origin.
Check the project classes file or the API documentation to see which classes are available.
Check the project_class.py file or the API documentation to see which classes are available.
[project classes](https://rwth-ebc.github.io/AixWeather//4-joss_paper//docs/code/aixweather.html#module-aixweather.project_class)

```python
from aixweather.project_class import ProjectClassDWDHistorical
Expand All @@ -26,7 +28,8 @@ For this, we use the datetime module to specify dates.

```python
import datetime as dt
DWD_pull_project = ProjectClassDWDHistorical(

project = ProjectClassDWDHistorical(
start=dt.datetime(2022, 1, 1),
end=dt.datetime(2023, 1, 1),
station=15000,
Expand All @@ -40,17 +43,15 @@ DWD_pull_project = ProjectClassDWDHistorical(
Step 1: Import historical weather from the DWD open access database

```python
DWD_pull_project.import_data()
print(
f"\nHow the imported data looks like:\n{DWD_pull_project.imported_data.head()}\n"
)
project.import_data()
print(f"\nHow the imported data looks like:\n{project.imported_data.head()}\n")
```

Step 2: Convert this imported data to the core format

```python
DWD_pull_project.data_2_core_data()
print(f"\nHow the core data looks like:\n{DWD_pull_project.core_data.head()}\n")
project.data_2_core_data()
print(f"\nHow the core data looks like:\n{project.core_data.head()}\n")
```

You may optionally also use data quality check utils, like:
Expand All @@ -62,16 +63,64 @@ from aixweather.data_quality_checks import plot_heatmap_missing_values
Plot data quality

```python
plot = plot_heatmap_missing_values(DWD_pull_project.core_data)
plot = plot_heatmap_missing_values(project.core_data)
plot.show()
```

Step 3: Convert this core data to an output data format of your choice

```python
DWD_pull_project.core_2_csv()
DWD_pull_project.core_2_json()
DWD_pull_project.core_2_pickle()
DWD_pull_project.core_2_mos()
DWD_pull_project.core_2_epw()
project.core_2_csv()
project.core_2_json()
project.core_2_pickle()
project.core_2_mos()
project.core_2_epw()
```

By the way, if you want to run this with some other weather data source, here are some copy-paste snippets to get you started:

For DWD Forecast data

```python
from aixweather.project_class import ProjectClassDWDForecast

project = ProjectClassDWDForecast(
station="06710", # Example station: Lausanne
abs_result_folder_path=None, # Optional: specify result path
)
```

For EPW and TRY we need to import the .epw or .dat file
These imports are just to create the path to the file stored in the tests folder

```python
import os
from aixweather import definitions
```

For EPW files

```python
from aixweather.project_class import ProjectClassEPW

project = ProjectClassEPW(
path=os.path.join(
definitions.ROOT_DIR,
"tests/test_files/regular_tests/EPW/test_EPW_Essen_Ladybug/input/DEU_NW_Essen_104100_TRY2035_05_Wint_BBSR.epw",
), # Example: EPW weather file for Essen
abs_result_folder_path=None,
)
```

For TRY (Test Reference Year) data

```python
from aixweather.project_class import ProjectClassTRY

project = ProjectClassTRY(
path=os.path.join(
definitions.ROOT_DIR,
"tests/test_files/regular_tests/TRY/test_TRY2015/input/TRY2015_507931060546_Jahr.dat"
),
)
```

0 comments on commit e831ebf

Please sign in to comment.