Skip to content

Commit

Permalink
Check to ensure you can only download from RectRegions
Browse files Browse the repository at this point in the history
  • Loading branch information
natgeo-wong committed Aug 24, 2024
1 parent ab21029 commit e536e27
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/downloads/downloads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ Arguments
- `overwrite` : `false` by default. If set to true, existing data will be overwritten.
"""
function download(
e5ds :: Union{ERA5Hourly,ERA5Monthly},
e5ds :: ERA5CDStore,
evar :: SingleVariable,
ereg :: ERA5Region;
ispy :: Bool = false,
grib :: Bool = false,
overwrite :: Bool = false
)

downloadcheckereg(ereg)

if ispy
pythonprint(e5ds,evar,ereg)
else; cdsretrieve(e5ds,evar,ereg,grib,overwrite)
Expand Down Expand Up @@ -63,12 +65,13 @@ Arguments
- `overwrite` : `false` by default. If set to true, existing data will be overwritten.
"""
function download(
e5ds :: Union{ERA5Hourly,ERA5Monthly},
e5ds :: ERA5CDStore,
evar :: Vector{SingleVariable},
ereg :: ERA5Region;
overwrite :: Bool = false
)

downloadcheckereg(ereg)
cdsretrieve(e5ds,evar,ereg,overwrite)

end
Expand Down Expand Up @@ -119,6 +122,8 @@ function download(
overwrite :: Bool = false
)

downloadcheckereg(ereg)

if ispy
pythonprint(e5ds,evar,ereg)
else
Expand Down Expand Up @@ -150,6 +155,18 @@ function downloadcheckhPa(

end

function downloadcheckereg(
ereg :: ERA5Region
)

if !(ereg.geo <: RectRegion)

error("$(modulelog()) - ERA5Reanalysis is not yet set up to download GeoRegions that are not RectRegions. Check back in a later update for more.")

end

end

function downloadcheckplvl(
pall :: Bool,
ptop :: Int,
Expand Down

0 comments on commit e536e27

Please sign in to comment.