Skip to content

Commit 0da46b8

Browse files
authored
Merge pull request #106 from JuliaGeodynamics/mt_fix_function_names
updated function names for profile processing
2 parents 037c2d9 + ed1b19c commit 0da46b8

File tree

6 files changed

+120
-28
lines changed

6 files changed

+120
-28
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ tutorial/test.tiff
2222
*.jld2
2323
*.tiff
2424
*.nc
25+
!/test/test_files/ISCTest.xml

src/ProfileProcessing.jl

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -356,10 +355,10 @@ Extracts data along a vertical or horizontal profile
356355
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)
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
@@ -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

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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,22 @@ 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

test/test_data_import.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ data_Image = screenshot_to_UTMData(filename,Corner_LowerLeft, Corner_
8181

8282
# test the import of xml files from ISC
8383
# the search criteria are set in a way that only one event should be found
84-
download_data("http://www.isc.ac.uk/cgi-bin/web-db-run?request=COLLECTED&req_agcy=ISC-EHB&out_format=QuakeML&ctr_lat=&ctr_lon=&radius=&max_dist_units=deg&searchshape=RECT&top_lat=49&bot_lat=37&left_lon=4&right_lon=20&srn=&grn=&start_year=2000&start_month=1&start_day=01&start_time=00%3A00%3A00&end_year=2005&end_month=12&end_day=31&end_time=00%3A00%3A00&min_dep=&max_dep=&min_mag=5.8&max_mag=&req_mag_type=Any&req_mag_agcy=Any&min_def=&max_def=&include_magnitudes=on&include_links=on&include_headers=on&include_comments=on&table_owner=iscehb","ISCTest.xml")
85-
Data_ISC = getlonlatdepthmag_QuakeML("ISCTest.xml");
84+
# as the download fails quite frequently, the XML file has been added to the repository
85+
# for completeness, the download link is kept here
86+
# download_data("http://www.isc.ac.uk/cgi-bin/web-db-run?request=COLLECTED&req_agcy=ISC-EHB&out_format=QuakeML&ctr_lat=&ctr_lon=&radius=&max_dist_units=deg&searchshape=RECT&top_lat=49&bot_lat=37&left_lon=4&right_lon=20&srn=&grn=&start_year=2000&start_month=1&start_day=01&start_time=00%3A00%3A00&end_year=2005&end_month=12&end_day=31&end_time=00%3A00%3A00&min_dep=&max_dep=&min_mag=5.8&max_mag=&req_mag_type=Any&req_mag_agcy=Any&min_def=&max_def=&include_magnitudes=on&include_links=on&include_headers=on&include_comments=on&table_owner=iscehb","ISCTest.xml")
87+
Data_ISC = getlonlatdepthmag_QuakeML("test_files/ISCTest.xml");
8688
@test Value(Data_ISC.depth[1])==-13.0km
8789
@test Data_ISC.fields.Magnitude[1]==5.8

test/test_files/ISCTest.xml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<q:quakeml xmlns:q="http://quakeml.org/xmlns/quakeml/1.2" xmlns="http://quakeml.org/xmlns/bed/1.2">
4+
<eventParameters publicID="smi:ISCEHB/bulletin">
5+
<creationInfo>
6+
<agencyID>ISC</agencyID>
7+
<creationTime>2024-03-19T09:56:26</creationTime>
8+
</creationInfo>
9+
<description>ISC-EHB Bulletin</description>
10+
<event publicID="smi:ISCEHB/evid=610803926">
11+
<preferredOriginID>smi:ISCEHB/origid=608918847</preferredOriginID>
12+
<description>
13+
<text>Sicily</text>
14+
<type>Flinn-Engdahl region</type>
15+
</description>
16+
<type>earthquake</type>
17+
<typeCertainty>known</typeCertainty>
18+
<creationInfo>
19+
<agencyID>ISC-EHB</agencyID>
20+
<author>ISC-EHB</author>
21+
</creationInfo>
22+
<origin publicID="smi:ISCEHB/origid=608918847">
23+
<time>
24+
<value>2002-09-06T01:21:29.08Z</value>
25+
</time>
26+
<latitude>
27+
<value>38.3200</value>
28+
</latitude>
29+
<longitude>
30+
<value>13.7240</value>
31+
</longitude>
32+
<depth>
33+
<value>13000.0</value>
34+
</depth>
35+
<depthType>operator assigned</depthType>
36+
<quality>
37+
<usedPhaseCount>769</usedPhaseCount>
38+
<associatedStationCount>743</associatedStationCount>
39+
<standardError>0.9500</standardError>
40+
</quality>
41+
<creationInfo>
42+
<author>ISC-EHB</author>
43+
<agencyID>ISC-EHB</agencyID>
44+
</creationInfo>
45+
<evaluationMode>manual</evaluationMode>
46+
<evaluationStatus>reviewed</evaluationStatus>
47+
<originUncertainty>
48+
<preferredDescription>uncertainty ellipse</preferredDescription>
49+
<minHorizontalUncertainty>1700</minHorizontalUncertainty>
50+
<maxHorizontalUncertainty>2600</maxHorizontalUncertainty>
51+
<azimuthMaxHorizontalUncertainty>20.0</azimuthMaxHorizontalUncertainty>
52+
</originUncertainty>
53+
</origin>
54+
<magnitude publicID="smi:ISCEHB/magid=5498826">
55+
<mag>
56+
<value>5.80</value>
57+
</mag>
58+
<type>mb</type>
59+
<originID>smi:ISCEHB/origid=608918847</originID>
60+
<stationCount>118</stationCount>
61+
<creationInfo>
62+
<author>ISC</author>
63+
</creationInfo>
64+
</magnitude>
65+
<magnitude publicID="smi:ISCEHB/magid=5498827">
66+
<mag>
67+
<value>5.50</value>
68+
</mag>
69+
<type>MS</type>
70+
<originID>smi:ISCEHB/origid=608918847</originID>
71+
<stationCount>123</stationCount>
72+
<creationInfo>
73+
<author>ISC</author>
74+
</creationInfo>
75+
</magnitude>
76+
<magnitude publicID="smi:ISCEHB/magid=3622904">
77+
<mag>
78+
<value>5.93</value>
79+
</mag>
80+
<type>MW</type>
81+
<originID>smi:ISCEHB/origid=608918847</originID>
82+
<stationCount>27</stationCount>
83+
<creationInfo>
84+
<author>HRVD</author>
85+
</creationInfo>
86+
</magnitude>
87+
<preferredMagnitudeID>smi:ISCEHB/magid=5498827</preferredMagnitudeID>
88+
</event>
89+
</eventParameters>
90+
</q:quakeml>

0 commit comments

Comments
 (0)