Skip to content

Instantly share code, notes, and snippets.

View meggart's full-sized avatar

Fabian Gans meggart

  • Max-Planck-Institute for Biogeochemistry
  • Jena, Germany
View GitHub Profile
@meggart
meggart / Pangeo.ipynb
Last active October 16, 2022 21:43
Example of using ESDL with Pangeo data
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@meggart
meggart / gist:e29e6381d9400ff789eefbccc109d6f9
Last active October 7, 2019 10:09
DimensionalData interface proposal.md
using DimensionalData
using GeoData
# Functions to be extended
"""
    gridcoordinates(::Gridtype,x)
module SphericalHarmonics
using FastTransforms
import Geodesy: LLA,distance
immutable PLM{T}
coefs::Matrix{T}
end
function lm2ij(l,m)
l<0 && throw(BoundsError("l must be positive"))
import Interpolations
import Dierckx
function interpolate_data(tsteps_old, tsteps_new, y, options)
# Apply interpolation according to the options
y_interp = if options.interpolation_method == "Dierckx"
if options.boundary_condition == "flat"
s = Dierckx.Spline1D(tsteps_old,y,bc="nearest")
s(tsteps_new)
@meggart
meggart / partialshard.jl
Last active August 17, 2023 16:09
Dagger PartialShards
using Dagger
struct PartialShard
chunks::Dict{Dagger.Processor,Tuple{Dagger.Chunk,Dagger.Chunk}}
end
function partialshard(@nospecialize(f); procs=nothing, workers=nothing, per_thread=false)
if procs === nothing
import DiskArrays: AbstractDiskArray, DiskArrays, Unchunked, Chunked, GridChunks
struct SimpleFileDiskArray{C<:Union{Int,Nothing}} <: AbstractDiskArray{UInt8,1}
file::String
s::Int
chunksize::C
end
Base.size(s::SimpleFileDiskArray) = (s.s,)
function SimpleFileDiskArray(filename;chunksize=nothing)
isfile(filename) || throw(ArgumentError("File $filename does not exist"))
using NetCDF, YAXArrays
import DiskArrayEngine as DAE
ds = open_dataset("/Net/Groups/BGI/data/DataStructureMDI/DATA/Incoming/ESACCI/LC/v2_1_1/orgdata/C3S-LC-L4-LCCS-Map-300m-P1Y-2020-v2.1.1.nc")
lc = ds.lccs_class
c = YAXArrays.counter(lc)
using Distributed
addprocs(16)