Hi Troels,

A nice code simplification here would be to not have the +"\n" code
until you are looping over these text elements and sending them to the
file.  I.e. delete them then change the writing line to
plot_file.write(line+'\n'), so that '\n' only appears once in the
entire method.

Regards,

Edward



On 13 October 2014 18:19,  <tlin...@nmr-relax.com> wrote:
> Author: tlinnet
> Date: Mon Oct 13 18:19:36 2014
> New Revision: 26262
>
> URL: http://svn.gna.org/viewcvs/relax?rev=26262&view=rev
> Log:
> Added better figure control of chi2 values on z-axis for surface plots.
>
> Modified:
>     trunk/pipe_control/opendx.py
>
> Modified: trunk/pipe_control/opendx.py
> URL: 
> http://svn.gna.org/viewcvs/relax/trunk/pipe_control/opendx.py?rev=26262&r1=26261&r2=26262&view=diff
> ==============================================================================
> --- trunk/pipe_control/opendx.py        (original)
> +++ trunk/pipe_control/opendx.py        Mon Oct 13 18:19:36 2014
> @@ -470,6 +470,7 @@
>          plot_file = open_write_file(file_name=self.file_prefix+'.py', 
> dir=self.dir, force=True)
>
>          matplotlib_file = [
> +            'from copy import deepcopy'+"\n",
>              'import numpy as np'+"\n",
>              'import scipy.interpolate'+"\n",
>              'from numpy.ma import masked_where'+"\n",
> @@ -565,21 +566,24 @@
>              '    # Set which x, y, z to plot'+"\n",
>              '    x_p = xi'+"\n",
>              '    y_p = yi'+"\n",
> -            '    c_p = ci'+"\n",
> +            '    c_p = deepcopy(ci)'+"\n",
>              ''+"\n",
>              '    # Cut map at a certain height.'+"\n",
>              '    # First get index os largest values'+"\n",
> -            '    #out_val = 5*map_mask_c_min'+"\n",
> -            '    out_val = map_mask_c_max'+"\n",
> -            '    ci_mask = masked_where(ci >= out_val, ci)'+"\n",
> +            '    #z_max = map_mask_c_max'+"\n",
> +            '    z_max = map_mask_c_min + 0.5*map_mask_c_min'+"\n",
> +            '    ci_mask = masked_where(ci >= z_max, ci)'+"\n",
>              ''+"\n",
>              '    # Replace with 0.0'+"\n",
> -            '    ci[ci_mask.mask] = 0.0'+"\n",
> +            '    c_p[ci_mask.mask] = 0.0'+"\n",
>              '    # Find new max'+"\n",
> -            '    new_max = np.max(ci)'+"\n",
> +            '    new_max = np.max(c_p)'+"\n",
>              ''+"\n",
>              '    # Insert values in array.'+"\n",
> -            '    ci[ci_mask.mask] = new_max'+"\n",
> +            '    c_p[ci_mask.mask] = new_max'+"\n",
> +            ''+"\n",
> +            '    # Define min.'+"\n",
> +            '    z_min = map_mask_c_min - 0.5*map_mask_c_min'+"\n",
>              ''+"\n",
>              '    # Create figure and plot'+"\n",
>              '    ax = fig.add_subplot(nr_rows, nr_cols, 1, 
> projection="3d")'+"\n",
> @@ -592,7 +596,7 @@
>              '    ##ax.scatter(x_p, y_p, c_p, c="y", marker="o", s=5)'+"\n",
>              ''+"\n",
>              '    # Add contour levels on sides.'+"\n",
> -            '    ax.contour(x_p, y_p, c_p, zdir="z", offset=0, 
> cmap=cm.coolwarm)'+"\n",
> +            '    ax.contour(x_p, y_p, c_p, zdir="z", offset=z_min, 
> cmap=cm.coolwarm)'+"\n",
>              '    ax.contour(x_p, y_p, c_p, zdir="x", offset=map_mask_x_min, 
> cmap=cm.coolwarm)'+"\n",
>              '    ax.contour(x_p, y_p, c_p, zdir="y", offset=map_mask_y_min, 
> cmap=cm.coolwarm)'+"\n",
>              ''+"\n",
> @@ -653,7 +657,7 @@
>              ''+"\n",
>              ''+"\n",
>              '    # Set limits'+"\n",
> -            '    ax.set_zlim(0, out_val)'+"\n",
> +            '    ax.set_zlim(z_min, z_max)'+"\n",
>              ''+"\n",
>              ''+"\n",
>              '    # Create figure and plot'+"\n",
>
>
> _______________________________________________
> relax (http://www.nmr-relax.com)
>
> This is the relax-commits mailing list
> relax-comm...@gna.org
>
> To unsubscribe from this list, get a password
> reminder, or change your subscription options,
> visit the list information page at
> https://mail.gna.org/listinfo/relax-commits

_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-devel mailing list
relax-devel@gna.org

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-devel

Reply via email to