Skip to content

Commit ed1b19c

Browse files
committed
address comments
- updated gitignore - changed extract_profile_data back to extract_ProfileData - adapted tests
1 parent 7a50ed9 commit ed1b19c

File tree

5 files changed

+118
-25
lines changed

5 files changed

+118
-25
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: 9 additions & 9 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_profile_data, create_ProfileData, GMG_Dataset, load_dataset_file, combine_vol_data
6-
export extract_profile_data!, read_picked_profiles
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
"""
@@ -348,11 +348,11 @@ end
348348

349349

350350
"""
351-
extract_profile_data!(Profile::ProfileData,VolData::GeoData, SurfData::NamedTuple, PointData::NamedTuple; DimsVolCross=(100,100),Depth_extent=nothing,DimsSurfCross=(100,),section_width=50)
351+
extract_ProfileData!(Profile::ProfileData,VolData::GeoData, SurfData::NamedTuple, PointData::NamedTuple; DimsVolCross=(100,100),Depth_extent=nothing,DimsSurfCross=(100,),section_width=50)
352352
353353
Extracts data along a vertical or horizontal profile
354354
"""
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)
355+
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)
356356

357357
if !isnothing(VolData)
358358
create_profile_volume!(Profile, VolData; DimsVolCross=DimsVolCross, Depth_extent=Depth_extent)
@@ -383,11 +383,11 @@ end
383383

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

392392
# read profile
393393
profile_list = read_picked_profiles(ProfileCoordFile)
@@ -408,7 +408,7 @@ function extract_profile_data(ProfileCoordFile::String,ProfileNumber::Int64,Data
408408
VolData_combined = combine_vol_data(VolData)
409409

410410
# project data onto profile:
411-
extract_profile_data!(profile, VolData_combined, SurfData, PointData,
411+
extract_ProfileData!(profile, VolData_combined, SurfData, PointData,
412412
DimsVolCross=DimsVolCross, DimsSurfCross=DimsSurfCross,
413413
Depth_extent=DepthVol, section_width=WidthPointProfile)
414414

@@ -420,7 +420,7 @@ end
420420
421421
# Boris: I don't know exactly in which format you have your current files;
422422
### wrapper function to extract data for a single profile
423-
function extract_profile_data(ProfileCoordFile,ProfileNumber,DataSetName,DataSetFile,DataSetType,DimsVolCross,DepthVol,DimsSurfCross,WidthPointProfile)
423+
function extract_ProfileData(ProfileCoordFile,ProfileNumber,DataSetName,DataSetFile,DataSetType,DimsVolCross,DepthVol,DimsSurfCross,WidthPointProfile)
424424
425425
# start and end points are saved in a text file
426426
profile_data = readdlm(ProfileCoordFile,skipstart=1,',')
@@ -479,7 +479,7 @@ function create_ProfileData(file_profiles,file_datasets;Depth_extent=(-300,0),Di
479479
for iprofile = 1:length(ProfileNumber)
480480
481481
# 2. process the profiles
482-
ExtractedData = extract_profile_data(file_profiles,ProfileNumber[iprofile],DataSetName,DataSetFile,DataSetType,DimsVolCross,Depth_extent,DimsSurfCross,WidthPointProfile)
482+
ExtractedData = extract_ProfileData(file_profiles,ProfileNumber[iprofile],DataSetName,DataSetFile,DataSetType,DimsVolCross,Depth_extent,DimsSurfCross,WidthPointProfile)
483483
484484
# 3. save data as JLD2
485485
fn = "Profile"*string(ProfileNumber[iprofile])

test/test_ProfileProcessing.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,25 @@ GeophysicalModelGenerator.create_profile_point!(prof4,Data.Point, section_width=
8282

8383

8484
# Test the main profile extraction routines:
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)
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-
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)
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-
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)
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-
extract_profile_data!(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
@@ -121,6 +121,6 @@ Depth_extent=nothing
121121
DimsSurfCross=(100,)
122122
section_width=50km
123123

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)
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

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)