AntarikshVishwakarma / Jet-Analysis-Module

Developing a module for preprocessing, PIV, post-processing and analysis of jets, aiming at quantify key parameters from experimental data like entrainment rates, diffusivity, spreading angle, self-similarity (planar or axisymmetric jets), etc
1 stars 0 forks source link

Request to review results #2

Open AntarikshVishwakarma opened 3 years ago

AntarikshVishwakarma commented 3 years ago

Dear Prof. Liberzon,

The ipynb file has 4 codes which I had ran last week and obtained the results. Codes are mostly the same as in the OpenPIV tutorial other than changing the interrogation window size and declaring variables within functions. I was unsure if those are the results that are supposed to be obtained for the images which I had analyzed on. Can I also know what do the red and blue arrows mean for solution 1 and are the arrows in the correct direction as well?

I am currently trying to understand the remaining tutorial codes and seeing the backend codes (on the OpenPIV GitHub page) and I also wanted to replicate a user's vortex PIV result OpenPIV Python Flavor Learning and Testing from a Novice Perspective on OpenPIV's Google group.

Other than OpenPIV documentation, OpenPIV GUI documentation and the OpenPIV GitHub page are there any other resources that I can refer to while completing the above tasks?

Thank you

Yours sincerely Antriksha

alexlib commented 3 years ago

Hi @AntarikshVishwakarma Thanks for the inputs. It seems that you can run OpenPIV quite efficiently. Except for the last figures which do not show vortices (I was thinking it should show a strong vortex, so there is some mistake there) the rest looks quite reasonable.

I suggest you to install the new version of OpenPIV, please repeat the run but replace the first line with

pip install -e git+https://github.com/openpiv/openpiv-python@windef_refactoring#egg=openpiv-python

Then read the changes required for the new version:

  1. everywhere you use openpiv.process, please change to openpiv.pyprocess
  2. everywhere you used before x, y = get_coordinates(image_size, window_size, overlap) it is now x, y = get_coordinates(image_size, search_area_size, overlap). of course if you use equal size for window_size and search_area_size or do not use search_area_size at all, then it does not matter
  3. the tools.save has changed and now it saves 6 columns and not 5: tools.save(x, y, u, v, sig2noise, mask) - we added sig2noise (like it was in the window deformation method which was different from the rest).

But the results should be faster and better.

AntarikshVishwakarma commented 3 years ago

Dear Prof. Liberzon,

For the last part of the OpenPIVtrials ipynb file, I had by mistake used the same images. Basically those two images of the vortices are the same image. When I tried two distinct images the same code gave an expected output by drawing vectors in the direction of the motion of tracer particles.

I had used "!pip install -e git+https://github.com/openpiv/openpiv-python@windef_refactoring#egg=openpiv-python" to install the latest version of OpenPIV. After doing the mentioned changes to the codes I was running into an error which stated that it could not find openpiv module. While installing there was also a warning "WARNING: Generating metadata for package openpiv-python produced metadata for project name openpiv. Fix your #egg=openpiv-python fragments.". I searched online about the "Fix your #egg= fragments" warning. It was told online to run the following command : "!pip install setuptools --upgrade". This command did not remove the warning but the compiler was able to detect openpiv now.

However, I was trying a seperate tutorial code and was running into an error which was of the following type: "ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 441 and the array at index 2 has size 81". Does this have to do something with the warning? The line where this code shows up was the following: "x, y, u, v = scaling.uniform(x, y, u, v, scaling_factor = 96.52 )" I checked the dimensions of x,y,u and v none of them seemed to have the dimension being mentioned in the error, so which array is the compiler pointing out? I tried running the code with different images but the same error occurred on a different line with different array sizes and index locations.

The ipynb file is "Problemcode", the images which I was trying to use are pic1.bmp, pic2.bmp, B001_1.tif, B001_2.tif. I have just uploaded the files in my Jet Analysis Module repository.

Thank you

Yours sincerely Antriksha

alexlib commented 3 years ago

Hi @AntarikshVishwakarma .

