Skip to content

First post-processing functions #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions docs/src/man/lamem_post_processing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Post processing of numerical models

To evaluate and analyse numerical simulations, we provide a few routines to make it easier to extract the dataset information.


```@docs
get_phase
get_phase_bool
search_for_phase_properties
get_data_timestep
split_at__to_type
search_for_model_constrains
track_point_over_time
deserialize_file
```
61 changes: 61 additions & 0 deletions docs/src/man/tutorial_lamem_post_processing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Post processing of LaMEM files

## Goal
This tutorial visualizes how to do comparative analysis and quantitative evaluation of LaMEM models. The post-processing is julia based and extracts the information directly from the .pvtr-file.


## Steps

## 1. Get general information
Before beginning the post-processing, it is useful to extract some general information about the model. This includes material properties of the different phases, time of the time step, ascii-file stored information and the model data.


```julia
using GeophysicalModelGenerator, LaMEM, Serialization

#### set path and variables
dat_path = ("../test/test_files/Subduction_VEP.dat")
model_path = ("../test/test_files/timestep/")
model_name = "VEP"
timestep = "Timestep_00000000_0.00000000e+00"
FileName_pvtr = "output.pvtr"
p_fields = ["phase", "temperature"]
output_dir = model_path

# extract data information from ascii file
surface_level = search_for_model_constrains(dat_path, "surf_level")

# read output file
material_block = Dict{String, Dict{String, Dict{String, String}}}() # Dictionary to store material properties
material_block = search_for_phase_properties(dat_path, model_name, "<MaterialStart>", "<MaterialEnd>")

# get the time as a float number
time = split_at__to_type([timestep],3,"Float")


# extract data information for selected fields
data = get_data_timestep(model_path,timestep,FileName_pvtr,p_fields,surface_level,false)
```

## 2. Start post-processing
To analyse the differences between models and its evolution, coordinates of specific phases can be obtained either as a vector or as a matrix. Additionally, a point can be tracked over time for specific fields.


```julia
# get information about where the phase is located
processing_folder = joinpath(model_path,timestep)
path = replace(processing_folder,"\\" => "/")*"/"
indices = get_phase(path,FileName_pvtr,[2],false)
matrix = get_phase_bool(path,FileName_pvtr,indices)

# track one point over time
name = "track"*string(indices[1])
track_point = track_point_over_time(indices[1],p_fields,model_name,model_path,surface_level,name,output_dir,false)

tracked_point = deserialize_file(output_dir,name)
```




If you want to run the entire example, you can find the .jl code [here](https://github.com/JuliaGeodynamics/GeophysicalModelGenerator.jl/blob/main/tutorial/Tutorial_post_processing.jl)
Loading