comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » CMIP5 files - time
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
CMIP5 files - time [message #86114] Mon, 07 October 2013 11:29 Go to next message
limiqt is currently offline  limiqt
Messages: 27
Registered: October 2013
Junior Member
Hi everyone,
I was wondering if you could help me with the following. I am using monthly CMIP5 files. These files are ncdf files. This files have a variable (data) changing with time and the time info embedded in the .nc files.

Im doing this:
filein='pr_Amon_HadGEM2-ES_piControl_r1i1p1_198412-200911.nc '
ncid = ncdf_open(fileIn)
ncim = ncdf_varid(ncid, 'pr')
NCDF_VARGET, ncid, ncim, _data
sdata=size(_data)
nc=sdata(1) & nl=sdata(2) & nt=sdata(3)
print, nc, nl, nt

I get : 192 145 300

The dimensions in the file are time, lat, lon and pr

I need to read the time from the .nc file and associate each time to the variable. Eg:
time 0 (198412) should be 192x145x0
time 1 (198501) should be 192x145x1
..
..
time 299 (200911) should be 192x145x299

I was wondering if someone could help me solving this problem.

Thanks

Lim.
Re: CMIP5 files - time [message #86135 is a reply to message #86114] Thu, 10 October 2013 06:46 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
limiqt@gmail.com writes:

> I was wondering if you could help me with the following. I am using monthly CMIP5 files. These files are ncdf files. This files have a variable (data) changing with time and the time info embedded in the .nc files.
>
> Im doing this:
> filein='pr_Amon_HadGEM2-ES_piControl_r1i1p1_198412-200911.nc '
> ncid = ncdf_open(fileIn)
> ncim = ncdf_varid(ncid, 'pr')
> NCDF_VARGET, ncid, ncim, _data
> sdata=size(_data)
> nc=sdata(1) & nl=sdata(2) & nt=sdata(3)
> print, nc, nl, nt
>
> I get : 192 145 300
>
> The dimensions in the file are time, lat, lon and pr
>
> I need to read the time from the .nc file and associate each time to the variable. Eg:
> time 0 (198412) should be 192x145x0
> time 1 (198501) should be 192x145x1
> ..
> ..
> time 299 (200911) should be 192x145x299
>
> I was wondering if someone could help me solving this problem.

I'm not sure what problem we are talking about. Read the time variable
out of the file. It will be associated with the arrays as you expect it
to be.

If you don't know the name of the time variable, you can browse the file
with ncdf_browser from the Coyote Library.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: CMIP5 files - time [message #86145 is a reply to message #86114] Thu, 10 October 2013 17:33 Go to previous messageGo to next message
SonicKenking is currently offline  SonicKenking
Messages: 51
Registered: October 2010
Member
On Tuesday, October 8, 2013 5:29:08 AM UTC+11, Lim wrote:
> Hi everyone,
>
> I was wondering if you could help me with the following. I am using monthly CMIP5 files. These files are ncdf files. This files have a variable (data) changing with time and the time info embedded in the .nc files.
>
>
>
> Im doing this:
>
> filein='pr_Amon_HadGEM2-ES_piControl_r1i1p1_198412-200911.nc '
>
> ncid = ncdf_open(fileIn)
>
> ncim = ncdf_varid(ncid, 'pr')
>
> NCDF_VARGET, ncid, ncim, _data
>
> sdata=size(_data)
>
> nc=sdata(1) & nl=sdata(2) & nt=sdata(3)
>
> print, nc, nl, nt
>
>
>
> I get : 192 145 300
>
>
>
> The dimensions in the file are time, lat, lon and pr
>
>
>
> I need to read the time from the .nc file and associate each time to the variable. Eg:
>
> time 0 (198412) should be 192x145x0
>
> time 1 (198501) should be 192x145x1
>
> ..
>
> ..
>
> time 299 (200911) should be 192x145x299
>
>
>
> I was wondering if someone could help me solving this problem.
>
>
>
> Thanks
>
>
>
> Lim.

Do you mean something like the following?
for i=0,299 do (scope_varfetch("time_"+strtrim(i,2), /enter)) = _data[*,*,i]
Re: CMIP5 files - time [message #86146 is a reply to message #86145] Fri, 11 October 2013 03:10 Go to previous messageGo to next message
Fabzi is currently offline  Fabzi
Messages: 305
Registered: July 2010
Senior Member
On 10/11/2013 02:33 AM, SonicKenking wrote:
> Do you mean something like the following?
> for i=0,299 do (scope_varfetch("time_"+strtrim(i,2), /enter)) = _data[*,*,i]

I think we should stop suggesting scope_varfetch in this group, but this
may be just my opinion... I am 99% sure that when you read climate data
from CF compliant NCDF files, scope_varfetch is definitely not needed.
The question from lim is not clearly formulated.
Re: CMIP5 files - time [message #86148 is a reply to message #86146] Fri, 11 October 2013 05:26 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Fabien writes:

> I think we should stop suggesting scope_varfetch in this group, but this
> may be just my opinion... I am 99% sure that when you read climate data
> from CF compliant NCDF files, scope_varfetch is definitely not needed.
> The question from lim is not clearly formulated.

Amen to this! I'm a 100% sure it's not needed. :-)

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to speed up kernel density smoothing for many data points
Next Topic: code checking tools

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:06:44 PDT 2025

Total time taken to generate the page: 0.00444 seconds