Skip to content

Instantly share code, notes, and snippets.

@astrolitterbox
astrolitterbox / JRP_test.py
Created February 1, 2023 15:22
JRP case test
import numpy as np
from pyunicorn.timeseries import RecurrencePlot, RecurrenceNetwork, CrossRecurrencePlot, JointRecurrencePlot
def logistic_map(x0, r, T):
"""
Returns a time series of length T using the logistic map
x_(n+1) = r*x_n(1-x_n) at parameter r and using the initial condition x0.
INPUT: x0 - Initial condition, 0 <= x0 <= 1
@astrolitterbox
astrolitterbox / rekvizitai.txt
Created November 26, 2022 14:12
Technariumo rekvizitai
VšĮ Šviesos kūgiai
LT717044060007931577
paskirtis:
Parama Ukrainos medikams
@astrolitterbox
astrolitterbox / NOW_cleanup.py
Created July 18, 2022 15:22
NOW DB cleanup
import pandas as pd
import numpy as np
taxa = pd.read_csv("Raw_NOW_data/now_export_locsp_2022-04-27.csv", delimiter="\t", na_values = ["\\N", "n", "N"], \
dtype={'MAX_AGE': 'float64', 'MIN_AGE': 'float64', 'LIDNUM': 'int'})
taxa = taxa.fillna(-999)
print(taxa.shape)
NA_g = taxa['GENUS']==-999
@astrolitterbox
astrolitterbox / ex_2.R
Last active March 18, 2021 15:56
2 chapter exercises from Statistical Rethinking
# -------------------- 2E1.
# . Which of the expressions below correspond to the statement: the probability of rain on Monday?
#Pr(rain)
#Pr(rain|Monday)
#Pr(Monday|rain)
#Pr(rain, Monday)/ Pr(Monday)
#2) Pr(rain|Monday)
# ------------------------------ 2E2.
#Which of the following statements corresponds to the expression: Pr(Monday|rain)?
@astrolitterbox
astrolitterbox / rotate.sh
Created January 23, 2019 18:59
Batch rotating pdf files in a repository by 180 degrees
for file in *.PDF; do
pdftk $file cat 1-endsouth output $file"_rot.pdf"
done
@astrolitterbox
astrolitterbox / lightbulbs.py
Created February 18, 2016 19:00
Random locations for lightbulbs. More at http://blog.technarium.lt
from __future__ import division
import math
import matplotlib.pyplot as plt
import numpy as np
width = 200
length = 300
n_lines = 6
min_dist = 10
min_separation = 50
@astrolitterbox
astrolitterbox / sunrise_simulator
Last active April 10, 2021 14:41
Arduino sunrise simulator
int duty = 0;
int steps = 256; //no. of light levels
int sunrisespeed = 20;//no. of pulses, change to ~5400 to have 30min-long sunrise
int minutesUntilSunrise = 0; //change to time until sunrise in minutes
int i;
int j;
int pulsepin = 9;
unsigned long currentMillis = 0;
int previousMillis = 0;
\usepackage{minted}
\begin{document}
\subsection*{Implementation}
\begin{minted}{python}
for i in range(m):
diff = self.dataset - points[:, i, newaxis]
tdiff = dot(self.inv_cov, diff)
energy = sum(diff * tdiff, axis=0) / 2.0
result[i] = sum(exp(-energy), axis=0)
@astrolitterbox
astrolitterbox / write_data_table.py
Last active August 29, 2015 14:23
Rendering a LaTeX table (Astronomy and Astrophysics format) in Python
from __future__ import division
#A decently-looking table in A&A long table format (http://www.aanda.org/author-information/latex-issues/latex-examples#large_tables)
#all the data columns are provided as lists, selected from a database. I cut that part out for clarity.
ofile = open('texts/datatable.tex', 'w')
ofile.write('\documentclass[onecolumn, 11pt]{aa}')
ofile.write('\usepackage{array}\n')
ofile.write('\pagestyle{empty}\n')
ofile.write('\setlength\extrarowheight{4pt}\n')
@astrolitterbox
astrolitterbox / Fit_line.py
Last active August 29, 2015 14:02
A minimal working example of fitting your model to data using SciPy.
# A minimal working example of fitting your model to data using SciPy.
# I rewrote the Cookbook example (http://wiki.scipy.org/Cookbook/FittingData) for a simpler case
# and simpler syntax.
from __future__ import division
from pylab import *
from scipy import *
import numpy as np
from scipy import optimize