Skip to content

Instantly share code, notes, and snippets.

View zonca's full-sized avatar

Andrea Zonca zonca

View GitHub Profile
@zonca
zonca / testFEVbr.cpp
Created February 16, 2011 22:15
test trilinos FEVBr
#include <list>
#include <string>
#include <math.h>
#include "Epetra_ConfigDefs.h"
#ifdef HAVE_MPI
#include "mpi.h"
#include "Epetra_MpiComm.h"
#else
#include "Epetra_SerialComm.h"
@zonca
zonca / testFEVbr_extract.cpp
Created February 19, 2011 03:46
testing ExtractEntryView
#include <list>
#include <string>
#include <math.h>
#include "Epetra_ConfigDefs.h"
#ifdef HAVE_MPI
#include "mpi.h"
#include "Epetra_MpiComm.h"
#else
#include "Epetra_SerialComm.h"
@zonca
zonca / run.sh
Created February 28, 2011 23:54
Trilinos VbrMatrix ram usage
g++ -O2 testVBR.cpp -ltrilinos_epetra -I/usr/include/trilinos/ -I/usr/include/openmpi -o testVBR && mpirun -n 2 ./testVBR
cmake_minimum_required (VERSION 2.6)
project(testTP)
include_directories("/usr/include/trilinos/", "/usr/include/openmpi")
add_executable(testTP testTP.cpp)
target_link_libraries(testTP trilinos_epetra)
@zonca
zonca / pyfitsleak.py
Created March 23, 2011 23:59
memory leakage in pyfits.new_table
import objgraph
import pyfits
import gc
import numpy as np
print("Create table")
#a=pyfits.Column(name='',format='K',array=[1,2,3]) # Column instead correctly frees up memory
a=pyfits.new_table([pyfits.Column(name='',format='K',array=[1,2,3])])
print("Delete table")
@zonca
zonca / oneoverfsim.py
Created May 18, 2011 22:21
Pink noise
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import mlab
def one_over_f(f, knee, alpha):
desc = np.ones_like(f)
desc[f<KNEE] = np.abs((f[f<KNEE]/KNEE)**(-alpha))
desc[0] = 1
return desc
@zonca
zonca / vec2angexample
Created July 13, 2011 17:59
healpy vec2ang
import healpy
vec=np.array([[0, 0, 1], [1, 0, 0]])
theta, phi = healpy.vec2ang(vec)
#theta = array([ 0. , 1.57079633])
#phi = array([ 0., 0.])
@zonca
zonca / gist:1080918
Created July 13, 2011 18:16
healpy anafast issue with unseen points
m = np.ones(healpy.nside2npix(64))
cl = healpy.anafast(m) # array([ 12.56637061, 0. ,0. .... all zeros
m[100:200]=healpy.UNSEEN
clunseen = healpy.anafast(m) # array([ 1.39439151e+56, 1.37741024e+56,
m[100:200]=0
clzero = healpy.anafast(m) # array([ 1.25152959e+01, 5.13689503e-05, 5.01205239e-05,
@zonca
zonca / qdtest.py
Created July 14, 2011 09:14
query_disc issue
NSIDE=8
vec = [ 0.17101007, 0.03015369, 0.98480775]
qd=healpy.query_disc(NSIDE, vec, 6, deg=True, nest=False)
m = np.zeros(healpy.nside2npix(NSIDE))
m[qd]=1
healpy.mollview(m)
print(qd)
#array([ 3, 0, 11, 4])
#IDL
@zonca
zonca / mbp.py
Created August 4, 2011 10:56
Mismatch Bandpasses
import numpy as np
from planck import LFI
import matplotlib.pyplot as plt
lfi = LFI.LFI()
def horn2freq(horn):
if horn <= 23:
return 70
elif horn <= 26: