Commit cd07896241bf847ce43ccf04a27bafa3f9d2e3c6
1 parent
5dfa1064
initial version
Showing
6 changed files
with
787 additions
and
0 deletions
dev/license_new.txt
0 โ 100644
| 1 | + * This program is free software: you can redistribute it and/or modify * | |
| 2 | + * it under the terms of the GNU General Public License as published by * | |
| 3 | + * the Free Software Foundation, either version 3 of the License, or * | |
| 4 | + * (at your option) any later version. * | |
| 5 | + * * | |
| 6 | + * This program is distributed in the hope that it will be useful, * | |
| 7 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
| 8 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
| 9 | + * GNU General Public License for more details. * | |
| 10 | + * * | |
| 11 | + * You should have received a copy of the GNU General Public License * | |
| 12 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. * | |
| 13 | + | ... | ... |
dev/license_old.txt
0 โ 100644
dev/macosx_package.sh
0 โ 100755
| 1 | +#!/bin/bash -f | |
| 2 | + | |
| 3 | +# Set parameters | |
| 4 | +cfitsio=cfitsio3280 | |
| 5 | +ncurses=ncurses-5.9 | |
| 6 | +readline=readline-6.2 | |
| 7 | +gammalib=gammalib-00-04-12 | |
| 8 | +ctools=ctools-00-03-00 | |
| 9 | +installdir=/usr/local/gamma | |
| 10 | +swig_path=/Users/jurgen/Software/swig/swig2.0.4/bin | |
| 11 | + | |
| 12 | +# Set flags | |
| 13 | +do_delete=1 | |
| 14 | +do_cfitsio=1 | |
| 15 | +do_ncurses=1 | |
| 16 | +do_readline=1 | |
| 17 | +do_gammalib=1 | |
| 18 | +do_ctools=1 | |
| 19 | +do_python25=1 | |
| 20 | +do_python26=1 | |
| 21 | +do_python27=1 | |
| 22 | + | |
| 23 | +# Set configuration | |
| 24 | +export CFLAGS="-arch ppc -arch i386 -arch x86_64" | |
| 25 | +export CXXFLAGS="-arch ppc -arch i386 -arch x86_64" | |
| 26 | +export LDFLAGS="-arch ppc -arch i386 -arch x86_64" | |
| 27 | + | |
| 28 | +# Remove old installation | |
| 29 | +if [ $do_delete -eq 1 ]; then | |
| 30 | + sudo rm -rf $installdir | |
| 31 | +fi | |
| 32 | + | |
| 33 | +# Dump header | |
| 34 | +rm install.log | |
| 35 | +echo > "Mac OS X packaging" > install.log | |
| 36 | + | |
| 37 | +# Install cfitsio | |
| 38 | +if [ $do_cfitsio -eq 1 ]; then | |
| 39 | + tar xfz $cfitsio.tar.gz | |
| 40 | + cd cfitsio | |
| 41 | + echo " " >> ../install.log | |
| 42 | + echo "cfitsio" >> ../install.log | |
| 43 | + ./configure --prefix=$installdir | |
| 44 | + make shared | |
| 45 | + sudo make install | |
| 46 | + file $installdir/lib/libcfitsio.a >> ../install.log | |
| 47 | + file $installdir/lib/libcfitsio.dylib >> ../install.log | |
| 48 | + otool -L $installdir/lib/libcfitsio.dylib >> ../install.log | |
| 49 | + cd .. | |
| 50 | +fi | |
| 51 | + | |
| 52 | +# Install ncurses (not needed since available on Mac OS X) | |
| 53 | +if [ $do_ncurses -eq 1 ]; then | |
| 54 | + tar xfz $ncurses.tar.gz | |
| 55 | + cd $ncurses | |
| 56 | + echo " " >> ../install.log | |
| 57 | + echo "Ncurses" >> ../install.log | |
| 58 | + ./configure --prefix=$installdir --with-shared | |
| 59 | + make | |
| 60 | + sudo make install | |
| 61 | + file $installdir/lib/libncurses.dylib >> ../install.log | |
| 62 | + otool -L $installdir/lib/libncurses.dylib >> ../install.log | |
| 63 | + cd .. | |
| 64 | +fi | |
| 65 | + | |
| 66 | +# Install readline (not needed since available on Mac OS X) | |
| 67 | +if [ $do_readline -eq 1 ]; then | |
| 68 | + tar xfz $readline.tar.gz | |
| 69 | + cd $readline | |
| 70 | + echo " " >> ../install.log | |
| 71 | + echo "Readline" >> ../install.log | |
| 72 | + ./configure --prefix=$installdir | |
| 73 | + make | |
| 74 | + sudo make install | |
| 75 | + file $installdir/lib/libreadline.dylib >> ../install.log | |
| 76 | + otool -L $installdir/lib/libreadline.dylib >> ../install.log | |
| 77 | + cd .. | |
| 78 | +fi | |
| 79 | + | |
| 80 | +# Decide which Python versions to build | |
| 81 | +VERSIONS= | |
| 82 | +declare -a PYTHONS | |
| 83 | +let count=0 | |
| 84 | +if [ $do_python25 -eq 1 ]; then | |
| 85 | + VERSIONS=$VERSIONS"2.5 " | |
| 86 | + PYTHONS[$count]="/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5" | |
| 87 | + ((count++)) | |
| 88 | +fi | |
| 89 | +if [ $do_python26 -eq 1 ]; then | |
| 90 | + VERSIONS=$VERSIONS"2.6 " | |
| 91 | + PYTHONS[$count]="/System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6" | |
| 92 | + ((count++)) | |
| 93 | +fi | |
| 94 | +if [ $do_python27 -eq 1 ]; then | |
| 95 | + VERSIONS=$VERSIONS"2.7 " | |
| 96 | + PYTHONS[$count]="/Users/jurgen/Software/python/python27/10.5/3-way/bin/python2.7" | |
| 97 | + ((count++)) | |
| 98 | +fi | |
| 99 | + | |
| 100 | +# Install gammalib | |
| 101 | +if [ $do_gammalib -eq 1 ]; then | |
| 102 | + | |
| 103 | + # Secure PATH | |
| 104 | + OLD_PATH=$PATH | |
| 105 | + | |
| 106 | + # Decompress tarball and step into GammaLib | |
| 107 | + tar xfz $gammalib.tar.gz | |
| 108 | + cd $gammalib | |
| 109 | + | |
| 110 | + # Make GammaLib builds | |
| 111 | + let count=0 | |
| 112 | + for VERSION in $VERSIONS; do | |
| 113 | + | |
| 114 | + # Dump version | |
| 115 | + echo " " >> ../install.log | |
| 116 | + echo "GammaLib for Python $VERSION" >> install.log | |
| 117 | + | |
| 118 | + # Create symbolic link for this Python version | |
| 119 | + rm -rf python$VERSION | |
| 120 | + mkdir -p python$VERSION | |
| 121 | + cd python$VERSION | |
| 122 | + ln -s ${PYTHONS[$count]} python | |
| 123 | + export PATH=$PWD:$swig_path:/usr/bin:/bin:/usr/sbin:/sbin | |
| 124 | + echo $PATH >> ../../install.log | |
| 125 | + cd .. | |
| 126 | + | |
| 127 | + # Dump Python version | |
| 128 | + python -V >> ../install.log | |
| 129 | + | |
| 130 | + # Remove pyext/build | |
| 131 | + rm -rf pyext/build | |
| 132 | + | |
| 133 | + # Build GammaLib | |
| 134 | + ./configure --prefix=$installdir | |
| 135 | + make -j8 | |
| 136 | + sudo make install | |
| 137 | + file $installdir/lib/libgamma.la >> ../install.log | |
| 138 | + file $installdir/lib/libgamma.dylib >> ../install.log | |
| 139 | + file $installdir/lib/python$VERSION/site-packages/_gammalib.so >> ../install.log | |
| 140 | + otool -L $installdir/lib/libgamma.dylib >> ../install.log | |
| 141 | + otool -L $installdir/lib/python$VERSION/site-packages/_gammalib.so >> ../install.log | |
| 142 | + | |
| 143 | + # Increment version counter | |
| 144 | + ((count++)) | |
| 145 | + | |
| 146 | + done | |
| 147 | + | |
| 148 | + # GammaLib post install | |
| 149 | + cd .. | |
| 150 | + sudo cp gammalib-setup $installdir/bin/gammalib-setup | |
| 151 | + | |
| 152 | + # Recover PATH | |
| 153 | + export PATH=$OLD_PATH | |
| 154 | + | |
| 155 | +fi | |
| 156 | + | |
| 157 | + | |
| 158 | +# Install ctools | |
| 159 | +if [ $do_ctools -eq 1 ]; then | |
| 160 | + | |
| 161 | + # Secure PATH | |
| 162 | + OLD_PATH=$PATH | |
| 163 | + | |
| 164 | + # Decompress tarball and step into ctools | |
| 165 | + tar xfz $ctools.tar.gz | |
| 166 | + cd $ctools | |
| 167 | + | |
| 168 | + # Make ctools builds | |
| 169 | + let count=0 | |
| 170 | + for VERSION in $VERSIONS; do | |
| 171 | + | |
| 172 | + # Dump version | |
| 173 | + echo " " >> ../install.log | |
| 174 | + echo "ctools for Python $VERSION" >> install.log | |
| 175 | + | |
| 176 | + # Create symbolic link for this Python version | |
| 177 | + rm -rf python$VERSION | |
| 178 | + mkdir -p python$VERSION | |
| 179 | + cd python$VERSION | |
| 180 | + ln -s ${PYTHONS[$count]} python | |
| 181 | + export PATH=$PWD:$swig_path:/usr/bin:/bin:/usr/sbin:/sbin | |
| 182 | + echo $PATH >> ../../install.log | |
| 183 | + cd .. | |
| 184 | + | |
| 185 | + # Dump Python version | |
| 186 | + python -V >> ../install.log | |
| 187 | + | |
| 188 | + # Build ctools | |
| 189 | + make distclean | |
| 190 | + ./configure --prefix=$installdir | |
| 191 | + make | |
| 192 | + sudo make install | |
| 193 | + file $installdir/lib/libctools.la >> ../install.log | |
| 194 | + file $installdir/lib/libctools.dylib >> ../install.log | |
| 195 | + file $installdir/lib/python$VERSION/site-packages/_ctools.so >> ../install.log | |
| 196 | + otool -L $installdir/lib/libctools.dylib >> ../install.log | |
| 197 | + otool -L $installdir/lib/python$VERSION/site-packages/_ctools.so >> ../install.log | |
| 198 | + | |
| 199 | + # Increment version counter | |
| 200 | + ((count++)) | |
| 201 | + | |
| 202 | + done | |
| 203 | + | |
| 204 | + # ctools post install | |
| 205 | + cd .. | |
| 206 | + | |
| 207 | + # Recover PATH | |
| 208 | + export PATH=$OLD_PATH | |
| 209 | + | |
| 210 | +fi | ... | ... |
dev/macosx_testpkg.sh
0 โ 100755
| 1 | +#!/bin/bash -f | |
| 2 | +############################################################################# | |
| 3 | +# Test Mac OS X package # | |
| 4 | +# ------------------------------------------------------------------------- # | |
| 5 | +# Copyright (C) 2011 Jurgen Knodlseder # | |
| 6 | +# ------------------------------------------------------------------------- # | |
| 7 | +# # | |
| 8 | +# This program is free software: you can redistribute it and/or modify # | |
| 9 | +# it under the terms of the GNU General Public License as published by # | |
| 10 | +# the Free Software Foundation, either version 3 of the License, or # | |
| 11 | +# (at your option) any later version. # | |
| 12 | +# # | |
| 13 | +# This program is distributed in the hope that it will be useful, # | |
| 14 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
| 15 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
| 16 | +# GNU General Public License for more details. # | |
| 17 | +# # | |
| 18 | +# You should have received a copy of the GNU General Public License # | |
| 19 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
| 20 | +# # | |
| 21 | +# ------------------------------------------------------------------------- # | |
| 22 | +# This script tests a Mac OS X package prior to release. It is assumed that # | |
| 23 | +# the package has been installed in ${GAMMALIB}. # | |
| 24 | +############################################################################# | |
| 25 | + | |
| 26 | +# Set GAMMALIB environment variable | |
| 27 | +export GAMMALIB=$HOME/ctools | |
| 28 | +#GAMMALIB=$HOME/test/gamma | |
| 29 | +#GAMMALIB=/usr/local/gamma | |
| 30 | + | |
| 31 | +# Set supported architectures (for command line tests) | |
| 32 | +ARCHS="ppc i386 x86_64" | |
| 33 | + | |
| 34 | +# Set supported Python versions | |
| 35 | +declare -a PYTHONS | |
| 36 | +let count=0 | |
| 37 | +PYTHONS[$count]=/System/Library/Frameworks/Python.framework/Versions/2.5/bin | |
| 38 | +((count++)) | |
| 39 | +PYTHONS[$count]=/System/Library/Frameworks/Python.framework/Versions/2.6/bin | |
| 40 | +((count++)) | |
| 41 | +PYTHONS[$count]=/Users/jurgen/Software/python/python27/10.5/3-way/bin | |
| 42 | +((count++)) | |
| 43 | + | |
| 44 | +# Loop over Python versions | |
| 45 | +let index=0 | |
| 46 | +while [ $index -lt $count ]; do | |
| 47 | + | |
| 48 | + # Set PATH | |
| 49 | + export PATH=${PYTHONS[$index]}:/opt/local/bin:/usr/bin:/bin:/usr/sbin:/sbin | |
| 50 | + | |
| 51 | + # Reset PYTHONPATH | |
| 52 | + export PYTHONPATH= | |
| 53 | + | |
| 54 | + # Source initialisation script | |
| 55 | + source $GAMMALIB/bin/gammalib-init.sh | |
| 56 | + | |
| 57 | + # Determine Python version | |
| 58 | + PYTHON_VERSION=`python -c "import sys, string; \ | |
| 59 | + ver=string.split(sys.version)[0].split('.'); \ | |
| 60 | + print ver[0]+'.'+ver[1]"` | |
| 61 | + | |
| 62 | + # Determine Python architectures | |
| 63 | + PYTHON_BIN=`which python` | |
| 64 | + PYTHON_ARCHS= | |
| 65 | + if [ "x`file $PYTHON_BIN | grep ppc`" != x ]; then | |
| 66 | + PYTHON_ARCHS=$PYTHON_ARCHS"ppc " | |
| 67 | + fi | |
| 68 | + if [ "x`file $PYTHON_BIN | grep i386`" != x ]; then | |
| 69 | + PYTHON_ARCHS=$PYTHON_ARCHS"i386 " | |
| 70 | + fi | |
| 71 | + if [ "x`file $PYTHON_BIN | grep x86_64`" != x ]; then | |
| 72 | + PYTHON_ARCHS=$PYTHON_ARCHS"x86_64 " | |
| 73 | + fi | |
| 74 | + | |
| 75 | + # Loop over Python architectures | |
| 76 | + let goods=0 | |
| 77 | + let bads=0 | |
| 78 | + ARCH_GOOD= | |
| 79 | + ARCH_BAD= | |
| 80 | + for ARCH in $PYTHON_ARCHS; do | |
| 81 | + | |
| 82 | + # Reset error counter | |
| 83 | + let errors=0 | |
| 84 | + | |
| 85 | + # Check if gammalib import works | |
| 86 | + RES=`arch -$ARCH python -c "from gammalib import *" 2>&1` | |
| 87 | + if [ "x$RES" != x ]; then | |
| 88 | + echo "ERROR (Python$PYTHON_VERSION-$ARCH): Unable to import gammalib ($RES)" | |
| 89 | + ((errors++)) | |
| 90 | + fi | |
| 91 | + | |
| 92 | + # Check if ctools import works | |
| 93 | + RES=`arch -$ARCH python -c "from ctools import *" 2>&1` | |
| 94 | + if [ "x$RES" != x ]; then | |
| 95 | + echo "ERROR (Python$PYTHON_VERSION-$ARCH): Unable to import ctools ($RES)" | |
| 96 | + ((errors++)) | |
| 97 | + fi | |
| 98 | + | |
| 99 | + # Check if gammalib and ctools import works | |
| 100 | + RES=`arch -$ARCH python -c "from ctools import *; from gammalib import *" 2>&1` | |
| 101 | + if [ "x$RES" != x ]; then | |
| 102 | + echo "ERROR (Python$PYTHON_VERSION-$ARCH): Unable to import ctools & gammalib ($RES)" | |
| 103 | + ((errors++)) | |
| 104 | + fi | |
| 105 | + | |
| 106 | + # Check if GModels() works | |
| 107 | + RES=`arch -$ARCH python -c "from gammalib import *; \ | |
| 108 | + m=GModels(); \ | |
| 109 | + print m" 2>&1` | |
| 110 | + if [ "x`echo $RES | grep Traceback`" != x ]; then | |
| 111 | + echo "ERROR (Python$PYTHON_VERSION-$ARCH): $RES" | |
| 112 | + ((errors++)) | |
| 113 | + fi | |
| 114 | + | |
| 115 | + # Remove existing result files | |
| 116 | + rm -f events.fits | |
| 117 | + rm -f cntmap.fits | |
| 118 | + rm -f selected_events.fits | |
| 119 | + rm -f results_unbinned.xml | |
| 120 | + | |
| 121 | + # Check if ctobssim works in Python | |
| 122 | + RES=`arch -$ARCH python -c "from ctools import *; \ | |
| 123 | + from gammalib import *; \ | |
| 124 | + sim = ctobssim(); \ | |
| 125 | + sim['infile'].filename('$GAMMALIB/share/models/crab.xml'); \ | |
| 126 | + sim['outfile'].filename('events.fits'); \ | |
| 127 | + sim['caldb'].string('$GAMMALIB/share/caldb/cta'); \ | |
| 128 | + sim['irf'].string('kb_E_50h_v3'); \ | |
| 129 | + sim['ra'].real(83.63); \ | |
| 130 | + sim['dec'].real(22.01); \ | |
| 131 | + sim['rad'].real(10.0); \ | |
| 132 | + sim['tmin'].real(0.0); \ | |
| 133 | + sim['tmax'].real(1800.0); \ | |
| 134 | + sim['emin'].real(0.1); \ | |
| 135 | + sim['emax'].real(100.0); \ | |
| 136 | + sim.execute()" 2>&1` | |
| 137 | + if [ "x`echo $RES | grep Traceback`" != x ]; then | |
| 138 | + echo "ERROR (Python$PYTHON_VERSION-$ARCH): $RES" | |
| 139 | + ((errors++)) | |
| 140 | + fi | |
| 141 | + if [ ! -s "events.fits" ]; then | |
| 142 | + echo "ERROR (Python$PYTHON_VERSION-$ARCH): ctobssim - No valid events.fits file." | |
| 143 | + ((errors++)) | |
| 144 | + fi | |
| 145 | + | |
| 146 | + # Check if ctbin works in Python | |
| 147 | + RES=`arch -$ARCH python -c "from ctools import *; \ | |
| 148 | + from gammalib import *; \ | |
| 149 | + bin = ctbin(); \ | |
| 150 | + bin['evfile'].filename('events.fits'); \ | |
| 151 | + bin['outfile'].filename('cntmap.fits'); \ | |
| 152 | + bin['emin'].real(0.1); \ | |
| 153 | + bin['emax'].real(100.0); \ | |
| 154 | + bin['enumbins'].integer(20); \ | |
| 155 | + bin['nxpix'].integer(200); \ | |
| 156 | + bin['nypix'].integer(200); \ | |
| 157 | + bin['binsz'].real(0.02); \ | |
| 158 | + bin['coordsys'].string('CEL'); \ | |
| 159 | + bin['xref'].real(83.63); \ | |
| 160 | + bin['yref'].real(22.01); \ | |
| 161 | + bin['proj'].string('CAR'); \ | |
| 162 | + bin.execute()" 2>&1` | |
| 163 | + if [ "x`echo $RES | grep Traceback`" != x ]; then | |
| 164 | + echo "ERROR (Python$PYTHON_VERSION-$ARCH): $RES" | |
| 165 | + ((errors++)) | |
| 166 | + fi | |
| 167 | + if [ ! -s "cntmap.fits" ]; then | |
| 168 | + echo "ERROR (Python$PYTHON_VERSION-$ARCH): ctbin - No valid cntmap.fits file." | |
| 169 | + ((errors++)) | |
| 170 | + fi | |
| 171 | + | |
| 172 | + # Check if ctselect works in Python | |
| 173 | + RES=`arch -$ARCH python -c "from ctools import *; \ | |
| 174 | + from gammalib import *; \ | |
| 175 | + select = ctselect(); \ | |
| 176 | + select['infile'].filename('events.fits'); \ | |
| 177 | + select['outfile'].filename('selected_events.fits'); \ | |
| 178 | + select['ra'].real(83.63); \ | |
| 179 | + select['dec'].real(22.01); \ | |
| 180 | + select['rad'].real(4.0); \ | |
| 181 | + select['emin'].real(0.1); \ | |
| 182 | + select['emax'].real(100.0); \ | |
| 183 | + select['tmin'].real(0.0); \ | |
| 184 | + select['tmax'].real(1800); \ | |
| 185 | + select.execute()" 2>&1` | |
| 186 | + if [ "x`echo $RES | grep Traceback`" != x ]; then | |
| 187 | + echo "ERROR (Python$PYTHON_VERSION-$ARCH): $RES" | |
| 188 | + ((errors++)) | |
| 189 | + fi | |
| 190 | + if [ ! -s "selected_events.fits" ]; then | |
| 191 | + echo "ERROR (Python$PYTHON_VERSION-$ARCH): ctselect - No valid selected_events.fits file." | |
| 192 | + ((errors++)) | |
| 193 | + fi | |
| 194 | + | |
| 195 | + # Check if ctlike works in Python | |
| 196 | + RES=`arch -$ARCH python -c "from ctools import *; \ | |
| 197 | + from gammalib import *; \ | |
| 198 | + like = ctlike(); \ | |
| 199 | + like['evfile'].filename('selected_events.fits'); \ | |
| 200 | + like['srcmdl'].filename('$GAMMALIB/share/models/crab.xml'); \ | |
| 201 | + like['outmdl'].filename('results_unbinned.xml'); \ | |
| 202 | + like['caldb'].string('$GAMMALIB/share/caldb/cta'); \ | |
| 203 | + like['irf'].string('kb_E_50h_v3'); \ | |
| 204 | + like['method'].string('UNBINNED'); \ | |
| 205 | + like.execute()" 2>&1` | |
| 206 | + if [ "x`echo $RES | grep Traceback`" != x ]; then | |
| 207 | + echo "ERROR (Python$PYTHON_VERSION-$ARCH): $RES" | |
| 208 | + ((errors++)) | |
| 209 | + fi | |
| 210 | + if [ ! -s "results_unbinned.xml" ]; then | |
| 211 | + echo "ERROR (Python$PYTHON_VERSION-$ARCH): ctlike - No valid results_unbinned.xml file." | |
| 212 | + ((errors++)) | |
| 213 | + fi | |
| 214 | + | |
| 215 | + # Collect good and bad Python architectures | |
| 216 | + if [ $errors == 0 ]; then | |
| 217 | + ARCH_GOOD=$ARCH_GOOD" "$ARCH | |
| 218 | + ((goods++)) | |
| 219 | + else | |
| 220 | + ARCH_BAD=$ARCH_BAD" "$ARCH | |
| 221 | + ((bads++)) | |
| 222 | + fi | |
| 223 | + | |
| 224 | + done | |
| 225 | + | |
| 226 | + # Signal success and failures | |
| 227 | + if [ $goods -gt 0 ]; then | |
| 228 | + echo "Python$PYTHON_VERSION support works for$ARCH_GOOD." | |
| 229 | + fi | |
| 230 | + if [ $bads -gt 0 ]; then | |
| 231 | + echo "Python$PYTHON_VERSION support fails for$ARCH_BAD." | |
| 232 | + fi | |
| 233 | + | |
| 234 | + # Increment index | |
| 235 | + ((index++)) | |
| 236 | + | |
| 237 | +done | |
| 238 | + | |
| 239 | +# | |
| 240 | +# Now test the command line interface | |
| 241 | +#==================================== | |
| 242 | + | |
| 243 | +# Source initialisation script | |
| 244 | +source $GAMMALIB/bin/gammalib-init.sh | |
| 245 | + | |
| 246 | +# Create pfiles directory and set environment | |
| 247 | +rm -rf pfiles | |
| 248 | +mkdir -p pfiles | |
| 249 | +export PFILES=pfiles | |
| 250 | + | |
| 251 | +# Loop over architectures | |
| 252 | +for ARCH in $ARCHS; do | |
| 253 | + | |
| 254 | + # Remove existing result files | |
| 255 | + rm -f events.fits | |
| 256 | + rm -f cntmap.fits | |
| 257 | + rm -f selected_events.fits | |
| 258 | + rm -f results_unbinned.xml | |
| 259 | + | |
| 260 | + # Check if ctobssim works from command line | |
| 261 | + arch -$ARCH ctobssim \ | |
| 262 | + infile="$GAMMALIB/share/models/crab.xml" \ | |
| 263 | + outfile="events.fits" \ | |
| 264 | + caldb="$GAMMALIB/share/caldb/cta" \ | |
| 265 | + irf="kb_E_50h_v3" \ | |
| 266 | + ra=83.63 \ | |
| 267 | + dec=22.01 \ | |
| 268 | + rad=10.0 \ | |
| 269 | + tmin=0.0 \ | |
| 270 | + tmax=1800.0 \ | |
| 271 | + emin=0.1 \ | |
| 272 | + emax=100.0 | |
| 273 | + if [ -s "events.fits" ]; then | |
| 274 | + echo "ctobssim($ARCH): ok." | |
| 275 | + else | |
| 276 | + echo "ERROR ($ARCH): ctobssim failed." | |
| 277 | + fi | |
| 278 | + | |
| 279 | + # Check if ctbin works from command line | |
| 280 | + arch -$ARCH ctbin \ | |
| 281 | + evfile="events.fits" \ | |
| 282 | + outfile="cntmap.fits" \ | |
| 283 | + emin=0.1 \ | |
| 284 | + emax=100.0 \ | |
| 285 | + enumbins=20 \ | |
| 286 | + nxpix=200 \ | |
| 287 | + nypix=200 \ | |
| 288 | + binsz=0.02 \ | |
| 289 | + coordsys="CEL" \ | |
| 290 | + xref=83.63 \ | |
| 291 | + yref=22.01 \ | |
| 292 | + proj="CAR" | |
| 293 | + if [ -s "cntmap.fits" ]; then | |
| 294 | + echo "ctbin($ARCH): ok." | |
| 295 | + else | |
| 296 | + echo "ERROR ($ARCH): ctbin failed." | |
| 297 | + fi | |
| 298 | + | |
| 299 | + # Check if ctselect works from command line | |
| 300 | + arch -$ARCH ctselect \ | |
| 301 | + infile="events.fits" \ | |
| 302 | + outfile="selected_events.fits" \ | |
| 303 | + ra=83.63 \ | |
| 304 | + dec=22.01 \ | |
| 305 | + rad=10.0 \ | |
| 306 | + tmin=0.0 \ | |
| 307 | + tmax=1800.0 \ | |
| 308 | + emin=0.1 \ | |
| 309 | + emax=100.0 | |
| 310 | + if [ -s "selected_events.fits" ]; then | |
| 311 | + echo "ctselect($ARCH): ok." | |
| 312 | + else | |
| 313 | + echo "ERROR ($ARCH): ctselect failed." | |
| 314 | + fi | |
| 315 | + | |
| 316 | + # Check if ctlike works from command line | |
| 317 | + arch -$ARCH ctlike evfile="selected_events.fits" \ | |
| 318 | + srcmdl="$GAMMALIB/share/models/crab.xml" \ | |
| 319 | + outmdl="results_unbinned.xml" \ | |
| 320 | + method="UNBINNED" \ | |
| 321 | + caldb="$GAMMALIB/share/caldb/cta" \ | |
| 322 | + irf="kb_E_50h_v3" | |
| 323 | + if [ -s "results_unbinned.xml" ]; then | |
| 324 | + echo "ctlike($ARCH): ok." | |
| 325 | + else | |
| 326 | + echo "ERROR ($ARCH): ctlike failed." | |
| 327 | + fi | |
| 328 | + | |
| 329 | +done | |
| 330 | + | ... | ... |
dev/release_gammalib.sh
0 โ 100755
| 1 | +#! /bin/bash -f | |
| 2 | + | |
| 3 | +# Set parameters | |
| 4 | +installdir=$(pwd)/build | |
| 5 | +makedoc="no" | |
| 6 | + | |
| 7 | +echo "Checkout latest GammaLib" | |
| 8 | +rm -rf gammalib | |
| 9 | +cvs -Q -d /home/cvs export -N -r HEAD "gammalib" | |
| 10 | + | |
| 11 | +# Extract version number | |
| 12 | +version=`cat gammalib/configure.ac | grep 'AC_INIT' | awk -F"[" '{print $3}' | sed 's/],//' | sed 's/\./ /g'` | |
| 13 | +version=`printf "%2.2d-%2.2d-%2.2d" $version` | |
| 14 | +echo "GammaLib version: "$version | |
| 15 | + | |
| 16 | +# Set source directory | |
| 17 | +sourcedir=gammalib-$version | |
| 18 | +rm -rf $sourcedir | |
| 19 | +mv gammalib $sourcedir | |
| 20 | + | |
| 21 | +# | |
| 22 | +echo "Create Makefile.in and configure scripts" | |
| 23 | +cd $sourcedir | |
| 24 | +./autogen.sh | |
| 25 | +rm -f gammalib.sh | |
| 26 | +rm -rf dev | |
| 27 | +cd .. | |
| 28 | + | |
| 29 | +# | |
| 30 | +echo "Create gammalib_wrap.cpp and gammalib.py files for python binding (making swig obsolete)" | |
| 31 | +inc_inst="-I$sourcedir/inst/mwl/pyext -I$sourcedir/inst/lat/pyext -I$sourcedir/inst/cta/pyext" | |
| 32 | +opt_inst="-DWITH_INST_MWL -DWITH_INST_LAT -DWITH_INST_CTA" | |
| 33 | +swig -c++ -python -Wall -includeall -I$sourcedir/src $inc_inst $opt_inst -o $sourcedir/pyext/gammalib_wrap.cpp -outdir $sourcedir/pyext $sourcedir/pyext/gammalib.i | |
| 34 | + | |
| 35 | +# | |
| 36 | +if [ "x$makedoc" == "xyes" ] ; then | |
| 37 | + echo "Create doxygen documentation" | |
| 38 | + cd $sourcedir/doc | |
| 39 | + doxygen Doxyfile | |
| 40 | + cd latex | |
| 41 | + make | |
| 42 | + make | |
| 43 | + dvips -o refman.ps refman | |
| 44 | + ps2pdf refman.ps | |
| 45 | + cd ../.. | |
| 46 | +fi | |
| 47 | + | |
| 48 | +# | |
| 49 | +echo "Create LaTeX documentation" | |
| 50 | +cd $sourcedir/doc | |
| 51 | +# | |
| 52 | +latex gammalib_um.tex | |
| 53 | +dvips gammalib_um.dvi -o gammalib_um.ps | |
| 54 | +ps2pdf gammalib_um.ps | |
| 55 | +rm -f gammalib_um.dvi gammalib_um.aux gammalib_um.log gammalib_um.tex gammalib_um.toc manual.sty gammalib_um.ps | |
| 56 | +# | |
| 57 | +cd dev/coding | |
| 58 | +latex gammalib_coding.tex | |
| 59 | +dvips gammalib_coding.dvi -o gammalib_coding.ps | |
| 60 | +ps2pdf gammalib_coding.ps | |
| 61 | +cd ../.. | |
| 62 | +mv dev/coding/gammalib_coding.pdf . | |
| 63 | +# | |
| 64 | +cd dev/inst | |
| 65 | +latex gammalib_inst.tex | |
| 66 | +dvips gammalib_inst.dvi -o gammalib_inst.ps | |
| 67 | +ps2pdf gammalib_inst.ps | |
| 68 | +cd ../.. | |
| 69 | +mv dev/inst/gammalib_inst.pdf . | |
| 70 | +# | |
| 71 | +cd dev/maths | |
| 72 | +latex gammalib_maths.tex | |
| 73 | +dvips gammalib_maths.dvi -o gammalib_maths.ps | |
| 74 | +ps2pdf gammalib_maths.ps | |
| 75 | +cd ../.. | |
| 76 | +mv dev/maths/gammalib_maths.pdf . | |
| 77 | +# | |
| 78 | +cd dev/sdd | |
| 79 | +latex gammalib_sdd.tex | |
| 80 | +dvips gammalib_sdd.dvi -o gammalib_sdd.ps | |
| 81 | +ps2pdf gammalib_sdd.ps | |
| 82 | +cd ../.. | |
| 83 | +mv dev/sdd/gammalib_sdd.pdf . | |
| 84 | +# | |
| 85 | +cd dev/srs | |
| 86 | +latex gammalib_srs.tex | |
| 87 | +dvips gammalib_srs.dvi -o gammalib_srs.ps | |
| 88 | +ps2pdf gammalib_srs.ps | |
| 89 | +cd ../.. | |
| 90 | +mv dev/srs/gammalib_srs.pdf . | |
| 91 | +# | |
| 92 | +rm -rf dev | |
| 93 | +cd ../.. | |
| 94 | + | |
| 95 | +echo "Make files read/write" | |
| 96 | +chmod -R u+rw $sourcedir | |
| 97 | + | |
| 98 | +echo "Create tarball" | |
| 99 | +tar cvf - $sourcedir > $sourcedir.tar | |
| 100 | +rm -f $sourcedir.tar.gz | |
| 101 | +gzip $sourcedir.tar | |
| 102 | + | |
| 103 | +# | |
| 104 | +echo "Configure GammaLib" | |
| 105 | +cd $sourcedir | |
| 106 | +./configure --prefix=$installdir | |
| 107 | + | |
| 108 | +# | |
| 109 | +echo "Compile GammaLib" | |
| 110 | +make -j10 | |
| 111 | + | |
| 112 | +# | |
| 113 | +echo "Check GammaLib" | |
| 114 | +make check | |
| 115 | + | |
| 116 | +# | |
| 117 | +echo "Install GammaLib" | |
| 118 | +make install | ... | ... |
dev/replace_license.py
0 โ 100755
| 1 | +#! /usr/bin/env python | |
| 2 | + | |
| 3 | +import os | |
| 4 | +import glob | |
| 5 | + | |
| 6 | + | |
| 7 | +# =========================== # | |
| 8 | +# Read license text from file # | |
| 9 | +# =========================== # | |
| 10 | +def read_license(filename): | |
| 11 | + """ | |
| 12 | + Read license text from file. | |
| 13 | + """ | |
| 14 | + # Initialise lines | |
| 15 | + lines = [] | |
| 16 | + | |
| 17 | + # Loop over file | |
| 18 | + for line in open(filename, 'r'): | |
| 19 | + if len(line.rstrip("\n").strip(" ")) > 0: | |
| 20 | + lines.append(line) | |
| 21 | + | |
| 22 | + # Return lines | |
| 23 | + return lines | |
| 24 | + | |
| 25 | + | |
| 26 | +# ==================== # | |
| 27 | +# Replace license text # | |
| 28 | +# ==================== # | |
| 29 | +def replace_license(filename, license_old, license_new): | |
| 30 | + """ | |
| 31 | + Replace license text in file. | |
| 32 | + """ | |
| 33 | + # Set temporary name | |
| 34 | + tmpname = "test.txt" | |
| 35 | + | |
| 36 | + # Open temporary file | |
| 37 | + file = open(tmpname, "w") | |
| 38 | + | |
| 39 | + # Initialise old text line finder | |
| 40 | + ifind = 0 | |
| 41 | + | |
| 42 | + # Loop over file | |
| 43 | + for line in open(filename, 'r'): | |
| 44 | + | |
| 45 | + # Search line for license text | |
| 46 | + if line == license_old[ifind]: | |
| 47 | + ifind += 1 | |
| 48 | + if ifind >= len(license_old): | |
| 49 | + for replace in license_new: | |
| 50 | + file.write(replace) | |
| 51 | + print "License text upated in file "+filename+"." | |
| 52 | + ifind = 0 | |
| 53 | + | |
| 54 | + # Handle partial license text | |
| 55 | + elif ifind > 0: | |
| 56 | + print "Partial old license text found in file "+filename+". Ignored." | |
| 57 | + ifind = 0 | |
| 58 | + | |
| 59 | + # ... otherwise write out line | |
| 60 | + else: | |
| 61 | + file.write(line) | |
| 62 | + | |
| 63 | + # Close temporary file | |
| 64 | + file.close() | |
| 65 | + | |
| 66 | + # Replace input file | |
| 67 | + os.rename(tmpname, filename) | |
| 68 | + | |
| 69 | + # Return | |
| 70 | + return | |
| 71 | + | |
| 72 | + | |
| 73 | +# ======================================================== # | |
| 74 | +# Replace license text in files with name given by pattern # | |
| 75 | +# ======================================================== # | |
| 76 | +def update_files(pattern, license_old, license_new): | |
| 77 | + """ | |
| 78 | + Replace license text in files with name given by pattern. | |
| 79 | + """ | |
| 80 | + # Get sorted list of files | |
| 81 | + files = glob.glob(pattern) | |
| 82 | + files.sort() | |
| 83 | + | |
| 84 | + # Loop over all files | |
| 85 | + for file in files: | |
| 86 | + replace_license(file, license_old, license_new) | |
| 87 | + | |
| 88 | + # Return | |
| 89 | + return | |
| 90 | + | |
| 91 | + | |
| 92 | +# ======================== # | |
| 93 | +# Main routine entry point # | |
| 94 | +# ======================== # | |
| 95 | +if __name__ == '__main__': | |
| 96 | + """ | |
| 97 | + Replace old by new license text. | |
| 98 | + """ | |
| 99 | + # Load license files | |
| 100 | + license_old = read_license("license_old.txt") | |
| 101 | + license_new = read_license("license_new.txt") | |
| 102 | + | |
| 103 | + # Replace license text | |
| 104 | + update_files("include/*.hpp", license_old, license_new) | |
| 105 | + update_files("pyext/*.i", license_old, license_new) | |
| 106 | + update_files("src/*/*.*pp", license_old, license_new) | |
| 107 | + update_files("inst/*/include/*.hpp", license_old, license_new) | |
| 108 | + update_files("inst/*/pyext/*.i", license_old, license_new) | |
| 109 | + update_files("inst/*/src/*.cpp", license_old, license_new) | |
| 110 | + update_files("inst/*/test/*.*pp", license_old, license_new) | |
| 111 | + update_files("test/*.*pp", license_old, license_new) | |
| 112 | + | ... | ... |