-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
31 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,4 +77,4 @@ function nc_aggregate_dir(indir; | |
end | ||
|
||
|
||
export nc_aggregate, nc_aggregate_dir | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
""" | ||
nc_crop(f::String, range, fout::String; | ||
compress=false, overwrite=false, kw...) | ||
只有一个变量的情况。 | ||
""" | ||
function nc_crop(f::String, range::Vector, fout::String; | ||
compress=false, overwrite=false, kw...) | ||
|
||
lon, lat = st_dims(f) | ||
ilon = findall(range[1] .<= lon .<= range[2]) |> zip | ||
ilat = findall(range[3] .<= lat .<= range[4]) |> zip | ||
|
||
A = nc_read(f, ind=(ilon, ilat, :)); | ||
var = nc_bands(f)[1] | ||
_dims = ncvar_dim(f) | ||
_dims["lon"] = _dims["lon"][ilon] | ||
_dims["lat"] = _dims["lat"][ilat] | ||
|
||
nc_write(fout, var, A, _dims; compress, overwrite, kw...) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,4 +114,3 @@ function nc_subset(d::AbstractDataFrame, range; | |
end | ||
|
||
|
||
export nc_subset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
include("nc_aggregate.jl") | ||
include("nc_combine.jl") | ||
include("nc_subset.jl") | ||
include("nc_crop.jl") | ||
|
||
export nc_aggregate, nc_aggregate_dir | ||
export nc_combine | ||
export nc_subset, nc_crop |