def gen_docs(model_info): # type: (ModelInfo) -> None """ Generate the doc string with the figure inserted before the references. """ # Load the doc string from the module definition file and store it in rst docstr = generate.make_doc(model_info) # Auto caption for figure captionstr = '\n' captionstr += '.. figure:: img/' + figfile(model_info) + '\n' captionstr += '\n' if model_info.parameters.has_2d: captionstr += ' 1D and 2D plots corresponding to the default parameters of the model.\n' else: captionstr += ' 1D plot corresponding to the default parameters of the model.\n' captionstr += '\n' # Add figure reference and caption to documentation (at end, before References) pattern = '\*\*REFERENCE' match = re.search(pattern, docstr.upper()) if match: docstr1 = docstr[:match.start()] docstr2 = docstr[match.start():] docstr = docstr1 + captionstr + docstr2 else: print('------------------------------------------------------------------') print('References NOT FOUND for model: ', model_info.id) print('------------------------------------------------------------------') docstr += captionstr open(sys.argv[2],'w').write(docstr)
def gen_docs(model_info, outfile): # type: (ModelInfo, str) -> None """ Generate the doc string with the figure inserted before the references. """ # Load the doc string from the module definition file and store it in rst docstr = generate.make_doc(model_info) # Auto caption for figure captionstr = '\n' captionstr += '.. figure:: img/' + figfile(model_info) + '\n' captionstr += '\n' if model_info.parameters.has_2d: captionstr += ' 1D and 2D plots corresponding to the default parameters of the model.\n' else: captionstr += ' 1D plot corresponding to the default parameters of the model.\n' captionstr += '\n' # Add figure reference and caption to documentation (at end, before References) pattern = r'\*\*REFERENCE' match = re.search(pattern, docstr.upper()) sources = link_sources(model_info) insertion = captionstr + sources if match: docstr1 = docstr[:match.start()] docstr2 = docstr[match.start():] docstr = docstr1 + insertion + docstr2 else: print( '------------------------------------------------------------------' ) print('References NOT FOUND for model: ', model_info.id) print( '------------------------------------------------------------------' ) docstr += insertion with open(outfile, 'w') as fid: fid.write(docstr)
import sys, os, math, re import numpy as np import matplotlib.pyplot as plt import pylab sys.path.insert(0, os.path.abspath('..')) from sasmodels import generate, core from sasmodels.direct_model import DirectModel from sasmodels.data import empty_data1D, empty_data2D # Convert ../sasmodels/models/name.py to name model_name = os.path.basename(sys.argv[1])[:-3] model_info = core.load_model_info(model_name) model = core.build_model(model_info) # Load the doc string from the module definition file and store it in rst docstr = generate.make_doc(model_info) # Calculate 1D curve for default parameters pars = dict((p.name, p.default) for p in model_info['parameters']) # Plotting ranges and options opts = { 'xscale': 'log', 'yscale': 'log' if not model_info['structure_factor'] else 'linear', 'zscale': 'log' if not model_info['structure_factor'] else 'linear', 'q_min': 0.001, 'q_max': 1.0, 'nq': 1000, 'nq2d': 1000, 'vmin': 1e-3, # floor for the 2D data results 'qx_max': 0.5,