Beispiel #1
0
def renderVszTest(invsz, outfile, test_saves=False, test_unlink=False):
    """Render vsz document to create outfile."""

    doc = document.Document()
    mode = 'hdf5' if os.path.splitext(invsz)[1] == '.vszh5' else 'vsz'
    doc.load(invsz, mode=mode)

    if test_unlink:
        for d in doc.data:
            doc.data[d].linked = None

    if test_saves and h5py is not None:
        tempfilename = 'self-test-temporary.vszh5'
        doc.save(tempfilename, mode='hdf5')
        doc = document.Document()
        doc.load(tempfilename, mode='hdf5')
        os.unlink(tempfilename)

    if test_saves:
        tempfilename = 'self-test-temporary.vsz'
        doc.save(tempfilename, mode='vsz')
        doc = document.Document()
        doc.load(tempfilename, mode='vsz')
        os.unlink(tempfilename)

    ifc = document.CommandInterface(doc)
    ifc.Export(outfile)
Beispiel #2
0
 def do(self,
        ds_x,
        ds_y,
        start=50.,
        percent=0.,
        reconfigure='Continue',
        smooth=5,
        smode='X and Y',
        ds_out='coeff'):
     doc = document.Document()
     insertData(doc, {'ds_x': ds_x, 'ds_y': ds_y})
     ds = doc.data['ds_y']
     doc.setData('ds_y', ds)
     fields = {
         'ds_x': 'ds_x',
         'ds_y': 'ds_y',
         'start': start,
         'percent': percent,
         'reconfigure': reconfigure,
         'smooth': smooth,
         'smode': smode,
         'ds_out': ds_out
     }
     p = CoefficientPlugin(**fields)
     p.getDatasets(fields)
     out = p.updateDatasets(fields, veusz.plugins.DatasetPluginHelper(doc))
     return out
Beispiel #3
0
def export(exports, args):
    '''A shortcut to load a set of files and export them.'''
    import veusz.document as document
    for expfn, vsz in zip(exports, args[1:]):
        doc = document.Document()
        ci = document.CommandInterpreter(doc)
        ci.Load(vsz)
        ci.run('Export(%s)' % repr(expfn))
Beispiel #4
0
def export(exports, docs):
    '''A shortcut to load a set of files and export them.'''
    from veusz import document
    from veusz import utils
    for expfn, vsz in czip(exports, docs):
        doc = document.Document()
        ci = document.CommandInterpreter(doc)
        ci.Load(vsz)
        ci.run('Export(%s)' % repr(expfn))
Beispiel #5
0
def export(exports, docs, options):
    '''A shortcut to load a set of files and export them.'''
    from veusz import document
    from veusz import utils

    # TODO: validate options
    opttxt = ', '.join(options) if options else ''

    for expfn, vsz in czip(exports, docs):
        doc = document.Document()
        ci = document.CommandInterpreter(doc)
        ci.Load(vsz)
        ci.run('Export(%s, %s)' % (repr(expfn), opttxt))
Beispiel #6
0
    def __init__(self, title, doc=None):
        qt4.QMainWindow.__init__(self)

        self.setWindowTitle(title)

        self.document = doc
        if not doc:
            self.document = document.Document()

        self.plot = plotwindow.PlotWindow(self.document, self)
        self.toolbar = None

        self.setCentralWidget(self.plot)
Beispiel #7
0
def renderTest(invsz, outfile):
    """Render vsz document to create outfile."""

    d = document.Document()
    ifc = document.CommandInterface(d)

    # this lot looks a bit of a mess
    cmds = d.eval_context
    for cmd in document.CommandInterface.safe_commands:
        cmds[cmd] = getattr(ifc, cmd)
    for cmd in document.CommandInterface.unsafe_commands:
        cmds[cmd] = getattr(ifc, cmd)

    exec "from numpy import *" in cmds
    ifc.AddImportPath(os.path.dirname(invsz))
    exec open(invsz) in cmds
    ifc.Export(outfile)
    def __init__(self, file_prefix):
        QtGui.QMainWindow.__init__(self)

        self.ui = Ui_DWLMainWindow()
        self.ui.setupUi(self)

        self._set_up_statusbar()
        self._set_up_menu()
        self.document = document.Document()
        self.plot = DWLPlotWindow(self.document, self)
        self.toolbar = self.plot.createToolbar(self, None)
        self.toolbar.show()
        self.setCentralWidget(self.plot)
        self.plotting_logic = PlottingLogic(self, self.document, file_prefix)

        # print current x,y mouse position in lower left hand corner
        self.connect(self.plot, QtCore.SIGNAL("sigAxisValuesFromMouse"),
                     self.slotUpdateAxisValues)
 def do(self, ax, ay, bx, by, op='A-B', **kw):
     doc = document.Document()
     insertData(doc, {'ax': ax, 'ay': ay, 'bx': bx, 'by': by})
     fields = {
         'ax': 'ax',
         'ay': 'ay',
         'bx': 'bx',
         'by': 'by',
         'ds_out': 'out',
         'operation': op,
         'smooth': False,
         'relative': True,
         'tolerance': 1.
     }
     fields.update(kw)
     p = CurveOperationPlugin(**fields)
     p.getDatasets(fields)
     out = p.updateDatasets(fields, veusz.plugins.DatasetPluginHelper(doc))
     return out
    def do(self, beta, R0, T, dil='', dilT='', gdil='', gdilT='', **kw):
        fields = self.fields.copy()
        doc = document.Document()
        p = self.create_plugin(doc,
                               fields,
                               beta,
                               R0,
                               T,
                               dil='',
                               dilT='',
                               gdil='',
                               gdilT='',
                               **kw)

        logging.debug('get ds')
        p.getDatasets(fields)
        logging.debug('update ds')
        out = p.updateDatasets(fields, veusz.plugins.DatasetPluginHelper(doc))
        return out
    def test_when_temperature_changes_too_little_sample_expansion_and_sample_expansion_temperature_are_empty(
            self):
        """
           If temperature changes too little, it becomes impossible to
           interpolate data to calculate density variations.
           So, no variation is assumed.
        """
        N = 100
        beta = np.ones(N) * 4.3
        R0 = np.ones(N) * 6220
        fixed_temperature = np.ones(N) * 25

        fields = self.fields.copy()
        doc = document.Document()

        plugin = self.create_plugin(doc, fields, beta, R0, fixed_temperature)

        #sample expansion is 'dil'
        #sample expansion temperature is 'dilT'
        for actual_default_value in [
                field for field in plugin.fields
                if field.name.startswith("dil")
        ]:
            self.assertEqual('', actual_default_value.default)