Re: [Numpy-discussion] numpy arrays

2012-06-09 Thread Patrick Redmond
How do you want the output files to be formatted? Binary data? Textual representation? This function can do both: http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.tofile.html And numpy supports a variety of methods for outputting to files (and reading data back in):

Re: [Numpy-discussion] numpy arrays

2012-06-09 Thread Patrick Redmond
On Sat, Jun 9, 2012 at 2:12 PM, bob tnur bobtnu...@gmail.com wrote: how to save  multiple files like cm1.txt,cm2.txt,cm3.txt etc and to produce their corresponding outputs cm1.out,cm2.out,cm3.out etc.    or how to modify this:    np.savetxt(fname, (a,b), fmt='%4.8f') You can save them to

Re: [Numpy-discussion] 1D array sorting ascending and descending by fields

2012-06-05 Thread Patrick Redmond
On Mon, Jun 4, 2012 at 6:08 PM, Chris Barker chris.bar...@noaa.gov wrote: could you multiply the numeric field by -1, sort, then put it back Yeah, that works great for my situation. Thanks Chris! On Mon, Jun 4, 2012 at 8:17 PM, Benjamin Root ben.r...@ou.edu wrote: While that may work for this

[Numpy-discussion] 1D array sorting ascending and descending by fields

2012-06-04 Thread Patrick Redmond
Hi! I have a one-dimensional ndarray with two fields. I'd like to sort in descending order by field 'a', breaking ties by sorting in ascending order by field 'b'. I've found combinations of sorting and reversing followed by stable sorting that work, but there must be a straightforward way to do

Re: [Numpy-discussion] 1D array sorting ascending and descending by fields

2012-06-04 Thread Patrick Redmond
Here's how I sorted primarily by field 'a' descending and secondarily by field 'b' ascending: (Note that 'a' is the second column, 'b' is the first) data array([('b', 0.03), ('c', 0.03), ('f', 0.03), ('e', 0.01), ('d', 0.04), ('a', 0.04)], dtype=[('b',