Beispiel #1
0
    def plot_random_var(self,
                        var_list=None,
                        histogram_kwargs=None,
                        plot_kwargs=None):
        """Plot histogram and the PDF.

        This function creates a histogram to display the random variable
        distribution.

        Parameters
        ----------
        var_list : list, optional
            List of random variables, in string format, to plot.
            Default is plotting all the random variables.
        histogram_kwargs : dict, optional
            Additional key word arguments can be passed to change
            the plotly.go.histogram (e.g. histnorm="probability density", nbinsx=20...).
            *See Plotly API to more information.
        plot_kwargs : dict, optional
            Additional key word arguments can be passed to change the plotly go.figure
            (e.g. line=dict(width=4.0, color="royalblue"), opacity=1.0, ...).
            *See Plotly API to more information.

        Returns
        -------
        fig : Plotly graph_objects.Figure()
            A figure with the histogram plots.

        Examples
        --------
        >>> import ross.stochastic as srs
        >>> elm = srs.st_shaft_example()
        >>> fig = elm.plot_random_var(["odl"])
        >>> # fig.show()
        """
        label = dict(
            L="Length",
            idl="Left inner diameter",
            odl="Left outer diameter",
            idr="Right inner diameter",
            odr="Right outer diameter",
        )
        is_random = self.is_random
        if "material" in is_random:
            is_random.remove("material")

        if var_list is None:
            var_list = is_random
        elif not all(var in is_random for var in var_list):
            raise ValueError(
                "Random variable not in var_list. Select variables from {}".
                format(is_random))

        return plot_histogram(self.attribute_dict,
                              label,
                              var_list,
                              histogram_kwargs={},
                              plot_kwargs={})
    def plot_random_var(self,
                        var_list=None,
                        histogram_kwargs=None,
                        plot_kwargs=None):
        """Plot histogram and the PDF.

        This function creates a histogram to display the random variable
        distribution.

        Parameters
        ----------
        var_list : list, optional
            List of random variables, in string format, to plot.
            Default is plotting all the random variables.
        histogram_kwargs : dict, optional
            Additional key word arguments can be passed to change
            the plotly.go.histogram (e.g. histnorm="probability density", nbinsx=20...).
            *See Plotly API to more information.
        plot_kwargs : dict, optional
            Additional key word arguments can be passed to change the plotly go.figure
            (e.g. line=dict(width=4.0, color="royalblue"), opacity=1.0, ...).
            *See Plotly API to more information.

        Returns
        -------
        fig : Plotly graph_objects.Figure()
            A figure with the histogram plots.

        Examples
        --------
        >>> import ross.stochastic as srs
        >>> elm = srs.st_bearing_example()
        >>> fig = elm.plot_random_var(["kxx"])
        >>> # fig.show()
        """
        label = dict(
            kxx="Kxx",
            kxy="Kxy",
            kyx="Kyx",
            kyy="Kyy",
            cxx="Cxx",
            cxy="Cxy",
            cyx="Cyx",
            cyy="Cyy",
        )
        if var_list is None:
            var_list = self.is_random
        elif not all(var in self.is_random for var in var_list):
            raise ValueError(
                "Random variable not in var_list. Select variables from {}".
                format(self.is_random))

        return plot_histogram(self.attribute_dict, label, var_list,
                              histogram_kwargs, plot_kwargs)
Beispiel #3
0
    def plot_random_var(self,
                        var_list=[],
                        histogram_kwargs={},
                        plot_kwargs={}):
        """Plot histogram and the PDF.

        This function creates a histogram to display the random variable
        distribution.

        Parameters
        ----------
        var_list : list, optional
            List of random variables, in string format, to plot.
        histogram_kwargs : dict, optional
            Additional key word arguments can be passed to change
            the plotly.go.histogram (e.g. histnorm="probability density", nbinsx=20...).
            *See Plotly API to more information.
        plot_kwargs : dict, optional
            Additional key word arguments can be passed to change the plotly go.figure
            (e.g. line=dict(width=4.0, color="royalblue"), opacity=1.0, ...).
            *See Plotly API to more information.

        Returns
        -------
        fig : Plotly graph_objects.Figure()
            A figure with the histogram plots.

        Examples
        --------
        >>> import ross.stochastic as srs
        >>> E = np.random.uniform(208e9, 211e9, 5)
        >>> st_steel = srs.ST_Material(name="Steel", rho=7810, E=E, G_s=81.2e9)
        >>> fig = st_steel.plot_random_var(["E"])
        >>> # fig.show()
        """
        label = dict(
            E="Young's Modulus",
            G_s="Shear Modulus",
            Poisson="Poisson coefficient",
            rho="density",
        )
        is_random = self.is_random

        if not all(var in self.is_random for var in var_list):
            raise ValueError(
                "Not random variable in var_list. Select variables from {}".
                format(is_random))

        return plot_histogram(self.attribute_dict,
                              label,
                              var_list,
                              histogram_kwargs={},
                              plot_kwargs={})
