Re: Error in masking wrf data using shapefile

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri Feb 21 2014 - 16:09:31 MST

Tabish,

I haven't had luck with making the masking code faster, so I've attached what I have so far.

The function to use is shapefile_mask_data, which is in the attached "shapefile_mask_data.ncl" script.

The script that calls this function is wrf_hgt_shapefile_mask.ncl.

To mask your data, you need to attach the special "lat2d" and "lon2d" attributes as shown in the script,
and then call the masking function with:

  hgt_mask = shapefile_mask_data(hgt,"USA_adm/USA_adm2.shp","NAME_1","Ohio",False)

where:

   "hgt" is the 2D variable you want to mask (that should have the lat2d/lon2d attributes attached)
   "USA_adm/USA_adm2.shp" is the name of the shapefile
   "NAME_1" is the name of the variable on the shapefile that will contain the name of the area you want to use for masking (in this case, NAME_1 is the names of the U.S. states)
   "Ohio" is the name of the area (can be an array like (/"Ohio","Michigan"/)) you want to mask
   The last argument indicates whether you want to protect the values inside or outside of "Ohio". (True means protect them).

If you change the "False" to "True", then all values outside of Ohio will get set to missing.

See attached image. This was done using False for the last argument.

--Mary

On Feb 21, 2014, at 8:16 AM, Tabish Ansari <tabishumaransari@gmail.com> wrote:

> Hi
>
> I am trying to mask my wrf data using the shapefile for India. I am doing this based on the method used in "mask_gadm.ncl" script recently released after the shapefiles webinar.
>
> To my knowledge I have made all the correct modifications, however I am getting the following error:
>
> fatal:No coordinate variable exists for dimension (south_north) in variable (data)
> fatal:["Execute.c":7743]:Execute: Error occurred at or near line 29 in file masking.ncl
>
> fatal:["Execute.c":7743]:Execute: Error occurred at or near line 180 in file masking.ncl
>
> Also I would like to know what is the difference between a "rectilinear grid" and a "curvilinear grid" and is my wrf data suitable to be directly used in this script?
>
> I have attached the script below.
>
> --
> Thanks & Regards
> Tabish Umar Ansari
> MS Research Scholar
> Environmental & Water Resources Engineering Division
> Department of Civil Engineering
> IIT Madras
> <masking.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

wrf_hgt_shapefile_mask.ohio.png
Received on Fri Feb 21 16:09:44 2014

This archive was generated by hypermail 2.1.8 : Mon Mar 03 2014 - 14:26:18 MST