Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie, easier way to grab file into array...sorting descending order

Status
Not open for further replies.

eve25

Programmer
Feb 9, 2004
32
US
Hi folks,

I am a Python newbie and using it for scientific computation...due to its supposed efficiency I am trying to use Numarray (after trying scipy and seeing how week was the documantation for that)
I didn't manage to find a function grabbing a matrix from a file into a 2d array..except for particulat data file (FITS,netCDF)...would you have any idea on how to do that? (for now i am just reading the file and splitting on spaces to get it into the array but I doubt it is the most powerfull manner... :) )
Also, I want to sort a 1d float array in descending order./..I have managed to do that on a list that way...

def descendingCmp(a,b):
return - cmp(a,b)
...
li.sort(descendingCmp)

but not on an array...any ideas?

Any help would be grately appreciated! Thanks and Happy New Year!!!!
:)
 
Hi,

I may be completely stupid but as far as I understand it that's how I have done on list and as I said, sure it works fine with lists but not with arrays...

Thanks!
 
> I may be completely stupid...

Nope, I am.
Haven't used numarray myself yet and grabbed the first google hit.

Anyway, taking a quick look at numarray, I see numarray.NumArray whose instances have a sort method.

Although how the sort method works is beyond me right now.

Can you confirm that you are working with instances of numarray.NumArray?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top