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
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)
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"))
@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 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)
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"))
@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)
@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 / parseprj.jl
Created August 20, 2019 07:04
Parse prj from Shapefile
import Tokenize.Tokens: IDENTIFIER, LSQUARE, COMMA, RSQUARE, STRING, ENDMARKER
function parsetokens(t,ar)
if t[1].kind==Tokenize.Tokens.IDENTIFIER
@assert t[2].kind==LSQUARE
brackcount=1
i=3
while true
t[i].kind==LSQUARE && (brackcount=brackcount+1)
t[i].kind==RSQUARE && (brackcount=brackcount-1)
brackcount==0 && break
FROM jupyter/datascience-notebook:eb149a8c333a
MAINTAINER [email protected]
LABEL version='0.6.1'
USER root
RUN sudo apt-get update && sudo apt-get upgrade -y
RUN sudo apt-get install -y git unzip apt-utils vim
ADD start.sh /usr/local/bin/start.sh
This file has been truncated, but you can view the full file.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import numpy.fft as fft\n",