• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python loader.Loader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sas.sascalc.dataloader.loader.Loader的典型用法代码示例。如果您正苦于以下问题:Python Loader类的具体用法?Python Loader怎么用?Python Loader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Loader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self):
        PluginBase.__init__(self, name="Pr Inversion")
        ## Simulation window manager
        self.simview = None

        ## State data
        self.alpha = self.DEFAULT_ALPHA
        self.nfunc = self.DEFAULT_NFUNC
        self.max_length = self.DEFAULT_DMAX
        self.q_min = None
        self.q_max = None
        self.has_bck = False
        self.slit_height = 0
        self.slit_width = 0
        ## Remember last plottable processed
        self.last_data = ""
        self._current_file_data = None
        ## Time elapsed for last computation [sec]
        # Start with a good default
        self.elapsed = 0.022
        self.iq_data_shown = False

        ## Current invertor
        self.invertor = None
        self.pr = None
        self.data_id = IQ_DATA_LABEL
        # Copy of the last result in case we need to display it.
        self._last_pr = None
        self._last_out = None
        self._last_cov = None
        ## Calculation thread
        self.calc_thread = None
        ## Estimation thread
        self.estimation_thread = None
        ## Result panel
        self.control_panel = None
        ## Currently views plottable
        self.current_plottable = None
        ## Number of P(r) points to display on the output plot
        self._pr_npts = 51
        self._normalize_output = False
        self._scale_output_unity = False

        ## List of added P(r) plots
        self._added_plots = {}
        self._default_Iq = {}
        self.list_plot_id = []

        # Associate the inversion state reader with .prv files
        from inversion_state import Reader

        # Create a CanSAS/Pr reader
        self.state_reader = Reader(self.set_state)
        self._extensions = '.prv'
        l = Loader()
        l.associate_file_reader('.prv', self.state_reader)
        #l.associate_file_reader(".svs", self.state_reader)

        # Log startup
        logging.info("Pr(r) plug-in started")
开发者ID:ianhi,项目名称:sasview,代码行数:60,代码来源:pr.py


示例2: test_double_trans_spectra

 def test_double_trans_spectra(self):
     xmlreader = XMLreader(self.isis_1_1_doubletrans, self.schema_1_1)
     self.assertTrue(xmlreader.validate_xml())
     reader = Loader()
     data = reader.load(self.isis_1_1_doubletrans)
     for item in data:
         self._check_data(item)
开发者ID:rprospero,项目名称:sasview,代码行数:7,代码来源:utest_cansas.py


示例3: get_panels

    def get_panels(self, parent):
        """
        Create and return the list of wx.Panels for your plug-in.
        Define the plug-in perspective.

        Panels should inherit from DefaultPanel defined below,
        or should present the same interface. They must define
        "window_caption" and "window_name".

        :param parent: parent window

        :return: list of panels
        """
        # # Save a reference to the parent
        self.parent = parent
        self.frame = MDIFrame(self.parent, None, 'None', (100, 200))
        self.invariant_panel = InvariantPanel(parent=self.frame)
        self.frame.set_panel(self.invariant_panel)
        self._frame_set_helper()
        self.invariant_panel.set_manager(manager=self)
        self.perspective.append(self.invariant_panel.window_name)
        # Create reader when fitting panel are created
        self.state_reader = reader(self.set_state)
        # append that reader to list of available reader
        loader = Loader()
        loader.associate_file_reader(".inv", self.state_reader)
        # loader.associate_file_reader(".svs", self.state_reader)
        # Return the list of panels
        return [self.invariant_panel]
开发者ID:ianhi,项目名称:sasview,代码行数:29,代码来源:invariant.py


示例4: on_click_save

    def on_click_save(self, event):
        """
        Save change into a file
        """
        if not self._data:
            return
        self.on_change_run(event=None)
        self.on_change_title(event=None)
        path = None
        wildcard = "CanSAS 1D files(*.xml)|*.xml"
        dlg = wx.FileDialog(self, "Choose a file",
                            self._default_save_location, "", wildcard , wx.SAVE)

        for data in self._data:
            if issubclass(data.__class__, Data2D):
                msg = "No conventional writing format for \n\n"
                msg += "Data2D at this time.\n"
                dlg = wx.MessageDialog(None, msg, 'Error Loading File',
                                             wx.OK | wx.ICON_EXCLAMATION)
                dlg.ShowModal()
            else:
                if dlg.ShowModal() == wx.ID_OK:
                    path = dlg.GetPath()
                    mypath = os.path.basename(path)
                    loader = Loader()
                    format = ".xml"
                    if os.path.splitext(mypath)[1].lower() == format:
                        loader.save(path, data, format)
                    try:
                        self._default_save_location = os.path.dirname(path)
                    except:
                        pass
                    dlg.Destroy()
        event.Skip()
