[Thread Prev][Thread Next][Index]

Re: extracting the netCDF data within the polygon path (ascii)



On Thu, 6 Mar 2003, Dong-Ha Min wrote:
> > Dong-Ha Min wrote:
> > > I want to extract the data from a netCDF-format file for a specific
> > > geographic region defined by the irregular-shape polygon paths in a
> > > separate ascii file. Can someone guide me step by step how to do this?
> > >
> > > For example, say, I have a levitus_climatology.cdf (data 1) and want to
> > > extract the sea surface temperature from the region given by data 2 (see
> > > below).
> > >
> > > data2 (lon, lat)
> > > ---------------
> > > 160.5 20.5
> > > 160.5 30.5
> > > 170.5 30.5
> > > 170.5 20.5
> > > 160.5 20.5

Hi Dong-Ha,

For simple polygons or curves, you can do this with masking (IF..THEN)  
statements; you just give the equations for the edges.  An example:

use coads_climatology
let xd = (x[g=sst]-210)/180
let yd = y[g=sst]/90
let/title="SST snowcone"/unit="`sst,r=unit`" sst_snowcone = \
   IF yd LT (.3^2-xd^2)^.5 AND yd GT 2*abs(xd)-.6 THEN sst
set window/asp=1.3 1
cancel view
set view upper; shade/l=1 sst_snowcone; go land
set view lower; plot sst_snowcone[x=@ave,y=@ave]

The bottom plot is an average over the "valid" snowcone region.

For more complex polygons or curves, such as cruise or flight paths, you
could create a script to determine the equations from a supplied list of
waypoints, and then build up the mask step-by-step.  You might have to
create some temporary files to contain the masks at intermediate steps,
since there's a limit on the complexity of IF..THEN statements.

Andrew

+--------------------------------------------------------+
|   Dr. Andrew T. Wittenberg   |        GFDL/NOAA        |
|      atw@gfdl.noaa.gov       |      Princeton, NJ      |
+--------------------------------------------------------+







[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement