mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-05 15:51:12 +00:00
renamed python_tools to python_src to maintain consistency
This commit is contained in:
parent
0f4bc75527
commit
4dcaf3959b
21 changed files with 0 additions and 0 deletions
54
python_src/misc_util/figureOutMask.py
Normal file
54
python_src/misc_util/figureOutMask.py
Normal file
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env python
|
||||
#+
|
||||
# VIDE -- Void IDentification and Examination -- ./python_tools/misc_util/figureOutMask.py
|
||||
# Copyright (C) 2010-2014 Guilhem Lavaux
|
||||
# Copyright (C) 2011-2014 P. M. Sutter
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; version 2 of the License.
|
||||
#
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#+
|
||||
|
||||
# build a low-resolution mask given the actual galaxy positions
|
||||
|
||||
import numpy as np
|
||||
import healpy as hp
|
||||
import os
|
||||
import shutil
|
||||
import glob
|
||||
import sys
|
||||
|
||||
galFile = "path/to/galaxy/file"
|
||||
outMaskFile = "path/to/output/mask"
|
||||
|
||||
nside = 128
|
||||
npix = hp.nside2npix(nside)
|
||||
mask = np.zeros((npix))
|
||||
|
||||
for line in open(galFile):
|
||||
line = line.split()
|
||||
RA = np.float(line[3])
|
||||
Dec = np.float(line[4])
|
||||
z = np.float(line[5])
|
||||
|
||||
phi = np.pi/180.*RA
|
||||
theta = Dec*np.pi/180.
|
||||
theta = np.pi/2. - Dec*np.pi/180.
|
||||
pos = np.zeros((3))
|
||||
|
||||
pix = hp.ang2pix(nside, theta, phi)
|
||||
mask[pix] = 1.
|
||||
|
||||
print "Sky Fraction:", 1.0*len(mask[mask>0])/len(mask)
|
||||
|
||||
hp.write_map(outMaskFile, mask)
|
116
python_src/misc_util/gather_sources.py
Normal file
116
python_src/misc_util/gather_sources.py
Normal file
|
@ -0,0 +1,116 @@
|
|||
#+
|
||||
# VIDE -- Void IDentification and Examination -- ./build_tools/gather_sources.py
|
||||
# Copyright (C) 2010-2014 Guilhem Lavaux
|
||||
# Copyright (C) 2011-2014 P. M. Sutter
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; version 2 of the License.
|
||||
#
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#+
|
||||
import shutil
|
||||
import tempfile
|
||||
import re
|
||||
from git import Repo,Tree,Blob
|
||||
|
||||
def apply_license(license, relimit, filename):
|
||||
header = re.sub(r'@FILENAME@', filename, license)
|
||||
|
||||
with open(filename) as f:
|
||||
lines = f.read()
|
||||
|
||||
lines = re.sub(relimit, lambda x: (("" if x.group(1) is None else x.group(1)) + header), lines)
|
||||
|
||||
with tempfile.NamedTemporaryFile(delete=False, mode="wt", encoding="UTF-8") as tmp_sources:
|
||||
tmp_sources.write(lines)
|
||||
|
||||
shutil.move(tmp_sources.name, filename)
|
||||
|
||||
|
||||
def apply_python_license(filename):
|
||||
license="""#+
|
||||
# VIDE -- Void IDentification and Examination -- @FILENAME@
|
||||
# Copyright (C) 2010-2014 Guilhem Lavaux
|
||||
# Copyright (C) 2011-2014 P. M. Sutter
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; version 2 of the License.
|
||||
#
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#+
|
||||
"""
|
||||
|
||||
print("Shell/Python file: %s" % filename)
|
||||
relimit=r'^(#!.*\n)?#\+\n(#.*\n)*#\+\n'
|
||||
apply_license(license, relimit, filename)
|
||||
|
||||
|
||||
def apply_cpp_license(filename):
|
||||
license="""/*+
|
||||
VIDE -- Void IDentification and Examination -- @FILENAME@
|
||||
Copyright (C) 2010-2014 Guilhem Lavaux
|
||||
Copyright (C) 2011-2014 P. M. Sutter
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
+*/
|
||||
"""
|
||||
print("C++ file: %s" % filename)
|
||||
relimit = r'(?s)^()/\*\+.*\+\*/\n'
|
||||
apply_license(license, relimit, filename)
|
||||
|
||||
|
||||
def analyze_tree(prefix, t):
|
||||
for entry in t:
|
||||
ename = entry.name
|
||||
if ename == 'external' or ename == 'zobov':
|
||||
continue
|
||||
if type(entry) == Tree:
|
||||
analyze_tree(prefix + "/" + ename, entry)
|
||||
elif type(entry) == Blob:
|
||||
if re.match(".*\.(sh|py|pyx)$",ename) != None:
|
||||
fname=prefix+"/"+ename
|
||||
apply_python_license(fname)
|
||||
if re.match('.*\.(cpp|hpp|h)$', ename) != None:
|
||||
fname=prefix+"/"+ename
|
||||
apply_cpp_license(fname)
|
||||
|
||||
|
||||
if __name__=="__main__":
|
||||
import sys
|
||||
if len(sys.argv) >= 2:
|
||||
apply_python_license(sys.argv[1])
|
||||
sys.exit(0)
|
||||
|
||||
repo = Repo(".")
|
||||
assert repo.bare == False
|
||||
t = repo.tree()
|
||||
analyze_tree(".", t)
|
Loading…
Add table
Add a link
Reference in a new issue