Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
01e97dc
Merge branch 'release/1.1.0' into main
carlosrenatosouza2 Apr 15, 2025
28f76d0
Merge branch 'release/1.2.0' into main
carlosrenatosouza2 Apr 23, 2025
72b8e07
Update README.md
carlosrenatosouza2 Apr 23, 2025
46fd64b
README.md updated to merge.
carlosrenatosouza2 May 9, 2025
89a68e1
merge conflicts README.md
carlosrenatosouza2 May 9, 2025
cd99d38
Merge branch 'release/1.3.0' into main
Jun 3, 2025
0d56cc1
initial implementation
Oct 14, 2025
48f0d48
wip
Oct 14, 2025
cb05f5b
wip
Oct 14, 2025
9874557
add mesh var to preprocessing stages
Oct 16, 2025
7af0e7d
add mesh var to degrid and init
Oct 16, 2025
fac10c3
correct issue with mesh dir
Oct 16, 2025
29931e6
correct typo
Oct 16, 2025
1757b91
implementing atmos
Oct 16, 2025
b92bf06
wip
Oct 16, 2025
7724a7b
postprocessing
Oct 16, 2025
f014cbc
test wmo course working with ERA5 data and simulation 2007-06-22
Oct 29, 2025
98814e3
split make_degrib for GFS and ERA5 data
Oct 29, 2025
587fba4
add GFS and ERA5 options to preprocessing
Oct 29, 2025
5f022fd
finish options ERA5 and GFS
Oct 29, 2025
f092051
error in case simulation params not set
Oct 30, 2025
9d0adc1
add postprocessing on native grid
Oct 30, 2025
7b1286f
add sources for mesh generation and postprocessing on native MPAS grid
Oct 30, 2025
d25144f
small edits
Oct 30, 2025
b9e4412
keep data/ folder in vtx-mpas-meshes
Oct 30, 2025
1c763fd
create fixed/ in second step
Oct 30, 2025
a7561dd
wip
Oct 30, 2025
88aaf7e
add script to plot grid
Oct 30, 2025
484cf1b
wip
Oct 30, 2025
8a51bb1
edit setenv
Oct 30, 2025
ed30448
small change postproc script
Oct 30, 2025
6210f6a
wip
Oct 30, 2025
1fa318b
wip
Oct 30, 2025
baa10c7
change dir ERA5 data
Nov 3, 2025
1d90db5
remove plotting from create-mesh
Nov 3, 2025
36c2a74
wip
Nov 3, 2025
7ac3ded
change dir of Vtable.ECMWF
Nov 4, 2025
149f893
wip
Nov 4, 2025
9ef1dcd
add instructions
Nov 4, 2025
6efd791
wip instructions
Nov 4, 2025
6749147
small edits
Nov 4, 2025
cdc3728
wip
Nov 4, 2025
f2343b8
animate script
Nov 5, 2025
b22dda3
Merge branch 'feature/scripts-849-NF' of https://github.com/guilherme…
Nov 5, 2025
389ce78
change model run config
Nov 5, 2025
a588e53
add idealized case to workflow
Nov 11, 2025
1599486
add option grid with constant res global
Nov 11, 2025
3e842ee
template mesh input file
Nov 11, 2025
a302280
correct PATH MPAS-Limited-Area
Nov 11, 2025
eae1edb
tutorial meshes
Nov 11, 2025
8d948c0
wip
Nov 11, 2025
04363f0
wip
Nov 11, 2025
329b3f5
wip
Nov 11, 2025
0dd811d
wip
Nov 11, 2025
0684d3a
wip
Nov 11, 2025
820f6de
review tutorial1
Nov 11, 2025
25e3aeb
organize run post mpas
Nov 11, 2025
1b94226
tutorial 2
Nov 11, 2025
f4d7015
Merge branch 'feature/scripts-849-NF-idealized' of https://github.com…
Nov 11, 2025
ac81aec
update tutorial 2
Nov 11, 2025
3c64769
update tutorial 2
Nov 11, 2025
81f434c
new template 0.run script, set for idealized case
Nov 11, 2025
770b6a9
tutorial 3
Nov 12, 2025
f6dadbf
correction in vtx-mpas-meshes
Nov 12, 2025
7a1b73b
mpas plot change color scheme
Nov 12, 2025
dc58597
wip
Nov 12, 2025
fc3b8cd
update tutorials
Nov 12, 2025
bd753e7
new figs tutorial
Nov 13, 2025
7383874
small corrections
Nov 13, 2025
bfaa222
update tutorials 1 2
Nov 13, 2025
e1c06a8
update tutorial 3
Nov 13, 2025
3eb4c38
wip
Nov 13, 2025
5def1dd
new figs tutorial 2 ncar
Nov 13, 2025
c857ac5
correct mesh_generator depending on grid case
Nov 13, 2025
5d35fc8
update figs group2 tut2
Nov 13, 2025
93677f7
small correction
Nov 13, 2025
f9f8e8c
small corrections
Nov 13, 2025
7d9bbd1
regional simulation
Nov 27, 2025
44cb92c
preprocessing almost working; missing is test with blend_bdy_terrain …
Dec 2, 2025
137cde4
add lbc_in for atmosphere run
Dec 3, 2025
d053910
wip
Dec 3, 2025
6ebb1b8
wip
Dec 3, 2025
6331473
small changes
Dec 4, 2025
ea654d3
regional for GFS: make degrib
Dec 5, 2025
60e0e32
wip
Dec 7, 2025
3053919
add scripts for ERA5 download
Dec 7, 2025
a1d5ee8
account for LBC input in idealized case
Dec 7, 2025
b94c2ef
tutorial 2 updated; working
Dec 7, 2025
77a58d3
tutorial 3 updated; working
Dec 8, 2025
de732d1
tutorial 4; preprocessing working
Dec 8, 2025
06706f8
new figs
Dec 8, 2025
2c031f6
tutorial 5; preprocessing working
Dec 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ dataout
execs
.venv
scripts/GF_ConvPar_nml
sources
sources/MONAN-Model_release
sources/convert_mpas_release
sources/CGFD-USP-Create-Mesh/vtx-mpas-meshes/data/*
!sources/CGFD-USP-Create-Mesh/vtx-mpas-meshes/data/.gitkeep
run.*
*.pyc
Binary file added docs/figs/grid3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/figs/grid4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/figs/grid5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/figs/mesh_params.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/figs/pressure_group1_ncar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/figs/pressure_group1_tut1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/figs/pressure_group2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/figs/surface_pressure_tut3_2007062300.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/figs/surface_pressure_tut3_2007062400.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/figs/surface_pressure_tut3_2007062500.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/figs/vorticity_group1_ncar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/figs/vorticity_group1_tut1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/figs/vorticity_group2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
359 changes: 359 additions & 0 deletions docs/tutorial1-meshes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,359 @@
# Tutorial for generating personalized meshes for MONAN

## 1) First steps in EGEON
To start our exercise, we first need to log in into EGEON and set up a conda environment, which will be needed to execute some of the steps in running a MONAN simulation.

### 1.1) Log in

In your terminal, write
```
ssh -Y $USER@egeon-login.cptec.inpe.br
```
entering in `$USER` the username you received from the organization team. You will then be prompted to give your password, which you should have received as well.

### 1.2) Load the anaconda module

Once you are in, load the anaconda module by
```
module load anaconda3-2022.05-gcc-11.2.0-q74p53i
```

### 1.3) Configure shell to use conda
Start with the command
```
conda init
```
Then, do
```
source ~/.bashrc
```

### 1.4) Make sure you have access to our conda environment

Write the command
```
conda config --add envs_dirs /pesq/share/monan/curso_OMM_INPE_2025/.conda/envs
```

### 1.5) Test if you can activate our conda environment

Write the command
```
conda activate vtx_env
```

If you see "(vtx_env)" in front of your username in the terminal, you're all set to start!

## 2) Cloning scripts repository
Our second step is to clone the repository `scripts_CD-CT`, which contains all the code needed to run a MONAN simulation.

### 2.1) Go to your work directory:
```
cd /mnt/beegfs/$USER
```
### 2.2) Clone the scripts repository:

```
git clone -b feature/scripts-849-NF-idealized https://github.com/CGFD-USP/scripts_CD-CT
```

## 3) Generating MONAN meshes
Now that you have the scripts repository, we can start generating meshes. In this tutorial you will generate three types of mesh:

1) A **uniform global mesh**, i.e. a mesh with cells approximately the same size all over the globe. This type of mesh will be used in our first exercise with MONAN, where we will perform an idealized global simulation taking artificial initial conditions;

2) A **refined global mesh**, i.e. a mesh where the size of cells decreases over a particular region of interest where one wants detailed information of simulated phenomena. This type of mesh will be used both in our first exercise with MONAN, for comparison with uniform global meshes, and in our second exercise, where we will simulate an actual cyclone that happened in the La Plata region in 2007;

3) A **refined regional mesh**, i.e. a mesh where as above the size of cells decreases over a region of interest, but where the rest of the globe is cut off so that one can perform the simulation only over that particular region, thereby saving a lot of computational time. This type of mesh will be used for the cases we will study over the next days of the course.

To start generating our meshes, we need to tell the code our username so that it knows where to look for the mesh generation algorithm and where to save our meshes. To do this, follow steps 3.1)-3.2) below.

### 3.1) Go to the scripts directory
```
cd scripts_CD-CT/scripts
```

### 3.2) Substitute in mesh_input_file.txt the placeholder $USER by your actual username
```
sed -i "s|\\\$USER|$USER|g" mesh_input_file.txt
```

Now, check in mesh_input_file.txt if your username is actually there. For this, open the file with the text editor
```
vi mesh_input_file.txt
```
After opening the file, make sure that the variables ending in "`_dir`" contain a directory using your actual username. For example, if the username is `guilherme.mendonca`, you should see:
```
exp_dir=/mnt/beegfs/guilherme.mendonca/scripts_CD-CT/scripts
vtx_mpas_meshes_dir=/mnt/beegfs/guilherme.mendonca/scripts_CD-CT/sources/CGFD-USP-Create-Mesh/vtx-mpas-meshes
meshes_dir=/mnt/beegfs/guilherme.mendonca/scripts_CD-CT/datain/fixed
```
Check if these three lines contain your username. If so, we are ready to generate our meshes!

### 3.3) Uniform global mesh
We start with the uniform global mesh. Still in `mesh_input_file.txt`, you can edit the characteristics of your mesh. These characteristics are generally set by the variables
```
## Coordinates of mesh center
lon=-30
lat=50
## Inner and outer radius (km)
inner_radius=2000
outer_radius=2800
## Number of external layers for r > outer_radius
n_layers=8
## High resolution for r < inner_radius
high_res=240
## Low resolution for r > outer_radius
low_res=600
## Whether to cut regional mesh (y/n)
do_regional=n
## Grid type (doughnut/constant)
grid_type=constant
```

Most of these parameters only make sense when thinking about a refined mesh. For this first exercise with a uniform mesh, the only parameters we have to worry about are `high_res`, which will define the resolution of our mesh (in km), `do_regional`, which defines whether we want a global or a regional mesh, and `grid_type`, which defines whether our mesh will have constant resolution or will be refined.

For our uniform global mesh, make sure the following values are set:
```
high_res=240
do_regional=n
grid_type=constant
```

Please leave the remaining parameters as they are. Now save and exit the file (command :wq).

#### 3.3.1) Generate the mesh

Now, you can generate the mesh by executing
```
bash 2.create_mesh.bash
```

#### 3.3.2) Plot the mesh

After `2.create_mesh.bash` finishes running, we can plot the generated mesh. To do that, first get the geographical files needed for the plot:

```
mkdir -p "/home/$USER/.local/share" && cp -r /pesq/share/monan/curso_OMM_INPE_2025/.local/share/cartopy "/home/$USER/.local/share/"
```

Now, edit the file plot_mpas_grid.bash:
```
vi plot_mpas_grid.bash
```

In GFILEPATH, add the name of the mesh you just generated after ${DATAIN}/fixed/, for example:
```
## Grid file
GFILEPATH=${DATAIN}/fixed/lat_50_lon_-30_oradius_2800_iradius_2000_margin_800_hres_240_lres_600.region.grid.nc
```

In POSTFILEPATH, add the directory you want to save the plot, for example:
```
## Output directory and filename to save plot
POSTFILEPATH=${DATAIN}/fixed/lat_50_lon_-30_oradius_2800_iradius_2000_margin_800_hres_240_lres_600.region.grid.png
```

Save and exit (:wq) plot_mpas_grid.bash, then run the script:
```
bash plot_mpas_grid.bash
```

After the plot is done, you may or may not be able to open the plot in EGEON. You can try by

```
module load imagemagick-7.0.8-7-gcc-11.2.0-46pk2go
display /mnt/beegfs/$USER/scripts_CD-CT/datain/fixed/$MESH.grid.png
```
where in `$MESH` you use the name of your generated mesh (see `POSTFILEPATH` above).

If this does not work, you need to copy the plot to your local machine to then open it locally. This can be done by opening another terminal, then doing
```
scp $USER@egeon.cptec.inpe.br:/mnt/beegfs/$USER/scripts_CD-CT/datain/fixed/$MESH.grid.png .
```
where `$USER` is your username and `$MESH` the name of your mesh.

The result should look like the following:
![Alt text](figs/lat_50_lon_-30_oradius_2800_iradius_2000_margin_800_hres_240_lres_240.region.grid_corrected.png)


### 3.3) Refined global mesh
We now proceed to the refined global mesh. Open again `mesh_input_file.txt` with vi:
```
vi mesh_input_file.txt
```
Now, the remaining parameters we ignored in the last section become important. A refined mesh looks something like this:

![Alt text](figs/mesh_params.png)



As shown in the figure, `high_res`and `low_res` indicate the resolution inside and outside our region of interest. Parameters `inner_radius` and `outer_radius` indicate the radius of the internal part of this region, where the resolution is equal to `high_res`, and the radius of the external region, where the resolution is equal to `low_res`; the difference between these parameters give the size of the transition region where the resolution changes. Important are now also `lat` and `lon`, which give the center of this region of interest.

For our refined global mesh, copy and paste the mesh parameters as follows:
```
## Coordinates of mesh center
lon=-30
lat=50
## Inner and outer radius (km)
inner_radius=2000
outer_radius=2800
## Number of external layers for r > outer_radius
n_layers=8
## High resolution for r < inner_radius
high_res=48
## Low resolution for r > outer_radius
low_res=240
## Whether to cut regional mesh (y/n)
do_regional=n
## Grid type (doughnut/constant)
grid_type=doughnut
# Automatic additions
```
where now `grid_type=doughnut` indicates that we want the refinement. The parameter `n_layers`is still not relevant for us: it indicates, if you have a regional mesh, how many "layers" of cells around outer_radius one wants to have before cutting the regional mesh from the global mesh.

**Important: Make sure the last line file_name=lat_50_lon_-30_oradius_2800_iradius_2000_margin_800_hres_240_lres_600.region is deleted**, because it refers to the mesh we generated in the previous section.

Save and exit the file (command :wq).

#### 3.3.1) Generate the mesh

Now, you can generate the mesh by executing
```
bash 2.create_mesh.bash
```

#### 3.3.2) Plot the mesh

To plot the mesh, edit the file plot_mpas_grid.bash:
```
vi plot_mpas_grid.bash
```

In GFILEPATH, add the name of the mesh you just generated after ${DATAIN}/fixed/, for example:
```
## Grid file
GFILEPATH=${DATAIN}/fixed/lat_50_lon_-30_oradius_2800_iradius_2000_margin_800_hres_48_lres_240.region.grid.nc
```

In POSTFILEPATH, add the directory you want to save the plot, for example:
```
## Output directory and filename to save plot
POSTFILEPATH=${DATAIN}/fixed/lat_50_lon_-30_oradius_2800_iradius_2000_margin_800_hres_48_lres_240.region.grid.png
```

Save and exit (:wq) plot_mpas_grid.bash, then run the script:
```
bash plot_mpas_grid.bash
```

After the plot is done, you may or may not be able to open the plot in EGEON. You can try by

```
module load imagemagick-7.0.8-7-gcc-11.2.0-46pk2go
display /mnt/beegfs/$USER/scripts_CD-CT/datain/fixed/$MESH.grid.png
```
where in `$MESH` you use the name of your generated mesh (see `POSTFILEPATH` above).

If this does not work, you need to copy the plot to your local machine to then open it locally. This can be done by opening another terminal, then doing
```
scp $USER@egeon.cptec.inpe.br:/mnt/beegfs/$USER/scripts_CD-CT/datain/fixed/$MESH.grid.png .
```
where `$USER` is your username and `$MESH` the name of your mesh.

The result should look like this:

![Alt text](figs/lat_50_lon_-30_oradius_2800_iradius_2000_margin_800_hres_48_lres_240.region.grid.png)

### 3.4) Refined regional mesh
We now proceed to the refined regional mesh. Open again `mesh_input_file.txt` with vi:
```
vi mesh_input_file.txt
```
Now, the only difference to the refined global mesh is that we want our mesh to be regional. For this, we just have to set `do_regional=y`. In addition, now `n_layers`becomes important: it tells the code how many "layers" of cells around outer_radius one wants to have before cutting the regional mesh from the global mesh. Hence it defines the limiting region where the regional mesh will be cut. We will use the default value `n_layers=8`.

Hence, you can copy the parameters as follows:
```
## Coordinates of mesh center
lon=-30
lat=50
## Inner and outer radius (km)
inner_radius=2000
outer_radius=2800
## Number of external layers for r > outer_radius
n_layers=8
## High resolution for r < inner_radius
high_res=48
## Low resolution for r > outer_radius
low_res=240
## Whether to cut regional mesh (y/n)
do_regional=y
## Grid type (doughnut/constant)
grid_type=doughnut
# Automatic additions
```

**Important: Make sure the last line file_name=lat_50_lon_-30_oradius_2800_iradius_2000_margin_800_hres_48_lres_240.region is deleted**, because it refers to the mesh we generated in the previous section.

Save and exit the file (command :wq).

#### 3.3.1) Generate the mesh

Before you generate this mesh, make sure the previous mesh is not overwritten by doing

```
mv ../datain/fixed/lat_50_lon_-30_oradius_2800_iradius_2000_margin_800_hres_48_lres_240.region.grid.nc ../datain/fixed/lat_50_lon_-30_oradius_2800_iradius_2000_margin_800_hres_48_lres_240.global.grid.nc

mv ../datain/fixed/lat_50_lon_-30_oradius_2800_iradius_2000_margin_800_hres_48_lres_240.region.graph.info ../datain/fixed/lat_50_lon_-30_oradius_2800_iradius_2000_margin_800_hres_48_lres_240.global.graph.info

mv ../datain/fixed/lat_50_lon_-30_oradius_2800_iradius_2000_margin_800_hres_48_lres_240.region ../datain/fixed/lat_50_lon_-30_oradius_2800_iradius_2000_margin_800_hres_48_lres_240.global

mv ../datain/fixed/lat_50_lon_-30_oradius_2800_iradius_2000_margin_800_hres_48_lres_240.region.grid.png ../datain/fixed/lat_50_lon_-30_oradius_2800_iradius_2000_margin_800_hres_48_lres_240.global.grid.png
```

Now, you can generate the mesh by executing
```
bash 2.create_mesh.bash
```

#### 3.3.2) Plot the mesh

To plot the mesh, edit the file plot_mpas_grid.bash:
```
vi plot_mpas_grid.bash
```

In GFILEPATH, add the name of the mesh you just generated after ${DATAIN}/fixed/, for example:
```
## Grid file
GFILEPATH=${DATAIN}/fixed/lat_50_lon_-30_oradius_2800_iradius_2000_margin_800_hres_48_lres_240.region.grid.nc
```

In POSTFILEPATH, add the directory you want to save the plot, for example:
```
## Output directory and filename to save plot
POSTFILEPATH=${DATAIN}/fixed/lat_50_lon_-30_oradius_2800_iradius_2000_margin_800_hres_48_lres_240.region.grid.png
```

Save and exit (:wq) plot_mpas_grid.bash, then run the script:
```
bash plot_mpas_grid.bash
```

After the plot is done, you may or may not be able to open the plot in EGEON. You can try by

```
module load imagemagick-7.0.8-7-gcc-11.2.0-46pk2go
display /mnt/beegfs/$USER/scripts_CD-CT/datain/fixed/$MESH.grid.png
```
where in `$MESH` you use the name of your generated mesh (see `POSTFILEPATH` above).

If this does not work, you need to copy the plot to your local machine to then open it locally. This can be done by opening another terminal, then doing
```
scp $USER@egeon.cptec.inpe.br:/mnt/beegfs/$USER/scripts_CD-CT/datain/fixed/$MESH.grid.png .
```
where `$USER` is your username and `$MESH` the name of your mesh.

The result should look like this:

![Alt text](figs/lat_50_lon_-30_oradius_2800_iradius_2000_margin_800_hres_48_lres_240.region.grid_cut.png)
Loading