开发者ID:ianhi,项目名称:sasview,代码行数:34,代码来源:data_editor.py


示例5: test_singleton

 def test_singleton(self):
     """
         Testing whether Loader is truly a singleton
     """
     # Create a 'new' Loader
     b = Loader()
     self.assertEqual(self.loader._get_registry_creation_time(),
                      b._get_registry_creation_time())
开发者ID:ianhi,项目名称:sasview,代码行数:8,代码来源:testLoad.py


示例6: load_data

def load_data(filename):
    """
    Load data using a sasview loader.
    """
    from sas.sascalc.dataloader.loader import Loader
    loader = Loader()
    data = loader.load(filename)
    if data is None:
        raise IOError("Data %r could not be loaded" % filename)
    return data
开发者ID:bmaranville,项目名称:sasmodels,代码行数:10,代码来源:data.py


示例7: nxcansas_writer

class nxcansas_writer(unittest.TestCase):

    def setUp(self):
        self.loader = Loader()
        self.writer = NXcanSASWriter()
        self.read_file_1d = "cansas1d.xml"
        self.write_file_1d = "export1d.h5"
        self.read_file_2d = "exp18_14_igor_2dqxqy.dat"
        self.write_file_2d = "export2d.h5"

        self.data_1d = self.loader.load(self.read_file_1d)[0]

        self.data_2d = self.loader.load(self.read_file_2d)[0]
        self.data_2d.detector[0].name = ''
        self.data_2d.source.radiation = 'neutron'

    def test_write_1d(self):
        self.writer.write([self.data_1d], self.write_file_1d)
        data = self.loader.load(self.write_file_1d)
        self.assertTrue(len(data) == 1)
        data = data[0]
        self.assertTrue(len(data.x) == len(self.data_1d.x))
        self.assertTrue(len(data.y) == len(self.data_1d.y))
        self.assertTrue(len(data.dy) == len(self.data_1d.dy))
        self._check_metadata(data, self.data_1d)

    def test_write_2d(self):
        self.writer.write([self.data_2d], self.write_file_2d)
        data = self.loader.load(self.write_file_2d)
        self.assertTrue(len(data) == 1)
        data = data[0]
        self.assertTrue(len(data.data) == len(self.data_2d.data))
        self.assertTrue(len(data.qx_data) == len(self.data_2d.qx_data))
        self.assertTrue(len(data.qy_data) == len(self.data_2d.qy_data))
        self._check_metadata(data, self.data_2d)

    def _check_metadata(self, written, correct):
        self.assertTrue(written.title == correct.title)
        self.assertTrue(written.sample.name == correct.sample.name)
        self.assertAlmostEqual(written.sample.thickness, correct.sample.thickness)
        self.assertAlmostEqual(written.sample.temperature, correct.sample.temperature)
        self.assertTrue(written.instrument == correct.instrument)
        self.assertTrue(len(written.detector) == len(correct.detector))
        for i in range(len(written.detector)):
            written_det = written.detector[i]
            correct_det = correct.detector[i]
            self.assertAlmostEqual(written_det.distance, correct_det.distance)
            self.assertTrue(written_det.name == correct_det.name)
        self.assertTrue(written.source.radiation == correct.source.radiation)

    def tearDown(self):
        if os.path.isfile(self.write_file_1d):
            os.remove(self.write_file_1d)
        if os.path.isfile(self.write_file_2d):
            os.remove(self.write_file_2d)
开发者ID:lewisodriscoll,项目名称:sasview,代码行数:55,代码来源:utest_nxcansas_writer.py


示例8: test_old_cansas_files

 def test_old_cansas_files(self):
     reader1 = XMLreader(self.cansas1d, self.schema_1_0)
     self.assertTrue(reader1.validate_xml())
     file_loader = Loader()
     file_loader.load(self.cansas1d)
     reader2 = XMLreader(self.cansas1d_units, self.schema_1_0)
     self.assertTrue(reader2.validate_xml())
     reader3 = XMLreader(self.cansas1d_badunits, self.schema_1_0)
     self.assertTrue(reader3.validate_xml())
     reader4 = XMLreader(self.cansas1d_slit, self.schema_1_0)
     self.assertTrue(reader4.validate_xml())
