Skip to content

Commit

Permalink
Merge pull request #49 from JuliaGeodynamics/irregular_coords_mt
Browse files Browse the repository at this point in the history
Update data_types.jl
  • Loading branch information
boriskaus authored Feb 27, 2024
2 parents 3e80a17 + 7f3a693 commit d67abd9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 29 deletions.
41 changes: 21 additions & 20 deletions paper/paper.md → docs/paper/paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,34 @@ tags:
- tectonics
- geophysics
authors:
- name: Adrian M. Price-Whelan
orcid: 0000-0000-0000-0000
affiliation: "1, 2" # (Multiple affiliations must be quoted)
- name: Author Without ORCID
equal-contrib: true # (This is how you can denote equal contributions between multiple authors)
- name: Boris J.P. Kaus
orcid: 0000-0002-0247-8660
affiliation: 1 # (Multiple affiliations must be quoted)
- name: Marcel Thielmann
orcid: 0000-0003-1185-3730
affiliation: 2
- name: Author with no affiliation
corresponding: true # (This is how to denote the corresponding author)
affiliation: 3
- given-names: Ludwig
dropping-particle: van
surname: Beethoven
- name: Arne Spang
orcid: 0000-0002-6107-0403
affiliation: 2
- name: Luca de Siena
orcid: 0000-0002-3615-5923
affiliation: 3
- name: Pascal Aellig
#orcid: 0000-0003-1185-3730
affiliation: 1
- name: Jacob Frasukiewicz
#orcid: 0000-0003-1185-3730
affiliation: 1
affiliations:
- name: Lyman Spitzer, Jr. Fellow, Princeton University, USA
- name: Johannes Gutenberg University Mainz, Germany
index: 1
- name: Institution Name, Country
- name: University of Bayreuth, Germany
index: 2
- name: Independent Researcher, Country
- name: Bologna University, Italy
index: 3
date: 13 August 2017
bibliography: paper.bib

# Optional fields if submitting to a AAS journal too, see this blog post:
# https://blog.joss.theoj.org/2018/12/a-new-collaboration-with-aas-publishing
aas-doi: 10.3847/xxxxx <- update this with the DOI from AAS once you know it.
aas-journal: Astrophysical Journal <- The name of the AAS journal.
date: 27 February 2024
bibliography: paper.bib
---

# Summary
Expand Down
16 changes: 8 additions & 8 deletions src/data_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@ struct GeoData <: AbstractGeneralGrid
if isa(lon, StepRangeLen)
lon = Vector(lon);
end

# Check ordering of the arrays in case of 3D
# Check ordering of the arrays in case of 3D -- the check is not bullet proof for now
if sum(size(lon).>1)==3
if maximum(abs.(diff(lon,dims=2)))>maximum(abs.(diff(lon,dims=1))) || maximum(abs.(diff(lon,dims=3)))>maximum(abs.(diff(lon,dims=1)))
@warn "It appears that the lon array has a wrong ordering"
end
if maximum(abs.(diff(lat,dims=1)))>maximum(abs.(diff(lat,dims=2))) || maximum(abs.(diff(lat,dims=3)))>maximum(abs.(diff(lat,dims=2)))
@warn "It appears that the lat array has a wrong ordering"
end
if maximum(abs.(diff(lon,dims=2)))>maximum(abs.(diff(lon,dims=1))) || maximum(abs.(diff(lon,dims=3)))>maximum(abs.(diff(lon,dims=1)))
@warn ("It appears that the lon array has a wrong ordering")
end
if maximum(abs.(diff(lat,dims=1)))>maximum(abs.(diff(lat,dims=2))) || maximum(abs.(diff(lat,dims=3)))>maximum(abs.(diff(lat,dims=2)))
@warn ("It appears that the lat array has a wrong ordering")
end
end

# fields should be a NamedTuple. In case we simply provide an array, lets transfer it accordingly
Expand Down
4 changes: 3 additions & 1 deletion test/test_data_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ Data_set1 = GeoData(Lon,Lat,Depth,(FakeData=Data,Data2=Data.+1.))
@test Value(Data_set1.depth[1,2,3])==-8.0km

# double-check that giving 3D arrays in the wrong ordering triggers a warning message
@test_throws ErrorException("It appears that the lon array has a wrong ordering") GeoData(Lat,Lon,Depth,(FakeData=Data,Data2=Data.+1.))
Data_set2 = GeoData(Lat,Lon,Depth,(FakeData=Data,Data2=Data.+1.))

#@test (test_logger.logs[1].level==Warn && test_logger.logs[1].message=="It appears that the lon array has a wrong ordering")

# Create 2D arrays & convert them
Lon,Lat,Depth = LonLatDepthGrid(10:20,30:40,-50km);
Expand Down

0 comments on commit d67abd9

Please sign in to comment.