Re: Error in masking wrf data using shapefile

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri Feb 21 2014 - 09:11:58 MST

Tabish,

This script was written for a rectilinear grid only. I have one that works for a curvilinear grid, and will include that here when I'm done with it. I'm trying to make it run faster.

Meanwhile, you can see our glossary for a definition of curvilinear and rectilinear grids:

  http://www.ncl.ucar.edu/Document/glossary.shtml#RectilinearGrid
  http://www.ncl.ucar.edu/Document/glossary.shtml#CurvilinearGrid

The very simple definition is that a rectilinear grid is one that is represented by one-dimensional coordinate arrays, and a curvilinear grid is one whose lat/lon arrays are two-dimensional.

You can always tell you have a rectilinear grid right away if you do a "printVarSummary" on the variable. For example, assume the output of "printVarSummary" looks like this:

Variable: ts
Type: float
Total Size: 414056448 bytes
            103514112 values
Number of Dimensions: 3
Dimensions and sizes: [time | 1872] x [lat | 192] x [lon | 288]
Coordinates:
            time: [15.5..56924.5]
            lat: [ -90.. 90]
            lon: [ 0..358.75]

The fact that you have the "lat" and "lon" arrays listed under "Coordinates" *and* they have the same names listed under "Dimensions and sizes" tells you that these are one-dimensional coordinate arrays, and hence this is a rectilinear grid.

For a curvilinear grid, it's not as obvious. If I do a printVarSummary on a WRF output variable, like "HGT", I might see something like this:

Variable: hgt
Type: float
Total Size: 162328 bytes
            40582 values
Number of Dimensions: 3
Dimensions and sizes: [Time | 1] x [south_north | 197] x [west_east | 206]
Coordinates:
Number Of Attributes: 6
  FieldType : 104
  MemoryOrder : XY
  description : Terrain Height
  units : m
  stagger :
  coordinates : XLONG XLAT

Note that there are no arrays listed under the "Coordinates", so right away I know I do not have any coordinate arrays, and hence I know I don't have a rectilinear grid.

However, there is a "coordinates" *attribute" which has the strings "XLONG" and "XLAT". This is telling me that the latitude and longitude locations for "hgt" are stored in variables called "XLONG" and "XLAT", and hopefully they are also on the file (in this case, they are). XLAT and XLONG look like this:

Variable: XLAT
Type: float
Total Size: 162328 bytes
            40582 values
Number of Dimensions: 3
Dimensions and sizes: [Time | 1] x [south_north | 197] x [west_east | 206]
Coordinates:
Number Of Attributes: 5
  FieldType : 104
  MemoryOrder : XY
  description : LATITUDE, SOUTH IS NEGATIVE
  units : degree_north
  stagger :

Variable: XLONG
Type: float
Total Size: 162328 bytes
            40582 values
Number of Dimensions: 3
Dimensions and sizes: [Time | 1] x [south_north | 197] x [west_east | 206]
Coordinates:
Number Of Attributes: 5
  FieldType : 104
  MemoryOrder : XY
  description : LONGITUDE, WEST IS NEGATIVE
  units : degree_east
  stagger :

Note that these arrays are basically 2D (I'm not counting the "Time" dimension). Note also that the dimension names (and hence the dimension sizes) are the same as the dimension names of HGT. This is a curvilinear grid.

It's important to know that not all curvilinear arrays will have a "coordinates" attribute. For example, some of the older WRF output files do not have a "coordinates" attribute.

If you get a file with no coordinate arrays or a "coordinates" attribute with the name of the lat/lon arrays, then you can do an "ncl_filedump" on the file to see if you can find some lat/lon arrays that look like they belong with the variable. Usually this is not too difficult, because for one, the dimension sizes will have to match in the rightmost two dimensions, and the arrays might have a "long_name" or "description" attribute with names like "latitude", "longitude", "lat", "lon", etc.

--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
Received on Fri Feb 21 09:12:10 2014

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