Re: How to skip lines when reading in a file [message #74951] |
Mon, 07 February 2011 12:18 |
Heinz Stege
Messages: 189 Registered: January 2003
|
Senior Member |
|
|
On Mon, 7 Feb 2011 10:10:40 -0800 (PST), Ashley Berg wrote:
> I have monthly mean temp data from Jan 1958 to Dec 2008 (1 col, 612
> rows). I want only the data from the months of December, January, and
> February in a new array, so the resulting time series will be one
> column by 153 rows. I'm not sure how to grab only those three months
> while ignoring the other 9. Could someone show me the best way to do
> this? Thank you!
What about something like:
array=all rows from file
array=reform(array,12,n_elements(array)/12,/overwrite)
array=array[[0,1,11],*] ; wanted months
array=array[*]
Not tested, simply written into the news reader.
HTH, Heinz
|
|
|
Re: How to skip lines when reading in a file [message #74952 is a reply to message #74951] |
Mon, 07 February 2011 10:34  |
Ashley Berg
Messages: 14 Registered: February 2011
|
Junior Member |
|
|
On Feb 7, 11:23 am, Gray <grayliketheco...@gmail.com> wrote:
> On Feb 7, 1:10 pm, Ashley Berg <ashley.b...@gmail.com> wrote:
>
>> I have monthly mean temp data from Jan 1958 to Dec 2008 (1 col, 612
>> rows). I want only the data from the months of December, January, and
>> February in a new array, so the resulting time series will be one
>> column by 153 rows. I'm not sure how to grab only those three months
>> while ignoring the other 9. Could someone show me the best way to do
>> this? Thank you!
>
> Do you have some way of knowing which month corresponds to which
> data? Like a month array or something? What are your data types?
> You're going to want to use WHERE().
That's a good idea; since there are no month labels on the data in the
file (just the numbers), I can just create a month array, and where
month[i] is DEC, JAN, or FEB I could have it grab temp[i] from my data
array. That way I'd get a new array with just the temps from those
three months. I'll give that a try.
|
|
|
Re: How to skip lines when reading in a file [message #74953 is a reply to message #74952] |
Mon, 07 February 2011 10:23  |
Gray
Messages: 253 Registered: February 2010
|
Senior Member |
|
|
On Feb 7, 1:10 pm, Ashley Berg <ashley.b...@gmail.com> wrote:
> I have monthly mean temp data from Jan 1958 to Dec 2008 (1 col, 612
> rows). I want only the data from the months of December, January, and
> February in a new array, so the resulting time series will be one
> column by 153 rows. I'm not sure how to grab only those three months
> while ignoring the other 9. Could someone show me the best way to do
> this? Thank you!
Do you have some way of knowing which month corresponds to which
data? Like a month array or something? What are your data types?
You're going to want to use WHERE().
|
|
|