CMIP5 files - time [message #86114] |
Mon, 07 October 2013 11:29  |
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   |
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   |
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 #86148 is a reply to message #86146] |
Fri, 11 October 2013 05:26  |
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.")
|
|
|