Re: masking an area of china, there is a error or a bug.

From: Dazhen HUANG <huangdzh_at_nyahnyahspammersnyahnyah>
Date: Mon Jan 03 2011 - 23:58:05 MST

Thanks for Rick 's help !
 I followed Rick 's suggestion and print the var f
       printVarSummary(f):
       " Variable: f
         (0)
         filename: bou1_4l
         path: bou1_4l.shp
            file global attributes:
               layer_name : bou1_4l
               geometry_type : polyline
               geom_segIndex : 0
               geom_numSegs : 1
               segs_xyzIndex : 0
               segs_numPnts : 1
            dimensions:
               geometry = 2
               segments = 2
               num_features = 1382 // unlimited
               num_segments = 1382
               num_points = 66530
            variables:
               integer geometry ( num_features, geometry )
                integer segments ( num_segments, segments )
                double x ( num_points )
                double y ( num_points )
       print(ilt1):
       " Variable: ilt1
         Type: integer
         Total Size: 4 bytes
                     1 values
         Number of Dimensions: 1
         Dimensions and sizes: [1]
         Coordinates:
         Number Of Attributes: 1
           _FillValue : -999
         (0) -999 "
So I changed the value of ilt1 to zero:
       ilt1 = 0
      print(ilt1):
       " Variable: ilt1
         Type: integer
         Total Size: 4 bytes
                     1 values
         Number of Dimensions: 1
         Dimensions and sizes: [1]
         Coordinates:
         Number Of Attributes: 1
           _FillValue : -999
         (0) 0 "
 and the picture was generated, But the map is not the one i want.
  
 Also I tried the "shapefile example 1", but failed :
        " fatal:Either file (f) isn't defined or variable (UNEMPLOY) is not a variable in the file "
        the file f is the same file as above.
  
 So ask the question again.
  
 Dazhen
  
  ------------------
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Dazhen HUANG, Mr. #(ƴ)
 Department of Atmospheric Sciences,
 Sun Yat-sen University,
 No.135, Xingang West Road. Guangzhou, 510275, P.R.China
 Tel: (+86)15913147616
Email: huangdzh@foxmail.com
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


  
   
  
  ------------------ Original ------------------
  From: "Rick Brownrigg"<brownrig@ucar.edu>;
 Date: Tue, Jan 4, 2011 01:29 AM
 To: "Dazhen HUANG"<huangdzh@foxmail.com>;
 Cc: "ncl-talk"<ncl-talk@ucar.edu>;
 Subject: Re: [ncl-talk] masking an area of china, there is a error or a bug.

  
Hi Dazhen,

 I can't tell for certain what the issue is. Multiple polygons within a shapefile is certainly an issue; you might do a printVarSummary(f) on that shapefile to verify that i) it is a polygon-type shapefile (as opposed to polyline), and how many polygons there are. If there are multiple polygons, you'll need to loop over them to properly build your mask (See shapefile example 1). Alternatively and depending on the resolution of your data, you might select and use only the largest polygon, on the presumption that it represents the mainland, and that masking the islands is negligible.
 

 Also, I have to wonder if perhaps your indices are backwards:
 

    ilt1 = ilt_mn(dimsizes(ilt_mn)-1) ; Start of lat box
   iln1 = iln_mn(dimsizes(iln_mn)-1) ; Start of lon box
   ilt2 = ilt_mx(0) ; End of lat box
   iln2 = iln_mx(0) ; End of lon box
 

 Should that be?
 

   ilt1 = ilt_mn(0)
   ilt2 = ilt_mx(dimsizes(ilt_mx)-1)
   iln1 = iln_mn(0)
   iln2 = iln_mx(dimsizes(iln_mx)-1)
 

 I'm not certain about that -- it might help to print these values to see if they are what you think they are.
 

 Hope that helps,
 

 Rick
 

   On Jan 2, 2011, at 10:55 PM, Dazhen HUANG wrote:

  Hello all,
  
    I try to mask an area of china with the shp file, but something goes wrong, it showed as:
  
     "fatal:Subscript out of range, error in subscript #0
     fatal:An error occurred reading lat1d
     fatal:Execute: Error occurred at or near line 73 in file mask_9_cn.ncl"
  
     David Brown told me that,
     " the problem starts with the line: ilt_mn = ind(min_mrb_lat.gt.lat1d)
        The variable ilt_mn gets set to a missing value because there are no values of the array lat1d where the value of min_mrb_lat is greater. Therefore lit_mn gets set to a missing value and therefore causes an out-of-range subscript in the line that reports the error:
                  if(gc_inout(lat1d(ilt),lon1d(iln),mrb_lat,mrb_lon)) then "
  
     I guest that the problem is from the shp file, Maybe there are two or more areas other than one area. so the function gc_inout() connot do it. I am trying to make a new shp file now, but I'm not sure this will work then.

  
     Is there anyone would like to help me?
     
     Thanks!
     
     Dazhen
  
  ------------------
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Dazhen HUANG, Mr. #(ƴ)
 Department of Atmospheric Sciences,
 Sun Yat-sen University,
 No.135, Xingang West Road. Guangzhou, 510275, P.R.China
 Email: huangdzh@foxmail.com
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


  
<mask_9_cn.ncl>_______________________________________________
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 Jan 3 23:58:26 2011

This archive was generated by hypermail 2.1.8 : Tue Jan 04 2011 - 09:16:52 MST