Skip to content

Finish the dryrun option. Download full file when no Vars. Reshuffle code around. #1730

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

Merged
merged 5 commits into from
May 17, 2025
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/GMT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export

# Reexport some from Dates
Year, Month, Week, Day, Hour, Minute, Second, year, month, week, day, hour, minute, second, now, today,
bissextile,

@?, @G, @dir

Expand Down
542 changes: 277 additions & 265 deletions src/extras/weather.jl

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1400,6 +1400,20 @@ function bituncat2(N::Int64)::Tuple{Int, Int}
return parse(Int, s[1:32]; base=2), parse(Int, s[33:64]; base=2)
end

# ---------------------------------------------------------------------------------------------------
"""
bissextile(year::Integer) -> Bool

Extremly fast function to check if a year is bissextile (leap year).
See https://hueffner.de/falk/blog/a-leap-year-check-in-three-instructions.html

It falls back to classic method for years < 0.
"""
function bissextile(year::Integer)::Bool
year >= 0 && return ((year * 1073750999) & 3221352463) <= 126976
(year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0))
end

# ---------------------------------------------------------------------------------------------------
include("makeDCWs.jl")

Expand Down
6 changes: 3 additions & 3 deletions test/test_misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@
var = era5vars(["t2m", "skt"]); # "t2m" is the 2m temperature and "skt" is the skin temperature
dt = era5time(hour=10:14);
@test_throws ArgumentError ecmwf(dataset="reanalysis-era5-land", params=[var, dt], pressure=[1000, 900], region=(-10, 0, 30, 45), key="blabla")
ecmwf(:forecast, time=0, type="fc", stream="oper", levels=["1000", "925"]);
ecmwf(:forecast, var="t", R="PTC", levlist=["1000", "925", "850"], cube=1)
ecmwf(:forecast, var="t", R="PTC", steps=0:3:6, cube=1)
ecmwf(:forecast, time=0, type="fc", stream="oper", levels=["1000", "925"], dryrun=true);
ecmwf(:forecast, var="t", R="PTC", levlist=["1000", "925", "850"])
ecmwf(:forecast, var="t", R="PTC", steps=0:3:6)

# MB-System
println(" MB-System")
Expand Down
3 changes: 3 additions & 0 deletions test/test_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@
n = GMT.bitcat2(10, 20);
n1, n2 = GMT.bituncat2(n);
@test n1 == 10 && n2 == 20

@test !bissextile(100)
@test bissextile(-4)
end
10 changes: 5 additions & 5 deletions test/test_views.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ imshow(I, coast=(land=:red,), show=false)
I = mat2img(rand(UInt16,32,32),x=[220800 453600], y=[3.5535e6 3.7902e6]);
imshow(I, show=false)
x = range(-10, 10, length = 30);
f(x,y) = sqrt(x^2 + y^2);
imshow(x,x,f, Vd=dbg2);
imshow(x,f, Vd=dbg2);
imshow(f, x, Vd=dbg2);
imshow(f, x, x, Vd=dbg2);
f2(x,y) = sqrt(x^2 + y^2);
imshow(x,x,f2, Vd=dbg2);
imshow(x,f2, Vd=dbg2);
imshow(f2, x, Vd=dbg2);
imshow(f2, x, x, Vd=dbg2);
imshow(-2:0.1:2, -1:0.1:3,"rosenbrock", Vd=dbg2);
imshow(-2:0.1:2, "rosenbrock", Vd=dbg2);
imshow("lixo", Vd=dbg2);
Expand Down
Loading