[ncl-talk] Masking with shapefile

Mary Haley haley at ucar.edu
Thu Sep 15 08:52:51 MDT 2016


Amit,

It's always important to look at your variables if your NCL script is
giving you errors.  If you do:

printVarSummary(var)

you will see that none of the metadata from "IMR_DLY" on the file was
carried over to "var", and hence shapefile_mask_data has no lat/lon
information to work with.

I'm not sure why you are using "doubletofloat", but all of these functions
strip off metadata when you use them.

To restore the metadata before you call the masking function, add:

copyVarMeta(a->IMR_DLY,var)

Really, though, you shouldn't need to use "doubletofloat" unless you are
trying to save memory.

Also, you don't need this:

  lat                 =  a->latitude
  lon                 =  a->longitude

because once you copy over the metadata, the "latitude" and "longitude"
arrays will automatically be carried along with "var", and you can access
the arrays with "var&latitude" and "var&longitude".

--Mary


On Thu, Sep 15, 2016 at 4:32 AM, Amit Kumar <amitkumar.777 at hotmail.com>
wrote:

> Hi All,
>
>
> I've a gridded data & I want to mask it while using shapefile. But it is
> not taking it as a grid and giving error: shapefile_mask_data: Error: not
> a valid rectilinear, curvilinear, or unstructured grid
>
>
>       left_longitude : 30.05
>       right_longitude : 120.05
>       upper_latitude : 40.05
>       lower_latitude : -39.95
>       lat_interval : 0.1
>       lon_interval : 0.1
>       NCO : "4.5.4"
>       CDO : Climate Data Operators version 1.7.0 (http://mpimet.mpg.de/cdo
> )
>    dimensions:
>       longitude = 300
>       latitude = 380
>       time = 1  // unlimited
>    variables:
>       double longitude ( longitude )
>          standard_name :    longitude
>          long_name :    longitude
>          units :    degrees_east
>          axis :    X
>
>       double latitude ( latitude )
>          standard_name :    latitude
>          long_name :    latitude
>          units :    degrees_north
>          axis :    Y
>
>       double time ( time )
>          standard_name :    time
>          units :    minutes since 2000-1-1 00:00:00
>          calendar :    standard
>          axis :    T
>
>       float IMR_DLY ( time, latitude, longitude )
>          standard_name :    Precipitation
>          long_name :    INSAT Multispectral Rainfall(Daily)
>          units :    mm/day
>          _FillValue :    -999
>          missing_value :    -999
>
>
>
> Now how to convert my data into a valid rectilinear, curvilinear, or
> unstructured grid so that masking can be performed.
>
>
> var                 = doubletofloat(a->IMR_DLY)
>   lat                 =  a->latitude
>   lon                 =  a->longitude
> shp_mask = shapefile_mask_data(var(i,:,:),filename,opt) ------> error here
>
>
> script is also attached.
>
> _______________________________________________
> 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/20160915/efdc70c6/attachment.html 


More information about the ncl-talk mailing list