Skip to content

Thelampire patch 3#89

Open
thelampire wants to merge 29 commits intodevelopmentfrom
thelampire-patch-3
Open

Thelampire patch 3#89
thelampire wants to merge 29 commits intodevelopmentfrom
thelampire-patch-3

Conversation

@thelampire
Copy link
Contributor

@thelampire thelampire commented May 27, 2021

Many modifications should be reviewed before merging. --> Reviewed them. This merge should not cause any problems and should be backwards compatible.
I am going to merge this to development on June 4.

thelampire and others added 22 commits November 18, 2019 19:27
Addition of the options['Plot units'] for the plot.py. It uses the unit_conversion from the updated tools.
The following description is added to the options part of the plot.py:
        'Plot units': The plotting units for each axis. It can be a dictionary or a list. Its
            use is different for the two cases as such:
            Dictionary input: keywords: axis name (e.g. 'Device R'), value: unit (e.g. 'mm')
                The number of keys is not limited. The ones from the axes will be used.
                e.g.: options['Plot units']={'Device R':'mm', 'Device z':'mm', 'Time':'ms'}
            List input: the number of values should correspond to the axes input as such:
                e.g.: axes=['Device R','Device z','Time'] --> options['Plot units']=['mm','mm','ms']

Further modifications: Cleaned the unnecessary old code fragments from the commented lines.
Removed spatial_unit_translation as it was only used by the plot.py where it was removed.
Please don't check what I modified. Left in a debugger print.
This revision is a general overplotting option for the plot.py. It has replaced the 'EFIT options' as that has only been used by me.
It can handle any number of contours and paths. It needs to be in the same time unit as the original data and in the format like the default_overplot_options variable.
Overplotting options extended, they are working now for all the 2D plot types. Also added the option of 'Equal axes' and 'Axes visibility'.
The former maintains equal x and y axis if their coordinate units are the same. The latter removes the xtitle and the ytitle from the axes. It's useful when plotting multiple plots.
Option changes:
'Video format': can be multiple types, OS is checked whether it's available in the CV2 or not.
'Overplot options': line added as an overplottable object. Description added to the options.
'Prevent saturation': Now it works for all the plot-types and doesn't change the values of the original data object.
'Equal axes': description added
'Axes visibility': description added

Misc. mods:
Locator variable is not used --> commented it out
plotdata_low, plotdata_high are unused --> commented them out,
Fixed the issue with the incorrect value of the [0,0] coordinate. d[0,0] +=1 assigns the value to the data object, which is undesired.
c,ydata_low,ydata_high were undefined at lines 1437, 1446. I defined them.
data_object.py: added a whitespace, no functional change.
Axes unit conversions were not working for image_like plotting so far. Now it shows the correct coordinate.
spectral_analysis.py: Fixed the hanning window option.
plot.py: Bugfix
One bugfix in spectral analysis and a whitespace in plot.py
Sandor's implementation is working, I shouldn't have fixed the Spyder warning.
axes_unit conversion was only working if the axes was given from the option's. Now it works if it is not an input.
Another bugfix with the overplot options.
Plotting against coordinates which have temporal changes is now allowed. This version is only a backup. It needs to be fixed for stationary coordinates, because this uses way too much memory.
Fixed the sliding axis in the animations and the memory issue in the previous release. There were also some bugs related to line plotting when either horizontal or vertical plotting was not present.
Bugfixes for image_like plotting. It got messed up after the set_autoscale_on setting and some modifications had to be issued to get the former functionality back.
The hanning window was first type casted to the data type and then multipied with the data. That made the whole result to flicker. In this new code the typecast is done on the result after the multiplication.
Typo fixes and a whole lot of issues remain unresolved. See the issues for reference
Nothing substantion was modified.
Spectral analysis couldn't do anything about a 2D CCF function, it was failing all the time. A temporary solution has been implemented, which only work with 2D data, but not with 2+1D. A solution needs to be found, but it serves the purpuse. It is also a bit slow compared to the scipy CCF calculator.
The end of the slicing range was not set to the proper one.
plot.py: minor modifications, two lines removed for macos compatibility. They need to be checked for windows.
tools.py: Added the 2D polynomial fitting and a helper function for spectral_analysis
spectral_analysis.py: Fixed the 2D correlation calculation, now a time series of 2D images can be correlated with another 2D image. Added the option of "Correct ACF peak" which currects the peak of the cross-correlation function by fitting a parabola on its peak.
# for i in range(len(mx_shape)): #THIS IS A SOLUTION FOR LARGE MATRICES, BUT NOT COMMITED
# index_arrays.append(slice(min(index[i]),max(index[i])+1)) #DUE TO BEING UNTESTED. NEEDS TO BE UNCOMMENTED IF ONE WANTS TO USE IT

# mx_dim = len(mx_shape)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a discussion about this beofre. My shorter method does the exact same, but magnitudes faster. I have been using this for over a year, it should be fit for the development package.

print(_time_unit+' was not found in the translation. Returning 1.')
return 1

def spatial_unit_translation(spatial_unit=None):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was removed because there is a more general unit conversion method.


if (self.options['Colorbar']):
cbar = plt.colorbar(img,ax=self.ax_act)
cbar.set_label(self.d.data_unit.name)
#EFIT overplot feature implementation:
#It needs to be more generalied in the future as the coordinates are not necessarily in this order: [time_index,spat_index]
#This needs to be cross-checked with the time array's dimensions wherever there is a call for a certain index.
if ('EFIT options' in self.options and self.options['EFIT options'] is not None):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part was removed because it is too specific for the EFIT. It has been merged into the overplotting options.

if (self.yrange is not None):
self.ax_act.set_ylim(self.yrange[0],self.yrange[1])


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the new overplot options.

video_codec_code = 'XVID'
else:
raise ValueError("Cannot write video in format '"+_options['Video format']+"'.")
if ((os.sys.platform == 'darwin' or 'linux' in os.sys.platform) and
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Video format for different OSs

@thelampire thelampire marked this pull request as ready for review May 27, 2021 03:15
Copy link
Contributor Author

@thelampire thelampire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that this merge can be performed without any hiccups. Please confirm and merge!

cd was an index variable, should have been correlation_dimensions
The option of 'Correct ACF range' was added with a default of [-2,-1,1,2].
data_object: Added a clarification string into the Error raising.

plot: Added the option of plotting a grid of arrows onto the contour, anim-contour or animation. Useful for depiction of velocimetry. A good example is shown in flap_nstx in analyze_hesel_data.py.
Copy link
Contributor Author

@thelampire thelampire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ACF peak fitting breaks down with awkwardly sliced data, this needs to be fixed when it comes up again. Otherwise it's working with 1D and 2D data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants