[ncl-talk] Masking
Muhammad Omer Mughal
m.mughal1 at postgrad.curtin.edu.au
Wed Nov 8 00:35:31 MST 2017
Hi Mary
Thank you for the reply. The adjustment works perfectly to mask the data. I have another question related to this. When I use the wrfoutput file and use the commands lat2d I get this output
Variable: data3
Type: float
Total Size: 108360 bytes
27090 values
Number of Dimensions: 2
Dimensions and sizes: [south_north | 129] x [west_east | 210]
Coordinates:
Number Of Attributes: 8
lon2d : <ARRAY of 27090 elements>
lat2d : <ARRAY of 27090 elements>
coordinates : XLONG XLAT XTIME
stagger :
units : K
description : TEMP at 2 M
MemoryOrder : XY
FieldType : 104
When I use this to a sliced file from nco which has changed the attributes of the file I get the following output.
Variable: data2
Type: float
Total Size: 108360 bytes
27090 values
Number of Dimensions: 2
Dimensions and sizes: [y | 129] x [x | 210]
Coordinates:
Number Of Attributes: 9
lon2d : <ARRAY of 210 elements>
lat2d : <ARRAY of 210 elements>
stagger :
description : TEMP at 2 M
MemoryOrder : XY
FieldType : 104
coordinates : XLONG XLAT
units : K
time : 40320
Also when I use the sliced file to mask the data I get the error
(0) shapefile_mask_data:Error: not a valid rectilinear,curvilinear, or unstructured grid.
I will appreciate your help
Muhammad Omer Mughal
MSc BSc Mechanical Engineering
PhD Research Scholar
Remote Sensing and Satellite Research Group
Department of Imaging and Applied Physics
Curtin University
Curtin University
Tel | +61 8 9266 7962
Fax | +61 8 9266 2377
Mobile | 0470 237 525
Email | m.mughal1 at postgrad.curtin.edu.au<mailto:m.lynch at curtin.edu.au>
Web | http://curtin.edu.au<http://curtin.edu.au/>
Curtin University is a trademark of Curtin University of Technology.
CRICOS Provider Code 00301J (WA), 02637B (NSW)
________________________________
From: Mary Haley <haley at ucar.edu>
Sent: Wednesday, 8 November 2017 12:42:12 AM
To: Muhammad Omer Mughal
Cc: ncl-talk at ucar.edu
Subject: Re: [ncl-talk] Masking
Muhammad,
It looks like you are trying to use a rectilinear lat/lon grid for masking rather than the original lat/lon data associated with your "T2" variable.
If your file is indeed a WRF output file, then you should use the XLAT/XLONG variables on the file, rather than trying to create your own lat/lon arrays.
Your code would look something like this:
nt = 0
data
= wrf_user_getvar(a, "T2",
nt)
data at lat2d = wrf_user_getvar(a, "lat", nt)
data at lon2d = wrf_user_getvar(a,
"lon",
nt)
data at _FillValue = -9999
opt = True
opt at debug = True
data_mask = shapefile_mask_data(data,"Shapefile/malay.shp",opt)
For an example that masks a WRF output file, see example shapefile_14_mask.ncl
at:
http://www.ncl.ucar.edu/Applications/shapefiles.shtml#ex14
Note that this example is specifying "Ohio" as the specific area in the shapefile to mask against, but if you simply want to use the whole shapefile, then you do not need to set "shape_var" or "shape_names" as this script is doing.
--Mary
On Tue, Nov 7, 2017 at 6:48 AM, Muhammad Omer Mughal <m.mughal1 at postgrad.curtin.edu.au<mailto:m.mughal1 at postgrad.curtin.edu.au>> wrote:
Hi
I am using a WRF output file and I did the following changes "ONLY" to the code[ https://www.ncl.ucar.edu/Applications/Scripts/mask_9.ncl] . I want to mask the temperature in Malaysia using the shape file malay.shp. Can you kindly tell me what else do I need to change as currently I am not able to see the data masked within Malaysia. I will be grateful for your help
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
begin
MASK_INSIDE = True
a = addfile("./UTC_0.nc","r")
lat=a->XLAT
lon=a->XLONG
minlat=min(lat)
maxlat=max(lat)
minlon=min(lon)
maxlon=max(lon)
nlat=129
nlon=210
lat1d = fspan(minlat,maxlat,nlat)
lon1d = fspan(minlon,maxlon,nlon)
data = wrf_user_getvar(a, "T2", 0)
data at _FillValue = -9999
lat1d = fspan(minlat,maxlat,nlat)
lon1d = fspan(minlon,maxlon,nlon)
lat1d at units = "degrees_north"
lon1d at units = "degrees_east"
;---Attach lat/lon coordinate array information.
data!0 = "lat"
data!1 = "lon"
data&lat = lat1d
data&lon = lon1d
f = addfile("Shapefile/malay.shp", "r")
mrb_lon = f->x
mrb_lat = f->y
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)
www.ncl.ucar.edu<https://www.ncl.ucar.edu/Applications/Scripts/mask_9.ncl>
www.ncl.ucar.edu<http://www.ncl.ucar.edu>
;***** ; mask_9.ncl ; ; Concepts illustrated: ; - Drawing the Mississippi River Basin using data from a shapefile ; - Masking a data array based on a geographical ...
www.ncl.ucar.edu<https://www.ncl.ucar.edu/Applications/Scripts/mask_9.ncl>
www.ncl.ucar.edu<http://www.ncl.ucar.edu>
;***** ; mask_9.ncl ; ; Concepts illustrated: ; - Drawing the Mississippi River Basin using data from a shapefile ; - Masking a data array based on a geographical ...
Muhammad Omer Mughal
MSc BSc Mechanical Engineering
PhD Research Scholar
Remote Sensing and Satellite Research Group
Department of Imaging and Applied Physics
Curtin University
Curtin University
Tel | +61 8 9266 7962
Fax | +61 8 9266 2377
Mobile | 0470 237 525
Email | m.mughal1 at postgrad.curtin.edu.au<mailto:m.lynch at curtin.edu.au>
Web | http://curtin.edu.au<http://curtin.edu.au/>
Curtin University is a trademark of Curtin University of Technology.
CRICOS Provider Code 00301J (WA), 02637B (NSW)
_______________________________________________
ncl-talk mailing list
ncl-talk at ucar.edu<mailto: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/20171108/9765989d/attachment.html>
More information about the ncl-talk
mailing list