Skip to content

Commit b00c61c

Browse files
committed
ProfileProcessing.jl
1 parent 348dc81 commit b00c61c

File tree

4 files changed

+65
-65
lines changed

4 files changed

+65
-65
lines changed

docs/src/man/profile_processing.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ load_GMG
1111
save_GMG
1212
cross_section
1313
ProfileData
14-
extractProfileData
15-
createProfileData
14+
extract_ProfileData
15+
create_ProfileData
1616
GMG_Dataset
17-
load_Dataset_file
18-
combine_VolData
19-
extractProfileData!
20-
readPickedProfiles
17+
load_dataset_file
18+
combine_vol_data
19+
extract_ProfileData!
20+
read_picked_profiles
2121
```

docs/src/man/tutorial_ProfileProcessing.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ julia> keys(Data)
4545

4646
If you want to compare different tomographic datasets with each other, and create votemaps, for example you can merge them all into a single dataset:
4747
```julia
48-
julia> VolData_combined = combine_VolData(VolData, dataset_preferred = 1)
48+
julia> VolData_combined = combine_vol_data(VolData, dataset_preferred = 1)
4949
```
5050
In this case, we take the dimensions of the first dataset and propject all other data onto that. You can customize that.
5151

@@ -62,8 +62,8 @@ Horizontal ProfileData
6262
## Project data onto profiles
6363
You can project all data onto the profiles with:
6464
```julia
65-
julia> extractProfileData!(prof1, VolData_combined, SurfData, PointData)
66-
julia> extractProfileData!(prof2, VolData_combined, SurfData, PointData)
65+
julia> extract_ProfileData!(prof1, VolData_combined, SurfData, PointData)
66+
julia> extract_ProfileData!(prof2, VolData_combined, SurfData, PointData)
6767
julia> prof1
6868
Vertical ProfileData
6969
lon/lat : (5.0, 45.0)-(15.0, 49.0)
@@ -74,7 +74,7 @@ Vertical ProfileData
7474

7575
By default we use 50 km wide band of the data to project pointdata. You can change that with:
7676
```julia
77-
julia> extractProfileData!(prof1, VolData_combined, SurfData, PointData, section_width=10km)
77+
julia> extract_ProfileData!(prof1, VolData_combined, SurfData, PointData, section_width=10km)
7878
```
7979

