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
import numpy as np | |
import healpy | |
RA = np.random.random(10000)*360 | |
DEC= np.random.random(10000)*135-45 | |
NSIDE = 64 #nside determines the size of the pixels | |
pixels = healpy.ang2pix(NSIDE, np.radians(90-DEC), np.radians(RA)) #NOTE healpy uses colatitude (north pole 0) instead of latitude | |
hitmap = np.ones(healpy.nside2npix(NSIDE)) * healpy.UNSEEN #by convention non hit pixels have a specific value | |
pixels_binned = np.bincount(pixels) | |
hitmap[:len(pixels_binned)] = pixels_binned | |
healpy.mollview(hitmap, xsize=2000) |
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
import numpy as np | |
def rebin(a, new_shape): | |
""" | |
Resizes a 2d array by averaging or repeating elements, | |
new dimensions must be integral factors of original dimensions | |
Parameters | |
---------- | |
a : array_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
from contextlib import closing | |
class File(object): | |
def __init__(self, filename): | |
self.filename = filename | |
print('Created object for %s' % self.filename) | |
def open(self): | |
print('Opening %s' % self.filename) |
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
import datetime | |
import time | |
import numpy as np | |
from pytpm import convert, tpm | |
az = 3.30084818 | |
el = 0.94610742 | |
lat = 34.64 | |
lon = -103.7 |
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
import datetime | |
import time | |
import numpy as np | |
import ephem | |
az = np.radians(6.8927) | |
el = np.radians(-60.7665) | |
lon = -1 * np.radians(109 + 24/60. + 53.1/60**2) | |
lat = np.radians(33 + 41/60. + 46.0/60.**2) |
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 swap PrgEnv-pgi PrgEnv-gnu | |
CC -g -o simpletest.o -I/opt/cray/trilinos/10.8.3.0/GNU/46/x86_64/include -c simpletest.cpp | |
CC -g simpletest.o -o simpletest -rdynamic -ltpetra_gnu -lkokkos_gnu -lkokkosnodeapi_gnu -ltpi_gnu -lteuchos_gnu -L/opt/cray/trilinos/10.8.3.0/GNU/46/x86_64/lib |
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
cimport numpy as np | |
ctypedef np.long_t DTYPE_int_t | |
ctypedef np.double_t DTYPE_double_t | |
cimport cython | |
@cython.boundscheck(False) # turn of bounds-checking for entire function | |
@cython.wraparound(False) | |
def accumulate( | |
np.ndarray[DTYPE_double_t, ndim=1] a not None, |
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
import pyfits | |
from scipy.constants import c | |
from scipy.integrate import trapz | |
rimo=pyfits.open('rimo.fits') | |
for ext in rimo[3:]: | |
f = c/ext.data['WAVENUMBER']/1.e6 #GHz | |
t = ext.data['TRANSMISSION'] | |
print "%s = Sum: %.2f, Max: %.2f, Integ: %.2f" % (ext.name, t.sum(), t.max(), trapz(t[1:], f[1:])) |
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
from multiprocessing import Pool | |
import numpy as np | |
from time import sleep | |
import logging as l | |
l.basicConfig(format = "%(asctime)-15s [Process: %(process)s] %(message)s", level=l.DEBUG) | |
def write_your_array(filename, a): | |
l.info("writing %s in background process" % filename) | |
# implement writing |
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
import numpy as np | |
import h5py | |
data = np.ones(10, dtype=[("THETA",np.double),("PHI",np.double),("PSI",np.double),("FLAG",np.bool)]) | |
with h5py.File("testout.h5", mode='w') as f: | |
f.create_dataset("data", data=data) |