Skip to content

Instantly share code, notes, and snippets.

Avatar
🐼
I am a panda.

George Datseris Datseris

🐼
I am a panda.
View GitHub Profile
@Datseris
Datseris / fit_ellipse.jl
Created Jul 4, 2022
Simple Julia code that can fit ellipses to 2D data.
View fit_ellipse.jl
"""
fit_ellipse(x, y) → a, b, θ, x_0, y_0, p
Fit an ellipse into the 2D data defined by `(x, y)`.
Return: semi-major axis length, semi-minor axis length, ellipse rotation,
center coordinates and a parameter container for quadratic form of ellipse,
which is just `M = hcat(x.^2, x.*y, y.^2, x, y); M*p = 1`.
Code modified from:
https://www.matecdev.com/posts/julia-least-squares-qr.html
using a lot of stuff from:
@Datseris
Datseris / schelling.jl
Last active May 7, 2022
Gist of Agents.jl introductory workshop
View schelling.jl
### Step 1: decide space
using Agents
space = GridSpace((10, 10); periodic = false)
### Step 2: make agent type
mutable struct SchellingAgent <: AbstractAgent
id::Int
pos::NTuple{2, Int}
group::Int
@Datseris
Datseris / makie_tutorial.jl
Last active Aug 2, 2022
Making animated and interactive scientific visualizations in Makie.jl
View makie_tutorial.jl
# # Making animated and interactive scientific
# # visualizations in Makie.jl
# Alrighty, in this short tutorial I'll teach you how to make
# animated scientific such as this video, or this application.
# Prerequisitives:
# * Basic familiarity with Julia (obviously)
# * Basic familiarity with Makie.jl
@Datseris
Datseris / phase_interactive.jl
Created Feb 9, 2021
interactive r toggling for phase dependent induced transition
View phase_interactive.jl
using GLMakie, InteractiveDynamics, DynamicalSystems, OrdinaryDiffEq, LinearAlgebra
diffeq = (alg = Tsit5(), dtmax = 0.02, abstol = 1e-6, reltol = 1e-6)
function hassan_alkhayuon(u, p, t) # From talk of Hassan Alkhayuon
r, c, μ, ν, α, β, χ, δ = p
N, P = u
common = α*N*P/+N)
dN = r*N*(1 - (c/r)*N)*((N-μ)/(N+ν)) - common
dP = χ*common - δ*P
return SVector(dN, dP)
@Datseris
Datseris / hassan_alkhayuon_statespace.jl
Last active Feb 9, 2021
Attempts at reproducing phase-tipping plots of https://arxiv.org/abs/2101.12107
View hassan_alkhayuon_statespace.jl
using DynamicalSystems, PyPlot, LinearAlgebra, OrdinaryDiffEq
# ODE solver options:
diffeq = (alg = Vern9(), reltol = 1e-10, abstol = 1e-10)
# non-dimensionalized Rozenweig-MacArthur model
function rozenweig_macarthur(u, p, t)
k, m, c = p
x, y = u
common = m*x*y/(1+x)
xdot = x*(1-x/k) - common
@Datseris
Datseris / mutualinfo.jl
Created Dec 5, 2020
mutual information pure
View mutualinfo.jl
function naivehist(x::AbstractVector, ε::Real)
mi, ma = extrema(x)
hs = zeros(Int((ma-mi)÷ε) + 1)
is = zeros(Int, length(x))
for (j, e) in enumerate(x)
xi = Int((e-mi)÷ε + 1)
hs[xi] += 1
is[j] = xi
end
return hs ./ length(x), is
View xarray_to_climarray.jl
using ClimateBase, Dates
# This needs to numpy, xarray and dask installed from Conda
using PyCall
xr = pyimport("xarray")
np = pyimport("numpy")
"""
climarray_from_xarray(xa, fieldname, name = Symbol(fieldname))
Load underlying field with given `fieldname` from the given xarray instance `xa`,
optionally providing a name for it. This `xa` can be loaded with commands like
@Datseris
Datseris / man.txt
Last active Feb 13, 2020
project manifest
View man.txt
############### in Juno version ####################################
(AlbedoProperties) pkg> st -m
Project AlbedoProperties v0.0.0
Status `C:\Users\m300808\ownCloud\Projects\AlbedoProperties\Manifest.toml`
[621f4979] AbstractFFTs v0.5.0
[85c772de] AbstractNumbers v0.2.1
[537997a7] AbstractPlotting v0.9.17 #master (https://github.com/JuliaPlots/AbstractPlotting.jl.git)
[27a7e980] Animations v0.3.1
[7d9fca2a] Arpack v0.4.0
@Datseris
Datseris / TraceCalls.jl
Created Feb 12, 2020 — forked from pfitzseb/TraceCalls.jl
TraceCalls.jl with Cassette
View TraceCalls.jl
module TraceCalls
using Cassette
mutable struct Trace
level::Int
cutoff::Int
end
Cassette.@context TraceCtx