Skip to content

Commit

Permalink
update introduction, remove mamba
Browse files Browse the repository at this point in the history
  • Loading branch information
fneum committed Apr 15, 2024
1 parent c7fd066 commit 2ad3a9f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 57 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
data-science-for-esm/data
*.geojson
*.nc
*.tiff
*.tif
*.html
*.png
data-science-for-esm/tmp/
data-science-for-esm/_build/
data-science-for-esm/tmp.csv
*cleared.ipynb
2 changes: 1 addition & 1 deletion data-science-for-esm/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Book settings
title: Data Science for Energy System Modelling # The title of the book. Will be placed in the left navbar.
author: Fabian Neumann # The author of the book
copyright: "2022-2023" # Copyright year to be placed in the footer
copyright: "2022-2024" # Copyright year to be placed in the footer
logo: logo.png # A path to the book logo

# Force re-execution of notebooks on each build.
Expand Down
56 changes: 15 additions & 41 deletions data-science-for-esm/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Welcome to the website accompanying the course [Data Science for Energy System M

On this website you will find practical introductions to many Python packages that are useful for dealing with energy data and building energy system models. Course materials other than practical introductions to Python packages for students at TU Berlin are provided on [ISIS](https://isis.tu-berlin.de/course/view.php?id=35495).

The course covers tutorials and examples for getting started with Python, `numpy`, `matplotlib`, `pandas`, `geopandas`, `cartopy`, `rasterio`, `pysheds`, `atlite`, `networkx`, `pyomo`, `pypsa`, `plotly`, `hvplot`, and `streamlit`. Topics covered include:
The course covers tutorials and examples for getting started with Python, `numpy`, `matplotlib`, `pandas`, `geopandas`, `cartopy`, `rasterio`, `pysheds`, `atlite`, `networkx`, `linopy`, `pypsa`, `plotly`, `hvplot`, and `streamlit`. Topics covered include:

- time series analysis (e.g. wind and solar production)
- tabular data (e.g. LNG terminals, power plants, industrial sites)
Expand All @@ -18,6 +18,7 @@ The course covers tutorials and examples for getting started with Python, `numpy
- capacity expansion planning
- sector-coupling
- interactive visualisation and dashboarding

## Python

:::{note}
Expand All @@ -44,24 +45,16 @@ Follow the link above to obtain a one-click installers for your operating system

For **Linux and MacOS users**, you can access the command line by opening the _terminal_ program.

For **Windows users**, you should first install Anaconda (described above) or miniconda/micromamba (described below), which gives you access to the "Anaconda Prompt" desktop application. (Instructions for this are given on the [Anaconda Website](https://docs.anaconda.com/anaconda/user-guide/getting-started/#write-a-python-program-using-anaconda-prompt-or-terminal).)
For **Windows users**, you should first install Anaconda (described above) or miniconda (described below), which gives you access to the "Anaconda Prompt" desktop application. (Instructions for this are given on the [Anaconda Website](https://docs.anaconda.com/anaconda/user-guide/getting-started/#write-a-python-program-using-anaconda-prompt-or-terminal).)

From the Anaconda Prompt, you should be able to run `conda` and other shell commands.

### Lightweight alternatives: micromamba and miniconda

If you don't want to download a large file like the Anaconda Python Distribution (ca. 800 MB), there are
lightweight alternative installation methods (like `micromamba` and `miniconda`.

1. [Micromamba Installation](https://mamba.readthedocs.io/en/latest/installation.html#micromamba)
2. [Miniconda Installation](https://docs.conda.io/en/latest/miniconda.html)

### Installing Python without a package manager
### Lightweight alternative: `miniconda`

If you do not wish to install a package manager (not recommended), an
alternative is to directly install official Python distributions.
If you don't want to download a large file like the Anaconda Python Distribution (ca. 800 MB), there is a
lightweight alternative installation called `miniconda`.

A good tutorial for this can be found [here](https://realpython.com/installing-python/).
- [Miniconda Installation](https://docs.conda.io/en/latest/miniconda.html)

### Using Python without a local installation

Expand All @@ -74,6 +67,10 @@ Python coupled with a package manager provides a way to make isolated,
reproducible _environments_ where you have fine-tuned control over all packages
and configuration.

First, ensure that your conda installation is up to date:

conda update -n base -c conda-forge conda

To create a conda environment, you execute the following command:

conda create --name my_environment python=3.11 numpy
Expand Down Expand Up @@ -116,31 +113,12 @@ configuration can be installed by executing

conda env create -f my_environment.yml

Below we will see an example of an environment file.

For extensive documentation on using environments, please see
[the conda documentation](https://conda.io/docs/using/envs.html).

## Speeding things up with Mamba
## Python environment for this course: `esm-2024`

In order to put together an actual Python environment from your package specifications,
`conda` has to solve a difficult puzzle, to ensure that the combination of packages is mutually compatible.
Each package specified has certain dependencies on other packages.
Moreover, each version of one package requires certain minimum versions of other
packages.
Other packages in your environment may have different or incompatible versions.
The default implementation of `conda` can be very slow.
Fortunately, there is a much faster alternative called [mamba](https://mamba.readthedocs.io/en/latest/index.html).
To install it, just run:

conda install -n base -c conda-forge mamba

Now you can install environments and packages as before, but using the `mamba` command
instead of `conda`. Everything will be faster.

## Python environment for this course: `esm-2023`

## With `conda` or `mamba`
## With `conda`

The latest environment specification for this course can be downloaded under the following link as a [`YAML`-file](https://en.wikipedia.org/wiki/YAML):

Expand All @@ -149,17 +127,13 @@ https://github.com/fneum/data-science-for-esm/blob/main/environment.yaml
There is a download button at the top-right corner.

After navigating to the folder where the `environment.yaml` file is stored,
you can reate this environment using `conda` or `mamba` (faster)
you can reate this environment using `conda` (faster)

conda env create -f environment.yml

or

mamba create -f environment.yml

Activate this environment

mamba activate esm-2023
conda activate esm-2023

This environment should be sufficient for all of your work in this course.

Expand Down
16 changes: 4 additions & 12 deletions environment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: esm-2023
name: esm-2024
channels:
- conda-forge
dependencies:
Expand All @@ -15,9 +15,9 @@ dependencies:
- yaml
- pyomo
- netcdf4
- pypsa>=0.25.1
- atlite>=0.2.11
- powerplantmatching>=0.5.7
- pypsa>=0.27
- atlite>=0.2.12
- powerplantmatching>=0.5.12
- rasterio>=1.3.2
- pysheds

Expand All @@ -34,13 +34,9 @@ dependencies:
- openpyxl

# geodata utilities
# - fiona
- shapely>2
# - proj
#- geopy
- pyepsg
- cartopy>=0.22
#- descartes
- country_converter

# plotting
Expand All @@ -51,10 +47,6 @@ dependencies:
- geoviews>=1.10
- graphviz

# solvers
# - coincbc
# - glpk

# publishing
- jupyter-book
- ghp-import
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ networkx
pyyaml
pyomo>=6.5
netcdf4
pypsa>=0.25.1
atlite>=0.2.11
pypsa>=0.27
atlite>=0.2.12
pysheds
powerplantmatching>=0.5.7
powerplantmatching>=0.5.12
rasterio>=1.3.2
ipython
jupyterlab
Expand Down

0 comments on commit 2ad3a9f

Please sign in to comment.