Skip to content

Commit 7a50ed9

Browse files
committed
updated function names for profile processing
1 parent 037c2d9 commit 7a50ed9

File tree

3 files changed

+48
-49
lines changed

3 files changed

+48
-49
lines changed

src/ProfileProcessing.jl

Lines changed: 19 additions & 20 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, extract_ProfileData, create_ProfileData, GMG_Dataset, load_dataset_file, combine_vol_data
6-
export extract_ProfileData!, read_picked_profiles
5+
export ProfileData, extract_profile_data, create_ProfileData, GMG_Dataset, load_dataset_file, combine_vol_data
6+
export extract_profile_data!, read_picked_profiles
77
import Base: show
88

99
"""
@@ -251,11 +251,11 @@ end
251251

252252

253253
"""
254-
CreateProfileVolume!(Profile::ProfileData, VolData::AbstractGeneralGrid; DimsVolCross::NTuple=(100,100), Depth_extent=nothing)
254+
create_profile_volume!(Profile::ProfileData, VolData::AbstractGeneralGrid; DimsVolCross::NTuple=(100,100), Depth_extent=nothing)
255255
256256
Creates a cross-section through a volumetric 3D dataset `VolData` with the data supplied in `Profile`. `Depth_extent` can be the minimum & maximum depth for vertical profiles
257257
"""
258-
function CreateProfileVolume!(Profile::ProfileData, VolData::AbstractGeneralGrid; DimsVolCross::NTuple=(100,100), Depth_extent=nothing)
258+
function create_profile_volume!(Profile::ProfileData, VolData::AbstractGeneralGrid; DimsVolCross::NTuple=(100,100), Depth_extent=nothing)
259259

260260
if Profile.vertical
261261
# take a vertical cross section
@@ -276,7 +276,7 @@ end
276276

277277

278278
### internal function to process surface data - contrary to the volume data, we here have to save lon/lat/depth pairs for every surface data set, so we create a NamedTuple of GeoData data sets
279-
function CreateProfileSurface!(Profile::ProfileData, DataSet::NamedTuple; DimsSurfCross=(100,))
279+
function create_profile_surface!(Profile::ProfileData, DataSet::NamedTuple; DimsSurfCross=(100,))
280280
num_datasets = length(DataSet)
281281

282282
tmp = NamedTuple() # initialize empty one
@@ -309,9 +309,8 @@ function CreateProfileSurface!(Profile::ProfileData, DataSet::NamedTuple; DimsSu
309309
end
310310

311311

312-
313312
### function to process point data - contrary to the volume data, we here have to save lon/lat/depth pairs for every point data set
314-
function CreateProfilePoint!(Profile::ProfileData, DataSet::NamedTuple; section_width=50km)
313+
function create_profile_point!(Profile::ProfileData, DataSet::NamedTuple; section_width=50km)
315314
num_datasets = length(DataSet)
316315

317316
tmp = NamedTuple() # initialize empty one
@@ -349,17 +348,17 @@ end
349348

350349

351350
"""
352-
extract_ProfileData!(Profile::ProfileData,VolData::GeoData, SurfData::NamedTuple, PointData::NamedTuple; DimsVolCross=(100,100),Depth_extent=nothing,DimsSurfCross=(100,),section_width=50)
351+
extract_profile_data!(Profile::ProfileData,VolData::GeoData, SurfData::NamedTuple, PointData::NamedTuple; DimsVolCross=(100,100),Depth_extent=nothing,DimsSurfCross=(100,),section_width=50)
353352
354353
Extracts data along a vertical or horizontal profile
355354
"""
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)
355+
function extract_profile_data!(Profile::ProfileData,VolData::Union{Nothing,GeoData}=nothing, SurfData::NamedTuple=NamedTuple(), PointData::NamedTuple=NamedTuple(); DimsVolCross=(100,100),Depth_extent=nothing,DimsSurfCross=(100,),section_width=50km)
357356

358357
if !isnothing(VolData)
359-
CreateProfileVolume!(Profile, VolData; DimsVolCross=DimsVolCross, Depth_extent=Depth_extent)
358+
create_profile_volume!(Profile, VolData; DimsVolCross=DimsVolCross, Depth_extent=Depth_extent)
360359
end
361-
CreateProfileSurface!(Profile, SurfData, DimsSurfCross=DimsSurfCross)
362-
CreateProfilePoint!(Profile, PointData, section_width=section_width)
360+
create_profile_surface!(Profile, SurfData, DimsSurfCross=DimsSurfCross)
361+
create_profile_point!(Profile, PointData, section_width=section_width)
363362

364363
return nothing
365364
end
@@ -384,11 +383,11 @@ end
384383

385384
# this is mostly for backwards compatibility
386385
"""
387-
extract_ProfileData(ProfileCoordFile::String,ProfileNumber::Int64,DataSetFile::String; DimsVolCross=(100,100),DepthVol=nothing,DimsSurfCross=(100,),WidthPointProfile=50km)
386+
extract_profile_data(ProfileCoordFile::String,ProfileNumber::Int64,DataSetFile::String; DimsVolCross=(100,100),DepthVol=nothing,DimsSurfCross=(100,),WidthPointProfile=50km)
388387
389388
This is a convenience function (mostly for backwards compatibility with the MATLAB GUI) that loads the data from file & projects it onto a profile
390389
"""
391-
function extract_ProfileData(ProfileCoordFile::String,ProfileNumber::Int64,DataSetFile::String; DimsVolCross=(100,100),DepthVol=nothing,DimsSurfCross=(100,),WidthPointProfile=50km)
390+
function extract_profile_data(ProfileCoordFile::String,ProfileNumber::Int64,DataSetFile::String; DimsVolCross=(100,100),DepthVol=nothing,DimsSurfCross=(100,),WidthPointProfile=50km)
392391

393392
# read profile
394393
profile_list = read_picked_profiles(ProfileCoordFile)
@@ -409,7 +408,7 @@ function extract_ProfileData(ProfileCoordFile::String,ProfileNumber::Int64,DataS
409408
VolData_combined = combine_vol_data(VolData)
410409

411410
# project data onto profile:
412-
extract_ProfileData!(profile, VolData_combined, SurfData, PointData,
411+
extract_profile_data!(profile, VolData_combined, SurfData, PointData,
413412
DimsVolCross=DimsVolCross, DimsSurfCross=DimsSurfCross,
414413
Depth_extent=DepthVol, section_width=WidthPointProfile)
415414

@@ -421,7 +420,7 @@ end
421420
422421
# Boris: I don't know exactly in which format you have your current files;
423422
### wrapper function to extract data for a single profile
424-
function extract_ProfileData(ProfileCoordFile,ProfileNumber,DataSetName,DataSetFile,DataSetType,DimsVolCross,DepthVol,DimsSurfCross,WidthPointProfile)
423+
function extract_profile_data(ProfileCoordFile,ProfileNumber,DataSetName,DataSetFile,DataSetType,DimsVolCross,DepthVol,DimsSurfCross,WidthPointProfile)
425424
426425
# start and end points are saved in a text file
427426
profile_data = readdlm(ProfileCoordFile,skipstart=1,',')
@@ -446,13 +445,13 @@ function extract_ProfileData(ProfileCoordFile,ProfileNumber,DataSetName,DataSetF
446445
ind_point = findall( x -> x .== "Point", DataSetType)
447446
448447
# extract volume data
449-
CreateProfileVolume!(Profile,DataSetName[ind_vol],DataSetFile[ind_vol],DimsVolCross,DepthVol)
448+
create_profile_volume!(Profile,DataSetName[ind_vol],DataSetFile[ind_vol],DimsVolCross,DepthVol)
450449
451450
# extract surface data
452-
CreateProfileSurface!(Profile,DataSetName[ind_surf],DataSetFile[ind_surf],DimsSurfCross)
451+
create_profile_surface!(Profile,DataSetName[ind_surf],DataSetFile[ind_surf],DimsSurfCross)
453452
454453
# extract point data
455-
CreateProfilePoint!(Profile,DataSetName[ind_point],DataSetFile[ind_point],WidthPointProfile)
454+
create_profile_point!(Profile,DataSetName[ind_point],DataSetFile[ind_point],WidthPointProfile)
456455
457456
return Profile
458457
end
@@ -480,7 +479,7 @@ function create_ProfileData(file_profiles,file_datasets;Depth_extent=(-300,0),Di
480479
for iprofile = 1:length(ProfileNumber)
481480
482481
# 2. process the profiles
483-
ExtractedData = extract_ProfileData(file_profiles,ProfileNumber[iprofile],DataSetName,DataSetFile,DataSetType,DimsVolCross,Depth_extent,DimsSurfCross,WidthPointProfile)
482+
ExtractedData = extract_profile_data(file_profiles,ProfileNumber[iprofile],DataSetName,DataSetFile,DataSetType,DimsVolCross,Depth_extent,DimsSurfCross,WidthPointProfile)
484483
485484
# 3. save data as JLD2
486485
fn = "Profile"*string(ProfileNumber[iprofile])

src/utils.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ GeoData
124124
"""
125125
function cross_section_volume(V::AbstractGeneralGrid; dims=(100,100), Interpolate=false, Depth_level=nothing, Lat_level=nothing, Lon_level=nothing, Start=nothing, End=nothing, Depth_extent=nothing )
126126

