Re: Reading from netcdf files within NCL again - with more information

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Mon Aug 26 2013 - 13:11:58 MDT

Hi Helen,
I'm not sure if anyone else responded, and I'm not 100% sure if this is
what you are after, but the following will read in the first timestep
for the U and PS variables:

do nf = 0, nfili-1
    fi = addfile (diri+fili(nf), "r")
    PS = fi->PS(0,:,:)
    U = fi->U(0,:,:,:)
    lat = fi->lat
end do

If that is not what you are after please respond to ncl-talk..
Adam

On 08/23/2013 02:35 PM, Helen Parish wrote:
> I am resending this message with more information as I am told it may
> be difficult to know what the variables look like. I include a
> printVarSummary(U), printVarSummary(PS), and printVarSummary(lat) at
> the end if my question below. I am also told that Andy Mai may have
> responded to my post, but I did not receive that reply for some
> reason. Perhaps Andy could reply again if possible ?. Also, anyone
> else who has any ideas about how to do this.
>
> Thanks,
> Helen.
>
> I am trying to read data from 50 netcdf files. Within each of these
> netcdf files there are 10 model outputs (from the CAM model). I would
> like to read in the variables from only the first of the 10 outputs in
> each netcdf file. I am wondering if there is a way to do this kind of
> read within NCL ?. I have been using lines like these within my script
> to read variables from all the files :
>
> do nf = 0, nfili-1
>
> fi = addfile (diri+fili(nf), "r")
>
> PS = fi->PS
> U = fi->U
> lat = fi->lat
>
> end do
>
> However, this reads in all of the 10 outputs within the file.
>
> Does anyone know how to read in just one of the 10 outputs from each
> of the 50 files ?.
>
> Thanks,
> Helen.
>
> Variable: U
> Type: float
> Total Size: 110592000 bytes
> 27648000 values
> Number of Dimensions: 4
> Dimensions and sizes: [time | 10] x [lev | 50] x [lat | 192] x [lon |
> 288]
> Coordinates:
> time: [37333.33333333334..37438.33333333334]
> lev: [0.03554912016..91942.93428213599]
> lat: [ -90.. 90]
> lon: [ 0..358.75]
> Number Of Attributes: 3
> cell_methods : time: mean
> long_name : Zonal wind
> units : m/s
>
> Variable: PS
> Type: float
> Total Size: 2211840 bytes
> 552960 values
> Number of Dimensions: 3
> Dimensions and sizes: [time | 10] x [lat | 192] x [lon | 288]
> Coordinates:
> time: [37333.33333333334..37438.33333333334]
> lat: [ -90.. 90]
> lon: [ 0..358.75]
> Number Of Attributes: 3
> cell_methods : time: mean
> long_name : Surface pressure
> units : Pa
>
> Variable: lat
> Type: double
> Total Size: 1536 bytes
> 192 values
> Number of Dimensions: 1
> Dimensions and sizes: [lat | 192]
> Coordinates:
> lat: [ -90.. 90]
> Number Of Attributes: 2
> units : degrees_north
> long_name : latitude
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
______________________________________________________________
Adam Phillips                                asphilli@ucar.edu
NCAR/Climate and Global Dynamics Division       (303) 497-1726
P.O. Box 3000				
Boulder, CO 80307-3000    http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Aug 26 13:12:08 2013

This archive was generated by hypermail 2.1.8 : Fri Aug 30 2013 - 14:04:57 MDT