Skip to content

Commit 8e2dae2

Browse files
committed
ProfileProcessing.jl
1 parent 95ec8ef commit 8e2dae2

File tree

4 files changed

+54
-54
lines changed

4 files changed

+54
-54
lines changed

docs/src/man/profile_processing.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ load_GMG
1111
save_GMG
1212
CrossSection
1313
ProfileData
14-
ExtractProfileData
15-
CreateProfileData
14+
extractProfileData
15+
createProfileData
1616
GMG_Dataset
17-
Load_Dataset_file
17+
load_Dataset_file
1818
combine_VolData
19-
ExtractProfileData!
20-
ReadPickedProfiles
19+
extractProfileData!
20+
readPickedProfiles
2121
```

docs/src/man/tutorial_ProfileProcessing.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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> extractProfileData!(prof1, VolData_combined, SurfData, PointData)
66+
julia> extractProfileData!(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> extractProfileData!(prof1, VolData_combined, SurfData, PointData, section_width=10km)
7878
```
7979

8080
<!---
@@ -111,7 +111,7 @@ 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
@@ -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+
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)
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+
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)
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+
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)
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 = readPickedProfiles("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 = extractProfileData("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: 15 additions & 15 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, extractProfileData, createProfileData, GMG_Dataset, load_Dataset_file, combine_VolData
6+
export extractProfileData!, readPickedProfiles
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

@@ -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+
extractProfileData!(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 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)
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 readPickedProfiles(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+
extractProfileData(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 extractProfileData(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 = readPickedProfiles(ProfileCoordFile)
395395
profile = profile_list[ProfileNumber]
396396

397397
println("lon start ", profile.start_lonlat[1])
@@ -400,7 +400,7 @@ 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)
@@ -409,7 +409,7 @@ function ExtractProfileData(ProfileCoordFile::String,ProfileNumber::Int64,DataSe
409409
VolData_combined = combine_VolData(VolData)
410410

411411
# project data onto profile:
412-
ExtractProfileData!(profile, VolData_combined, SurfData, PointData,
412+
extractProfileData!(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 extractProfileData(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 createProfileData(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 = extractProfileData(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: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ 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
@@ -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+
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)
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+
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)
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+
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)
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+
extractProfileData!(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 = readPickedProfiles("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 = extractProfileData("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)