8080
<!---
@@ -111,21 +111,21 @@ Datasets = [data_Vol1,data_Vol2, data_Surf, data_EQ, data_SS]
111111
@test keys(VolData) == (:Hua2017, :Plomerova2022)
112112
113113
# read datasets from file
114-
Datasets_temp = load_Dataset_file("test_files/AlpineData.txt")
114+
Datasets_temp = load_dataset_file("test_files/AlpineData.txt")
115115
@test Datasets_temp[2].DirName == GMG_Dataset("INGV","Point","./Seismicity/CLASS/class_seis_alps.jld2", true).DirName
116116
117117
# Load data of all Datasets & split them in type of data
118118
DataVol, DataSurf, DataPoint, DataScreenshot, DataTopo = load_GMG(Datasets)
119119
@test keys(DataVol) == (:Hua2017, :Plomerova2022)
120120
121121
# Combine volumetric datasets into one
122-
VolData_combined1 = combine_VolData(VolData)
122+
VolData_combined1 = combine_vol_data(VolData)
123123
@test keys(VolData_combined1.fields) == (:Hua2017_Vp, :Hua2017_dVp_perc, :Plomerova2022_Vp, :Plomerova2022_dVp)
124124
125-
VolData_combined2 = combine_VolData(VolData, dims=(50,51,52))
125+
VolData_combined2 = combine_vol_data(VolData, dims=(50,51,52))
126126
@test VolData_combined2.fields.Hua2017_Vp[1000] ≈ 10.6904
127127
128-
VolData_combined3 = combine_VolData(VolData, lon=(1,22), lat=(40,52), dims=(50,51,52))
128+
VolData_combined3 = combine_vol_data(VolData, lon=(1,22), lat=(40,52), dims=(50,51,52))
129129
@test isnan(VolData_combined3.fields.Hua2017_Vp[1000])
130130
131131
# Define horizontal & vertical profiles
@@ -156,28 +156,28 @@ GeophysicalModelGenerator.CreateProfilePoint!(prof4,PointData, section_width=10k
156156
157157
158158
# Test the main profile extraction routines:
159-
extractProfileData!(prof1, VolData_combined1, SurfData, PointData)
160-
extractProfileData!(prof2, VolData_combined1, SurfData, PointData)
161-
extractProfileData!(prof3, VolData_combined1, SurfData, PointData)
162-
extractProfileData!(prof4, VolData_combined1, SurfData, PointData)
159+
extract_ProfileData!(prof1, VolData_combined1, SurfData, PointData)
160+
extract_ProfileData!(prof2, VolData_combined1, SurfData, PointData)
161+
extract_ProfileData!(prof3, VolData_combined1, SurfData, PointData)
162+
extract_ProfileData!(prof4, VolData_combined1, SurfData, PointData)
163163
164-
extractProfileData!(prof1, VolData_combined2, SurfData, PointData)
165-
extractProfileData!(prof2, VolData_combined2, SurfData, PointData)
166-
extractProfileData!(prof3, VolData_combined2, SurfData, PointData)
167-
extractProfileData!(prof4, VolData_combined2, SurfData, PointData)
164+
extract_ProfileData!(prof1, VolData_combined2, SurfData, PointData)
165+
extract_ProfileData!(prof2, VolData_combined2, SurfData, PointData)
166+
extract_ProfileData!(prof3, VolData_combined2, SurfData, PointData)
167+
extract_ProfileData!(prof4, VolData_combined2, SurfData, PointData)
168168
169-
extractProfileData!(prof1, VolData_combined3, SurfData, PointData)
170-
extractProfileData!(prof2, VolData_combined3, SurfData, PointData)
171-
extractProfileData!(prof3, VolData_combined3, SurfData, PointData)
172-
extractProfileData!(prof4, VolData_combined3, SurfData, PointData)
169+
extract_ProfileData!(prof1, VolData_combined3, SurfData, PointData)
170+
extract_ProfileData!(prof2, VolData_combined3, SurfData, PointData)
171+
extract_ProfileData!(prof3, VolData_combined3, SurfData, PointData)
172+
extract_ProfileData!(prof4, VolData_combined3, SurfData, PointData)
173173
174174
@test prof1.SurfData[1].fields[1][80] ≈ -37.58791461075397km
175175
@test isempty(prof2.SurfData)
176176
@test isnan(prof3.SurfData[1].fields[1][80])
177177
@test isempty(prof4.SurfData)
178178
179179
# Read profiles from file
180-
profile_list = readPickedProfiles("test_files/PickedProfiles.txt")
180+
profile_list = read_picked_profiles("test_files/PickedProfiles.txt")
181181
@test profile_list[5].start_lonlat == ProfileData(start_lonlat=(9.40627872242647, 45.5128223429144), end_lonlat=(7.85480813419117, 47.8635353553922)).start_lonlat
182182
183183
# Try the convenience function
@@ -187,7 +187,7 @@ Depth_extent=nothing
187187
DimsSurfCross=(100,)
188188
section_width=50km
189189
190-
profile_backwards_compat = extractProfileData("test_files/PickedProfiles.txt",1,"test_files/AlpineData_remote.txt",DimsVolCross=DimsVolCross,DepthVol=Depth_extent,DimsSurfCross=DimsSurfCross,WidthPointProfile=section_width)
190+
profile_backwards_compat = extract_ProfileData("test_files/PickedProfiles.txt",1,"test_files/AlpineData_remote.txt",DimsVolCross=DimsVolCross,DepthVol=Depth_extent,DimsSurfCross=DimsSurfCross,WidthPointProfile=section_width)
191191
192192
@test length(profile_backwards_compat.PointData[1].lon) == 440
193193

src/ProfileProcessing.jl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# this is ProfileProcessing.jl
33
# It contains functions and type definitions to gather selected data for given profiles
44

5-
export ProfileData, extractProfileData, createProfileData, GMG_Dataset, load_Dataset_file, combine_VolData
6-
export extractProfileData!, readPickedProfiles
5+
export ProfileData, extract_ProfileData, create_ProfileData, GMG_Dataset, load_dataset_file, combine_vol_data
6+
export extract_ProfileData!, read_picked_profiles
77
import Base: show
88

99
"""
@@ -133,7 +133,7 @@ end
133133

134134
"""
135135
136-
Datasets = load_Dataset_file(file_datasets::String)
136+
Datasets = load_dataset_file(file_datasets::String)
137137
138138
This loads a CSV textfile that lists datasets, which is expected to have the following format:
139139
@@ -149,7 +149,7 @@ Here, the meaning of the variables is:
149149
- `Active`: Do we want this file to be loaded or not? Optional parameter that defaults to `true`
150150
151151
"""
152-
function load_Dataset_file(file_datasets::String)
152+
function load_dataset_file(file_datasets::String)
153153
datasets = readdlm(file_datasets,',',skipstart =1); # read information on datasets to be used from text file
154154
n = size(datasets,1)
155155

@@ -209,13 +209,13 @@ end
209209

210210
"""
211211
212-
VolData_combined = combine_VolData(VolData::NamedTuple; lat=nothing, lon=nothing, depth=nothing, dims=(100,100,100), dataset_preferred = 1)
212+
VolData_combined = combine_vol_data(VolData::NamedTuple; lat=nothing, lon=nothing, depth=nothing, dims=(100,100,100), dataset_preferred = 1)
213213
214214
This takes different volumetric datasets (specified in `VolData`) & merges them into a single one.
215215
You need to either provide the "reference" dataset within the NamedTuple (`dataset_preferred`), or the lat/lon/depth and dimensions of the new dataset.
216216
217217
"""
218-
function combine_VolData(VolData::NamedTuple; lat=nothing, lon=nothing, depth=nothing, dims=(100,100,100), dataset_preferred = 1)
218+
function combine_vol_data(VolData::NamedTuple; lat=nothing, lon=nothing, depth=nothing, dims=(100,100,100), dataset_preferred = 1)
219219

220220
# Get dimensions of new Data_set
221221
i = dataset_preferred
@@ -349,11 +349,11 @@ end
349349

350350

351351
"""
352-
extractProfileData!(Profile::ProfileData,VolData::GeoData, SurfData::NamedTuple, PointData::NamedTuple; DimsVolCross=(100,100),Depth_extent=nothing,DimsSurfCross=(100,),section_width=50)
352+
extract_ProfileData!(Profile::ProfileData,VolData::GeoData, SurfData::NamedTuple, PointData::NamedTuple; DimsVolCross=(100,100),Depth_extent=nothing,DimsSurfCross=(100,),section_width=50)
353353
354354
Extracts data along a vertical or horizontal profile
355355
"""
356-
function extractProfileData!(Profile::ProfileData,VolData::Union{Nothing,GeoData}=nothing, SurfData::NamedTuple=NamedTuple(), PointData::NamedTuple=NamedTuple(); DimsVolCross=(100,100),Depth_extent=nothing,DimsSurfCross=(100,),section_width=50km)
356+
function extract_ProfileData!(Profile::ProfileData,VolData::Union{Nothing,GeoData}=nothing, SurfData::NamedTuple=NamedTuple(), PointData::NamedTuple=NamedTuple(); DimsVolCross=(100,100),Depth_extent=nothing,DimsSurfCross=(100,),section_width=50km)
357357

358358
if !isnothing(VolData)
359359
CreateProfileVolume!(Profile, VolData; DimsVolCross=DimsVolCross, Depth_extent=Depth_extent)
@@ -367,7 +367,7 @@ end
367367
"""
368368
This reads the picked profiles from disk and returns a vector of ProfileData
369369
"""
370-
function readPickedProfiles(ProfileCoordFile::String)
370+
function read_picked_profiles(ProfileCoordFile::String)
371371

372372
profiles = Vector{ProfileData}()
373373
profile_data = readdlm(ProfileCoordFile,skipstart=1,',')
@@ -384,14 +384,14 @@ end
384384

385385
# this is mostly for backwards compatibility
386386
"""
387-
extractProfileData(ProfileCoordFile::String,ProfileNumber::Int64,DataSetFile::String; DimsVolCross=(100,100),DepthVol=nothing,DimsSurfCross=(100,),WidthPointProfile=50km)
387+
extract_ProfileData(ProfileCoordFile::String,ProfileNumber::Int64,DataSetFile::String; DimsVolCross=(100,100),DepthVol=nothing,DimsSurfCross=(100,),WidthPointProfile=50km)
388388
389389
This is a convenience function (mostly for backwards compatibility with the MATLAB GUI) that loads the data from file & projects it onto a profile
390390
"""
391-
function extractProfileData(ProfileCoordFile::String,ProfileNumber::Int64,DataSetFile::String; DimsVolCross=(100,100),DepthVol=nothing,DimsSurfCross=(100,),WidthPointProfile=50km)
391+
function extract_ProfileData(ProfileCoordFile::String,ProfileNumber::Int64,DataSetFile::String; DimsVolCross=(100,100),DepthVol=nothing,DimsSurfCross=(100,),WidthPointProfile=50km)
392392

393393
# read profile
394-
profile_list = readPickedProfiles(ProfileCoordFile)
394+
profile_list = read_picked_profiles(ProfileCoordFile)
395395
profile = profile_list[ProfileNumber]
396396

397397
println("lon start ", profile.start_lonlat[1])
@@ -400,16 +400,16 @@ function extractProfileData(ProfileCoordFile::String,ProfileNumber::Int64,DataSe
400400
println("lat end ", profile.end_lonlat[2])
401401

402402
# read all datasets:
403-
Datasets_all = load_Dataset_file(DataSetFile)
403+
Datasets_all = load_dataset_file(DataSetFile)
404404

405405
# load all Data
406406
VolData, SurfData, PointData, ScreenshotData, TopoData = load_GMG(Datasets_all)
407407

408408
# merge VolData:
409-
VolData_combined = combine_VolData(VolData)
409+
VolData_combined = combine_vol_data(VolData)
410410

411411
# project data onto profile:
412-
extractProfileData!(profile, VolData_combined, SurfData, PointData,
412+
extract_ProfileData!(profile, VolData_combined, SurfData, PointData,
413413
DimsVolCross=DimsVolCross, DimsSurfCross=DimsSurfCross,
414414
Depth_extent=DepthVol, section_width=WidthPointProfile)
415415

@@ -421,7 +421,7 @@ end
421421
422422
# Boris: I don't know exactly in which format you have your current files;
423423
### wrapper function to extract data for a single profile
424-
function extractProfileData(ProfileCoordFile,ProfileNumber,DataSetName,DataSetFile,DataSetType,DimsVolCross,DepthVol,DimsSurfCross,WidthPointProfile)
424+
function extract_ProfileData(ProfileCoordFile,ProfileNumber,DataSetName,DataSetFile,DataSetType,DimsVolCross,DepthVol,DimsSurfCross,WidthPointProfile)
425425
426426
# start and end points are saved in a text file
427427
profile_data = readdlm(ProfileCoordFile,skipstart=1,',')
@@ -463,7 +463,7 @@ end
463463
### currently, the function is quite slow, as the different data sets are reloaded for each profile.
464464
### a faster way would be to load one data set and create the profiles from it and then move on to the next one. However, this would require to hold all the profile data in memory, which may be a bit much...
465465
466-
function createProfileData(file_profiles,file_datasets;Depth_extent=(-300,0),DimsVolCross=(500,300),DimsSurfCross = (100,),WidthPointProfile = 20km)
466+
function create_ProfileData(file_profiles,file_datasets;Depth_extent=(-300,0),DimsVolCross=(500,300),DimsSurfCross = (100,),WidthPointProfile = 20km)
467467
# get the number of profiles
468468
profile_data = readdlm(file_profiles,skipstart=1,',')
469469
NUM = convert.(Int,profile_data[:,1]);
@@ -480,7 +480,7 @@ function createProfileData(file_profiles,file_datasets;Depth_extent=(-300,0),Dim
480480
for iprofile = 1:length(ProfileNumber)
481481
482482
# 2. process the profiles
483-
ExtractedData = extractProfileData(file_profiles,ProfileNumber[iprofile],DataSetName,DataSetFile,DataSetType,DimsVolCross,Depth_extent,DimsSurfCross,WidthPointProfile)
483+
ExtractedData = extract_ProfileData(file_profiles,ProfileNumber[iprofile],DataSetName,DataSetFile,DataSetType,DimsVolCross,Depth_extent,DimsSurfCross,WidthPointProfile)
484484
485485
# 3. save data as JLD2
486486
fn = "Profile"*string(ProfileNumber[iprofile])

test/test_ProfileProcessing.jl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,21 @@ Datasets = [data_Vol1,data_Vol2, data_Surf, data_EQ, data_SS]
3737
@test keys(VolData) == (:Hua2017, :Plomerova2022)
3838

3939
# read datasets from file
40-
Datasets_temp = load_Dataset_file("test_files/AlpineData.txt")
40+
Datasets_temp = load_dataset_file("test_files/AlpineData.txt")
4141
@test Datasets_temp[2].DirName == GMG_Dataset("INGV","Point","./Seismicity/CLASS/class_seis_alps.jld2", true).DirName
4242

4343
# Load data of all Datasets & split them in type of data
4444
Data = load_GMG(Datasets)
4545
@test keys(Data.Volume) == (:Hua2017, :Plomerova2022)
4646

4747
# Combine volumetric datasets into one
48-
VolData_combined1 = combine_VolData(Data.Volume)
48+
VolData_combined1 = combine_vol_data(Data.Volume)
4949
@test keys(VolData_combined1.fields) == (:Hua2017_Vp, :Hua2017_dVp_perc, :Plomerova2022_Vp, :Plomerova2022_dVp)
5050

51-
VolData_combined2 = combine_VolData(Data.Volume, dims=(50,51,52))
51+
VolData_combined2 = combine_vol_data(Data.Volume, dims=(50,51,52))
5252
@test VolData_combined2.fields.Hua2017_Vp[1000] 10.6904
5353

54-
VolData_combined3 = combine_VolData(Data.Volume, lon=(1,22), lat=(40,52), dims=(50,51,52))
54+
VolData_combined3 = combine_vol_data(Data.Volume, lon=(1,22), lat=(40,52), dims=(50,51,52))
5555
@test isnan(VolData_combined3.fields.Hua2017_Vp[1000])
5656

5757
# Define horizontal & vertical profiles
@@ -82,25 +82,25 @@ GeophysicalModelGenerator.CreateProfilePoint!(prof4,Data.Point, section_width=10
8282

8383

8484
# Test the main profile extraction routines:
85-
extractProfileData!(prof1, VolData_combined1, Data.Surface, Data.Point)
86-
extractProfileData!(prof2, VolData_combined1, Data.Surface, Data.Point)
87-
extractProfileData!(prof3, VolData_combined1, Data.Surface, Data.Point)
88-
extractProfileData!(prof4, VolData_combined1, Data.Surface, Data.Point)
85+
extract_ProfileData!(prof1, VolData_combined1, Data.Surface, Data.Point)
86+
extract_ProfileData!(prof2, VolData_combined1, Data.Surface, Data.Point)
87+
extract_ProfileData!(prof3, VolData_combined1, Data.Surface, Data.Point)
88+
extract_ProfileData!(prof4, VolData_combined1, Data.Surface, Data.Point)
8989

90-
extractProfileData!(prof1, VolData_combined2, Data.Surface, Data.Point)
91-
extractProfileData!(prof2, VolData_combined2, Data.Surface, Data.Point)
92-
extractProfileData!(prof3, VolData_combined2, Data.Surface, Data.Point)
93-
extractProfileData!(prof4, VolData_combined2, Data.Surface, Data.Point)
90+
extract_ProfileData!(prof1, VolData_combined2, Data.Surface, Data.Point)
91+
extract_ProfileData!(prof2, VolData_combined2, Data.Surface, Data.Point)
92+
extract_ProfileData!(prof3, VolData_combined2, Data.Surface, Data.Point)
93+
extract_ProfileData!(prof4, VolData_combined2, Data.Surface, Data.Point)
9494

95-
extractProfileData!(prof1, VolData_combined3, Data.Surface, Data.Point)
96-
extractProfileData!(prof2, VolData_combined3, Data.Surface, Data.Point)
97-
extractProfileData!(prof3, VolData_combined3, Data.Surface, Data.Point)
98-
extractProfileData!(prof4, VolData_combined3, Data.Surface, Data.Point)
95+
extract_ProfileData!(prof1, VolData_combined3, Data.Surface, Data.Point)
96+
extract_ProfileData!(prof2, VolData_combined3, Data.Surface, Data.Point)
97+
extract_ProfileData!(prof3, VolData_combined3, Data.Surface, Data.Point)
98+
extract_ProfileData!(prof4, VolData_combined3, Data.Surface, Data.Point)
9999

100100

101101
# Test that it works if only EQ's are provided:
102102
prof4 = ProfileData(depth = -20)
103-
extractProfileData!(prof4, nothing, NamedTuple(), Data.Point)
103+
extract_ProfileData!(prof4, nothing, NamedTuple(), Data.Point)
104104
@test isnothing(prof4.VolData)
105105
@test isempty(prof4.SurfData)
106106
@test length(prof4.PointData[1].depth) == 3280
@@ -111,7 +111,7 @@ extractProfileData!(prof4, nothing, NamedTuple(), Data.Point)
111111
@test isempty(prof4.SurfData)
112112

113113
# Read profiles from file
114-
profile_list = readPickedProfiles("test_files/PickedProfiles.txt")
114+
profile_list = read_picked_profiles("test_files/PickedProfiles.txt")
115115
@test profile_list[5].start_lonlat == ProfileData(start_lonlat=(9.40627872242647, 45.5128223429144), end_lonlat=(7.85480813419117, 47.8635353553922)).start_lonlat
116116

117117
# Try the convenience function
@@ -121,6 +121,6 @@ Depth_extent=nothing
121121
DimsSurfCross=(100,)
122122
section_width=50km
123123

124-
profile_backwards_compat = extractProfileData("test_files/PickedProfiles.txt",1,"test_files/AlpineData_remote.txt",DimsVolCross=DimsVolCross,DepthVol=Depth_extent,DimsSurfCross=DimsSurfCross,WidthPointProfile=section_width)
124+
profile_backwards_compat = extract_ProfileData("test_files/PickedProfiles.txt",1,"test_files/AlpineData_remote.txt",DimsVolCross=DimsVolCross,DepthVol=Depth_extent,DimsSurfCross=DimsSurfCross,WidthPointProfile=section_width)
125125

126126
@test length(profile_backwards_compat.PointData[1].lon) == 440

0 commit comments

Comments
 (0)