示例#1
0
    def _itg(self):
        """
        Instantaneous photosynthesis (umol CO2/m2 leaf/s) and heat fluxes (W/m2).

        Uses `NumberProxy` class to calculate the heat fluxes and work out the
        foliage temperature which is then used in canopy photsynthesis.


        # Returns
            tuple: canopy assimilation and heat fluxes (`HeatFluxes`)

        """
        self.canopy_assimilation(Float(self._tf))
        return (self.canopyassim, ) + self.et + self.h
示例#2
0
class SphereSource(TopologySource):
    name = "Sphere"
    radius = Float(5.0)
    position = Tuple(0., 0., 0., editor_traits={'cols': 3})

    traits_view = View('name', 'radius', 'position', 'modified')

    @on_trait_change("radius, position")
    def on_edit(self):
        self.modified = False
        self.modified = True

    def execute(self):
        pt = gp.gp_Pnt(*self.position)
        R = self.radius
        sph = BRepPrimAPI.BRepPrimAPI_MakeSphere(pt, R)
        self.update_naming(sph)
        return sph.Shape()
示例#3
0
    def update(self, external_info):
        """
        Update the energy balance properties.

        # Arguments
            external_info (dict): will be used to pass information needed by parent classes

        # Returns
            None:

        """
        self.daily_heat_balance(
        )  # daily losses of water by evapotranspiration
        # provides information for Photosyn
        external_info['canopytemp'] = Float(self._tf)
        external_info['petcrop'] = self.dayet.crop
        external_info['petsoil'] = self.dayet.soil
        Photosyn.update(self, external_info)
示例#4
0
class ChamferFilter(FilterSource):
    name = "Chamfer Filter"

    input = Input
    
    size = Float(1.0)
    
    _n_edges = Int(4)
    
    _low = Int(0)
    
    edge_id = Range(low='_low', high='_n_edges')
    
    selector = Instance(TNaming.TNaming_Selector)
    
    traits_view = View(Item('edge_id'),
                       'size',
                       'modified')
    
    def _size_changed(self, new_size):
        self.modified = False
        self.modified = True
    
    @on_trait_change("input, edge_id, label")
    def on_change_selection(self):
        new_id = self.edge_id
        input = self.input
        label = self.label
        
        if not all((input, label)): return
        
        input_shape = input.shape
        
        sel_label = self.label.FindChild(4)
        selector = TNaming.TNaming_Selector(sel_label)
        
        self.selector = selector
        
        topo = Topo(input_shape)
        self._n_edges = topo.number_of_edges()
        for i,edge in enumerate(topo.edges()):
            if i==new_id:
                selector.Select(edge, input_shape)
                print "got selection!"
                break
        else:
            print "no selection"
            
        self.modified = False
        self.modified = True
            
            
    def execute(self):
        input_shape = self.input.shape
        
        topo = Topo(input_shape)
        self._n_edges = topo.number_of_edges()
        
        builder = BRepFilletAPI.BRepFilletAPI_MakeChamfer(input_shape)
        
        Map = TDF.TDF_LabelMap()
        itr = TDF.TDF_ChildIterator(self.parent_label, True)
        while itr.More():
            sub_label = itr.Value()
            Map.Add(sub_label)
            itr.Next()
            
        selector = self.selector
        ret = selector.Solve(Map)
        
        if not ret:
            raise Exception("Failed to solve for edge")
            #print "Failed to solve for edge"
        
        nt = TNaming.TNaming_Tool()
        selected_shape = nt.CurrentShape(selector.NamedShape())
        
        selected_edge = TopoDS.TopoDS().Edge(selected_shape)
        
        try:
            face = Topo(input_shape).faces_from_edge(selected_edge).next()
        except RuntimeError:
            raise #not sure how to handle this
        size = self.size
        builder.Add(size, size, selected_edge, face)
        
        self.update_naming(builder)
        return builder.Shape()