Git Product home page Git Product logo

waketracking's Introduction

SAMWICH Box

A Python-based toolbox for Simulated And Measured Wake Identification and CHaracterization

The notebooks in the example subdirectory are a good way to familiarize yourself with the capabilities of SAMWICH Box, e.g., examples/example_00_quick_start.ipynb.

Note that the contour-based wake trackers depend on the cv2 module from the OpenCV Open Source Computer Vision Library.

A detailed description of methods and usage can be found here: https://ewquon.github.io/waketracking/

waketracking's People

Contributors

ewquon avatar pauladoubrawa avatar

Stargazers

E. Branlard avatar  avatar Ewan Machefaux avatar Mayank Chetan avatar Sebastian Sanchez Perez-Moreno avatar  avatar  avatar

Watchers

James Cloos avatar  avatar  avatar  avatar  avatar

waketracking's Issues

Wake center curl model FAST.Farm

I am trying to extract the wake center from the vtk file of FAST.Farm output. To find the wake center of the

I am getting a wake center lower than the hub height of the turbine. The hub height is at 135m and the height of the wake center of the figure below is at 112m.

I believe I followed this example but maybe I overlooked something.

I have also attached the code i am using

image

from samwich.waketrackers import track
from samwich.dataloaders import PlanarData
import os
import numpy as np
import pyFAST.input_output.vtk_file as vtk_file

# Temporary inputs - Used only to make the specification of file names easier
# Main inputs
numPlans = 1 # Number of planes to be processed. Assumed to be equally spaced
dt = 3.6       # Time step between vtk files
folderPath = r'G:\FAST_Farm_Template\farm_9T_Mann_baseline_avg_V_curl_v2\Cond00_v10.0_PL0.2_TI6\Case00_wdir0.0_fixed_kcurl6\Seed_0' # Path to the folder with the FAST.Farm simulation
rootNameVTK = 'FFarm_mod.Low.DisYZ1.'     # Root name of the test case
outFolder = os.path.join(folderPath, 'wakescenter') # Output folder. Output files will have the same name as the vtks, but with .csv extensions.
rotorDiam = 240 # Rotor diameter
rootPath = os.path.join(folderPath, 'vtk_ff') # Subfolder with vtk's generated by FAST.Farm



# Create the output folder if it does not exist
if not os.path.exists(outFolder):
    os.makedirs(outFolder)





# List all vtk files

planes_xPos = np.zeros(1)+2519.22

listNames = []
listXPos  = []
for i in range(1):
    # Some versions of FAST.Farm write VTk names as 01 and others 1
    nameVTK = f'{rootNameVTK}{i+1000:05d}'
    nameVTK_wo0 = f'{rootNameVTK}{i+1000}'

    # List all files with nameVTK in the name
    thisListOfNames = [f for f in os.listdir(rootPath) if os.path.isfile(os.path.join(rootPath, f)) and nameVTK in f or nameVTK_wo0 in f]
    listNames.extend(thisListOfNames)
    listXPos.extend([planes_xPos[i]]*len(thisListOfNames))    

list_vtk = []
for vtkName in listNames[0:1]:
    filevtk=vtk_file.VTKFile(rootPath + '/' + vtkName)
    filevtk.yp_grid = filevtk.yp_grid[3:14]
    filevtk.zp_grid = filevtk.zp_grid[0:9]
    filevtk.point_data_grid['Velocity']=filevtk.point_data_grid['Velocity'][:,3:14,0:9,:]
    list_vtk.append(filevtk)


# Check how many files
print(len(list_vtk))




# Sort listNames alphabetically. That is enough to make sure that things are sorted by time
listNames = sorted(listNames)

