Skip to content

Commit

Permalink
Merge pull request #23 from skuschel/topic-usability
Browse files Browse the repository at this point in the history
usability improvements

Most importantly:
1) Dumpreader_ifc inherits all the high level Functions from the FieldAnalyzer. So there is no need to call the FieldAnalyzer directly anymore
2) ParticleAnalyzer and chooseCode got linked directly into postpic, no need to call the subpackages anymore.
  • Loading branch information
skuschel committed Feb 3, 2015
2 parents 9b2387f + 992d286 commit 7b87c0a
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 18 deletions.
71 changes: 65 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,70 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
doc/_build/

# PyBuilder
target/

# more stuff
*~
*.pyc
*.odt
.project
.pydevproject
*.egg-info
build/
dist/
doc/_build

*.png

# there might be ipython notebooks
*.ipynb
.ipynb_checkpoints

# if using spyder for development
.spyderworkspace
.spyderproject
17 changes: 7 additions & 10 deletions examples/simpleexample.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@


# choose the dummy reader. This reader will create fake data for testing.
pp.datareader.chooseCode('dummy')
pp.chooseCode('dummy')

dr = pp.datareader.readDump(3e5) # Dummyreader takes a float as argument, not a string.
dr = pp.readDump(3e5) # Dummyreader takes a float as argument, not a string.
# set and create directory for pictures.
savedir = '_examplepictures/'
import os
Expand All @@ -24,21 +24,18 @@
# project name will be prepended to all output names
plotter = pp.plotting.plottercls(dr, outdir=savedir, autosave=True, project='simpleexample')

# create the field analyzer to access field data (E and B fields) easily
fa = pp.analyzer.FieldAnalyzer(dr)

# we will need a refrence to the ParticleAnalyzer quite often
from postpic.analyzer import ParticleAnalyzer as PA
from postpic import ParticleAnalyzer as PA

# create ParticleAnalyzer for every particle species that exists.
pas = [PA(dr, s) for s in dr.listSpecies()]

if True:
# Plot Data from the FieldAnalyzer fa. This is very simple: every line creates one plot
plotter.plotField(fa.Ex()) # plot 0
plotter.plotField(fa.Ey()) # plot 1
plotter.plotField(fa.Ez()) # plot 2
plotter.plotField(fa.energydensityEM()) # plot 3
plotter.plotField(dr.Ex()) # plot 0
plotter.plotField(dr.Ey()) # plot 1
plotter.plotField(dr.Ez()) # plot 2
plotter.plotField(dr.energydensityEM()) # plot 3

# Using the ParticleAnalyzer requires an additional step:
# 1) The ParticleAnalyzer.createField method will be used to create a Field object
Expand Down
7 changes: 7 additions & 0 deletions postpic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@

__all__ = ['datareader', 'analyzer', 'plotting']

# high level functions
from analyzer import ParticleAnalyzer, identifyspecies
__all__ += ['ParticleAnalyzer', 'identifyspecies']

from datareader import chooseCode, readDump, readSim
__all__ += ['chooseCode', 'readDump', 'readSim']

# read version from installed metadata
from pkg_resources import get_distribution, DistributionNotFound
try:
Expand Down
4 changes: 3 additions & 1 deletion postpic/analyzer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
Analyzer package provides Classes and functions for analyzing
Particle and Field Data.
"""

from analyzer import *
from particles import ParticleAnalyzer
from fields import FieldAnalyzer

__all__ = ['ParticleAnalyzer', 'FieldAnalyzer', 'identifyspecies']
__all__ += analyzer.__all__

identifyspecies = analyzer.SpeciesIdentifier.identifyspecies
4 changes: 3 additions & 1 deletion postpic/datareader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@
import numpy as np
from .. import _const
from .. import datahandling as dh
from ..analyzer import FieldAnalyzer

# --- Interface ---


class Dumpreader_ifc(object):
class Dumpreader_ifc(FieldAnalyzer):
'''
Interface class for reading a single dump. A dump contains informations
about the simulation at a single timestep (Usually E- and B-Fields on
Expand Down Expand Up @@ -88,6 +89,7 @@ class Dumpreader_ifc(object):
__metaclass__ = abc.ABCMeta

def __init__(self, dumpidentifier, name=None):
super(Dumpreader_ifc, self).__init__(self)
self.dumpidentifier = dumpidentifier
self._name = name

Expand Down

0 comments on commit 7b87c0a

Please sign in to comment.