convert subset of netcdf file to matrix

From: Anandhi Aavudai <AavudaiA_at_nyahnyahspammersnyahnyah>
Date: Mon, 6 Jul 2009 11:32:57 -0400

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
Received on Mon Jul 06 2009 - 09:32:57 MDT

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