Here is a demo:

"""
from numpy import array, float64, percentile

a = array(range(100001), float64)
print(percentile(a, 90))
print(percentile(a, 50))
print(percentile(a, 20))
print(percentile(a, 10))
"""

Regards,

Edward



On 9 May 2014 18:14, Edward d'Auvergne <[email protected]> wrote:
> You may also want to try this logic:
>
> """
> from numpy import percentile
>
> all_chi2 = array(all_chi2, float64)
> self.contour_levels = []
> self.contour_levels.append(percentile(all_chi2, 90))
> self.contour_levels.append(percentile(all_chi2, 50))
> self.contour_levels.append(percentile(all_chi2, 20))
> self.contour_levels.append(percentile(all_chi2, 10))
> """
>
> This might work better with OpenDX.
>
> Regards,
>
> Edward
>
>
>
>
> On 9 May 2014 18:08, Edward d'Auvergne <[email protected]> wrote:
>> Hi Troels,
>>
>> A better way to handle this would be to pass in an array of 4 values
>> for the isosurface levels into write_program().  Then you can change
>> these values as needed in pipe_control.opendx and not have to worry
>> about what happens in lib.software.opendx ever again.  It would
>> decouple the logic and be much more flexible.
>>
>> Regards,
>>
>> Edward
>>
>> On 9 May 2014 17:33,  <[email protected]> wrote:
>>> Author: tlinnet
>>> Date: Fri May  9 17:33:05 2014
>>> New Revision: 23132
>>>
>>> URL: http://svn.gna.org/viewcvs/relax?rev=23132&view=rev
>>> Log:
>>> Made collecting of min, max and median value of chi2, when creating the 
>>> chi2 map.
>>>
>>> task #7792: (https://gna.org/task/?7792) Make the dx.map write suggest chi 
>>> surface values.
>>>
>>> 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=23132&r1=23131&r2=23132&view=diff
>>> ==============================================================================
>>> --- trunk/pipe_control/opendx.py        (original)
>>> +++ trunk/pipe_control/opendx.py        Fri May  9 17:33:05 2014
>>> @@ -24,7 +24,7 @@
>>>
>>>
>>>  # Python module imports.
>>> -from numpy import float64, array, zeros
>>> +from numpy import float64, array, median, zeros
>>>  from time import asctime, localtime
>>>
>>>  # relax module imports.
>>> @@ -164,8 +164,11 @@
>>>          # Create the strings associated with the map axes.
>>>          self.map_axes()
>>>
>>> +        # Generate the map.
>>> +        self.create_map()
>>> +
>>>          # Create the OpenDX .net program file.
>>> -        write_program(file_prefix=self.file_prefix, 
>>> point_file=self.point_file, dir=self.dir, inc=self.inc, N=self.n, 
>>> num_points=self.num_points, labels=self.labels, 
>>> tick_locations=self.tick_locations, tick_values=self.tick_values, 
>>> date=self.date)
>>> +        write_program(file_prefix=self.file_prefix, 
>>> point_file=self.point_file, dir=self.dir, inc=self.inc, N=self.n, 
>>> num_points=self.num_points, labels=self.labels, 
>>> tick_locations=self.tick_locations, tick_values=self.tick_values, 
>>> date=self.date, min_chi2=self.min_chi2, max_chi2=self.max_chi2, 
>>> median_chi2=self.median_chi2)
>>>
>>>          # Create the OpenDX .cfg program configuration file.
>>>          write_config(file_prefix=self.file_prefix, dir=self.dir, 
>>> date=self.date)
>>> @@ -176,9 +179,6 @@
>>>          # Create the OpenDX .general and data files for the given point.
>>>          if self.num_points > 1:
>>>              write_point(file_prefix=self.point_file, dir=self.dir, 
>>> inc=self.inc, point=self.point, num_points=self.num_points, 
>>> bounds=self.bounds, N=self.n)
>>> -
>>> -        # Generate the map.
>>> -        self.create_map()
>>>
>>>
>>>      def create_map(self):
>>> @@ -211,6 +211,11 @@
>>>          percent = 0.0
>>>          percent_inc = 100.0 / (self.inc + 1.0)**(self.n - 1.0)
>>>          print("%-10s%8.3f%-1s" % ("Progress:", percent, "%"))
>>> +
>>> +        # Define min/max chi2 values.
>>> +        min_chi2 = 1e20
>>> +        max_chi2 = 1.
>>> +        all_chi = []
>>>
>>>          # Fix the diffusion tensor.
>>>          unfix = False
>>> @@ -257,6 +262,14 @@
>>>                      else:
>>>                          map_file.write("%30f\n" % chi2)
>>>
>>> +                        # Save min and max values of chi2.
>>> +                        all_chi.append(chi2)
>>> +                        if chi2 < min_chi2:
>>> +                            min_chi2 = chi2
>>> +
>>> +                        if chi2 > max_chi2:
>>> +                            max_chi2 = chi2
>>> +
>>>                      # Increment the value of the third parameter.
>>>                      values[2] = values[2] + self.step_size[2]
>>>
>>> @@ -274,6 +287,11 @@
>>>          if unfix:
>>>              cdp.diff_tensor.fixed = False
>>>
>>> +        # Save the min/max chi2 values.
>>> +        self.min_chi2 = min_chi2
>>> +        self.max_chi2 = max_chi2
>>> +        # Save the median chi2 value.
>>> +        self.median_chi2 = median(array(all_chi))
>>>
>>>      def map_axes(self):
>>>          """Function for creating labels, tick locations, and tick values 
>>> for an OpenDX map."""
>>>
>>>
>>> _______________________________________________
>>> relax (http://www.nmr-relax.com)
>>>
>>> This is the relax-commits mailing list
>>> [email protected]
>>>
>>> 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
[email protected]

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