Skip to content

Commit b03a617

Browse files
committed
specify whether to save or not
1 parent 3e3d98c commit b03a617

File tree

2 files changed

+34
-23
lines changed

2 files changed

+34
-23
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ETOPO"
22
uuid = "eb8fb1ab-fde0-4497-ad36-194d38f2cde7"
33
authors = ["Nathanael Wong <natgeo.wong@outlook.com> and contributors"]
4-
version = "0.1.2"
4+
version = "0.1.3"
55

66
[deps]
77
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

src/get.jl

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ function getLandSea(
2424
geo :: GeoRegion = GeoRegion("GLB");
2525
resolution :: Int = 60,
2626
downloadglb :: Bool = false,
27+
save :: Bool = true,
2728
FT = Float32
2829
)
2930

@@ -65,7 +66,7 @@ function getLandSea(
6566
else
6667
@info "$(modulelog()) - Downloading the Global ETOPO $(uppercase(type)) Relief dataset ..."
6768
flush(stderr)
68-
setup(type,etd.path,resolution)
69+
setupLandSea(type,etd.path,resolution)
6970
end
7071

7172
gds = NCDataset(glbfnc)
@@ -87,10 +88,14 @@ function getLandSea(
8788
rlsm[roro .< 0] .= 0
8889
rlsm[isnan.(roro)] .= NaN
8990

90-
@info "$(modulelog()) - Saving the regional ETOPO Relief data for \"$(geo.ID)\" GeoRegion ..."
91-
flush(stderr)
91+
if save
92+
@info "$(modulelog()) - Saving the regional ETOPO Relief data for \"$(geo.ID)\" GeoRegion ..."
93+
flush(stderr)
94+
95+
saveLandSea(geo,ggrd.lon,ggrd.lat,rlsm,roro,etd.path,type,resolution)
96+
end
9297

93-
save(geo,ggrd.lon,ggrd.lat,rlsm,roro,etd.path,type,resolution)
98+
return LandSeaTopo{FT,FT}(ggrd.lon,ggrd.lat,rlsm,roro)
9499

95100
else
96101

@@ -151,30 +156,36 @@ function getLandSea(
151156
rlsm[roro .< 0] .= 0
152157
rlsm[isnan.(roro)] .= NaN
153158

154-
@info "$(modulelog()) - Saving the regional ETOPO Relief data for \"$(geo.ID)\" GeoRegion ..."
155-
flush(stderr)
156-
157-
save(geo,ggrd.lon,ggrd.lat,rlsm,roro,etd.path,type,resolution)
159+
if save
160+
@info "$(modulelog()) - Saving the regional ETOPO Relief data for \"$(geo.ID)\" GeoRegion ..."
161+
flush(stderr)
162+
163+
saveLandSea(geo,ggrd.lon,ggrd.lat,rlsm,roro,etd.path,type,resolution)
164+
end
165+
166+
return LandSeaTopo{FT,FT}(ggrd.lon,ggrd.lat,rlsm,roro)
158167

159168
end
160169

161-
end
170+
else
162171

163-
lds = NCDataset(lsmfnc)
164-
lon = lds["longitude"][:]
165-
lat = lds["latitude"][:]
166-
lsm = nomissing(lds["lsm"][:,:], NaN)
167-
oro = nomissing(lds["z"][:,:], NaN)
168-
close(lds)
172+
lds = NCDataset(lsmfnc)
173+
lon = lds["longitude"][:]
174+
lat = lds["latitude"][:]
175+
lsm = nomissing(lds["lsm"][:,:], NaN)
176+
oro = nomissing(lds["z"][:,:], NaN)
177+
close(lds)
169178

170-
@info "$(modulelog()) - Retrieving the regional ETOPO $(uppercase(type)) Land-Sea mask for the \"$(geo.ID)\" GeoRegion ..."
171-
flush(stderr)
179+
@info "$(modulelog()) - Retrieving the regional ETOPO $(uppercase(type)) Land-Sea mask for the \"$(geo.ID)\" GeoRegion ..."
180+
flush(stderr)
181+
182+
return LandSeaTopo{FT,FT}(lon,lat,lsm,oro)
172183

173-
return LandSeaTopo{FT,FT}(lon,lat,lsm,oro)
184+
end
174185

175186
end
176187

177-
function save(
188+
function saveLandSea(
178189
geo :: GeoRegion,
179190
lon :: Vector{<:Real},
180191
lat :: Vector{<:Real},
@@ -237,7 +248,7 @@ function save(
237248

238249
end
239250

240-
function setup(
251+
function setupLandSea(
241252
type :: AbstractString,
242253
path :: AbstractString,
243254
resolution :: Int,
@@ -267,7 +278,7 @@ function setup(
267278

268279
close(eds)
269280

270-
save(GeoRegion("GLB"),lon,lat,lsm,oro,etopopath(path),type,resolution)
281+
saveLandSea(GeoRegion("GLB"),lon,lat,lsm,oro,etopopath(path),type,resolution)
271282

272283
rm("tmp.nc",force=true)
273284

@@ -287,6 +298,6 @@ function setup(
287298
rlsm[roro .>= 0] .= 1
288299
rlsm[roro .< 0] .= 0
289300

290-
save(GeoRegion("GLB"),ggrd.lon,ggrd.lat,rlsm,roro,etopopath(path),type,resolution)
301+
saveLandSea(GeoRegion("GLB"),ggrd.lon,ggrd.lat,rlsm,roro,etopopath(path),type,resolution)
291302

292303
end

0 commit comments

Comments
 (0)