for i in range(numPlans):
    # Get indices of files for this plan
    ind4plan = [j for j, nm in enumerate(listNames) if f'{rootNameVTK}{i+1000:05d}' in nm or f'{rootNameVTK}{i+1000+1}' in nm]
    # Write to a csv file
    outFlPath = os.path.join(outFolder, f'{rootNameVTK}{i+1000:05d}.csv')    

    with open(outFlPath, 'w') as f:
        f.write('t,x,y,z')        

        dict4wake = {'y':[], 'z':[], 'u':[], 'v':[], 'w':[]}   # Used by SAMWICH
        for iTime, iP in enumerate(ind4plan):            
            time = dt*int(listNames[iP].split('.')[-2]) # TIme
            vtk = list_vtk[iP]            

            # 2D arrays with shape len(vtk.yp_grid): rows, len(vtk.zp_grid): columns
            dict4wake['u'] = vtk.point_data_grid['Velocity'][0, :, :, 0]
            dict4wake['v'] = vtk.point_data_grid['Velocity'][0, :, :, 1]
            dict4wake['w'] = vtk.point_data_grid['Velocity'][0, :, :, 2]
            xc = listXPos[i] # X position of the wake center (constant and equal to plane position)

            # Need 2D arrays with same shape as u, v, w
            dict4wake['z'], dict4wake['y'] = np.meshgrid(vtk.zp_grid, vtk.yp_grid)
            inp=dict4wake.copy()
            wakedata = PlanarData(inp)
            wake = track(wakedata.sliceI(), method='ConstantArea', verbose=True)
            
            wake.clear_plot() 
            wake.plot_contour(vmin=1,vmax=13)
            
            # Compute wake centers
            refArea = np.pi*240**2/4
            
            wake.remove_shear(alpha=0.2, zref=135, Uref=10)
            wake.clear_plot()  # force replot for python notebook
            wake.plot_contour(vmin=-5,vmax=5)             
            yc, zc = wake.find_centers(refArea,min_contour_points=5,verbosity=2) # y and z coordinates of the wake center

            
            # Write to file
            f.write(f'{time:.3f},{xc:.3f},{yc[0]:.3f},{zc[0]:.3f}')
            f.flush()
            wake.clear_plot()  
            wake.plot_contour(vmin=-5,vmax=5,outline=True)

I would really appreciate your help.

Best regards,

ConstantFlux tracker fails

For a mean wake, the "ConstantFlux" tracker is failing with the following message:


IndexError Traceback (most recent call last)
in
66 flux_function=lambda u,u_tot: -u*u_tot,
67 field_names=('u','u_tot'),
---> 68 verbosity=10)
69 else:
70 print('which method?')
~/waketracking/samwich/contour/ConstantFluxTracker.py in find_centers(self, ref_flux, flux_function, field_names, trajectory_file, outlines_file, weighted_center, contour_closure, min_contour_points, frame, Ntest, tol, check_deficit, verbosity)
136 fields=field_names,
137 vdcheck=check_deficit,
--> 138 debug=(verbosity > 0))
139 if not info['success']:
140 print('WARNING: find_contour_center was unsuccessful.')
~/waketracking/samwich/waketrackers.py in _find_contour_center(self, itime, target_value, weighted_center, contour_closure, min_contour_points, Ntest, tol, func, fields, vdcheck, debug)
867 Cdata.integrate_function(path, func,
868 testfields,
--> 869 vd=vd)
870 #NfnEvals += 1
871 if fval is not None and (avgdeficit < 0 or vd is None):
~/waketracking/samwich/contour_functions.py in integrate_function(self, path, func, fields, vd, Nmin)
318 if vd is not None:
319 print(inner.shape,vd.shape)
--> 320 vdavg = np.mean(vd.ravel()[inner])
321 else:
322 vdavg = None
IndexError: boolean index did not match indexed array along dimension 0; dimension is 5886 but corresponding boolean dimension is 2688
Collapse

Unable to calculate area

When using the constant area method to identify instantaneous wakes, the find_centers method fails at some times for which the wake is out of the frame. That is okay. However, when I call .calculate_areas() after calling .find_centers(...), the area computation fails whenever there are instances for which the tracking failed. The algorithm should know to only compute area whenever a "path" (wake edge) was successfully identified, and to skip the time indices for which no "path" could be successfully found.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.