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
""" | |
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: |
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
### 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 |
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
# # 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 |
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
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) |
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
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 |
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
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 |
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
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 |
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
############### 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 |
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
module TraceCalls | |
using Cassette | |
mutable struct Trace | |
level::Int | |
cutoff::Int | |
end | |
Cassette.@context TraceCtx |
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
*.css |
NewerOlder