Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #21 from ahmadia/refactor_toplevel

Refactor toplevel
  • Loading branch information...
commit 47de9546b040771f47890999cc25ca75a5d18624 2 parents 6764cc1 + 20f44f2
@ahmadia ahmadia authored
View
2  README.txt
@@ -1 +1 @@
-This repository will host the classic single-grid Clawpack code.
+This repository hosts VisClaw, the Clawpack visualization tools.
View
168 setup.py
@@ -0,0 +1,168 @@
+#!/usr/bin/env python
+"""VisClaw: Clawpack Visualization Library
+
+visclaw is a set of scripts for visualizing Clawpack data
+
+"""
+
+# much of the functionality of this file was taken from the scipy setup.py script.
+
+DOCLINES = __doc__.split("\n")
+
+import os
+import sys
+import warnings
+import subprocess
+import shutil
+import re
+
+if sys.version_info[0] < 3:
+ import __builtin__ as builtins
+else:
+ import builtins
+
+CLASSIFIERS = """\
+Development Status :: 4 - Beta
+Intended Audience :: Science/Research
+Intended Audience :: Developers
+License :: OSI Approved
+Programming Language :: C
+Programming Language :: Python
+Topic :: Software Development
+Topic :: Scientific/Engineering
+Operating System :: POSIX
+Operating System :: Unix
+Operating System :: MacOS
+
+"""
+
+MAJOR = 0
+MINOR = 1
+MICRO = 0
+ISRELEASED = False
+VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
+
+
+# Return the git revision as a string
+def git_version():
+ def _minimal_ext_cmd(cmd):
+ # construct minimal environment
+ env = {}
+ for k in ['SYSTEMROOT', 'PATH']:
+ v = os.environ.get(k)
+ if v is not None:
+ env[k] = v
+ # LANGUAGE is used on win32
+ env['LANGUAGE'] = 'C'
+ env['LANG'] = 'C'
+ env['LC_ALL'] = 'C'
+ out = subprocess.Popen(cmd, stdout = subprocess.PIPE, env=env).communicate()[0]
+ return out
+
+ try:
+ out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD'])
+ GIT_REVISION = out.strip().decode('ascii')
+ except OSError:
+ GIT_REVISION = "Unknown"
+
+ return GIT_REVISION
+
+
+# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
+# update it when the contents of directories change.
+if os.path.exists('MANIFEST'):
+ os.remove('MANIFEST')
+
+def write_version_py(filename='src/python/visclaw/version.py'):
+ cnt = """
+# THIS FILE IS GENERATED FROM VISCLAW SETUP.PY
+short_version = '%(version)s'
+version = '%(version)s'
+full_version = '%(full_version)s'
+git_revision = '%(git_revision)s'
+release = %(isrelease)s
+
+if not release:
+ version = full_version
+"""
+ # Adding the git rev number needs to be done inside
+ # write_version_py(), otherwise the import of scipy.version messes
+ # up the build under Python 3.
+ FULLVERSION = VERSION
+ if os.path.exists('.git'):
+ GIT_REVISION = git_version()
+ elif os.path.exists('src/python/visclaw/version.py'):
+ # must be a source distribution, use existing version file
+ from visclaw.version import git_revision as GIT_REVISION
+ else:
+ GIT_REVISION = "Unknown"
+
+ if not ISRELEASED:
+ FULLVERSION += '.dev-' + GIT_REVISION[:7]
+
+ a = open(filename, 'w')
+ try:
+ a.write(cnt % {'version': VERSION,
+ 'full_version' : FULLVERSION,
+ 'git_revision' : GIT_REVISION,
+ 'isrelease': str(ISRELEASED)})
+ finally:
+ a.close()
+
+
+def configuration(parent_package='',top_path=None):
+ from numpy.distutils.misc_util import Configuration
+
+ package_path=os.path.join(os.path.dirname(__file__),'src','python')
+ config = Configuration('visclaw', parent_package, top_path, package_path)
+ config.set_options(ignore_setup_xxx_py=True,
+ assume_default_configuration=True,
+ delegate_options_to_subpackages=True,
+ quiet=True)
+
+ config.get_version('src/python/visclaw/version.py')
+
+ return config
+
+
+def setup_package():
+ from numpy.distutils.core import setup
+
+ old_path = os.getcwd()
+ local_path = os.path.dirname(os.path.abspath(sys.argv[0]))
+ src_path = local_path
+
+ os.chdir(local_path)
+ sys.path.insert(0, local_path)
+ sys.path.insert(0, os.path.join(local_path, 'src/python/visclaw')) # to retrieve version
+
+ # Run build
+ old_path = os.getcwd()
+ os.chdir(src_path)
+ sys.path.insert(0, src_path)
+
+ # Rewrite the version file everytime
+ write_version_py()
+
+ try:
+ setup(
+ name = 'visclaw',
+ maintainer = "Clawpack Developers",
+ maintainer_email = "claw-dev@googlegroups.com",
+ description = DOCLINES[0],
+ long_description = "\n".join(DOCLINES[2:]),
+ url = "http://www.clawpack.org",
+ download_url = "https://github.com/clawpack/visclaw/tarball/master",
+ license = 'BSD',
+ classifiers=[_f for _f in CLASSIFIERS.split('\n') if _f],
+ platforms = ["Linux", "Solaris", "Mac OS-X", "Unix"],
+ package_dir={'':os.path.join('src','python')},
+ configuration=configuration )
+ finally:
+ del sys.path[0]
+ os.chdir(old_path)
+ return
+
+
+if __name__ == '__main__':
+ setup_package()
View
1  src/python/visclaw/.gitignore
@@ -0,0 +1 @@
+version.py
View
10 src/python/visclaw/Iplotclaw.py
@@ -34,7 +34,7 @@
print "problem importing pylab"
sys.exit(1)
-from visclaw import data, frametools, gaugetools
+from clawpack.visclaw import data, frametools, gaugetools
#rundata = data.ClawData('claw.data')
@@ -47,7 +47,7 @@ class Iplotclaw(cmd.Cmd):
Usage:
------
- >>> from visclaw.Iplotclaw import Iplotclaw
+ >>> from clawpack.visclaw.Iplotclaw import Iplotclaw
>>> ip = Iplotclaw() # new instantiation
>>> ip.plotloop() # to start looping
PLOTCLAW > help # for list of available commands
@@ -66,7 +66,7 @@ class Iplotclaw(cmd.Cmd):
Other arguments of Iplotclaw rarely need to be changed:
completekey='tab', stdin=None, stdout=None
"""
- from visclaw import frametools, data
+ from clawpack.visclaw import frametools, data
# initialization:
# ---------------
@@ -201,7 +201,7 @@ def help_help(self):
# next frame:
# -----------
def do_n(self, rest):
- from visclaw import frametools, data
+ from clawpack.visclaw import frametools, data
#print ' frameno = ',self.frameno
self.frameno = self.frameno+1
self.current_data = frametools.plotframe(self.frameno, self.plotdata)
@@ -375,7 +375,7 @@ def help_pwd(self):
# print figure to a file:
# -----------------------
def do_print(self, rest):
- #from visclaw import frametools
+ #from clawpack.visclaw import frametools
fname = rest
try:
for figno in self.plotdata._fignos:
View
1  src/python/visclaw/__init__.py
@@ -1,5 +1,4 @@
"""Output package for Pyclaw"""
import logging
-__all__ = ['frametools','data','Iplotclaw','colormaps','plotpages','plotclaw']
View
2  src/python/visclaw/colormaps.py
@@ -1,7 +1,7 @@
"""
Module colormap for creating custom color maps. For example...
- >>> from visclaw import colormaps
+ >>> from clawpack.visclaw import colormaps
>>> mycmap = colormaps.make_colormap({0:'r', 1.:'b'}) # red to blue
>>> colormaps.showcolors(mycmap) # displays resulting colormap
View
16 src/python/visclaw/data.py
@@ -8,7 +8,7 @@
import copy
import re
import logging
-from clawutil.clawdata import Data, ClawData
+from clawpack.clawutil.clawdata import Data, ClawData
# ============================================================================
@@ -191,7 +191,7 @@ def getframe(self,frameno,outdir=None):
frame has previously been read and the dictionary value is returned.
"""
- from pyclaw import solution
+ from clawpack.pyclaw import solution
framesoln_dict = self.framesoln_dict
@@ -336,7 +336,7 @@ def read_gauges(self, outdir='.'):
import os
import numpy as np
from matplotlib.mlab import find
- from visclaw import gaugetools
+ from clawpack.visclaw import gaugetools
from StringIO import StringIO
fname = os.path.join(outdir,'fort.gauge')
@@ -395,11 +395,11 @@ def read_gauges(self, outdir='.'):
def plotframe(self, frameno):
- from visclaw import frametools
+ from clawpack.visclaw import frametools
frametools.plotframe(frameno, self)
def printframes(self, verbose=True):
- #from visclaw import frametools
+ #from clawpack.visclaw import frametools
#frametools.printframes(self, verbose)
print "*** printframes is deprecated. Use plotpages.plotclaw_driver"
print "*** for added capabilities."
@@ -832,14 +832,14 @@ def __init__(self, name, plot_type, plotaxes):
self.add_attribute('amr_%s' % a, [])
if plot_type == '2d_pcolor':
- from visclaw import colormaps
+ from clawpack.visclaw import colormaps
self.add_attribute('pcolor_cmap',colormaps.yellow_red_blue)
self.add_attribute('pcolor_cmin',None)
self.add_attribute('pcolor_cmax',None)
self.add_attribute('add_colorbar',True)
elif plot_type == '2d_imshow':
- from visclaw import colormaps
+ from clawpack.visclaw import colormaps
self.add_attribute('imshow_cmap',colormaps.yellow_red_blue)
self.add_attribute('imshow_cmin',None)
self.add_attribute('imshow_cmax',None)
@@ -860,7 +860,7 @@ def __init__(self, name, plot_type, plotaxes):
self.add_attribute('amr_contour_%s' % a, [])
elif plot_type == '2d_schlieren':
- from visclaw import colormaps
+ from clawpack.visclaw import colormaps
self.add_attribute('schlieren_cmap',colormaps.schlieren_grays)
self.add_attribute('schlieren_cmin',None)
self.add_attribute('schlieren_cmax',None)
View
12 src/python/visclaw/frametools.py
@@ -34,7 +34,7 @@ def plotframe(frameno, plotdata, verbose=False):
"""
- from clawutil.clawdata import Data
+ from clawpack.clawutil.clawdata import Data
if verbose: print ' Plotting frame %s ... ' % frameno
if plotdata.mode() == 'iplotclaw':
@@ -574,7 +574,7 @@ def plotitem2(framesoln, plotitem, current_data, stateno):
import numpy as np
from numpy import ma
- from visclaw import colormaps
+ from clawpack.visclaw import colormaps
plotdata = plotitem._plotdata
@@ -944,8 +944,8 @@ def printframes(plotdata=None, verbose=True):
"""
import glob
- from visclaw.data import ClawPlotData
- from visclaw import plotpages
+ from clawpack.visclaw.data import ClawPlotData
+ from clawpack.visclaw import plotpages
@@ -1423,10 +1423,10 @@ def call_setplot(setplot, plotdata, verbose=True):
# Not sure if this is the right place to be doing this, maybe
# this should go higher up than this routine so it can check all
# of the same attributes?
- print "Would you like to use visclaw.setplot_default() instead [Y/n]?"
+ print "Would you like to use clawpack.visclaw.setplot_default() instead [Y/n]?"
use_default = raw_input()
if (use_default == "") or ("Y" in use_default.capitalize()):
- from visclaw import setplot_default
+ from clawpack.visclaw import setplot_default
setplot = setplot_default.setplot
else:
sys.exit(1)
View
10 src/python/visclaw/gaugetools.py
@@ -8,9 +8,9 @@
import traceback
-from clawutil.clawdata import Data
-from visclaw import plotpages
-from visclaw.frametools import set_show
+from clawpack.clawutil.clawdata import Data
+from clawpack.visclaw import plotpages
+from clawpack.visclaw.frametools import set_show
plotter = 'matplotlib'
if plotter == 'matplotlib':
@@ -369,7 +369,7 @@ def read_setgauges(datadir):
"""
import os
import numpy as np
- from clawutil.clawdata import Data
+ from clawpack.clawutil.clawdata import Data
from matplotlib.mlab import find
setgauges = Data()
@@ -540,7 +540,7 @@ def printgauges(plotdata=None, verbose=True):
"""
import glob
- from visclaw.data import ClawPlotData
+ from clawpack.visclaw.data import ClawPlotData
View
6 src/python/visclaw/geoplot.py
@@ -2,7 +2,7 @@
Useful things for plotting GeoClaw results.
"""
-from visclaw import colormaps
+from clawpack.visclaw import colormaps
from matplotlib.colors import Normalize
from geoclaw import topotools
from numpy import ma
@@ -234,8 +234,8 @@ def plot_topo_file(topoplotdata):
import os
import pylab
- from visclaw.data import Data
- from clawutil.clawdata import Data
+ from clawpack.visclaw.data import Data
+ from clawpack.clawutil.clawdata import Data
fname = topoplotdata.fname
topotype = topoplotdata.topotype
View
2  src/python/visclaw/multiframetools.py
@@ -127,7 +127,7 @@ def plot_multiframes(plotdata, verbose=False):
print "*** No frames found in plot_multiframes for "
print "*** plotitem named ",itemname
continue
- else if plotitem.plot_type == '1d_xt':
+ elif plotitem.plot_type == '1d_xt':
plot_var = plotitem.plot_var
var_over_t = []
times = []
View
4 src/python/visclaw/plotclaw.py
@@ -35,8 +35,8 @@ def plotclaw(outdir='.', plotdir='_plots', setplot = 'setplot.py',format='ascii'
format specifies the format of the files output from Clawpack
"""
- from visclaw.data import ClawPlotData
- from visclaw import plotpages
+ from clawpack.visclaw.data import ClawPlotData
+ from clawpack.visclaw import plotpages
plotdata = ClawPlotData()
plotdata.outdir = outdir
View
4 src/python/visclaw/plotpages.py
@@ -1927,8 +1927,8 @@ def plotclaw_driver(plotdata, verbose=False):
import glob, sys, os
import numpy as np
- from visclaw.data import ClawPlotData
- from visclaw import frametools, gaugetools, plotpages
+ from clawpack.visclaw.data import ClawPlotData
+ from clawpack.visclaw import frametools, gaugetools, plotpages
datadir = os.getcwd() # assume data files in this directory
View
2  src/python/visclaw/setplot_default.py
@@ -42,7 +42,7 @@ def setplot(plotdata):
plotitem.kwargs = {'linewidth':2,'markersize':5}
elif ndim==2:
plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor')
- from visclaw import colormaps
+ from clawpack.visclaw import colormaps
plotitem.pcolor_cmap = colormaps.yellow_red_blue
plotitem.add_colorbar = True
else:
View
13 src/python/visclaw/setup.py
@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+
+
+def configuration(parent_package='', top_path=None):
+ from numpy.distutils.misc_util import Configuration
+
+ config = Configuration('visclaw', parent_package, top_path)
+ return config
+
+
+if __name__ == '__main__':
+ from numpy.distutils.core import setup
+ setup(**configuration(top_path='').todict())
Please sign in to comment.
Something went wrong with that request. Please try again.