Skip to content

Commit e210a31

Browse files
authored
Merge pull request #102 from JuliaGeodynamics/bk-rename-functions-2
Rename function names to follow Julia style
2 parents b0eed7f + 96e77b5 commit e210a31

File tree

90 files changed

+1348
-1352
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+1348
-1352
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "GeophysicalModelGenerator"
22
uuid = "3700c31b-fa53-48a6-808a-ef22d5a84742"
33
authors = ["Boris Kaus", "Marcel Thielmann"]
4-
version = "0.6.0"
4+
version = "0.7.0"
55

66
[deps]
77
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Some of the key features are:
3333
- Create initial model setups for the 3D geodynamic code [LaMEM](https://github.com/UniMainzGeo/LaMEM).
3434
- Import LaMEM timesteps.
3535

36-
All data is transformed into either a `GeoData` or a `UTMData` structure which contains info about `longitude/latitude/depth`, `ew/ns/depth` coordinates along with an arbitrary number of scalar/vector datasets, respectively. All data can be exported to Paraview with the `write_Paraview` routine, which transfers the data to a `ParaviewData` structure (that contains Cartesian Earth-Centered-Earth-Fixed (ECEF) `x/y/z` coordinates, used for plotting)
36+
All data is transformed into either a `GeoData` or a `UTMData` structure which contains info about `longitude/latitude/depth`, `ew/ns/depth` coordinates along with an arbitrary number of scalar/vector datasets, respectively. All data can be exported to Paraview with the `write_paraview` routine, which transfers the data to a `ParaviewData` structure (that contains Cartesian Earth-Centered-Earth-Fixed (ECEF) `x/y/z` coordinates, used for plotting)
3737

3838
## Usage
3939
The best way to learn how to use this is to install the package (see below) and look at the tutorials in the [manual](https://juliageodynamics.github.io/GeophysicalModelGenerator.jl/dev/).

docs/src/man/Tutorial_AlpineData.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ and load both `GMG` and `GMT` with:
2626
using GeophysicalModelGenerator, GMT
2727
```
2828

29-
When loading both packages, several `GMT` routines within `GMG` will be loaded. One of these routines is the function `importTopo`, where one simply has to provide the region for which to download the topographic data and the data source.
29+
When loading both packages, several `GMT` routines within `GMG` will be loaded. One of these routines is the function `import_topo`, where one simply has to provide the region for which to download the topographic data and the data source.
3030

3131
```julia
32-
Topo = importTopo([4,20,37,50], file="@earth_relief_01m.grd")
32+
Topo = import_topo([4,20,37,50], file="@earth_relief_01m.grd")
3333
```
3434

3535
The data is available in different resolutions; see [here](http://gmt.soest.hawaii.edu/doc/latest/grdimage.html) for an overview. Generally, it is advisable to not use the largest resolution if you have a large area, as the files become very large.
3636

3737
If you have issues with loading the topography with `GMT`, there is also the alternative to download the data yourself and import it using `Rasters.jl`.
3838

39-
We can now export this data to a `VTK` format so that we can visualize it with `Paraview`. To do so, `GMG` provides the function `write_Paraview`:
39+
We can now export this data to a `VTK` format so that we can visualize it with `Paraview`. To do so, `GMG` provides the function `write_paraview`:
4040

4141
```julia
42-
write_Paraview(Topo, "Topography_Alps")
42+
write_paraview(Topo, "Topography_Alps")
4343
```
4444

4545
Also, if you want to save this data for later use in julia, you can save it as `*.jld2` file using the function `save_GMG`:
@@ -126,10 +126,10 @@ units = unique(tag) #get different units
126126
We will use these units later to save the Moho data separately for each tectonic unit.
127127

128128
### 2.2 Converting the data to a `GMG` dataset
129-
To convert this data to a `GMG` dataset, we now have to interpolate it to a regular grid. You can generate the respective grid with the `GMG` function `lonlatdepthGrid`
129+
To convert this data to a `GMG` dataset, we now have to interpolate it to a regular grid. You can generate the respective grid with the `GMG` function `lonlatdepth_grid`
130130

131131
```julia
132-
Lon,Lat,Depth = lonlatdepthGrid(9.9:0.02:15.1,45.0:.02:49.0,0km);
132+
Lon,Lat,Depth = lonlatdepth_grid(9.9:0.02:15.1,45.0:.02:49.0,0km);
133133
nothing #hide
134134
```
135135

@@ -156,7 +156,7 @@ for iunit = 1:length(units)
156156
#for later checking, we can now save the original point data as a VTK file:
157157
data_Moho = GeophysicalModelGenerator.GeoData(lon_tmp,lat_tmp,depth_tmp,(MohoDepth=depth_tmp*km,))
158158
filename = "Mroczek_Moho_" * units[iunit]
159-
write_Paraview(data_Moho, filename, PointsData=true)
159+
write_paraview(data_Moho, filename, PointsData=true)
160160

161161
#Now we create a KDTree for an effective nearest neighbor determination;
162162
kdtree = KDTree([lon_tmp';lat_tmp']; leafsize = 10)
@@ -187,7 +187,7 @@ for iunit = 1:length(units)
187187
#Finally, we can now export that data to VTK and save a `jld2` file using the `save_GMG` routine
188188
Data_Moho = GeophysicalModelGenerator.GeoData(Lon, Lat, Depth, (MohoDepth=Depth,PointDist=Dist),Data_attribs)
189189
filename = "Mrozek_Moho_Grid_" * units[iunit]
190-
write_Paraview(Data_Moho, filename)
190+
write_paraview(Data_Moho, filename)
191191
save_GMG(filename,Topo)
192192

193193
end
@@ -218,7 +218,7 @@ nothing #hide
218218
As before, we can export this dataset to `VTK` and also save it as a `jld2` file (as we are now exporting point data, we have to use the option `PointsData=true`):
219219

220220
```julia
221-
write_Paraview(Data_ISC, "EQ_ISC", PointsData=true);
221+
write_paraview(Data_ISC, "EQ_ISC", PointsData=true);
222222
save_GMG("EQ_ISC",Data_ISC)
223223
```
224224

@@ -363,10 +363,10 @@ nothing #hide
363363
At this stage we have the 3D velocity components on a grid. Yet, we don't have information yet about the elevation of the stations (as the provided data set did not give this).
364364
We could ignore that and set the elevation to zero, which would allow saving the data directly.
365365
Yet, a better way is to load the topographic map of the area and interpolate the elevation to the velocity grid.
366-
As we have already the loaded the topographic map in section 1 of this tutorial, we can simply reuse it. To interpolate, we will use the function `interpolateDataFields2D`
366+
As we have already the loaded the topographic map in section 1 of this tutorial, we can simply reuse it. To interpolate, we will use the function `interpolate_datafields_2D`
367367

368368
```julia
369-
topo_v, fields_v = interpolateDataFields2D(Topo, Lon, Lat)
369+
topo_v, fields_v = interpolate_datafields_2D(Topo, Lon, Lat)
370370
```
371371

372372
The variable we are interested in is the variable `topo_v`. `fields_v` contains the interpolation of all the fields in `Topo` to the new grid and we only keep it here for completeness.
@@ -380,7 +380,7 @@ Data_GPS_Sanchez = GeoData(Lon,Lat,topo_v,(Velocity_mm_year=(Ve,Vn,Vz),V_north=V
380380
And as always, we'll save everything in `VTK` format and in `jld2` format
381381

382382
```julia
383-
write_Paraview(Data_GPS_Sanchez, "GPS_Sanchez")
383+
write_paraview(Data_GPS_Sanchez, "GPS_Sanchez")
384384
save_GMG("GPS_Sanchez",Data_GPS_Sanchez)
385385
```
386386

@@ -445,7 +445,7 @@ nothing #hide
445445
And then we save it again.
446446

447447
```julia
448-
write_Paraview(Data, "Rappisi2022")
448+
write_paraview(Data, "Rappisi2022")
449449
save_GMG("Rappisi2022",Data)
450450
```
451451

docs/src/man/Tutorial_Basic.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ This is a so-called `GeoData` object, which is a 3D grid of seismic velocities a
3434
We can save this in `VTK` format, which is a widely used format that can for exampke be read by the 3D open-source visualization tool [Paraview](https://www.paraview.org/):
3535

3636
```julia
37-
write_Paraview(Tomo_Alps_full,"Tomo_Alps_full")
37+
write_paraview(Tomo_Alps_full,"Tomo_Alps_full")
3838
```
3939

4040
````
@@ -62,7 +62,7 @@ Different than the 3D tomographic model, the topography has size 1 for the last
6262
We can write this to disk as well
6363

6464
```julia
65-
write_Paraview(Topo_Alps,"Topo_Alps")
65+
write_paraview(Topo_Alps,"Topo_Alps")
6666
```
6767

6868
````
@@ -76,12 +76,12 @@ Note that I use the `Oleron` scientific colormap for the tomography which you ca
7676

7777
### 2. Extract subset of data
7878
As you can see the tomographic data covers a much larger area than the Alps itself, and in most of that area there is no data.
79-
It is thus advantageous to cut out a piece of the dataset that we are interested in which can be done with `extractSubvolume`:
79+
It is thus advantageous to cut out a piece of the dataset that we are interested in which can be done with `extract_subvolume`:
8080

8181
```julia
82-
Tomo_Alps = extractSubvolume(Tomo_Alps_full,Lon_level=(4,20),Lat_level=(36,50), Depth_level=(-600,-10))
82+
Tomo_Alps = extract_subvolume(Tomo_Alps_full,Lon_level=(4,20),Lat_level=(36,50), Depth_level=(-600,-10))
8383

84-
write_Paraview(Tomo_Alps,"Tomo_Alps");
84+
write_paraview(Tomo_Alps,"Tomo_Alps");
8585
```
8686

8787
````
@@ -95,10 +95,10 @@ Which looks like:
9595
### 3. Create cross sections
9696
Paraview has the option to `Slice` through the data but it is not very intuitive to do this in 3D. Another limitation of Paraview is that it does not have native support for spherical coordinates, and therefore the data is translated to cartesian (`x`,`y`,`z`) coordinates (with the center of the Earth at `(0,0,0)`).
9797
That makes this a bit cumbersome to make a cross-section at a particular location.
98-
If you are interested in this you can use the `crossSection` function:
98+
If you are interested in this you can use the `cross_section` function:
9999

100100
```julia
101-
data_200km = crossSection(Tomo_Alps, Depth_level=-200)
101+
data_200km = cross_section(Tomo_Alps, Depth_level=-200)
102102
```
103103

104104
````
@@ -114,7 +114,7 @@ GeoData
114114
As you see, this is not exactly at 200 km depth, but at the closest `z`-level in the data sets. If you want to be exactly at 200 km, use the `Interpolate` option:
115115

116116
```julia
117-
data_200km_exact = crossSection(Tomo_Alps, Depth_level=-200, Interpolate=true)
117+
data_200km_exact = cross_section(Tomo_Alps, Depth_level=-200, Interpolate=true)
118118
```
119119

120120
````
@@ -129,10 +129,10 @@ GeoData
129129

130130
In general, you can get help info for all functions with `?`:
131131
```julia
132-
help?> crossSection
133-
search: crossSection crossSectionVolume crossSectionPoints crossSectionSurface flattenCrossSection
132+
help?> cross_section
133+
search: cross_section cross_section_volume cross_section_points cross_section_surface flatten_cross_section
134134

135-
crossSection(DataSet::AbstractGeneralGrid; dims=(100,100), Interpolate=false, Depth_level=nothing, Lat_level=nothing, Lon_level=nothing, Start=nothing, End=nothing, Depth_extent=nothing, section_width=50km)
135+
cross_section(DataSet::AbstractGeneralGrid; dims=(100,100), Interpolate=false, Depth_level=nothing, Lat_level=nothing, Lon_level=nothing, Start=nothing, End=nothing, Depth_extent=nothing, section_width=50km)
136136

137137
Creates a cross-section through a GeoData object.
138138

@@ -156,11 +156,11 @@ search: crossSection crossSectionVolume crossSectionPoints crossSectionSurface f
156156
Example:
157157
≡≡≡≡≡≡≡≡
158158

159-
julia> Lon,Lat,Depth = lonlatdepthGrid(10:20,30:40,(-300:25:0)km);
159+
julia> Lon,Lat,Depth = lonlatdepth_grid(10:20,30:40,(-300:25:0)km);
160160
julia> Data = Depth*2; # some data
161161
julia> Vx,Vy,Vz = ustrip(Data*3),ustrip(Data*4),ustrip(Data*5);
162162
julia> Data_set3D = GeoData(Lon,Lat,Depth,(Depthdata=Data,LonData=Lon, Velocity=(Vx,Vy,Vz)));
163-
julia> Data_cross = crossSection(Data_set3D, Depth_level=-100km)
163+
julia> Data_cross = cross_section(Data_set3D, Depth_level=-100km)
164164
GeoData
165165
size : (11, 11, 1)
166166
lon ϵ [ 10.0 : 20.0]
@@ -172,7 +172,7 @@ search: crossSection crossSectionVolume crossSectionPoints crossSectionSurface f
172172
Let's use this to make a vertical cross-section as well:
173173

174174
```julia
175-
Cross_vert = crossSection(Tomo_Alps, Start=(5,47), End=(15,44))
175+
Cross_vert = cross_section(Tomo_Alps, Start=(5,47), End=(15,44))
176176
```
177177

178178
````
@@ -188,8 +188,8 @@ GeoData
188188
And write them to paraview:
189189

190190
```julia
191-
write_Paraview(Cross_vert,"Cross_vert");
192-
write_Paraview(data_200km,"data_200km");
191+
write_paraview(Cross_vert,"Cross_vert");
192+
write_paraview(data_200km,"data_200km");
193193
```
194194

195195
````
@@ -204,10 +204,10 @@ In creating this image, I used the `Clip` tool of Paraview to only show topograp
204204
### 4. Cartesian data
205205
As you can see, the curvature or the Earth is taken into account here. Yet, for many applications it is more convenient to work in Cartesian coordinates (kilometers) rather then in geographic coordinates.
206206
`GeophysicalModelGenerator` has a number of tools for this.
207-
First we need do define a `projectionPoint` around which we project the data
207+
First we need do define a `ProjectionPoint` around which we project the data
208208

209209
```julia
210-
proj = projectionPoint(Lon=12.0,Lat =43)
210+
proj = ProjectionPoint(Lon=12.0,Lat =43)
211211

212212
Topo_cart = convert2CartData(Topo_Alps, proj)
213213
```
@@ -241,8 +241,8 @@ CartData
241241
Save:
242242

243243
```julia
244-
write_Paraview(Tomo_cart,"Tomo_cart");
245-
write_Paraview(Topo_cart,"Topo_cart");
244+
write_paraview(Tomo_cart,"Tomo_cart");
245+
write_paraview(Topo_cart,"Topo_cart");
246246
```
247247

248248
````
@@ -259,13 +259,13 @@ Yet, because of the curvature of the Earth, the resulting 3D model is not strict
259259
This can be achieved in a relatively straightforward manner, by creating a new 3D dataset that is slightly within the curved boundaries of the projected data set:
260260

261261
```julia
262-
Tomo_rect = CartData(xyzGrid(-550.0:10:600, -500.0:10:700, -600.0:5:-17));
262+
Tomo_rect = CartData(xyz_grid(-550.0:10:600, -500.0:10:700, -600.0:5:-17));
263263
```
264264

265-
the routine `projectCartData` will then project the data from the geographic coordinates to the new rectilinear grid:
265+
the routine `project_CartData` will then project the data from the geographic coordinates to the new rectilinear grid:
266266

267267
```julia
268-
Tomo_rect = projectCartData(Tomo_rect, Tomo_Alps, proj)
268+
Tomo_rect = project_CartData(Tomo_rect, Tomo_Alps, proj)
269269
```
270270

271271
````
@@ -281,8 +281,8 @@ CartData
281281
we can do the same with topography:
282282

283283
```julia
284-
Topo_rect = CartData(xyzGrid(-550.0:1:600, -500.0:1:700, 0))
285-
Topo_rect = projectCartData(Topo_rect, Topo_Alps, proj)
284+
Topo_rect = CartData(xyz_grid(-550.0:1:600, -500.0:1:700, 0))
285+
Topo_rect = project_CartData(Topo_rect, Topo_Alps, proj)
286286
```
287287

288288
````
@@ -298,8 +298,8 @@ CartData
298298
Save it:
299299

300300
```julia
301-
write_Paraview(Tomo_rect,"Tomo_rect");
302-
write_Paraview(Topo_rect,"Topo_rect");
301+
write_paraview(Tomo_rect,"Tomo_rect");
302+
write_paraview(Topo_rect,"Topo_rect");
303303
```
304304

305305
````

docs/src/man/Tutorial_FaultDensity.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,18 @@ data = faults.data[indlon,indlat]
7676
Create GeoData from restricted data
7777

7878
```julia
79-
Lon3D,Lat3D, Faults = lonlatdepthGrid(Lon,Lat,0);
79+
Lon3D,Lat3D, Faults = lonlatdepth_grid(Lon,Lat,0);
8080
Faults[:,:,1] = data
8181
Data_Faults = GeoData(Lon3D,Lat3D,Faults,(Faults=Faults,))
8282
```
8383

8484
## 2. Create Density Map
85-
Create a density map of the fault data. This is done with the `countMap` function. This function takes a specified field of a 2D `GeoData` struct and counts the entries in all control areas which are defined by steplon (number of control areas in lon direction) and steplat (number of control areas in lat direction). The field should only consist of 0.0 and 1.0 and the steplength. The final result is normalized by the highest count.
85+
Create a density map of the fault data. This is done with the `countmap` function. This function takes a specified field of a 2D `GeoData` struct and counts the entries in all control areas which are defined by steplon (number of control areas in lon direction) and steplat (number of control areas in lat direction). The field should only consist of 0.0 and 1.0 and the steplength. The final result is normalized by the highest count.
8686

8787
```julia
8888
steplon = 188
8989
steplat = 104
90-
cntmap = countMap(Data_Faults,"Faults",steplon,steplat)
90+
cntmap = countmap(Data_Faults,"Faults",steplon,steplat)
9191
```
9292

9393
Plot the density map with coastlines
@@ -103,7 +103,7 @@ Plot this using `Plots.jl`:
103103

104104
```julia
105105
heatmap(lon,lat,coastlinesEurope',colormap=cgrad(:gray1,rev=true),alpha=1.0);
106-
heatmap!(lon,lat,cntmap.fields.countMap[:,:,1]',colormap=cgrad(:batlowW,rev=true),alpha = 0.8,legend=true,title="Fault Density Map Europe",ylabel="Lat",xlabel="Lon")
106+
heatmap!(lon,lat,cntmap.fields.countmap[:,:,1]',colormap=cgrad(:batlowW,rev=true),alpha = 0.8,legend=true,title="Fault Density Map Europe",ylabel="Lat",xlabel="Lon")
107107
```
108108

109109
![tutorial_Fault_Map](../assets/img/FaultDensity.png)

0 commit comments

Comments
 (0)