Re: Masking Tibetan Plateau

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Mon Apr 12 2010 - 08:46:19 MDT

There may have been some offline communication on this topic.
******
The original question was:

"I would like to know is there any way to mask the Tibetan Plateau while
plotting 850hpa winds in NCL??"

If you have something like

   u = f->U ; u(time,lat,lon) where lat[*] and lon[*]
   v = f->V

   latS = 28 ; user specified Tibetan Plateau boundaries
   latN = 40
   lonW = 75
   lonE = 104
                  ; mask values over Tibetan Plateau
   lat3d = conform(u, u&lat, 1)
   lon3d = conform(u, u&lon, 2)
                  ; use array syntax
   u = where(lat3d.ge.latS .and. lat3d.le.latN .and. \
                 lon3d.ge.lonW .and. lon3d.le.lonE \
                 ,u@_FillValue, u)
   v ...

   delete(lat3d) ; no longer needed
   delete(lon3d)

-----

I added another approach at

http://www.ncl.ucar.edu/Applications/regrid.shtml
See Example 13 [ Look at Example 12 first]

If interested in the topography data:

ftp ftp.cgd.ucar.edu
anonymous
email
cd pub/shea/TOPOGRAPHY
get ETOPO2_GLOBAL_2_ELEVATION.nc
quit

-----
Good Luck

On 4/10/10 5:16 PM, Rob Nicholas wrote:
> Hi Louis,
>
> Here's one way to do it. Let's assume you have files *z850.nc
> <http://z850.nc>* and *z_surface.nc <http://z_surface.nc>* each
> containing a single, identically named variable. Both have dimensions
> [lat][lon][time] and are on the same grid, but *z850.nc
> <http://z850.nc>* has an arbitrary number of timesteps while
> *z_surface.nc <http://z_surface.nc>* has only one timestep. The mask
> file can then be created using CDO with a single line of code:
>
> cdo setrtoc,-1.e9,0,0 -setrtoc,0,1.e9,1 -sub z_surface.nc
> <http://z_surface.nc> -timpctl,5 z850.nc <http://z850.nc> -timmin
> z850.nc <http://z850.nc> -timmax z850.nc <http://z850.nc> mask850.nc
> <http://mask850.nc>
>
> Or, broken down into multiple steps to show the process more clearly:
>
> cdo timpctl,5 z850.nc <http://z850.nc> -timmin z850.nc
> <http://z850.nc> -timmax z850.nc <http://z850.nc> z850_5th_pctl.nc
> <http://z850_5th_pctl.nc>
> cdo sub z_surface.nc <http://z_surface.nc> z850_5th_pctl.nc
> <http://z850_5th_pctl.nc> diff.nc <http://diff.nc>
> cdo setrtoc,-1.e9,0,0 -setrtoc,0,1.e9,1 diff.nc <http://diff.nc>
> mask850.nc <http://mask850.nc>
> rm z850_5th_pctl.nc <http://z850_5th_pctl.nc> diff.nc <http://diff.nc>
>
> You can then use the mask you've created with NCL's mask() function. I
> don't think it would be a big deal to replicate this wholly within NCL,
> but CDO is so blazingly fast (the above took less than 2 seconds on my
> laptop when applied to 60 years of monthly reanalysis data) and NCL
> seems to lack a function for computing percentiles, so it would be a bit
> more work. You could, of course, execute CDO from within NCL using the
> system() procedure if you like to keep everything in one place.
>
> ~Rob
>
>
> On Sat, Apr 10, 2010 at 1:28 AM, louis Vonder <appopson@yahoo.fr
> <mailto:appopson@yahoo.fr>> wrote:
> >
> > Hi Rob,
> > Can you share your CDO code with us?
> > Louis
> > Regards
> >
> > --- En date de : Ven 9.4.10, Rob Nicholas
> <rnicholas@atmos.washington.edu <mailto:rnicholas@atmos.washington.edu>>
> a écrit :
> >
> > De: Rob Nicholas <rnicholas@atmos.washington.edu
> <mailto:rnicholas@atmos.washington.edu>>
> > Objet: Re: [ncl-talk] Masking Tibetan Plateau
> > À: ncl-talk@ucar.edu <mailto:ncl-talk@ucar.edu>
> > Date: Vendredi 9 avril 2010, 19h26
> >
> > Hi A.R.,
> >
> > Others may have better ways to do this, but I'll share what I've done
> > and hope that others will chime in to correct/improve the method I'm
> > outlining.
> >
> > What I did was use the surface geopotential and the 850 mb heights
> > from NCEP/NCAR Reanalysis to create a mask. The tricky part about
> > masking out topography for fields on pressure levels, of course, is
> > this fact that geopotential height of the pressure levels change with
> > time. First I found 5th percentile* of 850 mb geopotential height for
> > each gridbox over the entire reanalysis period. Any gridbox where the
> > surface geopotential equalled or exceeded this value was set to 0; all
> > other gridboxes were set to 1. Then apply this masking array to the
> > 850 mb wind data using the NCL mask() function.
> >
> > I'm not going to suggest any specific NCL code (I used CDO for this
> > particular task) but I think the above could be done in just a few
> > lines.
> >
> > ~Rob
> >
> > * The "5th percentile" choice is really quite arbitrary, but I chose
> > it because using the minimum value for each gridbox ended up masking
> > out vast swaths of the globe to the point of making the fields useless
> > for my purpose.
> >
> >
> >
> > On Thu, Apr 8, 2010 at 9:04 PM, A.R Ragi <ar.ragi@gmail.com
> <mailto:ar.ragi@gmail.com>> wrote:
> > > Dear NCL users..,
> > >
> > > I would like to know is there any way to mask the Tibetan Plateau while
> > > plotting 850hpa winds in NCL??
> > >
> > > --
> > > *********************************************************************
> > > Thanks,
> > > A.R.Ragi
> > > M.Tech Atmospheric science
> > > Department of Atmospheric science
> > > Cochin University of Science and Technology
> > > Email : ar.ragi@gmail.com <mailto:ar.ragi@gmail.com>
> > >
> > > ***********************************************************************
> > > "I want to know how God created this world.I am not interested in
> this or
> > > that phenomenon. I want to know, his thought, the rest are details" .
> > > ---Albert Einstein
> > >
> > > ***********************************************************************
> > >
> > >
> > > _______________________________________________
> > > ncl-talk mailing list
> > > List instructions, subscriber options, unsubscribe:
> > > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> > >
> > >
> > _______________________________________________
> > ncl-talk mailing list
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Apr 12 08:46:25 2010

This archive was generated by hypermail 2.1.8 : Wed Apr 14 2010 - 09:15:22 MDT