Skip to content
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1534ad1
pymofa saving h5 DIRTY working
wbarfuss Oct 18, 2017
490e8e6
Added check for computed results
wbarfuss Oct 18, 2017
7050f16
Add aux function for init to treat raw path
wbarfuss Oct 18, 2017
04f13e5
Added parallel HDF5 storing
wbarfuss Oct 20, 2017
df734e4
Update README and setup.py
wbarfuss Oct 20, 2017
24e64b3
Update README.rst
wbarfuss Oct 20, 2017
e25f67a
exp handling and tutorial clean up with 'api' changes
wbarfuss Oct 20, 2017
5b0e51d
Clean up
wbarfuss Oct 20, 2017
6a8d3bb
Update README.rst
wbarfuss Oct 20, 2017
4b9cd31
Computed tasks tracked in hdf5 db
wbarfuss Oct 25, 2017
f9eb32a
Merge branch 'wb_data_iss1' of https://github.com/wbarfuss/modelingfr…
wbarfuss Oct 25, 2017
4fdf16e
Small chance in remaining tasks collection
wbarfuss Oct 26, 2017
ae18ccb
Add hdf5 lock clean up func
wbarfuss Oct 26, 2017
9411e06
Major changes in obtaining computed tasks
wbarfuss Mar 6, 2018
2a66d83
small change in visualiztion
wbarfuss Mar 8, 2018
cf65f18
minor changes
jakobkolb May 7, 2018
a3f2d47
Moved writing of results to data structure from master to slave. This…
jakobkolb May 9, 2018
75d2632
Moved writing of results to data structure from master to slave. This…
jakobkolb May 9, 2018
8f05e56
1) Moved the saving of finished tasks from the getter of the save fun…
jakobkolb May 11, 2018
18dd767
cosmetic changes for PEP compliance.
jakobkolb May 11, 2018
9c1d822
Merge branch 'wb_data_iss1' of https://github.com/wbarfuss/pymofa int…
jakobkolb May 14, 2018
8eee791
added type hints to public method interfaces of experiment_handling c…
jakobkolb May 23, 2018
ab3635f
catching SIGTERM issued by slrum 30 seconds prior to termination of r…
jakobkolb May 30, 2018
12bb8a9
added some inline comments to explain. This fixes #20
jakobkolb May 30, 2018
b957fea
Merge branch 'wb_data_iss1' of github.com:wbarfuss/pymofa into wb_dat…
jakobkolb May 30, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ target/


# Misc
*~
*~
*.idea
123 changes: 30 additions & 93 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,101 +6,38 @@ systematically.

.. contents::

Disclaimer
----------
This is free software - use at your own risk and convenience.


Usecase
-------
* You have some sort of computer model you want to do parameter studies with

Features
--------
* Computes parallel
* Works iteratively - *pymofa checks wheter you have already computed some task
and won't compute these again*

Design
------
* With pymofa you write one python file to set up one computer experiment
* This python file will contain a function (called the RUN_FUNC) that configures and exectues your model run
* The parameters of the RUN_FUNC will be the parameters of the experiment

This means:

* Raw data will be stored with these parameters
* You will need to give pymofa a list of parameter combination (i.e. a tuple
of parameter values of the same length as the parameters)
* If you want to change the parameters, write a new experiment

Usage
-----
To use the modeling framework write a python script representing one
"experiment" you want to perform with your model.

There you have to specify the path where you want to save your data, the sample
size you want to use, the parameter combinations with which you want to run
your model and a function to set up and run your model and save resulting data
::
# File: Experiment.py

# Imports
from ModelingFramwork import experiment_handling as eh
import YourModel
import cPickle
import itertools as it
import otherstuff

# For use on the cluster
SAVE_PATH = "path/where/to/store/the/ExperimentData"

def RUN_FUNC(pa, ra, me, ters, filename):
"""
<Your Docs>

Parameters
----------
...
filename: string
the filename where to pickle - passed from "experiment_handling"
This needs to be the last parameter of the RUN_FUNC
Experiment handling makes sure that each model run gets an unique ID
"""
# poss. do something with the parameters given above

# Running the model and obtian what you want to save
m = YourModel(mo, del, pa, ra, me, ters)
m.run()
result = m.get_result()

# Save Result
cPickle.dump(result, open(filename, "wb"))

# Determine some exit status and retun
# if exit_status != 1 MoFa will print a note
# of course, the data saving can be also dependend on exit status
exit_status = <determine exit status>
return exit_status

# Parameter combinations
pa = [1, 2, 3, 4]
ra = [1, 3, 5, 7, 9]
me = [0, 1]
ters = [42]
PARAM_COMBS = list(it.product(pa, ra, me, ters))

# Sample Size
SAMPLE_SIZE = 100

# Now start the computation
eh.compute(RUN_FUNC, PARAM_COMBS, SAMPLE_SIZE, SAVE_PATH)


Additionally you can post-process the generated model data for evaluation. For
this you need to provide an index, i.e. the subset of parameters that are the
parameters you want to study in more detail, evaluation functions and a name of
the resaved data file.
::
# Continuation of Experiment.py

# index is a dict with int keys giving the position in RUN_FUN parameter
# list and string values giving their names
INDEX = {0: "pa", 1: "ra"}

# eva is a dict of evaluation functions computing a "macro" quantity from
# the "micro" data, stored by RUN_FUN. These function need to receive an
# interable of filenames as their parameter. The corresponding files were
# generated by RUN_FUNC and need tobe treated accordingly. The keys of the
# eva dict are the corresponding names of the "macro" quantity.
EVA = {"<macroQ1>": lambda fnames: <do_something_with>([np.load(f)
for f in fnames]),
"<macroQ2>": lambda fnames: <do_something_different>([np.load(f)
for f
in fnames])}
# the name of the post processed data
NAME = "PostProcessedData_me0.pkl"

# another set of parameter combinations (optional) - you could also use
# PARAM_COMBS from above
PARAM_COMBS_me0 = list(it.product(pa, ra, [0], ters))

# This will now check for the largest available sample size and use it
eh.resave_data(SAVE_PATH, PARAM_COMBS_me0, INDEX, EVA, NAME)
# The file gets automatically saved at the sub-folder "./data/" which needs
# to exist
Please have a look at the tutorials (either interactivly after downloading this
repository or by starting `here <https://github.com/wbarfuss/pymofa/blob/master/tutorial/01_QuickStart.ipynb>`_)

For further documentation, use the source!

Expand Down
3 changes: 3 additions & 0 deletions pymofa/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
"""__init__.py of pymofa."""

from .experiment_handling import experiment_handling
from .safehdfstore import SafeHDFStore
Loading