Skip to content

Instantly share code, notes, and snippets.

@tcompa
tcompa / gist:40536a0c3f2ee9c1be6f639abaf6c6ef
Last active November 7, 2023 09:05
First attempt at linkml for ngff image
Start with this yaml file
id: https://w3id.org/linkml/examples/image
name: image
prefixes:
linkml: https://w3id.org/linkml/
image: https://w3id.org/linkml/examples/image
imports:
- linkml:types
default_range: string
{
"title": "CreateOmeZarr",
"type": "object",
"properties": {
"input_paths": {
"title": "Input Paths",
"type": "array",
"items": {
"type": "string"
},
@tcompa
tcompa / gr3d.py
Last active November 22, 2016 13:34
g(r)
def normalized_gr_3d(_samples, _N, _nbins, _rho):
'''
Returns g^{(2)} with the correct normalization, i.e. it goes to
((N-1)/N)*rho^2 for distances which are large, but smaller than L/2.
Args:
_samples :
_N : number of particles
_nbins : number of bins
_rho : number density (number of particle divided by volume)
'''
@tcompa
tcompa / numpy_example.py
Created October 6, 2016 08:08
frequencies
# numpy is the library which allows you to do all sort of calculations,
# and you need to import it at the beginning of the file
import numpy
# this is your function of the two frequencies, needed to construct the matrix
# you need to replace term2 with your own function
def fun(omega1, omega2):
term1 = numpy.exp(- (omega1 - omega2) ** 2 / 1000.0)
term2 = numpy.sinc((omega1 - omega2) ** 2)
return term1 * term2
@tcompa
tcompa / lists_strings.py
Created November 24, 2015 08:51
some fun with python lists/strings
# create and manipulate a list A
A = [1, 2, 3, 7, 3]
print 'A:', A
A.append(19)
print 'A:', A, ', after A.append(19)'
print 'A.index(7): %i' % A.index(7)
print 'A.count(3): %i' % A.count(3)
print 'A[1]:', A[1]
print 'A[-3:]:', A[-3:]
print 'sorted(A):', sorted(A)
@tcompa
tcompa / Plot_Examples.md
Last active August 29, 2015 14:27 — forked from gizmaa/Plot_Examples.md
Various Julia plotting examples using PyPlot