Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve lat and lon from results without using hasproperty #80

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions src/simulations/results/results_plotting_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,11 @@ function plot_glacier_heatmaps(results::Results, variables::Vector{Symbol}, titl
# Extract the rgi_id
rgi_id = :rgi_id in fieldnames(typeof(results)) ? results.rgi_id : "none"

# Extract longitude and latitude
lon = if hasproperty(results, :lon)
results.lon
else
nothing
end

lat = if hasproperty(results, :lat)
results.lat
else
nothing
end
# Extract longitude and latitude
lon = results.lon
lat = results.lat
Δx = results.Δx

Δx = results.Δx

ice_thickness_vars = [:H, :H₀, :H_glathida, :H_pred, :H_obs] # Ice thickness variables
velocity_vars = [:V, :Vx, :Vy, :V_pred, :V_obs] # Velocity variables, excluding V_diff

Expand Down Expand Up @@ -167,14 +157,14 @@ function plot_glacier_difference_evolution(results::Results, variables::Vector{S

# Extract data for the variable
data = getfield(results, variables[1])
#Extract longitude and latitude
lon = hasproperty(results, :lon) ? results.lon : "none"
lat = hasproperty(results, :lat) ? results.lat : "none"

#Extract longitude and latitude
lon = results.lon
lat = results.lat

#pixel width
Δx = results.Δx

# Check the shape of the extracted data
if typeof(data) ≠ Vector{Matrix{Float64}}
error("Only temporal quantities can be used in this function.")
Expand Down