Example #1
0
    def ingest_paths(self, filepath_list, min_points=None):
        """
        Creates VecField3d objects from each filepath in the list
        :param filepath_list:   list of filepaths to ingest
        """

        t = Timer()

        # inherit dimensional attributes from first cartesian field and length of file list
        first_vf = VecFieldCartesian(filepath_list[0], velocity_fs=self.velocity_fs)
        self.x_set = first_vf.x_set
        self.y_set = first_vf.y_set
        self.dims = first_vf.dims + tuple([len(filepath_list)])
        self.meshgrid = first_vf.meshgrid

        # fill the dynamic data matrix with zeros
        for key in self.dynamic_set.keys():
            self.dynamic_set[key] = np.ma.zeros(self.dims, 'float')

        # populate some attributes of the dynamic set then delete the vector field instance
        for i, filepath in enumerate(filepath_list):
            cvm = VecFieldCartesian(filepath, velocity_fs=self.velocity_fs)
            self.dynamic_set['U'][:, :, i] = cvm['U']
            self.dynamic_set['V'][:, :, i] = cvm['V']
            self.dynamic_set['W'][:, :, i] = cvm['W']
            self.dynamic_set['M'][:, :, i] = (cvm['U'] ** 2 + cvm['V'] ** 2 + cvm['W'] ** 2) ** 0.5  # magnitudes
            self.dynamic_set['P'][:, :, i] = (cvm['U'] ** 2 + cvm['V'] ** 2) ** 0.5                  # in plane mags
            del cvm

        # now extract the average and fluctuating components from the dynamic data set.
        self._get_average_and_fluctuating(min_points)
        t.finish()
Example #2
0
    def __init__(self, filepath, velocity_fs=None):
        """
        All meaningful attributes of a VecField3d object are constructed upon __init__.
        The "output" attribute is the mean_set.

        :param filepath:        local filepath to a .v3d file
        :param velocity_fs:     free stream velocity, values more than 125% this value will be masked
        """

        assert filepath.endswith(".v3d"), "Input is not a valid .v3d file! filepath='{0}'".format(filepath)
        t = Timer()
        self.filepath = os.path.abspath(filepath)   # local filepath to .v3d file
        self.velocity_fs = velocity_fs              # free stream velocity associated with this file
        self.headers = None                         # list of column headers
        self.dataframe = None                       # pandas dataframe of csv like data.
        self.dims = (None, None)                    # x, y dimensions of all matrix data

        # set up empty coordinate value dictionary, (x and y are two-dimensionalized 1d vectors)
        self.x_set = None
        self.y_set = None
        self.meshgrid = {"x_mesh": None,
                         "y_mesh": None}

        self.vel_matrix = {'U': None,       # x direction velocity
                           'V': None,       # y direction velocity
                           'W': None}       # z direction velocity

        # Build up the attributes
        self._read_v3d()                    # parse the .v3d file, populates the dataframe
        self._get_meshgrid()                # populate self.dims, self.meshgrid
        self._table_to_matrix()             # populate self.mean_set
        print("loaded {0} in {1} s".format(filepath, t.finish()))