source: sasview/sansmodels/src/sans/models/__init__.py @ 5d2b35a

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 5d2b35a was b1a65b6, checked in by Jae Cho <jhjcho@…>, 14 years ago

more fixes on media path for py2exe

  • Property mode set to 100644
File size: 3.3 KB
RevLine 
[ae3ce4e]1"""
2    1D Modeling for SANS
3"""
4## \mainpage Analytical Modeling for SANS
5#
6# \section intro_sec Introduction
7# This module provides theoretical models for the scattering
8# intensity for SANS.
9#
10# Documentation can be found here:
11#    http://danse.us/trac/sans/wiki/8_2_2_1DModelFitting
12#    http://danse.us/trac/sans/wiki/8_2_3_2DModeling
13#
14# \section install_sec Installation
15#
16# \subsection obtain Obtaining the Code
17#
18# The code is available here:
19# \verbatim
20#$ svn co svn://danse.us/sans/sansmodels
21# \endverbatim
22#
23# \subsection depends External Dependencies
24# None
25#
26# \subsection build Building the code
27# The standard python package can be built with distutils.
28# \verbatim
29#$ python setup.py build
30#$ python setup.py install
31# \endverbatim
32#
33# \section overview_sec Package Overview
34#
35# \subsection class Class Diagram:
36# \image html class_diag.png
37# Note that the CCylinderModel is written as C code.
38# CylinderModel acts as an adaptor class for the C extension.
39# Most model classes will be written that way.
40#
41# \subsection behav Behavior enumeration for pyre-level architecture:
42# \image html behavior_pyre.png
43#
44# \subsection behav Behavior enumeration for under-lying architecture:
45# \image html behavior.jpg
46#
47# \subsection Tutorial
48# To create a model:
49# \verbatim
50#from sans.models.ModelFactory import ModelFactory
51#    cyl = ModelFactory().getModel('CylinderModel')
52# \endverbatim
53#
54# To evaluate a model (at x=0.1 in this example):
55# \verbatim
56#    output = cyl.run(0.1)
57# \endverbatim
58#
59# To change a parameter:
60# \verbatim
61#    cyl.setParam('scale', 0.1)
62# \endverbatim
63#
64# To get the value of a parameter:
65# \verbatim
66#    cyl.getParam('scale')
67# \endverbatim
68#
69# Other examples are available as unit tests under sans.models.test.
70#
71# \section help_sec Contact Info
72# Code and Documentation by Mathieu Doucet as part of the DANSE project.
[b1a65b6]73#PLUGIN_ID = "models plug-in 0.4"
74from sans.models import *
[ae3ce4e]75
[b1a65b6]76import os
77from distutils.filelist import findall
78
79def get_data_path(media):
80    """
81    """
82    # Check for data path in the package
83    path = os.path.join(os.path.dirname(__file__), media)
84    if os.path.isdir(path):
85        return path
86
87    # Check for data path next to exe/zip file.
88    # If we are inside a py2exe zip file, we need to go up
89    # to get to the directory containing
90    # the media for this module
91    path = os.path.dirname(__file__)
92    #Look for maximum n_dir up of the current dir to find media
93    n_dir = 12
94    for i in range(n_dir):
95        path, _ = os.path.split(path)
96        media_path = os.path.join(path, media)
97        if os.path.isdir(media_path):
98            module_media_path = os.path.join(media_path, 'models_media')
99            if os.path.isdir(module_media_path):
100                return module_media_path
101            return media_path
102   
103    raise RuntimeError('Could not find models media files')
104
105def data_files():
106    """
107    Return the data files associated with media.
108   
109    The format is a list of (directory, [files...]) pairs which can be
110    used directly in setup(...,data_files=...) for setup.py.
111
112    """
113    data_files = []
114    path = get_data_path(media="media")
115    for f in findall(path):
116        data_files.append(('media/models_media', [f]))
117    return data_files
Note: See TracBrowser for help on using the repository browser.