Re: [Tutor] skip/slice more than every second?

2015-09-28 Thread questions anon
ns: [1, 5, 9,13] > > > > Sent from my iPhone > > > On 29 Sep 2015, at 04:16, questions anon > wrote: > > > > a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14] > > > > how can I show the first then skip three and show the next and so on? > > For example: > > sho

[Tutor] skip/slice more than every second?

2015-09-28 Thread questions anon
a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14] how can I show the first then skip three and show the next and so on? For example: show 1 then skip 2,3,4 then show 5 then skip 6,7,8 then show 9 then skip 10,11,12, etc. Any feedback will be greatly appreciated.

Re: [Tutor] print date and skip any repeats

2014-09-24 Thread questions anon
tle=ncvariablename+'v_DailyMax'+days cmap=plt.cm.jet CS = map.contourf(x,y,v_DailyMax, 15, cmap=cmap) l,b,w,h =0.1,0.1,0.8,0.8 cax = plt.axes([l+w+0.025, b, 0.025, h]) plt.colorbar(CS,cax=cax, drawedges=True) plt.savefig((os.path.join(OutputFolder, plottitle+'.png'))) plt.show()

Re: [Tutor] print date and skip any repeats

2014-09-22 Thread questions anon
your help lastdate=all_the_dates[1] onedateperday.append(lastdate) print onedateperday for date in all_the_dates: if date !=lastdate: lastdate=date onedateperday.append(lastdate) On Wed, Sep 17, 2014 at 7:35 PM, Cameron Simpson wrote: > On 17Sep2014 19:21, questi

[Tutor] print date and skip any repeats

2014-09-17 Thread questions anon
Hi Tutor, I think this should be simple but I can't find the right commands. I have a date for each hour for a whole month (and more) and I would like to write a loop that prints each date that is different but skips the dates that are the same. for i in date: print i and then skip i until differ

Re: [Tutor] Move files to a new directory with matching folder names

2014-05-27 Thread questions anon
Thanks all, I got it to work using: import os import shutil destination_prefix="/Data/test/" source_prefix="/Data/test1/" for year in range(2011, 2013): year = str(year) for month in range(1, 13): # convert to a string with leading 0 if needed month = "%02d" % month source = os.path.jo

Re: [Tutor] Move files to a new directory with matching folder names

2014-05-21 Thread questions anon
On Thu, May 22, 2014 at 11:11 AM, Steven D'Aprano wrote: > On Thu, May 22, 2014 at 10:25:27AM +1000, questions anon wrote: > > I have files contained separately in folders labelled by years and months > > and I would like to copy them into another directory where they have > >

[Tutor] Move files to a new directory with matching folder names

2014-05-21 Thread questions anon
I have files contained separately in folders labelled by years and months and I would like to copy them into another directory where they have matching folder names of years and months. I can do this for one folder at a time (see below) but I want it to be able to go through all the folders (2002/0

[Tutor] Find Daily max - create lists using date and add hourly data to that list for the day

2014-05-20 Thread questions anon
I have hourly 2D temperature data in a monthly netcdf and I would like to find the daily maximum temperature. The shape of the netcdf is (744, 106, 193) I would like to use the year-month-day as a new list name (i.e. 2009-03-01, 2009-03-022009-03-31) and then add each of the hours worth of te

[Tutor] loop through hours to calc max and plot

2014-03-18 Thread questions anon
Hi All, I have monthly netcdf files containing hourly temperature data. I would like to loop through all of the hours and calculate the max for each hour (00 - 23) and then make a plot. I have found a way for this to work for a couple of the hours (see below) but it requires a lot of set up to do e

Re: [Tutor] group txt files by month

2012-09-08 Thread questions anon
hmmm thank you, I obviously need to put some more thought in first. Thanks for the responses. On Sat, Sep 8, 2012 at 4:03 PM, Peter Otten <__pete...@web.de> wrote: > questions anon wrote: > > > Hello All, it has been a few months since I have used this and I have > only &

Re: [Tutor] group txt files by month

2012-09-07 Thread questions anon
h.month) > month += timedelta(days=32) > month = month.replace(day=01) > > > > > On Thu, Apr 5, 2012 at 4:57 PM, Peter Otten <__pete...@web.de> wrote: > >> questions anon wrote: >> >> > I have been able to write up what I want to do (usin

Re: [Tutor] table to dictionary and then analysis

2012-05-22 Thread questions anon
thanks for all of the responses, has been really helpful On Fri, May 18, 2012 at 8:54 PM, Russel Winder wrote: > On Thu, 2012-05-17 at 19:35 +1000, Steven D'Aprano wrote: > > On Thu, May 17, 2012 at 08:27:07AM +0100, Russel Winder wrote: > > > > > Should we be promoting use of the format method

Re: [Tutor] table to dictionary and then analysis

2012-05-14 Thread questions anon
10:16 PM, questions anon wrote: > > I am completely new to dictionaries and I am not even sure if this is what > I need to use. > I have a text file that I would like to run summary stats on particular > months, years and climate indices (in this case the climate indices are > r

[Tutor] table to dictionary and then analysis

2012-05-14 Thread questions anon
I am completely new to dictionaries and I am not even sure if this is what I need to use. I have a text file that I would like to run summary stats on particular months, years and climate indices (in this case the climate indices are rainfall and fire area, so not actualy climate indices at all).

Re: [Tutor] summary stats grouped by month year

2012-05-08 Thread questions anon
June entry by the average over all the non-zero June data. > > > I was just hoping to give you a working example that you could use to make > a functioning well thought out example that can handle the exceptions which > will arise (like missing data, or a data file with a string

Re: [Tutor] summary stats grouped by month year

2012-05-08 Thread questions anon
Excellent, thank you so much. I don't understand all the steps at this stage so I will need some time to go through it carefully but it works perfectly. Thanks again! On Tue, May 8, 2012 at 4:41 PM, Andre' Walker-Loud wrote: > Hello anonymous questioner, > > first comment - you may want to look i

[Tutor] summary stats grouped by month year

2012-05-07 Thread questions anon
I would like to calculate summary statistics of rainfall based on year and month. I have the data in a text file (although could put in any format if it helps) extending over approx 40 years: YEAR MONTHMeanRain 1972 Jan12.7083199 1972 Feb14.17007142 1972 Mar14.5659302 1972 Apr1.

Re: [Tutor] write list to columns

2012-04-13 Thread questions anon
thanks all! On Fri, Apr 13, 2012 at 2:02 AM, Alan Gauld wrote: > On 12/04/12 15:32, Mark Lawrence wrote: > > That's going to be quite awkward to do. Files like to be written one >>> complete line at a time. The normal approach would be to build up the >>> table structure in memory and then write

Re: [Tutor] write list to columns

2012-04-11 Thread questions anon
Perfect, thank you. Is there a way I could easily/quickly add headings to each column? On Thu, Apr 12, 2012 at 1:03 PM, Puneeth Chaganti wrote: > On Thu, Apr 12, 2012 at 8:01 AM, questions anon > wrote: > > I am trying to simply write a list of values to txt file in one column. >

[Tutor] write list to columns

2012-04-11 Thread questions anon
I am trying to simply write a list of values to txt file in one column. I would then like to add another list in a second column. Somehow they only appear as one long row. Any feedback will be greatly appreciated. print "rain max values", rmax print "yearmonth", monthyear OutputFolder=r"E:/test_o

Re: [Tutor] group txt files by month

2012-04-10 Thread questions anon
yrain), "mean: ", np.mean(monthlyrain) stop_month = datetime(2011, 12, 31) month = datetime(2011, 01, 01) while month < stop_month: accumulate_month(month.year, month.month) month += timedelta(days=32) month = month.replace(day=01) On Thu, Apr 5, 2012 at 4:57 PM, Peter Otten

Re: [Tutor] group txt files by month

2012-04-04 Thread questions anon
;feb", np.max(rain201102), np.min(rain201102), np.mean(rain201102), np.median(rain201102), np.std(rain201102) print "mar", np.max(rain201103), np.min(rain201103), np.mean(rain201103), np.median(rain201103), np.std(rain201103) On Thu, Apr 5, 2012 at 11:11 AM, questions anon wrote: >

Re: [Tutor] group txt files by month

2012-04-04 Thread questions anon
#x27;)and fname[0:7]==fname[0:7] e.g. r20110101.txt and r20110102.txt should go together but r20110601 should not. thanks On Tue, Apr 3, 2012 at 4:59 PM, Alan Gauld wrote: > On 03/04/12 04:59, questions anon wrote: > > I have a list of txt files that contain daily rainfall for many ye

[Tutor] group txt files by month

2012-04-02 Thread questions anon
I think what I am trying to do is relatively easy but can't get my head around how to do it. I have a list of txt files that contain daily rainfall for many years. I would like to produce a list that contains the year-month and the max, min and mean of rainfall for each month. My main question at t

[Tutor] change values in an array

2011-11-16 Thread questions anon
I am trying to do something really simple. I have a numpy array and if any values in the array are 255 I want to change them to 1. but I can't seem to get anything to work! If I use: for i, value in enumerate(mask_arr): if value==255: mask_arr[i]=1 I get this error: Traceback (most

[Tutor] memory errors with netCDF

2011-10-03 Thread questions anon
Hi Python Tutor, I keep receiving a memory error when processing many netcdf files. I assume it has something to do with how I loop things and maybe need to close things off properly.??? In the code below I am looping through a bunch of netcdf files (each file is hourly data for one month) and with

Re: [Tutor] raw_input() slice list

2011-09-28 Thread questions anon
Excellent, thank you and yes I need to work on how to catch and handle exceptions Thanks again! On Wed, Sep 28, 2011 at 4:13 PM, bob gailer wrote: > On 9/27/2011 11:18 PM, questions anon wrote: > > I would like to use user_input() to decide how to slice a list. > This works fine un

[Tutor] raw_input() slice list

2011-09-27 Thread questions anon
I would like to use user_input() to decide how to slice a list. This works fine until I try to leave it blank to try and select the whole list [:] I have posted the section of interest below and the error I get when I try to press enter. Further below that is the entire code. Any feedback will be g

Re: [Tutor] Funtions, modules & global variables

2011-09-26 Thread questions anon
this the correct way to do things? My main problem is not being able to feed the output from one function into the next. Thanks Sarah On Mon, Sep 26, 2011 at 10:35 AM, Alan Gauld wrote: > On 26/09/11 00:21, questions anon wrote: > >> Hi All, >> I am trying to move from writing on

[Tutor] Funtions, modules & global variables

2011-09-25 Thread questions anon
Hi All, I am trying to move from writing one long script each time I need to do a new thing but I do not quite understand how functions work, even after reading many manuals. My first attempt is to create a python file where I have defined a number of functions that get data in various ways. I have

Re: [Tutor] reclassify values in an array

2011-09-04 Thread questions anon
Thanks all, that helped me work out that I needed to try something else. If anyone else needs to know what method worked: big_array=N.ma.concatenate(all_FFDI) for x in N.nditer(big_array, op_flags=['readwrite']): if x<100: x[...]=x=0 elif x>=100: x[...]=x=1 sum=big_array.su

Re: [Tutor] reclassify values in an array

2011-09-02 Thread questions anon
gt; wrote: > questions anon wrote: > > > I have been going round in circles trying to solve something that sounds > > simple. I have a huge array and I would like to reclassify the values. > > Firstly just make them zeros and ones, for example if the values in the > > array are l

[Tutor] reclassify values in an array

2011-08-31 Thread questions anon
Dear All, I have been going round in circles trying to solve something that sounds simple. I have a huge array and I would like to reclassify the values. Firstly just make them zeros and ones, for example if the values in the array are less than 100 make them 0 and if greater than 100 make them 1.

Re: [Tutor] select particular directories and files

2011-08-30 Thread questions anon
Thanks, that also works really well. One of the hardest things I am finding with programming is that there is always more than one way to do something. This is a good and bad thing. Bad for beginners!! thanks On Tue, Aug 30, 2011 at 4:45 PM, Peter Otten <__pete...@web.de> wrote: > quest

Re: [Tutor] select particular directories and files

2011-08-29 Thread questions anon
g I > really like about python, you really can just play around with it. And with > all things, if you figure it out on your own, then you will likely feel > better about that, and also, you will retain the knowledge better and gain > more confidence in trying new things. > > > Ch

Re: [Tutor] select particular directories and files

2011-08-29 Thread questions anon
t if you get a list of > directories, then this should work. > > Well, it should work with the correction > > > for ncfile in glob.glob(dir+'\*.nc'): >> >> > > Cheers, > > Andre > > > > > > > On Aug 29, 2011, at 8:35 PM

Re: [Tutor] select particular directories and files

2011-08-29 Thread questions anon
'*' character to grab all files which end in '.nc' > > > Andre > > > > > On Aug 29, 2011, at 7:23 PM, questions anon wrote: > > Thanks for responding > When I try glob.glob I receive no errors but nothing prints. > > MainFolder=r"

Re: [Tutor] select particular directories and files

2011-08-29 Thread questions anon
"my selected netcdf files are:", ncfile any suggestions? thanks On Tue, Aug 30, 2011 at 10:07 AM, Emile van Sebille wrote: > On 8/29/2011 4:52 PM questions anon said... > > I am trying to select particular files within >> a particular subdirectory, >> >

[Tutor] select particular directories and files

2011-08-29 Thread questions anon
I am trying to select particular files within a particular subdirectory, I have been able to do both but not together! When I try to select my files within the dir loop nothing comes up, but when I leave the files outside the dir loops it selects all the files not just the ones in the dirs I have s

Re: [Tutor] directory within directory

2011-08-18 Thread questions anon
Excellent, thank you!! On Wed, Aug 17, 2011 at 5:43 PM, Peter Otten <__pete...@web.de> wrote: > questions anon wrote: > > > Thank you, that does create the directories in the new place but when I > > process the data it does not put the outputs in the correct directory

Re: [Tutor] numpy.mean across multiple netcdf files

2011-08-16 Thread questions anon
ata you averaged. Say the length of the sets are > [N0,N1,N2,N3,N4] with average values [a0,a1,a2,a3,a4], then to produce the > global average, you need to take > > avg = (1 / (N0+N1+N2+N3+N4) ) * (N0*a0 + N1*a1 + N2*a2 + N3*a3 + N4*a4) > > a few lines of algebra can demonstrate t

Re: [Tutor] directory within directory

2011-08-16 Thread questions anon
xes([l+w+0.025, b, 0.025, h], ) cbar=plt.colorbar(CS, cax=cax, drawedges=True) #save map as *.png and plot netcdf file plt.savefig((os.path.join(newdir,'TSFC'+date_string+'UTC.png'))) On Tue, Aug 16, 2011 at 6:21 PM, Peter Otten <__pete...@web.de>

[Tutor] directory within directory

2011-08-15 Thread questions anon
I would like to open up a bunch of files within a folder within a folder and then process them and output them in another location but with the same folder structure. I seem to having trouble with the folder within folder section. I have a separate folder for each year and then within a year I have

[Tutor] numpy.mean across multiple netcdf files

2011-08-10 Thread questions anon
I have many ncfiles each containing one month of hourly temperature data. I have worked out how to loop through a number of ncfiles and calculate the mean for each file at a particular time and even plot this and output as a *.png. What I am unsure of is how to calculate the mean at a particular ti

[Tutor] inserting degrees symbol in plot title

2011-08-09 Thread questions anon
I am creating a number of plots of temperature in degrees celsius and I would like the title of the plot to have - C° Through a search I found a way to print the symbol degree_symbol = unichr(176).encode("latin-1") print degree_symbol but when I add this to my plot title I receive a huge error (

Re: [Tutor] gzip

2011-08-08 Thread questions anon
f_out.write(newFile) print "end of processing" On Mon, Aug 8, 2011 at 6:34 PM, Stefan Behnel wrote: > questions anon, 08.08.2011 01:57: > > Thank you, I didn't realise that was all I needed. >> Moving on to the next problem: >> I would like to loop throug

Re: [Tutor] gzip

2011-08-07 Thread questions anon
newFile=compresseddata.read() f_out=open(f_in[:-3], "wb") f_out.write(newFile) On Sun, Aug 7, 2011 at 11:22 AM, Walter Prins wrote: > > > On 7 August 2011 01:52, questions anon wrote: > >> How can I output the decompressed file? s

[Tutor] gzip

2011-08-06 Thread questions anon
Hi All, I am trying to decompress at gzipped netcdf file and place the decompressed file in the same folder without the *.gz extension. I am using gzip. If I use the following code nothing happens. import gzip filepath="D:/test/surfacetemp.nc.gz" compresseddata=gzip.open(filepath, "rb") file_conte

Re: [Tutor] read in ascii and plot

2009-12-01 Thread questions anon
I would now like to add a line of best fit. I think the command is polyfit()?? But I can't seem to get it to work f=open('e:/testscatter.txt') data=[map(float,line.split()) for line in f] x, y=zip(*data) pylab.polyfit(x,y,1) pylab.scatter(x,y) pylab.show() Any feedback will be greatly appreciated

Re: [Tutor] read in ascii and plot

2009-12-01 Thread questions anon
Excellent thank you!! On Mon, Nov 30, 2009 at 7:03 PM, Kent Johnson wrote: > On Mon, Nov 30, 2009 at 8:26 PM, Wayne Werner > wrote: > > > A sample of the data is always helpful, but I'll take a shot in the dark. > > If you have data like this: > > 2.31 72 > > 9823 > > ... ..

[Tutor] read in ascii and plot

2009-11-30 Thread questions anon
I would like to read in two columns of data from a *.txt file I type f=open("e:/testascii.txt") import pylab pylab.scatter(f) and then receive an error. How do I point it to each column and do I need to do anything about the space gap between the two columns? Thanks in advance. _

[Tutor] simple plots

2009-08-21 Thread questions anon
I would like to make some simple plots using matplotlib (or any python plotting modules) and I can find lots of examples that generate random data and then plot those, but I cannot find any that read in data from excel or a text file, manipulate the data and then plot the data. Does anyone have any

[Tutor] calculate values of raster from vector

2009-08-14 Thread questions anon
Is there a way I could read in a raster image, read in a shapefile image and then calculate the mean and standard deviation of the raster values within the shapefile? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor