Skip to content

Instantly share code, notes, and snippets.

View ntessore's full-sized avatar

Nicolas Tessore ntessore

View GitHub Profile
@ntessore
ntessore / SVDLIBCSupport.h
Created August 21, 2014 21:35
SVDLIBC support module for Eigen
#ifndef EIGEN_SVDLIBCSUPPORT_H
#define EIGEN_SVDLIBCSUPPORT_H
#include <Eigen/Sparse>
namespace Eigen
{
namespace svdlib_h
{
extern "C"
@ntessore
ntessore / edit
Last active March 9, 2016 11:29
edit: wrapper script to launch editor
#!/bin/bash
##############################################################################
# One command to edit files from the command line. Helps your muscle memory. #
# #
# Do you instinctively write `mate` or `atom` to edit files, only to get #
# told `command not found` because you forgot you are in a SSH session? #
# The `edit` script is a simple wrapper that launches the command specified #
# through the `$EDITOR`, `$VISUAL` or `$EDIT_EDITOR` environment variable. #
# In this way, you will always use the same command to start editing files. #
@ntessore
ntessore / lensed-posterior.ipynb
Created November 9, 2016 10:35
sample posterior analysis for Lensed
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ntessore
ntessore / adsbibq.py
Last active March 27, 2017 08:49
query the ADS bibliography database for a list of bibcodes or the missing citations from a LaTeX log file
#!/usr/bin/env python
####
# small command line tool to get a BibTeX bibliography from ADS bibcodes
#
# $ adsbibq.py '2015A&A...580A..79T' '2016MNRAS.463.3115T'
#
# Query Results from the ADS Database
#
# Retrieved 2 abstracts, starting with number 1. Total number selected: 2.
@ntessore
ntessore / brew-unnecessary.sh
Last active August 17, 2018 14:01
homebrew: list "unneccessary" installed packages (i.e. not needed by any other package)
#!/bin/bash
####
# list "unneccessary" installed packages (i.e. not needed by any other package)
#
# save: $ curl -Lo /usr/local/bin/brew-unnecessary https://git.io/brew-unnecessary
# chmod: $ chmod +x /usr/local/bin/brew-unnecessary
# run: $ brew unnecessary
####
@ntessore
ntessore / window.py
Created June 27, 2019 12:36
CosmoSIS module for window function Cl bias
"""
Module to apply window function matrix to Cls
Compatible with matrices generated by https://github.com/ntessore/clwin.
Configuration:
Add an entry of the form `m_<spectrum> = <matrix.fits>` for each spectrum that
needs to be modified.
@ntessore
ntessore / get_lensed.sh
Created October 18, 2019 12:56
Install MultiNest and Lensed
export FC='/opt/local/bin/gfortran-mp-4.8'
set -e
mkdir lensed
pushd lensed
git clone --depth=1 https://github.com/farhanferoz/MultiNest
pushd MultiNest/MultiNest_v3.11_cmake/multinest
mkdir build
pushd build
@ntessore
ntessore / dl.py
Last active December 7, 2019 08:19
download a file if not already downloaded
# download file if not already downloaded
def dl(url, file=None):
from urllib.request import urlretrieve
from urllib.parse import urlparse
import os.path
if file is None:
file = os.path.basename(urlparse(url).path)
if not os.path.exists(file):
urlretrieve(url, file)
return file
@ntessore
ntessore / fftlognt.py
Last active November 13, 2020 10:13
FFTLog in Python, using only numpy and scipy.special.loggamma
import numpy as np
from scipy.fft import rfft, irfft
from scipy.special import loggamma
# constants
LN_2 = np.log(2)
LN_10 = np.log(10)
@ntessore
ntessore / lnbessel.c
Last active December 6, 2020 14:53
compute the logarithm of Bessel functions of large argument and order
// compute the logarithm of Bessel functions of large argument and order
//
// author: Nicolas Tessore <n.tessore@ucl.ac.uk>
// date: 6 Dec 2020
//
#include <math.h>
// compute the Bessel function ratio J_{nu-1}(x)/J_nu(x) from a continued