[ncl-talk] Sub: gc_inout

Mary Haley haley at ucar.edu
Mon Aug 21 07:54:30 MDT 2017


Dz,

The issue is that mrb_lat and mrb_lon need to be the same length, because
they are supposed to represent a closed polygon that you want to check
other points against.

My guess is that the lat / lon arrays you read off the file are different
lengths, as they each represent one dimension of your data.

I'm not sure, though, that gc_inout is being used correctly. I'm guessing
that the lat/lon arrays on the file do not represent a closed polygon, but
rather just a lat/lon grid for your data.

If you are simply trying to mask your variable based on another array, then
you may want to look at the "where" or "mask" functions:

http://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml
http://www.ncl.ucar.edu/Document/Functions/Built-in/mask.shtml

You can see some examples of masking here:

http://www.ncl.ucar.edu/Applications/mask.shtml

--Mary




On Mon, Aug 21, 2017 at 12:10 AM, dale zuri <dalezuri at gmail.com> wrote:

> Hi ,
> Could someone help me to fix this?
>
> Thanks
> Dz
> fatal:gc_inout: the lat/lon arrays must have the same dimension sizes
> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 57 in
> file
>
>  f1       = addfile("mask_cfsv2.nc", "r")
> printVarSummary (f1)
>   mrb_lon = f1->lon
>   mrb_lat = f1->lat
>   nmrb    = dimsizes(mrb_lon)
>
>   min_mrb_lat = min(mrb_lat)
>   max_mrb_lat = max(mrb_lat)
>   min_mrb_lon = min(mrb_lon)
>   max_mrb_lon = max(mrb_lon)
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> f    = addfile("Concat_precSum_0Z_198203-201003.nc", "r")   ; note the
> "s" of addfile
> ;T    = f[:]->precSum                ; read T from all files
> T    = f->var(:,{min_mrb_lat:max_mrb_lat},{min_mrb_lon:max_mrb_lon})
> ; read T from all files
> lon1d    = f->lon_0                ; read T from all files
> lat1d    = f->lat_0                ; read T from all files
> printVarSummary (T)
> printVarSummary (lat1d)
> ;printVarSummary (lon1d)
> ;printVarSummary (mrb_lon)
> ;print(lat1d-mrb_lat)
> ;print(lon1d-mrb_lon)
> ;return
>  dimp= dimsizes(T)
>   ntim    = dimp(0)
>   nlat    = dimp(1)
>   mlon    = dimp(2)
> ;;;;;;;;;;;;;;;;;;;;;
>
> ;---Create an array and initialize to _FillValue
>   pmask   = new(dimsizes(T), typeof(T), T at _FillValue)
> printVarSummary(pmask)
>   copy_VarCoords(T,pmask)
> ;;;;;;;;;;;;;;;;;;;;;;;;;;
> ;---Keep only data within the polygon
> ;   Use NCL array syntax (:) to propagate to all times
>
>   do nl=0,nlat-1
>     do ml=0,mlon-1
>       if(gc_inout(lat1d(nl),lon1d(ml),mrb_lat,mrb_lon)) then
> return
>
>
> _______________________________________________
> 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/20170821/3a8e8109/attachment.html 


More information about the ncl-talk mailing list