Skip to content

Commit

Permalink
Changes for functional inversions
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiBolibar committed May 15, 2024
1 parent 1457060 commit 1dbbcc1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Muninn"
uuid = "4b816528-16ba-4e32-9a2e-3c1bc2049d3a"
authors = ["Jordi Bolibar <[email protected]>"]
version = "0.2.7"
version = "0.3.0"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand All @@ -21,7 +21,7 @@ JLD2 = "0.4"
PyCall = "1"
Reexport = "1"
Revise = "3"
Sleipnir = "0.5"
Sleipnir = "0.6"
julia = "1.9"

[extras]
Expand Down
10 changes: 7 additions & 3 deletions src/models/mass_balance/mass_balance_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ function MB_timestep(model::Model, glacier::G, step::F, t::F) where {F <: Abstra
end


function MB_timestep!(model::Model, glacier::G, step::F, t::F) where {F <: AbstractFloat, G <: AbstractGlacier}
function MB_timestep!(model::Model, glacier::G, step::F, t; batch_id::Union{Nothing, I} = nothing) where {I <: Integer, F <: AbstractFloat, G <: AbstractGlacier}
# First we get the dates of the current time and the previous step
period = partial_year(Day, t - step):Day(1):partial_year(Day, t)

get_cumulative_climate!(glacier.climate, period)

# Convert climate dataset to 2D based on the glacier's DEM
downscale_2D_climate!(glacier)

model.iceflow.MB .= compute_MB(model.mass_balance, glacier.climate.climate_2D_step)
# Simulations using Reverse Diff require an iceflow and mass balance model per glacier
if isnothing(batch_id)
model.iceflow.MB .= compute_MB(model.mass_balance, glacier.climate.climate_2D_step)
else
model.iceflow[batch_id].MB .= compute_MB(model.mass_balance[batch_id], glacier.climate.climate_2D_step)
end
end

2 comments on commit 1dbbcc1

@JordiBolibar
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/106876

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.0 -m "<description of version>" 1dbbcc1689662015e1a1f8cae5d85b1c7354a495
git push origin v0.3.0

Please sign in to comment.