开发者ID:rprospero,项目名称:sasview,代码行数:11,代码来源:utest_cansas.py


示例9: testLoader

class testLoader(unittest.TestCase):
    
    def setUp(self):
        self.L=Loader()
        self.L.find_plugins('../plugins')
            
    def testplugin(self):
        """ 
            test loading with a test reader only 
            found in the plugins directory
        """
        output = self.L.load('test_data.test')
        self.assertEqual(output.x[0], 1234.)
开发者ID:ianhi,项目名称:sasview,代码行数:13,代码来源:testplugings.py


示例10: setUp

 def setUp(self):
     """
         Set up the initial conditions before _each_ test
         so that they all start from the same well-defined state. 
     """
     #Creating a loader
     self.L=Loader()
开发者ID:ianhi,项目名称:sasview,代码行数:7,代码来源:testLoad.py


示例11: get_panels

    def get_panels(self, parent):
        """
        Define the GUI panels
        """
        self.parent = parent
        self.frame = MDIFrame(self.parent, None, 'None', (100,200))
        self.data_id = IQ_DATA_LABEL
        self.corfunc_panel = CorfuncPanel(parent=self.frame)
        self.frame.set_panel(self.corfunc_panel)
        self.corfunc_panel.set_manager(self)
        self._frame_set_helper()
        self.perspective.append(self.corfunc_panel.window_name)

        l = Loader()
        l.associate_file_reader('.crf', self.state_reader)

        return [self.corfunc_panel]
开发者ID:rprospero,项目名称:sasview,代码行数:17,代码来源:corfunc.py


示例12: choose_data_file

    def choose_data_file(self, location=None):
        """
        Open a file dialog to allow loading a file
        """
        path = None
        if location == None:
            location = os.getcwd()

        l = Loader()
        cards = l.get_wildcards()
        wlist = '|'.join(cards)

        dlg = wx.FileDialog(self, "Choose a file", location, "", wlist, wx.OPEN)
        if dlg.ShowModal() == wx.ID_OK:
            path = dlg.GetPath()
            mypath = os.path.basename(path)
        dlg.Destroy()
        return path
开发者ID:ianhi,项目名称:sasview,代码行数:18,代码来源:data_editor.py


示例13: setUp

 def setUp(self):
     self.loader = Loader()
     self.datafile_basic = find("simpleexamplefile.h5")
     self.datafile_multiplesasentry = find(
         "test_data" + os.sep + "nxcansas_1Dand2D_multisasentry.h5")
     self.datafile_multiplesasdata = find(
         "test_data" + os.sep + "nxcansas_1Dand2D_multisasdata.h5")
     self.datafile_multiplesasdata_multiplesasentry = find(
         "test_data" + os.sep + "nxcansas_1Dand2D_multisasentry_multisasdata.h5")
开发者ID:rprospero,项目名称:sasview,代码行数:9,代码来源:utest_cansas.py


示例14: test_save_cansas_v1_0

 def test_save_cansas_v1_0(self):
     filename = "isis_1_0_write_test.xml"
     xmlreader = XMLreader(self.isis_1_0, self.schema_1_0)
     valid = xmlreader.validate_xml()
     self.assertTrue(valid)
     reader_generic = Loader()
     dataloader = reader_generic.load(self.isis_1_0)
     reader_cansas = Reader()
     cansasreader = reader_cansas.read(self.isis_1_0)
     for i in range(len(dataloader)):
         self._check_data(dataloader[i])
         self._check_data(cansasreader[i])
         reader_generic.save(filename, dataloader[i], None)
         reader2 = Reader()
         return_data = reader2.read(filename)
         written_data = return_data[0]
         xmlwrite = XMLreader(filename, self.schema_1_0)
         valid = xmlreader.validate_xml()
         self.assertTrue(valid)
         self._check_data(written_data)
开发者ID:ianhi,项目名称:sasview,代码行数:20,代码来源:utest_cansas.py


示例15: test_save_cansas_v1_0

 def test_save_cansas_v1_0(self):
     xmlreader = XMLreader(self.isis_1_0, self.schema_1_0)
     self.assertTrue(xmlreader.validate_xml())
     reader_generic = Loader()
     dataloader = reader_generic.load(self.isis_1_0)
     reader_cansas = Reader()
     cansasreader = reader_cansas.read(self.isis_1_0)
     for i in range(len(dataloader)):
         self._check_data(dataloader[i])
         self._check_data(cansasreader[i])
         reader_generic.save(self.write_1_0_filename, dataloader[i], None)
         reader2 = Reader()
         self.assertTrue(os.path.isfile(self.write_1_0_filename))
         return_data = reader2.read(self.write_1_0_filename)
         written_data = return_data[0]
         xmlreader = XMLreader(self.write_1_0_filename, self.schema_1_0)
         self.assertTrue(xmlreader.validate_xml())
         self._check_data(written_data)
     if os.path.isfile(self.write_1_0_filename):
         os.remove(self.write_1_0_filename)
开发者ID:rprospero,项目名称:sasview,代码行数:20,代码来源:utest_cansas.py


示例16: setUp

 def setUp(self):
     self.loader = Loader()
     self.f1_list = self.loader.load(find("ascii_test_1.txt"))
     self.f1 = self.f1_list[0]
     self.f2_list = self.loader.load(find("ascii_test_2.txt"))
     self.f2 = self.f2_list[0]
     self.f3_list = self.loader.load(find("ascii_test_3.txt"))
     self.f3 = self.f3_list[0]
     self.f4_list = self.loader.load(find("ascii_test_4.abs"))
     self.f4 = self.f4_list[0]
     self.f5_list = self.loader.load(find("ascii_test_5.txt"))
     self.f5 = self.f5_list[0]
开发者ID:rprospero,项目名称:sasview,代码行数:12,代码来源:utest_ascii.py


示例17: __init__

 def __init__(self, path, completefn=None,
              updatefn=None,
              yieldtime=0.01,
              worktime=0.01
              ):
     CalcThread.__init__(self, completefn,
              updatefn,
              yieldtime,
              worktime)
     self.path = path
     #Instantiate a loader 
     self.loader = Loader()
     self.starttime = 0
开发者ID:ianhi,项目名称:sasview,代码行数:13,代码来源:load_thread.py


示例18: designtest

class designtest(unittest.TestCase):
    
    def setUp(self):
        self.loader = Loader()
        
    def test_singleton(self):
        """
            Testing whether Loader is truly a singleton
        """
        # Create a 'new' Loader
        b = Loader()
        self.assertEqual(self.loader._get_registry_creation_time(),
                         b._get_registry_creation_time())
开发者ID:ianhi,项目名称:sasview,代码行数:13,代码来源:testLoad.py


示例19: setUp

    def setUp(self):
        self.loader = Loader()
        self.writer = NXcanSASWriter()
        self.read_file_1d = "cansas1d.xml"
        self.write_file_1d = "export1d.h5"
        self.read_file_2d = "exp18_14_igor_2dqxqy.dat"
        self.write_file_2d = "export2d.h5"

        self.data_1d = self.loader.load(self.read_file_1d)[0]

        self.data_2d = self.loader.load(self.read_file_2d)[0]
        self.data_2d.detector[0].name = ''
        self.data_2d.source.radiation = 'neutron'
开发者ID:lewisodriscoll,项目名称:sasview,代码行数:13,代码来源:utest_nxcansas_writer.py


示例20: OnLoad

 def OnLoad(self,event):
     path = None
     dlg = wx.FileDialog(None, "Choose a file", os.getcwd(), "", "*", wx.OPEN)
     if dlg.ShowModal() == wx.ID_OK:
         path = dlg.GetPath()
         mypath = os.path.basename(path)
         from sas.sascalc.dataloader.loader import  Loader
        
         #Instantiate a loader 
         L=Loader()
         
         #Receives data
         try:
             output=L.load(path)
         except:
             raise
        
         newplot=Data2D(image=output.data)
         newplot.setValues(output)
         self.plotpanel.add_image(newplot)
        
             
     dlg.Destroy()
开发者ID:rprospero,项目名称:sasview,代码行数:23,代码来源:test_panel2D.py



注:本文中的sas.sascalc.dataloader.loader.Loader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sass.compile函数代码示例发布时间:2022-05-27
下一篇:
Python SphereModel.SphereModel类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap