Draft
Conversation
Added a preselection of points to cross_section_points to reduce the number of e.g. earthquakes that have to be processed when a global dataset is used.
|
Your PR requires formatting changes to meet the project's style guidelines. Click here to view the suggested changes.diff --git a/src/utils.jl b/src/utils.jl
index 2158df2..aba995f 100644
--- a/src/utils.jl
+++ b/src/utils.jl
@@ -444,7 +444,7 @@ function cross_section_points(P::GeoData; Depth_level = nothing, Lat_level = not
end
if !isnothing(Lon_level) # vertical slice @ given longitude
-
+
# to define the projection point, only choose events close to the desired profile
p_Point = ProjectionPoint(Lat = sum(P.lat.val) / length(P.lat.val), Lon = Lon_level) # define the projection point (lat/lon) as the latitude and the mean of the longitudes of the data
P_UTM = convert2UTMzone(P, p_Point) # convert to UTM
@@ -474,22 +474,22 @@ function cross_section_points(P::GeoData; Depth_level = nothing, Lat_level = not
# convert P to UTM Data
# to avoid projection issues, reduce the given point data set to a set that is located abound the desired profile
# to choose the subset, we use a box around the profile with the profile width being added to the start and end points of the profile
- # approximate formula:
+ # approximate formula:
# Latitude: 1 deg = 110.574 km --> 1 km = 1/110.574 deg
- # Longitude: 1 deg = 111.320*cos(latitude) km --> 1km = 1/ 111.320 / cos(latitude)
- lat_add = 1.1 * ustrip(uconvert(u"km", section_width))/110.574 # multiply with 1.1 to make sure the box is large enough
- lat_start = minimum([Start[2],End[2]]) - lat_add;
- lat_end = maximum([Start[2],End[2]]) + lat_add;
-
- lon_add = 1.1*ustrip(uconvert(u"km", section_width))/111.3209
+ # Longitude: 1 deg = 111.320*cos(latitude) km --> 1km = 1/ 111.320 / cos(latitude)
+ lat_add = 1.1 * ustrip(uconvert(u"km", section_width)) / 110.574 # multiply with 1.1 to make sure the box is large enough
+ lat_start = minimum([Start[2], End[2]]) - lat_add
+ lat_end = maximum([Start[2], End[2]]) + lat_add
+
+ lon_add = 1.1 * ustrip(uconvert(u"km", section_width)) / 111.3209
- lon_start = minimum([Start[1],End[1]]) - lon_add/cos(deg2rad(minimum([Start[1],End[1]])))
- lon_end = maximum([Start[1],End[1]]) + lon_add/cos(deg2rad(maximum([Start[1],End[1]])))
+ lon_start = minimum([Start[1], End[1]]) - lon_add / cos(deg2rad(minimum([Start[1], End[1]])))
+ lon_end = maximum([Start[1], End[1]]) + lon_add / cos(deg2rad(maximum([Start[1], End[1]])))
- ind = findall( (lon_start .< P.lon.val .< lon_end) .& (lat_start .< P.lat.val .< lat_end))
+ ind = findall((lon_start .< P.lon.val .< lon_end) .& (lat_start .< P.lat.val .< lat_end))
- # now create a GeoData structure that only contains the subset, fields Magnitude and depth are hardcoded, more
- P_sub = GeoData(P.lon.val[ind], P.lat.val[ind], P.depth.val[ind], (Magnitude=P.fields.Magnitude[ind],Depth=P.fields.Depth[ind]))
+ # now create a GeoData structure that only contains the subset, fields Magnitude and depth are hardcoded, more
+ P_sub = GeoData(P.lon.val[ind], P.lat.val[ind], P.depth.val[ind], (Magnitude = P.fields.Magnitude[ind], Depth = P.fields.Depth[ind]))
P_UTM = convert2UTMzone(P_sub, p_Point) # convert to UTM
# create a GeoData set containing the points that create the profile plane (we need three points to uniquely define that plane) |
Contributor
Author
|
Tests are failing right now as the number of points after creating a profile are less than anticipated. I'm looking into that to see what is happening. |
| lon_start = minimum([Start[1],End[1]]) - lon_add/cos(deg2rad(minimum([Start[1],End[1]]))) | ||
| lon_end = maximum([Start[1],End[1]]) + lon_add/cos(deg2rad(maximum([Start[1],End[1]]))) | ||
|
|
||
| ind = findall( (lon_start .< P.lon.val .< lon_end) .& (lat_start .< P.lat.val .< lat_end)) |
Member
There was a problem hiding this comment.
Suggested change
| ind = findall( (lon_start .< P.lon.val .< lon_end) .& (lat_start .< P.lat.val .< lat_end)) | |
| ind = @. (lon_start < P.lon.val < lon_end) & (lat_start < P.lat.val < lat_end) |
I think you can get away without findall here
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added a preselection of points to cross_section_points to reduce the number of e.g. earthquakes that have to be processed when a global dataset is used. (#160)