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 | |
from scipy.spatial.distance import cdist | |
from distlib import pairwise_cython_blas, pairwise_cython, pairwise_cython_blas2 | |
import timeit | |
a = np.random.random(size=(10000,3)) | |
loop = 1 | |
repeat = 1 | |
funcs = ['cdist(a,a)', 'pairwise_cython(a)', 'pairwise_cython_blas(a)', 'pairwise_cython_blas2(a)'] |
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
function return_left_edge, axis, index, value | |
common tick_block, fixed_value_left_x, fixed_value_right_x | |
if value lt n_elements(fixed_value_left_x) then begin | |
tickmark = string_logexp(fixed_value_left_x[value]) | |
endif else begin | |
if value eq n_elements(fixed_right_x) then begin | |
tickmark = string_logexp(fixed_value_right_x[-1]) | |
endif else begin | |
tickmark = 'N!Dgal!N' | |
endelse |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
[~/temp/astropy-64bit-power-of-2 @Manodeeps-MacBook-Pro] gcc -std=gnu11 -O2 -Wall -Wextra test.c | |
test.c: In function 'naive_p2': | |
test.c:227:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] | |
while(result < n) { | |
^ | |
[~/temp/astropy-64bit-power-of-2 @Manodeeps-MacBook-Pro] ./a.out | |
Running in 64 bit mode | |
Checking overflow bug | |
nbytes = 9223372036854775807 nextp2 = -9223372036854775808 (unsigned) nextp2 = 9223372036854775808 | |
nbytes = -1 nextp2 = 1 (unsigned) nextp2 = 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
/* A code to print out the data size (in bytes) corresponding to the | |
common HDF5 native datatypes | |
Author: Manodeep Sinha | |
Date: 20/11/2019 | |
Compile with ` |
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
/* | |
Author: Manodeep Sinha | |
Date: 13th Nov, 2019 | |
Purpose: For the Uchuu collaboration | |
*** The code combines two distinct ids into one (32 bit or 64 bit) ID using bitshifts, and a bitwise OR *** | |
- Define the macro "USE_64BITS" to work with 64 bits for destination size of the combined ID. If "USE_64BITS" | |
is undefined, then the destination size will be 32 bits. |
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
def read_all_sage_galaxies_from_hdf5(h5file, snapnum=63, wanted_fields=None): | |
import h5py | |
import numpy as np | |
if wanted_fields == None: | |
wanted_fields = ['StellarMass', 'EjectedMass', 'ColdGas', 'BlackHoleMass', 'BulgeMass', 'CentralMvir', 'SfrDisk', 'Mvir', 'Rvir', | |
'infallVmax', 'TimeOfLastMajorMerger', 'TimeOfLastMinorMerger', 'SAGETreeIndex', 'Type'] | |
with h5py.File(h5file, 'r') as hf: | |
if hf['Header/Misc'].attrs['sage_data_version'] == b'1.00': | |
ncores = hf['Header/Misc'].attrs['num_cores'] |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <omp.h> | |
#include "hdf5.h" | |
#include "sglib.h" | |
/* |
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
## compiled with gcc -Wall -std=c99 xx.c -o xx -Wextra | |
## and then run. Produces the following output: | |
Printing mystring_fixed... | |
In print_string_fixed_len_array> string = `Fixed len array with (50) elements' | |
In print_string_pointer> string = `Fixed len array with (50) elements' | |
Printing mystring_fixed......done | |
Printing mystring... | |
In print_string_fixed_len_array> string = `Fixed (unspecified) length array' |
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
#!/usr/bin/env python | |
from __future__ import print_function | |
__author__ = "Manodeep Sinha" | |
__all__ = ["convert_single_ascii_halocat", "convert_ascii_halocat_files"] | |
import os | |
from uchuu_utils import get_parser, get_approx_totnumhalos, generic_reader,\ | |
get_metadata, resize_halo_datasets, write_halos |
NewerOlder