[ncl-talk] Fw: usage of landsea.nc for separation of point data

Geeta Geeta geetag54 at yahoo.com
Tue Jul 24 01:41:40 MDT 2018


thanks Dennis. It worked fine. 
Geeta. 

    On Monday, 23 July, 2018, 8:22:17 PM IST, Dennis Shea <shea at ucar.edu> wrote:  
 
 http://www.ncl.ucar.edu/Document/Functions/Shea_util/landsea_mask.shtml

As noted in the function description, the landsea_mask function returns a grid.

"Returns a grid that contains a land/sea mask given any latitude andlongitude array."

---
lsm  = landsea_mask(MASK,lat,lon)

The 'lat' and 'lon' define the coordinates of an array with some quasi-regular' structure:

   x(lat,lon)   where lat[*],lon[&] are the coordinates of a rectilinear grid.
   X(LAT,LON)   where LAT and LON are two-dimensional
                LAT ==> XLAT(nlat,mlon);  LON ==> XLON(nlat,mlon)

My understanding is that you are inputting station or random locations rather than a grid-type structure. 
You can use landsea_mask in a loop

   b      =        addfile("$NCARG_ROOT/lib/ncarg/data/cdf/landsea.nc","r")
   MASK   =        b->LSMASK
   printVarSummary(MASK)               ; (180,360)
   print("---")

   Z1          =   asciiread("dcc30wcc30.merged.may.050607.txt",-1,"string")                     
   NUM         =   dimsizes(Z1)
   print(NUM)
   print("---")

   LAT         =   new(NUM,float)
   LON         =   new(NUM,float)
   LSM         =   new(NUM,byte)

   do II       =   0, NUM-1
      SPLIT    =   str_split(Z1(II)," ") 
      LAT(II)  =   tofloat(SPLIT(15))
      LON(II)  =   tofloat(SPLIT(16))
      LSM(II)  =   landsea_mask(MASK,LAT(II),LON(II))   ;  individual locations (II)
   end do 

   print(LAT+"   "+LON+"   "+LSM)



On Sat, Jul 21, 2018 at 10:20 AM, Geeta Geeta <geetag54 at yahoo.com> wrote:

hi Dennis. 


I earlier sent a message that it has been sorted out. Pls excuse me. I have one small doubt. I have given one LAt/LON as input then the output is 0 or 1. But when I give full array of lat/lon as input, it gives me 2 dimensionsl array of 0 and 1. here is my code.  Z1         =    asciiread("dcc30wcc30.merged. may.050607.txt",-1,"string")                     ;                   print(Z1)    NUM        =    dimsizes(Z1)                    print(NUM)
   LAT         =   new(NUM,float)   LON         =   new(NUM,float)
   do II       =   0, NUM-1   SPLIT       =   str_split(Z1(II)," ")    LAT(II)     =   stringtofloat(SPLIT(15))   LON(II)     =   stringtofloat(SPLIT(16));                  print(LAT(II)+" "+LON(II))   end do 
;  Open landsea file
   b      =        addfile("$NCARG_ROOT/lib/ ncarg/data/cdf/landsea.nc","r" )   MASK   =        b->LSMASK                   printVarSummary(MASK)               ; 2 dim var                   print(LAT(0)+"------------ "+LON(0))
;   --------------MASK LAND DATA-------------------------- -------
;   lsm  =        landsea_mask(b->LSMASK,6. 049608,76.910484)   ;  Individual points, Output is 0 or 1    lsm  =        landsea_mask(b->LSMASK,LAT, LON)                      ;  Gave full array as input;   LO    =       mask(lsm,lsm.eq.1,False)                                          ;  Required for Plotting purpose                  printVarSummary(lsm)               ; 2 dim var;                 printVarSummary(LO)               ; 2 dim var;                 print(lsm)                  write_table("LL_MASKED.txt"," a",[/LAT,LON,lsm/],"%8.1f %8.1f %4i")
the output is Variable: NUMType: integerTotal Size: 4 bytes            1 valuesNumber of Dimensions: 1Dimensions and sizes: [1]Coordinates: (0) 94
Variable: MASKType: byteTotal Size: 64800 bytes            64800 valuesNumber of Dimensions: 2Dimensions and sizes: [lat | 180] x [lon | 360]Coordinates:             lat: [-89.5..89.5]            lon: [0.5..359.5]Number Of Attributes: 1  long_name : land_sea_mask(0) 12.2952------------ 78.1018
Variable: lsmType: byteTotal Size: 8836 bytes            8836 valuesNumber of Dimensions: 2Dimensions and sizes: [lat | 94] x [lon | 94]Coordinates:             lat: [12.29523..17.34258]            lon: [78.10181..72.63507]Number Of Attributes: 1  _FillValue : -127
My doubt is that in the output file, 8896 values are coming. (94*94).  
 Geeta. 

    On Friday, 20 July 2018 11:45 PM, Dennis Shea <shea at ucar.edu> wrote:
 

 Please carefully read the documentation:
   http://www.ncl.ucar.edu/ Document/Functions/Shea_util/ landsea_mask.shtml

As noted in the documentation, the land-sea mask is a 1x1 grid.

---------------

http://www.ncl.ucar.edu/ Applications/mask.shtml
mask_5.ncl
-----------------
http://www.ncl.ucar.edu/ Applications/climo.shtml
climo_6.ncl
------------------
http://www.ncl.ucar.edu/ Applications/unique.shtml
unique_14.ncl
------------------
http://www.ncl.ucar.edu/ Applications/mjoclivar.shtml
mjoclivar_1.ncl

On Fri, Jul 20, 2018 at 11:12 AM, Geeta Geeta <geetag54 at yahoo.com> wrote:

hi all. i have some lat/lon of some points that I have plotted on the map. It is a simple txt file which contains this information (lat/lon) and I have separarate these points into land and sea. 
I wanted to know how to use the file landsea.nc  that separates the point data over land and over ocean. sample txt file is shown below. 20080508.59705.7.HDF     13.367300 76.98685520080530.60046.7.HDF     17.905054 76.77920520090505.65352.7.HDF     5.941240   79.0020090517.65536.7.HDF     18.066799 76.019241
I have attached a sample figure for your reference. 
thanks for your suggestions Geeta.
______________________________ _________________
ncl-talk mailing list
ncl-talk at ucar.edu
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/ mailman/listinfo/ncl-talk





   

   
______________________________ _________________
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/20180724/0c9e4675/attachment.html>


More information about the ncl-talk mailing list