[ncl-talk] Selecting a Subset of Lat/Long Points from a wrfinput_d01 File

Guido Cioni guidocioni at gmail.com
Wed Mar 8 16:59:48 MST 2017


Hey Andrew,
if what you want is to subset data in a geographical region there are multiple ways to achieve that. 
Suppose you have 2-D lon and lat coordinates associated to your variable. Then you can use the where function (http://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml <http://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml>) like so (see Example 3): 

  data_new = where((data_read at lat2d.ge.latMin .and. data_read at lat2d.le.latMax  .and. \
               data_read at lon2d.ge.lonMin .and. data_read at lon2d.le.lonMax), data_read*1.3, data_read)

> Il giorno 09 mar 2017, alle ore 00:47, Andrew Schwartz <aschwa at ucar.edu> ha scritto:
> 
> Hi guys, 
> 
> I am working on changing the smois values within my wrfinput_d01 file so that we can examine the various effects of soil moisture on different atmospheric parameters. I have an ncl script that does this for all the values in the CONUS, but I need to change only a small subset of the actual values that's roughly the size of Colorado. I have never written an ncl script and am stumped currently. Are there any built-in functions that might make this easier or do I need to go another route? My current code is below.
> 
> Thanks!
> 
> -Andrew
> 
> =======================================================================
> 
> ;=============
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
> ;=============
> 
> ;---Open file to rewrite
>   f = addfile("wrfinput_d01","w")
> 
> ;---Read data
>   data_read = f->SMOIS(:,:,:,:)
>   print("==================================================================")
>   printVarSummary(data_read)
>   print("min/max data_read = " + min(data_read) + "/" + max(data_read))
> 
>   data_new = data_read * 1.3
> 
>   print("==================================================================")
>   printVarSummary(data_new)
>   print("min/max data_read = " + min(data_new) + "/" + max(data_new))
> 
>   print("==================================================================")
>   print("================= Outputting Data to File ========================")
>   print("==================================================================")
> 
> 
> ;---Write out new data
>   f->SMOIS = data_new
> 
> ;---Close file.
>   delete(f)
> 
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170309/6efd708f/attachment.html 


More information about the ncl-talk mailing list