Let's do things slowly and in this particular order:

  1. What platform do you use? Windows/Linux/Mac OS X/ ?
  2. The easiest way to work with Python nowadays is to use Anaconda Python Distribution https://www.anaconda.com/products/individual
  3. After you get Anaconda working, try to create new environment and install everything in that environment. I use Linux and I work in a command shell to do so: conda create -n openpiv python=3.8 and then conda activate openpiv. Then everytime you want to work on this project you need to switch to the environment by conda activate openpiv and see that your shell points to (openpiv) before you run the rest.
  4. in this environment you can install openpiv using conda install -c conda-forge openpiv or pip install openpiv. Any of these should bring you the version 0.23.2 (today the most updated version). you might want to use pip install openpiv --upgrade if you install it over the previous version.
  5. after than in the same shell (openpiv) you can try to run python and from python `>> import openpiv`` to see it's imported and running
  6. after that you need to add jupyter to work with the notebooks and other libraries to work with openpiv. Some of those are already installed due to openpiv installation and some might be missing if we forgot something. You can add those using conda install imageio (for example).
  7. run Jupyter notebook from that environment using jupyter notebook and then opening your notebook. In the top right corner check that you see the name of your kernel or choose it from the Change Kernel menu.
  8. Pull the new version of the notebook from this github repository - you'll find the updated version that runs. There were a couple of problems in the previous one.
AntarikshVishwakarma commented 3 years ago

Dear Prof. Liberzon,

I had a partition in my laptop already which was running Elementary OS (Linux distribution based on Ubuntu) so I tried coding there. I had followed your steps and was able to install Anaconda, and run OpenPIV. Upon comparing and correcting my code I was able to obtain the same result as you had uploaded.

Is there a particular task you want me to do with OpenPIV (like processing a certain image in a certain way) or should I proceed to reading the literature and see how I can implement self similarity and entrainment of jets in Python?

Yours sincerely Antriksha

alexlib commented 3 years ago

@AntarikshVishwakarma If you can run OpenPIV - try to analyse some jet data first. When we have this, we could try to plot velocity profiles of the jet at various distances. Then we'll make further progress

AntarikshVishwakarma commented 3 years ago

Dear Prof. Liberzon,

A new ipynb file called "Jet Velocity Analysis" has been uploaded in the repository. The images used in the analysis were taken from the PIV challenge website. I have attempted to overlay velocity vectors on the PIV image and also plotted velocity profile.

The values of the parameters that were set in the code (like threshhold, max_iter, kernel_size,scaling_factor, scale and width) was found by trial and error. I started from the default values in the tutorial and tried values greater and smaller than those values. I kept on changing the values until I found the vector plot on the image seemed correct. Is there a more rationale way to find the values for these terms?

Most of the vector lines are red whereas only 5 are blue. When I went through the openpiv>tools>save function the comment for mask reads "a two dimensional boolen array where elements corresponding to invalid vectors are True". After I print out the values of mask array, I noticed that most elements are True only 5 are false. However, when you see the actual motion of particles in the image (after downloading all images and playing it) they seem to follow the directions of red vectors. The blue vectors look more random. What mistake am I doing in the processing of the images that the program is thinking most of the vectors are invalid?

Lastly, please also let me know if my velocity profile plots are correct.

Yours Sincerely Antriksha

alexlib commented 3 years ago

First, please tell me which jet case you use? https://www.pivchallenge.org/pub03/index.html#a or https://www.pivchallenge.org/pub05/index.html#c ?

AntarikshVishwakarma commented 3 years ago

Prof. it was https://www.pivchallenge.org/pub05/index.html#c . I have mentioned the URL, the folder and the image name which I used in the Jupyter Notebook actually

alexlib commented 3 years ago

see my commit - I have no idea what was wrong with your case, except that we need to analyze 001a.bmp with 001b.bmp and not with 002a.bmp. the rest was strange, but i broke the process into cells to get a more clear picture.

AntarikshVishwakarma commented 3 years ago

Prof. , I had compared the latest commit with the code which I had submitted before, found some difference hence wanted to know the reasons behind them:

I understand the try and except commands are not required if we are using c001a.bmp and c001b.bmp only. Also since winsize = searchsize, I am assuming that the entire interrogation window will be used for the cross correlation analysis.

How do we decide the value for the overlap variable?

On the website it was given that the time interval between 001a and 002a is 200 micro seconds. So shouldn't dt = 100 micro seconds between 001a and 001b?

Can I know the reason why the correlation method in extended_search_area_piv function is selected as 'linear' ? And the normalized_correlation is set as 'False' ? Because on the GitHub page for OpenPIV (within the code for pyprocess) it was written that if the correlation method is linear then normalized correlation should be True

Is the value for the threshold variable in the sig2noise_val function decided by looking at the value of ((the first dimension of image size)/maximum value of x) ? I was trying to understand the meaning of the line 512/x.max()

alexlib commented 3 years ago

Prof. , I had compared the latest commit with the code which I had submitted before, found some difference hence wanted to know the reasons behind them:

I understand the try and except commands are not required if we are using c001a.bmp and c001b.bmp only.

Also since winsize = searchsize, I am assuming that the entire interrogation window will be used for the cross correlation analysis

How do we decide the value for the overlap variable?

On the website it was given that the time interval between 001a and 002a is 200 micro seconds. So shouldn't dt = 100 micro seconds between 001a and 001b?

Can I know the reason why the correlation method in extended_search_area_piv function is selected as 'linear' ? And the normalized_correlation is set as 'False' ? Because on the GitHub page for OpenPIV (within the code for pyprocess) it was written that if the correlation method is linear then normalized correlation should be True

Is the value for the threshold variable in the sig2noise_val function decided by looking at the value of ((the first dimension of image size)/maximum value of x) ? I was trying to understand the meaning of the line 512/x.max()

alexlib commented 3 years ago

please update your openpiv again, we fixed many bugs in the 0.23.3 version. We have not yet approved it for the regular installation, so you need to try pip install -e git+https://github.com/openpiv/openpiv-python@0.23.3c#egg=openpiv --upgrade

AntarikshVishwakarma commented 3 years ago

Dear Prof. Liberzon,

I had updated my OpenPIV and analyzed two jet images again. This time it was (https://www.pivchallenge.org/pub03/index.html#a). The exact folder and images used are in the ipynb file Jet Velocity Analysis 2. There seems to be a very large stray vector towards the right hand side of the vector plots, is that a valid or an invalid vector?

Yours sincerely Antriksha

alexlib commented 3 years ago

Dear Prof. Liberzon,

I had updated my OpenPIV and analyzed two jet images again. This time it was (https://www.pivchallenge.org/pub03/index.html#a). The exact folder and images used are in the ipynb file Jet Velocity Analysis 2. There seems to be a very large stray vector towards the right hand side of the vector plots, is that a valid or an invalid vector?

Yours sincerely Antriksha

It looks quite good. regarding the invalid vectors - you're welcome to apply also other validation methods: global value threshold, global standard deviation validation and local median before you you replace_outliers

https://github.com/OpenPIV/openpiv-python/blob/master/openpiv/validation.py

AntarikshVishwakarma commented 3 years ago

Dear Prof. Liberzon,

A new file "Jet Velocity Analysis 3" contains the analysis of the data removes the invalid vector. A new average velocity profile and usage of windef() in post processing. The results were also compared with the published paper whose details are within the notebook.

Yours sincerely Antriksha

alexlib commented 3 years ago

Hi Antriksha, I see the notebook, but I do not see the comparisons. I do not understand what could be wrong about mean or average velocity profiles. Can you please plot those figures that you compare to the paper?

AntarikshVishwakarma commented 3 years ago

Dear Prof. Liberzon,

The same file "Jet Velocity Analysis 3" has been updated with the images within the notebook. The average velocity profile plotted in the paper gives an impression of uniform spread of fluid as it moves from right to left. Whereas what I did was divided each point of instantaneous velocity profile at a particular x location with the average velocity at that x location. I am not sure which approach is correct.

Yours sincerely Antriksha

alexlib commented 3 years ago

he same file "Jet Velocity Analysis 3" has been updated with the images within the notebook. The average velocity profile plotted in the paper gives an impression of uniform spread of fluid as it moves from right to left. Whereas what I did was divided each point of instantaneous velocity profile at a particular x location with the average velocity at that x location. I am not sure which approach is correct.

I do not see if there is a problem. Please create Fig. 4 from the paper (results of PIV challenge) of normalized mean velocity profile vs normalized (scaled) width. It's a bit of work as you need to find first couple of things: center of the jet, change of mean velocity along the centerline with the distance, l(x), \eta and so on. Please do it twice - for the data you process with extended_search_piv and with windef.