User Profile
Collapse
-
second run of my program
I have a very large object. When I run my program first time it runs just fine. But if I want to re-run it it fails by saying that it is out of memory. Any suggestions? Perhaps, should I call destractor (sp?) after I am done working with my object and need to run my program the second time. I am not sure how to do it. Perhaps, is there a function in python that clears all the memory? Thanks. -
pickle
Dear all,
I have the following error:
"CPickle.dump(l oclist,fout) Memory Error". This error occurs when I am trying to use the function "Locations_to_f ile" (see below) as I think my object loclist is too big.
...Code:def Locations_to_file(loclist,fname): '''Routine to help write a list of location objects to a file''' try: fount = open(fname,"wb") -
plotting
Dear all, I was wondering if there is equivalent in python of this Matlab function:
PLOTCLR(X,Y,V) plots the values specified in V as a color coded scatter plot at the locations specified in the vectors X and Y. The current colormap of the figure is used for the color code. Any suggestions? Thanks. -
I have two numpy arrays
of not equal length. How to find the elements that are both in array1 and array2? Thanks!!! -
well, I have array a=['0','1','2','3']. I need now to do the following val1='9', then set
a=['0',['1','9'],'2','3']. Is there a way to do it? Thanks. -
difference: repr(a) and str(a)
In my program, I have value a=0.24
when I say : str(a) it prints 0.24
when I say: repr(a) ir print '0.24'
Why does str(a) not work? Thanks -
Yes, I did print all of these.....
However, in my program I have:
In this program append works just fine but then I go to extend it does not. I thought that if extend does not work, append will not either?Code:if coord_ind == None: ncdc_station.append(data_ncdc[il][3]) else: ncdc_station[coord_ind[0]].extend(data_ncdc[il][3])
Could you please help me to correct this problem. THANKSLeave a comment:
-
what is wrong with this line
it gives me an error that 'str' object has no attribute 'extend'. but I also triedCode:list[1].extend(data_ncdc[il][3])
Anybody? THANKSCode:list[1].extend(float(data_ncdc[il][3]))
-
numpy and python array index question
Dear all:
I have this function and it works just fine but it is slow:
Yet this line does not work...Code:def common_index(list1, list2, val1, val2): assert len(list1) == len(list2), "List not of equal length" for i in range(len(list1)): if list1[i] == val1 and list2[i] == val2: return [i] To optimize it: coord_ind=numpy.where(list1==val1 and list2==val2) -
optimization problem
My program runs but it is soooooooooo slow. I have lots of data files I am reading and this for loop is where the program takes FOREVER.......N ote I declare data_ncdc=[] and ncdc_station=[]. Any suggestions would be appreciated.... . THANKS!!!!!
...Code:for il in range(len(data_ncdc)): coord_ind = common_index(ave_lon_ncdc,ave_lat_ncdc, data_ncdc[il][0], data_ncdc[il][1]) if coord_ind == None: ave_lon_ncdc.append(float(data_ncdc[il][0])) -
Hi, I was wondering if you could help me again....How do I add something to numpy array? Say I have :
>>> a= numpy.zeros(0)
Then I want to start adding elements to a. By the end I want a to look something like this a=[[1, 2], [4]]. I have no problem doing it with the actual python lists.Leave a comment:
-
-
but here you assume you know the size of your array
I do not know the size....Leave a comment:
-
two simple questions about arrays
Dear all:
1.) how to initilize numpy array? I need something similar to:
data = []
2.) how to add elements to nested lists?
I have list a:
a= [[1 2][1 2 3 3]]
how to append something to a[0]
THANKS SO MUCH.
No activity results to display
Show More
Leave a comment: