-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #242 from JuliaClimate/Balinus-yaxarrays
Update ClimateTools to use YAXArrays backend
- Loading branch information
Showing
20 changed files
with
1,107 additions
and
779 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
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 |
---|---|---|
|
@@ -2,50 +2,29 @@ name = "ClimateTools" | |
uuid = "4f4ee721-4970-5af2-8560-6c1d960e3231" | ||
authors = ["Philippe Roy <[email protected]>"] | ||
repo = "https://github.com/JuliaClimate/ClimateTools.jl.git" | ||
version = "0.24.1" | ||
version = "0.24.2" | ||
|
||
[deps] | ||
ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197" | ||
AxisArrays = "39de3d68-74b9-583c-8d2d-e117c070f3a9" | ||
#ClimateBase = "35604d93-0fb8-4872-9436-495b01d137e2" | ||
CFTime = "179af706-886a-5703-950a-314cd64e0468" | ||
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" | ||
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" | ||
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7" | ||
Extremes = "fe3fe864-1b39-11e9-20b8-1f96fa57382d" | ||
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" | ||
DimensionalData = "0703355e-b756-11e9-17c0-8b28908087d0" | ||
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59" | ||
IterTools = "c8e1da08-722c-5040-9ed9-7db0dc04731e" | ||
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab" | ||
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" | ||
LombScargle = "fc60dff9-86e7-5f2f-a8a0-edeadbb75bd9" | ||
LongMemory = "f5f8e4a8-cb56-40ea-a13e-090cc212d358" | ||
MarSwitching = "b2b8a7f1-da70-4e5f-beaa-e2774ec39c2f" | ||
NetCDF = "30363a11-5582-574a-97bb-aa9a979735b9" | ||
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" | ||
Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" | ||
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca" | ||
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
Reexport = "189a3867-3050-52da-a836-e630ba90ab69" | ||
RollingFunctions = "b0e4dd01-7b14-53d8-9b45-175a3e362653" | ||
Shapefile = "8e980c4a-a4fe-5da2-b3a7-4b4b0353a2f4" | ||
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" | ||
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
YAXArrays = "c21b50f5-aa40-41ea-b809-c0f5e47bfa5c" | ||
Zarr = "0a941bbe-ad1d-11e8-39d9-ab76183a1d99" | ||
|
||
[compat] | ||
ArgCheck = "1, 2" | ||
AxisArrays = "0.3, 0.4" | ||
#ClimateBase = "0.6" | ||
DataFrames = "0.19, 0.20, 0.21, 1" | ||
Distances = "0.7, 0.8, 0.9, 0.10" | ||
Extremes = "0.3" | ||
HDF5 = "0.15, 0.16" | ||
Interpolations = "0.12, 0.13, 0.14" | ||
IterTools = "1" | ||
NCDatasets = "0.9, 0.10, 0.11, 0.12" | ||
NaNMath = "0.3, 1" | ||
NetCDF = "0.7, 0.8, 0.9, 0.10, 0.11" | ||
Polynomials = "0.5, 0.6, 0.7, 0.8, 1" | ||
ProgressMeter = "1" | ||
PyCall = "1" | ||
Reexport = "0.2, 1" | ||
RollingFunctions = "0.6, 0.7" | ||
Shapefile = "0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.10" | ||
julia = "1.5, 1.6, 1.7, 1.8, 1.9" | ||
julia = "1.10" | ||
|
||
[extras] | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
test = ["Test"] |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
using Pkg | ||
using PyCall | ||
# using Pkg | ||
# using PyCall | ||
|
||
if lowercase(get(ENV, "CI", "false")) == "true" | ||
# if lowercase(get(ENV, "CI", "false")) == "true" | ||
|
||
ENV["PYTHON"] = "" | ||
Pkg.build("PyCall") | ||
# ENV["PYTHON"] = "" | ||
# Pkg.build("PyCall") | ||
|
||
end | ||
# 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 |
---|---|---|
@@ -1,209 +1,38 @@ | ||
module ClimateTools | ||
|
||
# External modules | ||
using Reexport | ||
using CFTime | ||
using Dates | ||
using DimensionalData | ||
using LombScargle | ||
using LongMemory | ||
using Statistics | ||
using YAXArrays | ||
using NetCDF | ||
@reexport using NCDatasets | ||
using Shapefile | ||
using AxisArrays | ||
using NaNMath | ||
const axes = Base.axes | ||
using ArgCheck | ||
using DataFrames | ||
using Interpolations | ||
using ProgressMeter | ||
using Zarr | ||
using Polynomials | ||
using IterTools | ||
using Statistics | ||
using Random | ||
using Dates | ||
# using GeoStats | ||
# using InverseDistanceWeighting | ||
using Extremes | ||
using Distances | ||
using PyCall | ||
using RollingFunctions | ||
import Base.vcat | ||
import Base.getindex | ||
import Base.show | ||
import Base.size | ||
import Base.setindex! | ||
import Base.similar | ||
import Base.write | ||
import Statistics.minimum | ||
import Statistics.maximum | ||
import Statistics.std | ||
import Statistics.var | ||
import Statistics.mean | ||
import Statistics.quantile | ||
import Base: + | ||
import Base: - | ||
import Base: * | ||
import Base: / | ||
import Base.findmax | ||
|
||
const scipy = PyNULL() | ||
|
||
function __init__() | ||
copy!(scipy, pyimport_conda("scipy.interpolate", "scipy")) | ||
end | ||
|
||
|
||
# TYPES | ||
|
||
""" | ||
ClimGrid{A <: AxisArray} | ||
In-memory representation of Climate Forecast netCDF files. | ||
struct ClimGrid\n | ||
data::AxisArray # Data\n | ||
longrid::AbstractArray{N,2} where N # the longitude grid\n | ||
latgrid::AbstractArray{N,2} where N # the latitude grid\n | ||
msk::Array{N, 2} where N # Data mask (NaNs and 1.0)\n | ||
grid_mapping::Dict#{String, Any} # bindings for native grid\n | ||
dimension_dict::Dict\n | ||
model::String\n | ||
frequency::String # Day, month, years\n | ||
experiment::String # Historical, RCP4.5, RCP8.5, etc.\n | ||
run::String\n | ||
project::String # CORDEX, CMIP5, etc.\n | ||
institute::String # UQAM, DMI, etc.\n | ||
filename::String # Path of the original file\n | ||
dataunits::String # Celsius, kelvin, etc.\n | ||
latunits::String # latitude coordinate unit\n | ||
lonunits::String # longitude coordinate unit\n | ||
variable::String # Type of variable (i.e. can be the same as "typeofvar", but it is changed when calculating indices)\n | ||
typeofvar::String # Variable type (e.g. tasmax, tasmin, pr)\n | ||
typeofcal::String # Calendar type\n | ||
timeattrib::Dict # Time attributes (e.g. days since ... )\n | ||
varattribs::Dict # Variable attributes dictionary\n | ||
globalattribs::Dict # Global attributes dictionary\n | ||
end\n | ||
""" | ||
struct ClimGrid{A <: AxisArray} | ||
data::A | ||
longrid::Array{N,T} where T where N | ||
latgrid::Array{N,T} where T where N | ||
msk::Array{N,T} where T where N | ||
grid_mapping::Dict # information of native grid | ||
dimension_dict::Dict | ||
timeattrib::Dict | ||
model::String | ||
frequency::String | ||
experiment::String | ||
run::String | ||
project::String | ||
institute::String | ||
filename::String | ||
dataunits::String | ||
latunits::String # of the coordinate variable | ||
lonunits::String # of the coordinate variable | ||
variable::String # Type of variable | ||
typeofvar::String # Variable type (e.g. tasmax, tasmin, pr) | ||
typeofcal::String # Calendar type | ||
varattribs::Dict # Variable attributes | ||
globalattribs::Dict # Global attributes | ||
|
||
end | ||
|
||
""" | ||
ClimGrid(data; longrid=[], latgrid=[], msk=[], grid_mapping=Dict(), dimension_dict=Dict(), model="NA", frequency="NA", experiment="NA", run="NA", project="NA", institute="NA", filename="NA", dataunits="NA", latunits="NA", lonunits="NA", variable="NA", typeofvar="NA", typeofcal="NA", varattribs=Dict(), globalattribs=Dict()) | ||
Constructor of the ClimGrid function. Data is an AxisArray. Everything else is optional, but usually needed for further processing (mapping, interpolation, etc...). | ||
struct ClimGrid\n | ||
data::AxisArray # Data \n | ||
longrid::AbstractArray{N,2} where N # the longitude grid \n | ||
latgrid::AbstractArray{N,2} where N # the latitude grid \n | ||
msk::Array{N, 2} where N # Data mask (NaNs and 1.0) \n | ||
grid_mapping::Dict#{String, Any} # bindings for native grid \n | ||
dimension_dict::Dict\n | ||
model::String\n | ||
frequency::String # Day, month, years\n | ||
experiment::String # Historical, RCP4.5, RCP8.5, etc.\n | ||
run::String\n | ||
project::String # CORDEX, CMIP5, etc.\n | ||
institute::String # UQAM, DMI, etc.\n | ||
filename::String # Path of the original file\n | ||
dataunits::String # Celsius, kelvin, etc.\n | ||
latunits::String # latitude coordinate unit\n | ||
lonunits::String # longitude coordinate unit\n | ||
variable::String # Type of variable (i.e. can be the same as "typeofvar", but it is changed when calculating indices)\n | ||
typeofvar::String # Variable type (e.g. tasmax, tasmin, pr)\n | ||
typeofcal::String # Calendar type\n | ||
timeattrib::Dict # Time attributes (e.g. days since ... )\n | ||
varattribs::Dict # Variable attributes dictionary\n | ||
globalattribs::Dict # Global attributes dictionary\n | ||
end\n | ||
""" | ||
function ClimGrid(data; longrid=[], latgrid=[], msk=[], grid_mapping=Dict(), dimension_dict=Dict(), timeattrib=Dict(), model="NA", frequency="NA", experiment="NA", run="NA", project="NA", institute="NA", filename="NA", dataunits="NA", latunits="NA", lonunits="NA", variable="NA", typeofvar="NA", typeofcal="NA", varattribs=Dict(), globalattribs=Dict()) | ||
|
||
if isempty(dimension_dict) | ||
dimension_dict = Dict(["lon" => "lon", "lat" => "lat"]) | ||
end | ||
|
||
if isempty(msk) | ||
msk = Array{Float64}(ones((size(data, 1), size(data, 2)))) | ||
end | ||
|
||
ClimGrid(data, longrid, latgrid, msk, grid_mapping, dimension_dict, timeattrib, model, frequency, experiment, run, project, institute, filename, dataunits, latunits, lonunits, variable, typeofvar, typeofcal, varattribs, globalattribs) | ||
end | ||
using Interpolations | ||
using DataFrames | ||
using MarSwitching | ||
|
||
# Included files | ||
include("functions.jl") | ||
include("indices.jl") | ||
include("indicators.jl") | ||
include("extract.jl") | ||
include("interface.jl") | ||
include("cf_conventions.jl") | ||
include("aggregate.jl") | ||
include("autocorrelation.jl") | ||
include("biascorrect.jl") | ||
include("export.jl") | ||
include("time.jl") | ||
include("spatial.jl") | ||
include("analysis.jl") | ||
include("climatology.jl") | ||
include("ensembles.jl") | ||
#include("functions.jl") | ||
include("markov.jl") | ||
include("power.jl") | ||
include("plotting.jl") | ||
include("processERA5.jl") | ||
include("utils.jl") | ||
|
||
export ClimGrid | ||
export periodmean | ||
export finitemean | ||
export temporalsubset | ||
export verticalmean | ||
export get_timevec | ||
export buildtimetype | ||
export timeindex | ||
export buildarray_climato | ||
export buildarrayinterface | ||
export buildarray_annual | ||
export buildarray_resample | ||
export inpoly, inpolygrid, meshgrid, inpolyvec, ndgrid | ||
export findmax, findmin | ||
export frostdays, summerdays, icingdays, tropicalnights | ||
export daysabove10 #, daysbelow0, degdaysabove, degdaysbelow | ||
export RXday | ||
export vaporpressure, approx_surfacepressure | ||
export customthresover, customthresunder, annualmax, annualmin | ||
export annualmean, annualsum, prcp1 | ||
export wbgt, diurnaltemperature, meantemperature | ||
export drought_dc | ||
export ensemble_mean, ensemble_std, ensemble_max, ensemble_min | ||
export load, load2D | ||
export regrid, applymask | ||
export griddata | ||
export shapefile_coords, shapefile_coords_poly | ||
export resample, spatialsubset, timestep | ||
export qqmap, qqmaptf | ||
export biascorrect_extremes | ||
export permute_west_east | ||
export getdim_lat, getdim_lon, getdim_tim, isdefined, extractpoly | ||
export get_dimname, get_calendar | ||
export polyfit, polyval | ||
export @isdefined | ||
export merge | ||
export minimum, maximum, std, var, mean | ||
export quantile | ||
export get_max_clusters | ||
export get_position_clusters | ||
export daymean, daysum | ||
export monthmean, monthsum, temporalmean | ||
export yearmonthdayhour | ||
export write, findmindist | ||
|
||
export daily_fct, climato_tp, subsample, dates_builder_yearmonth, dates_builder_yearmonth_hardcode, dates_builder_yearmonthday, dates_builder_yearmonthday_hardcode, diff, cumsum, yearly_clim | ||
export yearly_clim | ||
export qqmap, qqmap_bulk | ||
export ensemble_fct | ||
export autocorrelation | ||
export MSModel | ||
|
||
|
||
end #module | ||
end |
Oops, something went wrong.