127-
DataSetType = CheckDataSet(V);
127+
DataSetType = check_data_set(V);
128128

129129
if DataSetType != 3
130130
error("cross_section_volume: the input data set has to be a volume!")
@@ -253,7 +253,7 @@ GeoData
253253
"""
254254
function cross_section_surface(S::AbstractGeneralGrid; dims=(100,), Interpolate=true, Depth_level=nothing, Lat_level=nothing, Lon_level=nothing, Start=nothing, End=nothing )
255255

256-
DataSetType = CheckDataSet(S);
256+
DataSetType = check_data_set(S);
257257
if DataSetType != 2
258258
error("cross_section_surface: the input data set has to be a surface!")
259259
end
@@ -337,7 +337,7 @@ Creates a projection of separate points (saved as a GeoData object) onto a chose
337337
"""
338338
function cross_section_points(P::GeoData; Depth_level=nothing, Lat_level=nothing, Lon_level=nothing, Start=nothing, End=nothing, section_width = 10km)
339339

340-
DataSetType = CheckDataSet(P);
340+
DataSetType = check_data_set(P);
341341
if DataSetType != 1
342342
error("cross_section_points: the input data set has to be a pointwise data set!")
343343
end
@@ -529,7 +529,7 @@ GeoData
529529
"""
530530
function 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)
531531

532-
DataSetType = CheckDataSet(DataSet); # check which kind of data set we are dealing with
532+
DataSetType = check_data_set(DataSet); # check which kind of data set we are dealing with
533533

534534
if DataSetType==1 # points
535535
DataProfile = cross_section_points(DataSet; Depth_level, Lat_level, Lon_level, Start, End, section_width)
@@ -814,7 +814,7 @@ function extract_subvolume(V::CartData;
814814
X_cross[i,j,1] = x_val
815815
end
816816

817-
Data_extract = InterpolateDataFields_CrossSection(V, X, Y, Z, X_cross);
817+
Data_extract = interpolate_data_fields_cross_section(V, X, Y, Z, X_cross);
818818

819819
else
820820
# Don't interpolate
@@ -838,11 +838,11 @@ end
838838

839839

840840
"""
841-
InterpolateDataFields_CrossSection(V::CartData, X,Y,Z,Xcross)
841+
interpolate_data_fields_cross_section(V::CartData, X,Y,Z,Xcross)
842842
843843
Interpolates data fields along a cross-section defined by `Xcross` and `Z`
844844
"""
845-
function InterpolateDataFields_CrossSection(V::CartData, X,Y,Z, X_cross)
845+
function interpolate_data_fields_cross_section(V::CartData, X,Y,Z, X_cross)
846846

847847
Data_extract = CartData(X,Y,Z, (FlatCrossSection=X_cross,))
848848

@@ -895,7 +895,7 @@ function CheckBounds(Data::AbstractArray, Data_Cross)
895895
end
896896

897897
# CHECKS FOR VOLUME, SURFACE OR POINTS
898-
function CheckDataSet(DataSet::GeoData)
898+
function check_data_set(DataSet::GeoData)
899899
if length(size(DataSet.lon)) == 1 # scattered points
900900
return 1
901901
else
@@ -907,7 +907,7 @@ function CheckDataSet(DataSet::GeoData)
907907
end
908908
end
909909

910-
function CheckDataSet(DataSet::CartData)
910+
function check_data_set(DataSet::CartData)
911911
if length(size(DataSet.x)) == 1 # scattered points
912912
return 1
913913
else

test/test_ProfileProcessing.jl

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,46 +61,46 @@ prof3 = ProfileData(start_lonlat=(5,45), end_lonlat=(5,49))
6161
prof4 = ProfileData(depth = -20)
6262

6363
# test internal routines to intersect profile with volumetric data:
64-
GeophysicalModelGenerator.CreateProfileVolume!(prof1, VolData_combined1)
64+
GeophysicalModelGenerator.create_profile_volume!(prof1, VolData_combined1)
6565
@test prof1.VolData.fields.Hua2017_Vp[30,40] 9.141520976523731
6666

67-
GeophysicalModelGenerator.CreateProfileVolume!(prof2, VolData_combined1)
67+
GeophysicalModelGenerator.create_profile_volume!(prof2, VolData_combined1)
6868
@test prof2.VolData.fields.Hua2017_Vp[30,40] 8.177263544536272
6969

70-
GeophysicalModelGenerator.CreateProfileVolume!(prof1, VolData_combined1, Depth_extent=(-300, -100))
70+
GeophysicalModelGenerator.create_profile_volume!(prof1, VolData_combined1, Depth_extent=(-300, -100))
7171
@test extrema(prof1.VolData.depth.val) == (-300.0, -100.0)
7272

7373
# Intersect surface data:
74-
GeophysicalModelGenerator.CreateProfileSurface!(prof1,Data.Surface)
74+
GeophysicalModelGenerator.create_profile_surface!(prof1,Data.Surface)
7575
@test prof1.SurfData[1].fields.MohoDepth[80] -37.58791461075397km
7676

7777
# ditto with EQ data:
78-
GeophysicalModelGenerator.CreateProfilePoint!(prof1,Data.Point, section_width=5km)
79-
GeophysicalModelGenerator.CreateProfilePoint!(prof4,Data.Point, section_width=10km)
78+
GeophysicalModelGenerator.create_profile_point!(prof1,Data.Point, section_width=5km)
79+
GeophysicalModelGenerator.create_profile_point!(prof4,Data.Point, section_width=10km)
8080
@test length(prof1.PointData[1].lon) == 13
8181
@test length(prof4.PointData[1].lon) == 445
8282

8383

8484
# Test the main profile extraction routines:
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)
85+
extract_profile_data!(prof1, VolData_combined1, Data.Surface, Data.Point)
86+
extract_profile_data!(prof2, VolData_combined1, Data.Surface, Data.Point)
87+
extract_profile_data!(prof3, VolData_combined1, Data.Surface, Data.Point)
88+
extract_profile_data!(prof4, VolData_combined1, Data.Surface, Data.Point)
8989

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)
90+
extract_profile_data!(prof1, VolData_combined2, Data.Surface, Data.Point)
91+
extract_profile_data!(prof2, VolData_combined2, Data.Surface, Data.Point)
92+
extract_profile_data!(prof3, VolData_combined2, Data.Surface, Data.Point)
93+
extract_profile_data!(prof4, VolData_combined2, Data.Surface, Data.Point)
9494

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)
95+
extract_profile_data!(prof1, VolData_combined3, Data.Surface, Data.Point)
96+
extract_profile_data!(prof2, VolData_combined3, Data.Surface, Data.Point)
97+
extract_profile_data!(prof3, VolData_combined3, Data.Surface, Data.Point)
98+
extract_profile_data!(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-
extract_ProfileData!(prof4, nothing, NamedTuple(), Data.Point)
103+
extract_profile_data!(prof4, nothing, NamedTuple(), Data.Point)
104104
@test isnothing(prof4.VolData)
105105
@test isempty(prof4.SurfData)
106106
@test length(prof4.PointData[1].depth) == 3280
@@ -121,6 +121,6 @@ Depth_extent=nothing
121121
DimsSurfCross=(100,)
122122
section_width=50km
123123

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)
124+
profile_backwards_compat = extract_profile_data("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)