Skip to content

Commit bc5ddcc

Browse files
authored
Allow to run with Julia 1.10 to fix ODINN test env (#163)
* allow to run with Julia 1.10 to fix ODINN test env * fix formatting
1 parent 8eb6f0c commit bc5ddcc

File tree

8 files changed

+31
-9
lines changed

8 files changed

+31
-9
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
cache-name: cache-artifacts
7070
with:
7171
path: ~/.julia/artifacts
72-
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
72+
key: ${{ runner.os }}-${{ runner.version }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
7373
restore-keys: |
7474
${{ runner.os }}-test-${{ env.cache-name }}-
7575
${{ runner.os }}-test-

Project.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ Contour = "0.6"
5353
CoordRefSystems = "0.16, 0.17, 0.18, 0.19"
5454
DataStructures = "0.18, 0.19"
5555
DateFormats = "0.1"
56-
Dates = "1.11"
56+
Dates = "1.10, 1.11"
5757
DimensionalData = "0.29"
58-
Distributed = "1.11"
58+
Distributed = "1.10, 1.11"
5959
Downloads = "1"
6060
FFTW = "1"
6161
GR = "0.73"
@@ -70,16 +70,16 @@ MLStyle = "0.4"
7070
NCDatasets = "0.14"
7171
NaNStatistics = "0.6"
7272
Observables = "0.5"
73-
Pkg = "1.11"
74-
Printf = "1.11"
73+
Pkg = "1.10, 1.11"
74+
Printf = "1.10, 1.11"
7575
Rasters = "0.13, 0.14"
7676
Revise = "3"
7777
Statistics = "1"
7878
Tar = "1"
79-
Test = "1.11"
79+
Test = "1.10, 1.11"
8080
Unitful = "1"
8181
Zygote = "0.7"
82-
julia = "1.11"
82+
julia = "1.10, 1.11"
8383

8484
[extras]
8585
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"

src/glaciers/climate/Climate2D.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,17 @@ A mutable struct representing a 2D climate for a glacier with various buffers an
7676
- `raw_climate::CLIMRAW`: Raw climate dataset for the whole simulation.
7777
7878
- `climate_raw_step::CLIMRAWSTEP`: Raw climate trimmed for the current step to avoid memory allocations.
79+
7980
- `climate_step::ClimateStep`: Climate data for the current step.
81+
8082
- `climate_2D_step::Climate2Dstep`: 2D climate data for the current step to feed to the mass balance (MB) model.
83+
8184
- `longterm_temps::Vector{F}`: Long-term temperatures for the ice rheology.
85+
8286
- `avg_temps::F`: Intermediate buffer for computing average temperatures.
87+
8388
- `avg_gradients::F`: Intermediate buffer for computing average gradients.
89+
8490
- `ref_hgt::F`: Reference elevation of the raw climate data.
8591
8692
Climate2D(
@@ -106,9 +112,13 @@ This function initializes the climate data for a glacier by:
106112
1. Creating a dummy period based on the simulation time span and step.
107113
108114
2. Loading the raw climate data from a NetCDF file.
115+
109116
3. Calculating the cumulative climate data for the dummy period.
117+
110118
4. Downscaling the cumulative climate data to a 2D grid.
119+
111120
5. Retrieving long-term temperature data for the glacier.
121+
112122
6. Returning the climate data, including raw climate data, cumulative climate data, downscaled 2D climate data, long-term temperatures, average temperatures, and average gradients.
113123
114124
Climate2D(

src/glaciers/climate/climate2D_utils.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ This function generates raw climate files for a specified RGI ID if they do not
2626
1. Constructs the path to the RGI directory using the provided `rgi_id` and `simparams`.
2727
2828
2. Checks if the raw climate file for the specified time span already exists.
29+
2930
3. If the file does not exist:
3031
3132
+ Retrieves the raw climate data.
@@ -315,6 +316,7 @@ Downscales climate data to a 2D grid based on the provided matrix of surface ele
315316
+ `"ref_hgt"`: Reference height.
316317
317318
- `S::Matrix{<: AbstractFloat}`: Surface elevation data.
319+
318320
- `Coords::Dict`: A dictionary with keys `"lon"` and `"lat"` for longitude and latitude coordinates.
319321
320322
# Returns

src/glaciers/glacier/glacier2D_utils.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,17 @@ Build glacier object for a given RGI ID and parameters.
213213
- `rgi_id::String`: The RGI ID of the glacier.
214214
215215
- `params::Parameters`: A `Parameters` object containing simulation parameters.
216+
216217
- `masking::Union{Int, Nothing, BitMatrix}`: Type of mask applied to the glacier to determine regions with no ice.
217218
218219
+ When `masking` is an `Int`, the mask is based on the initial ice thickness `H₀` and it is set to true for
219220
pixels outside at a distance of the glacier borders greater than the value of `masking`.
220221
+ When `masking` is set to `nothing`, the mask is set to a `BitMatrix` full of falses.
221222
+ When `masking` is a `BitMatrix`, this matrix is used for the mask.
222223
Defaults to `2`.
224+
223225
- `smoothing::Bool=false`: Optional; whether to apply smoothing to the initial ice thickness. Default is `false`.
226+
224227
- `test::Bool=false`: Optional; test flag. Default is `false`.
225228
226229
# Returns
@@ -752,7 +755,7 @@ end
752755
Return a matrix with booleans indicating if a given pixel is at distance at least
753756
`distance` in the set of non zero values of the matrix. This usually allows
754757
discarding the border pixels of a glacier.
755-
A positive value of `distance`` indicates a measurement from inside the glacier, while a negative `distance`` indicates one from outside.
758+
A positive value of `distance` indicates a measurement from inside the glacier, while a negative `distance` indicates one from outside.
756759
757760
Arguments:
758761

src/simulations/results/results_plotting_utils.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,7 @@ Generate various types of plots for glacier data.
774774
+ "evolution statistics": Temporal statistical metrics for a variable, with optional metrics like "average", "median", "min", "max", and "std".
775775
+ "integrated volume": Temporal evolution of the integrated ice volume for a variable.
776776
+ "bias": Scatter plot to visualize the bias between two variables.
777+
777778
- `variables::Vector{Symbol}`: Variables to be plotted, e.g., `:H`.
778779
779780
# Optional Keyword Arguments

src/simulations/results/results_plotting_video_utils.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,13 @@ Generate various types of videos for glacier data. For now only the evolution of
9191
9292
- `results`: A result object containing the simulation results including ice
9393
thickness over time.
94+
9495
- `glacier`: A glacier instance.
96+
9597
- `tspan`: The simulation time span.
98+
9699
- `step`: Time step to use to retrieve the results and generate the video.
100+
97101
- `pathVideo`: Path of the mp4 file to generate.
98102
99103
# Optional Keyword Arguments

test/runtests.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ function is_included_in_repl()
88
return false
99
end
1010

11+
Pkg.activate(dirname(Base.current_project()))
12+
Pkg.instantiate() # Need this to setup the ODINN env for multiprocessing
1113
if is_included_in_repl()
1214
# The Project.toml of the test environment to be used when running with include is in a subfolder to avoid that Julia uses this file in test mode
13-
Pkg.instantiate()
1415
Pkg.activate(dirname(Base.current_project())*"/test/test_env/")
16+
Pkg.resolve()
1517
end
1618

1719
if !parse(Bool, get(ENV, "CI", "false"))

0 commit comments

Comments
 (0)