Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug for phase tensor ellipse #40

Open
ralfschaa opened this issue Aug 24, 2017 · 0 comments
Open

Bug for phase tensor ellipse #40

ralfschaa opened this issue Aug 24, 2017 · 0 comments

Comments

@ralfschaa
Copy link

Hi all,

(very quiet here, is MTPy still developed?)

there seems to be a bug when plotting phase tensor ellipses using the skew angle (beta) with the 'skew_seg' colours.

BUG: negative angles don't get correctly mapped into the assigned color segments

Here is the relevant code in sub get_plot_color in module mtcolors.py:

for bb in range(bounds.shape[0]):                     
    if colorx >= bounds[bb] and colorx < bounds[bb+1]:
        cvar = float(bounds[bb])/bounds.max()         
        return get_color(cvar, cmap)                  

for negative value bounds[bb] is the upper bracket, which however should be the lower bracket.

Proposed solution - use positive values and multiply with the original sign (not thoroughly tested!)

        # Get the sign of the skew angle:                                               
        skew_sign = np.sign(colorx)                                                     
        # New variable to work with                                                     
        abs_color = np.abs(colorx)                                                      
                                                                                        
        # Use original code, start with angles outside given range:                     
        if abs_color > bounds.max():                                                    
            # Restore sign here:                                                        
            cvar = skew_sign*1.0                                                        
            return get_color(cvar, cmap)                                                
                                                                                        
        # Take care of angles in interval:
        for bb in range(bounds.shape[0]):                                               
            if abs_color >= bounds[bb] and abs_color < bounds[bb+1]:                    
                # Restore sign here:                                                    
                cvar = skew_sign*float(bounds[bb])/bounds.max()                         
                return get_color(cvar, cmap)                                            

Cheers
-Ralf

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

No branches or pull requests

1 participant