Exemple #1
0
 def NML2_run(self, rerun=False, a=None, **run_params):
     if not len(run_params):
         run_params = self.run_defaults
     a = ca.build_namespace(a=a,**run_params) # Convert keyword args to a namespace.  
     if self.a is None or a.__dict__ != self.a.__dict__ or rerun: # Only rerun if params have changed.  
         self.a = a
         self.lems_file_path = ca.make_lems_file(self.channel,self.a) # Create a lems file.
         self.results = ca.run_lems_file(self.lems_file_path,self.a) # Writes data to disk.  
Exemple #2
0
 def ca_make_lems_file(self, **params):
     # Set params in the SciUnit model instance
     self.params = params
     # ChannelAnalysis only accepts camelCase parameter names
     # This converts snake_case to camelCase
     params = {snake_to_camel(key): value for key, value in params.items()}
     # Build a namespace for use by ChannelAnalysis
     self.ca_namespace = ca.build_namespace(**params)
     # Make the new LEMS file
     self.lems_file_path = ca.make_lems_file(self.channel,
                                             self.ca_namespace)
Exemple #3
0
 def NML2_run(self, rerun=False, a=None, **run_params):
     if not len(run_params):
         run_params = self.run_defaults
     a = ca.build_namespace(
         a=a, **run_params)  # Convert keyword args to a namespace.
     if self.a is None or a.__dict__ != self.a.__dict__ or rerun:  # Only rerun if params have changed.
         self.a = a
         self.lems_file_path = ca.make_lems_file(
             self.channel, self.a)  # Create a lems file.
         self.results = ca.run_lems_file(self.lems_file_path,
                                         self.a)  # Writes data to disk.
Exemple #4
0
    def __init__(self, channel_file_path, channel_index=0, name=None):
        """
        channel_file_path: Path to NML file.
        channel_index: Order of channel in NML file (usually 0 since most files contain one channel).
        name: Optional model name.
        """
        self.nml_file_path = channel_file_path
        channels = ca.get_channels_from_channel_file(self.nml_file_path)
        self.channel = channels[channel_index]
        self.a = None
        self.run_defaults = ca.DEFAULTS.copy() # Temperature, clamp parameters, etc.  
        self.run_defaults.update({'nogui': True})
        self.run_defaults = ca.build_namespace()

        if name is None:
            name = os.path.split()[1].split('.')[0]
        super(ChannelModel,self).__init__(name=name)
Exemple #5
0
    def __init__(self, channel_file_path, channel_index=0, name=None):
        """
        channel_file_path: Path to NML file.
        channel_index: Order of channel in NML file (usually 0 since most files contain one channel).
        name: Optional model name.
        """
        self.nml_file_path = channel_file_path
        channels = ca.get_channels_from_channel_file(self.nml_file_path)
        self.channel = channels[channel_index]
        self.a = None
        self.run_defaults = ca.DEFAULTS.copy(
        )  # Temperature, clamp parameters, etc.
        self.run_defaults.update({'nogui': True})
        self.run_defaults = ca.build_namespace()

        if name is None:
            name = os.path.split()[1].split('.')[0]
        super(ChannelModel, self).__init__(name=name)