# [SciPy-User] array creation

7 messages
Open this post in threaded view
|

## [SciPy-User] array creation

 Hi, is there a function foo(ncols, min, max, delta) in mumpy/scipy to create an array such as 0 100 0 0 0 100 10 90 0 10 80 10 10 70 20 10 60 30 10 50 40 10 40 50 10 30 60 20 20 70 20 10 80 20 0 90 20 80 0 ... ... ... 90 10 0 90 0 10 100 0 0 Any help or link is welcome Elmar _______________________________________________ SciPy-User mailing list [hidden email] https://mail.scipy.org/mailman/listinfo/scipy-user
Open this post in threaded view
|

## Re: array creation

 Can you specify a little more clearly what you're looking for? I'm not seeing the pattern.On Wed, Nov 11, 2015 at 1:12 PM, elmar werling wrote:Hi, is there a function foo(ncols, min, max, delta) in mumpy/scipy to create an array such as 0       100     0 0       0       100 10      90      0 10      80      10 10      70      20 10      60      30 10      50      40 10      40      50 10      30      60 20      20      70 20      10      80 20      0       90 20      80      0 ...     ...     ...              90      10      0 90      0       10 100     0       0 Any help or link is welcome Elmar _______________________________________________ SciPy-User mailing list [hidden email] https://mail.scipy.org/mailman/listinfo/scipy-user _______________________________________________ SciPy-User mailing list [hidden email] https://mail.scipy.org/mailman/listinfo/scipy-user
Open this post in threaded view
|

## Re: array creation

 I need a generalized function foo(ncols, min, max, delta) for # two component mixing ratios (ncols=2, min=0, max=1, delta=0.1) for x1 in np.arange(0.0, 1.05, 0.1):      x2 = 1.0 - x1      print (x1, x2, ' = ', x1+x2) # three component mixing ratios (ncols=3, min=0, max=1, delta=0.1) for x1 in np.arange(0.0, 1.05, 0.1):      for x2 in np.arange(1.0 - x1, -0.01, -0.1):          x3 = 1.0 - x1 - x2          print(x1, x2, x3, ' = ', x1+x2+x3) # four component mixing ratios (ncols=3, min=0, max=1, delta=0.1) for x1 in np.arange(0.0, 1.05, 0.1):      for x2 in np.arange(1.0 - x1, -0.01, -0.1):          for x3 in np.arange(1.0 - x1 - x2, -0.01, -0.1):              x4 = 1.0 - x1 - x2 - x3              print(x1, x2, x3, x4, ' = ', x1+x2+x3+x4) On 11.11.2015 19:44, Max Shron wrote: > Can you specify a little more clearly what you're looking for? I'm not > seeing the pattern. > > On Wed, Nov 11, 2015 at 1:12 PM, elmar werling <[hidden email] > > wrote: > >     Hi, > >     is there a function foo(ncols, min, max, delta) in mumpy/scipy to >     create an array such as > >     0       100     0 >     0       0       100 >     10      90      0 >     10      80      10 >     10      70      20 >     10      60      30 >     10      50      40 >     10      40      50 >     10      30      60 >     20      20      70 >     20      10      80 >     20      0       90 >     20      80      0 >     ...     ...     ... >     90      10      0 >     90      0       10 >     100     0       0 > >     Any help or link is welcome > >     Elmar > > >     _______________________________________________ >     SciPy-User mailing list >     [hidden email] >     https://mail.scipy.org/mailman/listinfo/scipy-user> > > > > _______________________________________________ > SciPy-User mailing list > [hidden email] > https://mail.scipy.org/mailman/listinfo/scipy-user> _______________________________________________ SciPy-User mailing list [hidden email] https://mail.scipy.org/mailman/listinfo/scipy-user
Open this post in threaded view
|

## Re: array creation

 In reply to this post by Max Shron-2 with the following pattern the pattern is 0    100    0 0    0    100 10    90    0 10    80    10 10    70    20 10    60    30 10    50    40 10    40    50 10    30    60 10    20    70 10    10    80 10    0    90 20    80    0 20    70    10 20    60    20 20    50    30 20    40    40 20    30    50 20    20    60 20    10    70 20    0    80 30    70    0 30    60    10 30    50    20 30    40    30 30    30    40 30    20    50 30    10    60 30    0    70 ...   ...  ... On 11.11.2015 19:44, Max Shron wrote: > Can you specify a little more clearly what you're looking for? I'm not > seeing the pattern. > > On Wed, Nov 11, 2015 at 1:12 PM, elmar werling <[hidden email] > > wrote: > >     Hi, > >     is there a function foo(ncols, min, max, delta) in mumpy/scipy to >     create an array such as > >     0       100     0 >     0       0       100 >     10      90      0 >     10      80      10 >     10      70      20 >     10      60      30 >     10      50      40 >     10      40      50 >     10      30      60 >     20      20      70 >     20      10      80 >     20      0       90 >     20      80      0 >     ...     ...     ... >     90      10      0 >     90      0       10 >     100     0       0 > >     Any help or link is welcome > >     Elmar > > >     _______________________________________________ >     SciPy-User mailing list >     [hidden email] >     https://mail.scipy.org/mailman/listinfo/scipy-user> > > > > _______________________________________________ > SciPy-User mailing list > [hidden email] > https://mail.scipy.org/mailman/listinfo/scipy-user> _______________________________________________ SciPy-User mailing list [hidden email] https://mail.scipy.org/mailman/listinfo/scipy-user
Open this post in threaded view
|

## Re: array creation

 Elmar:You could use smth like this....import itertools as ittimport numpy as npdef foo(ncol=1, start=0, end=10, delta=0.1):    if ncol==1:        return np.arange(start, end, delta)    else:        ranges = ncol * [np.arange(start, end, delta), ]        for z in itt.product(*ranges):            yield zfor (x1, x2) in foo(ncol=2):     print(x1, x2)This is not exactly what you need but might help.Cheers2015-11-11 14:17 GMT-05:00 elmar werling :with the following pattern the pattern is 0    100    0 0    0    100 10    90    0 10    80    10 10    70    20 10    60    30 10    50    40 10    40    50 10    30    60 10    20    70 10    10    80 10    0    90 20    80    0 20    70    10 20    60    20 20    50    30 20    40    40 20    30    50 20    20    60 20    10    70 20    0    80 30    70    0 30    60    10 30    50    20 30    40    30 30    30    40 30    20    50 30    10    60 30    0    70 ...   ...  ... On 11.11.2015 19:44, Max Shron wrote: Can you specify a little more clearly what you're looking for? I'm not seeing the pattern. On Wed, Nov 11, 2015 at 1:12 PM, elmar werling <[hidden email] > wrote:     Hi,     is there a function foo(ncols, min, max, delta) in mumpy/scipy to     create an array such as     0       100     0     0       0       100     10      90      0     10      80      10     10      70      20     10      60      30     10      50      40     10      40      50     10      30      60     20      20      70     20      10      80     20      0       90     20      80      0     ...     ...     ...     90      10      0     90      0       10     100     0       0     Any help or link is welcome     Elmar     _______________________________________________     SciPy-User mailing list     [hidden email]     https://mail.scipy.org/mailman/listinfo/scipy-user _______________________________________________ SciPy-User mailing list [hidden email] https://mail.scipy.org/mailman/listinfo/scipy-user _______________________________________________ SciPy-User mailing list [hidden email] https://mail.scipy.org/mailman/listinfo/scipy-user -- Sasha _______________________________________________ SciPy-User mailing list [hidden email] https://mail.scipy.org/mailman/listinfo/scipy-user