Re: convert subset of netcdf file to matrix

From: Mateus Teixeira <mateus.teixeira_at_nyahnyahspammersnyahnyah>
Date: Mon, 6 Jul 2009 13:00:59 -0300

Hi Anandhi,

When you read the variable you can get a subset of the file, as you can see
below:

f = addfile( "myNetCDFfile.nc","r")
tmax = f->tmax( time|::10, {lat|10|12}, {lon|70:80} )

in which

subscripts using {} allows you use actual dimension values. In the time
dimension, it's used ::10 that means you getting fields for each 10 years,
supposing that your time dimension unit is year. I think this anwser your
two first questions. For more information about subscripts, please, see
http://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclVariables.shtml#Subscripts

For the third one, you can use write_matrix function, please, take a look at
http://www.ncl.ucar.edu/Document/Functions/Built-in/write_matrix.shtml

I hope it helps you!

Best regards

Mateus

2009/7/6 Anandhi Aavudai <AavudaiA_at_dep.nyc.gov>

> I am new to NCL. I have a netcdf file for a variable (say tmax) which
> covers the whole globe for 100 years.
> What should I do once I read the netcdf file using "function addfiles or
> addfile"
>
> 1. To get a subset of the netcdf file. The subset is a small region (say
> between lat 10 & 12 deg. N, lon 70 & 80 deg east) and a timestep for 10
> years?
>
> 3. To create a matrix of the subset data. The columns in the matrix are the
> lat, lon, time, level no, data value?
>
> 2. To write the matrix into an ascii file having a two line text header as
> well as the matrix from the third line?
>
> Thanks in advance for the support.
> Anandhi
>
>
> -----Original Message-----
> From: ncl-talk-bounces_at_ucar.edu [mailto:ncl-talk-bounces_at_ucar.edu] On
> Behalf Of ncl-talk-request_at_ucar.edu
> Sent: Sunday, July 05, 2009 2:00 PM
> To: ncl-talk_at_ucar.edu
> Subject: ncl-talk Digest, Vol 68, Issue 17
>
> Send ncl-talk mailing list submissions to
> ncl-talk_at_ucar.edu
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> or, via email, send a message with subject or body 'help' to
> ncl-talk-request_at_ucar.edu
>
> You can reach the person managing the list at
> ncl-talk-owner_at_ucar.edu
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of ncl-talk digest..."
>
>
> Today's Topics:
>
> 1. COARDS-compliant (Mark Fenbers)
> 2. Re: COARDS-compliant (Dennis Shea)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sat, 04 Jul 2009 14:46:08 -0400
> From: Mark Fenbers <Mark.Fenbers_at_noaa.gov>
> Subject: COARDS-compliant
> To: ncl-talk_at_ucar.edu
> Message-ID: <4A4FA370.4060007_at_noaa.gov>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> I just learned about and installed NCL today. My starting netCDF file
> is not COARDS-compliant, but ncl_filedump reads the file, interprets the
> information, and outputs variable:data pairs without errors. From what
> I read, I understand that ncl_convert2nc is capable of creating a
> COARDS-compliant netCDF file (presumably if given the proper options).
> However, ncl_convert2nc will not ingest a netCDF file like ncl_filedump
> can. So how would I go about converting one netCDF file to another?
>
> Mark
>
>
> ------------------------------
>
> Message: 2
> Date: Sun, 05 Jul 2009 08:27:56 -0600
> From: Dennis Shea <shea_at_ucar.edu>
> Subject: Re: COARDS-compliant
> To: Mark Fenbers <Mark.Fenbers_at_noaa.gov>
> Cc: ncl-talk_at_ucar.edu
> Message-ID: <4A50B86C.4040805_at_ucar.edu>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
>
>
> Mark Fenbers wrote:
> > I just learned about and installed NCL today. My starting netCDF file
> > is not COARDS-compliant, but ncl_filedump reads the file, interprets the
> > information, and outputs variable:data pairs without errors. From what
> > I read, I understand that ncl_convert2nc is capable of creating a
> > COARDS-compliant netCDF file (presumably if given the proper options).
>
> I believe that ncl_convert2nc will create COARDS compliant nc files from
> grib1 or grib2 source files.
>
> It will not convert non-COARDS compliant netCDF to COARDS-compliant.
> Not sure that could be done.
>
> It should be straight forward to write an NCL script that
> converts your initial non-CF file to COARDS compliant.
> You could then call that script.
>
>
> > However, ncl_convert2nc will not ingest a netCDF file like ncl_filedump
> > can.
>
> This is not clear what you mean here.
>
> > So how would I go about converting one netCDF file to another?
>
> fi = addfile("initial_file","r")
> fo = addfile("output_file.nc", "c")
>
> then read all the variables frim 'fi';
> use
> http://www.ncl.ucar.edu/Document/Functions/Built-in/getfilevarnames.shtml
>
> loop over each variable; change what u want to change and output
> each variable
>
> Good luck
>
>
> >
> > Mark
> > _______________________________________________
> > ncl-talk mailing list
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
> ------------------------------
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
> End of ncl-talk Digest, Vol 68, Issue 17
> ****************************************
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

-- 
Mateus da Silva Teixeira
Registered Linux User #466740

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jul 06 2009 - 10:00:59 MDT

This archive was generated by hypermail 2.2.0 : Tue Jul 07 2009 - 11:13:18 MDT