Beispiel #4
0
    def plot_random_var(self,
                        var_list=[],
                        histogram_kwargs={},
                        plot_kwargs={}):
        """Plot histogram and the PDF.

        This function creates a histogram to display the random variable
        distribution.

        Parameters
        ----------
        var_list : list, optional
            List of random variables, in string format, to plot.
        histogram_kwargs : dict, optional
            Additional key word arguments can be passed to change
            the plotly.go.histogram (e.g. histnorm="probability density", nbinsx=20...).
            *See Plotly API to more information.
        plot_kwargs : dict, optional
            Additional key word arguments can be passed to change the plotly go.figure
            (e.g. line=dict(width=4.0, color="royalblue"), opacity=1.0, ...).
            *See Plotly API to more information.

        Returns
        -------
        fig : Plotly graph_objects.Figure()
            A figure with the histogram plots.

        Examples
        --------
        >>> import ross.stochastic as srs
        >>> elm = srs.st_pointmass_example()
        >>> fig = elm.plot_random_var(["mx"])
        >>> # fig.show()
        """
        label = dict(
            mx="Mass on the X direction",
            my="Mass on the Y direction",
            m="Mass",
        )
        if not all(var in self.is_random for var in var_list):
            raise ValueError(
                "Not random variable in var_list. Select variables from {}".
                format(self.is_random))

        return plot_histogram(self.attribute_dict,
                              label,
                              var_list,
                              histogram_kwargs={},
                              plot_kwargs={})
Beispiel #5
0
    def plot_random_var(self, var_list=[], **kwargs):
        """Plot histogram and the PDF.

        This function creates a histogram to display the random variable
        distribution.

        Parameters
        ----------
        var_list : list, optional
            List of random variables, in string format, to plot.
        **kwargs : optional
            Additional key word arguments can be passed to change
            the numpy.histogram (e.g. density=True, bins=11, ...)

        Returns
        -------
        grid_plot : bokeh row
            A row with the histogram plots.

        Examples
        --------
        >>> import ross.stochastic as srs
        >>> elm = srs.st_shaft_example()
        >>> elm.plot_random_var(["odl"]) # doctest: +ELLIPSIS
        Row...
        """
        label = dict(
            L="Length",
            idl="Left inner diameter",
            odl="Left outer diameter",
            idr="Right inner diameter",
            odr="Right outer diameter",
        )
        is_random = self.is_random
        if "material" in is_random:
            is_random.remove("material")

        if not all(var in self.is_random for var in var_list):
            raise ValueError(
                "Not random variable in var_list. Select variables from {}".
                format(is_random))

        return plot_histogram(self.attribute_dict, label, var_list, **kwargs)
    def plot_random_var(self, var_list=[], **kwargs):
        """Plot histogram and the PDF.

        This function creates a histogram to display the random variable
        distribution.

        Parameters
        ----------
        var_list : list, optional
            List of random variables, in string format, to plot.
        **kwargs : optional
            Additional key word arguments can be passed to change
            the numpy.histogram (e.g. density=True, bins=11, ...)

        Returns
        -------
        grid_plot : bokeh row
            A row with the histogram plots.

        Examples
        --------
        >>> import ross.stochastic as srs
        >>> elm = srs.st_bearing_example()
        >>> elm.plot_random_var(["kxx"]) # doctest: +ELLIPSIS
        Row...
        """
        label = dict(
            kxx="Direct stiffness in the X direction",
            kxy="Cross coupled stiffness in the X direction",
            kyx="Cross coupled stiffness in the Y direction",
            kyy="Direct stiffness in the Y direction",
            cxx="Direct damping in the X direction",
            cxy="Cross coupled damping in the X direction",
            cyx="Cross coupled damping in the Y direction",
            cyy="Direct damping in the y direction",
        )
        if not all(var in self.is_random for var in var_list):
            raise ValueError(
                "Not random variable in var_list. Select variables from {}".
                format(self.is_random))

        return plot_histogram(self.attribute_dict, label, var_list, **kwargs)
Beispiel #7
0
    def plot_random_var(self, var_list=[], **kwargs):
        """Plot histogram and the PDF.

        This function creates a histogram to display the random variable
        distribution.

        Parameters
        ----------
        var_list : list, optional
            List of random variables, in string format, to plot.
        **kwargs : optional
            Additional key word arguments can be passed to change
            the numpy.histogram (e.g. density=True, bins=11, ...)

        Returns
        -------
        grid_plot : bokeh row
            A row with the histogram plots.

        Examples
        --------
        >>> import ross.stochastic as srs
        >>> E = np.random.uniform(208e9, 211e9, 5)
        >>> st_steel = ST_Material(name="Steel", rho=7810, E=E, G_s=81.2e9)
        >>> st_steel.plot_random_var(["E"]) # doctest: +ELLIPSIS
        Row...
        """
        label = dict(
            E="Young's Modulus",
            G_s="Shear Modulus",
            Poisson="Poisson coefficient",
            rho="density",
        )
        is_random = self.is_random

        if not all(var in self.is_random for var in var_list):
            raise ValueError(
                "Not random variable in var_list. Select variables from {}".
                format(is_random))

        return plot_histogram(self.attribute_dict, label, var_list, **kwargs)
Beispiel #8
0
    def plot_random_var(self, var_list=[], **kwargs):
        """Plot histogram and the PDF.

        This function creates a histogram to display the random variable
        distribution.

        Parameters
        ----------
        var_list : list, optional
            List of random variables, in string format, to plot.
        **kwargs : optional
            Additional key word arguments can be passed to change
            the numpy.histogram (e.g. density=True, bins=11, ...)

        Returns
        -------
        grid_plot : bokeh row
            A row with the histogram plots.

        Examples
        --------
        >>> import ross.stochastic as srs
        >>> elm = srs.st_disk_example()
        >>> elm.plot_random_var(["Id"]) # doctest: +ELLIPSIS
        Row...
        """
        label = dict(
            m="Mass",
            Id="Diametral moment of inertia",
            Ip="Polar moment of inertia",
        )
        if not all(var in self.is_random for var in var_list):
            raise ValueError(
                "Not random variable in var_list. Select variables from {}".
                format(self.is_random))

        return plot_histogram(self.attribute_dict, label, var_list, **kwargs)