Skip to content

Commit

Permalink
Moved Python venv to working directories.
Browse files Browse the repository at this point in the history
  • Loading branch information
lars2015 committed Dec 23, 2024
1 parent 3569476 commit 456b748
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ projects/meteo/era5/
projects/meteo/gfs/
projects/meteo/merra2/
projects/meteo/ncep/
projects/meteo/venv/
!projects/paraview/
projects/paraview/data/
!projects/python/
projects/python/plots/
projects/python/venv/
src/*.o
src/*.mod
src/atm2grid
Expand Down
5 changes: 5 additions & 0 deletions projects/meteo/get_era5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ dir=$4/${year}/${mon}
res=$5
dt=$6

# Create Python environment...
python3 -m venv venv
source ./venv/bin/activate
pip install "cdsapi>=0.7.2"

# Set time string...
tstr=$(seq 0 "$dt" 23 | awk '{printf("%02d:00:00/", $1)}' | awk '{print substr($1,1,length($1)-1)}')

Expand Down
20 changes: 5 additions & 15 deletions projects/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,9 @@ Here we provide some example Python scripts that can be used to plot MPTRAC outp

## Preparations

Create a virtual environment for python in your home directory:
The script `plot.sh` creates and activates a Python virtual environment (`venv`) in your working directory.

```
python3 -m venv ~/venv
```

Activate the environment:

```
source ~/venv/bin/activate
```

Install the python modules required for ingesting and plotting the data:
Additionally, it installs the necessary Python modules for data ingestion and plotting:

```
pip install basemap basemap-data cartopy matplotlib numpy pandas scipy xarray
Expand All @@ -26,23 +16,23 @@ Install the python modules required for ingesting and plotting the data:

Three programs are provided for plotting air parcel and grid output, `plot_atm.py`, `plot_atm_3d.py` and `plot_grid.py`.

Call the python plot scripts with parameter `datadir` (the directory of the data files) and `plotdir` (the directory where the plots will be written to), e.g., for `plot_atm.py` it would be:
Call the Python plot scripts with parameter `datadir` (the directory of the data files) and `plotdir` (the directory where the plots will be written to), e.g., for `plot_atm.py` it would be:

```
python ./plot_atm.py ../example/data pythonplots
```

## Plotting of trajectories and meteo map output of MPTRAC

To plot the trajectory data files created with `atm_select`, call the python script `atm_traj.py`:
To plot the trajectory data files created with `atm_select`, call the Python script `atm_traj.py`:

```
python3 plot_traj.py
```

Here, a single trajectory on a map is plotted from the data file `traj_5450.tab` provided in the directory `data`.

To plot meteo data files created with `met_map` call the python script `plot_met_map.py`:
To plot meteo data files created with `met_map` call the Python script `plot_met_map.py`:

```
python3 plot_met_map.py
Expand Down
6 changes: 4 additions & 2 deletions projects/python/plot.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#! /bin/bash

# Activate venv...
source ~/venv/bin/activate
# Create Python environment...
python3 -m venv venv
source ./venv/bin/activate
pip install basemap basemap-data cartopy matplotlib numpy pandas scipy xarray

# Setup...
datadir="../example/data.ref"
Expand Down

0 comments on commit 456b748

Please sign in to comment.