[ncl-talk] Shapefile masking: masks not written out for regions west of greenwich meridian for fixed-offset grid

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Wed Nov 30 09:02:03 MST 2022


Tabish, on the "Shapefiles" example page, there is a note near the top.  I
think this might be the problem.  Check the latitude ranges on your
shapefile and grids.

"Important note: The shapefile_mask_data function is a powerful function
used by many scripts on this page. In order for your data to be masked
correctly using this function, your longitude values must be in the same
range as the longitude values on the shapefile. Most shapefile longitude
values are in the range -180 to 180. You can use the print_shapefile_info
procedure above to print this information."


On Wed, Nov 30, 2022 at 8:24 AM Tabish Ansari via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:

> Hi
>
> I'm trying to write out masks for 3 distinct regions: Asia (AS), North
> America (NA) and Europe (EU) for two grids: a high resolution grid with
> greenwich meridian in the middle and a low resolution grid with greenwich
> meridian at the left edge. The shapefile mask data function seems to work
> fine and gives a "success" message in the end, however, while the output
> file contains correct masks for all the 3 regions for the high-resolution
> grid, the masks are incomplete for the low-resolution grid - anything west
> of Greenwich meridian is missing. Can this be due to the low-res grid not
> being centered at 0deg? The script is copied below:
>
>
> ======================================================================================
> load "./shapefile_utils.ncl"
>
> begin
>
> sname =
> "/work/users/tan/mask/ref-countries-2020-01m.shp/CNTR_RG_01M_2020_4326.shp/CNTR_RG_01M_2020_4326.shp"
>
> correctedlist_AS = (/"Aksai Chin","Arunachal
> Pradesh","Afghanistan","Bangladesh","Bhutan","Brunei","Cambodia","China","China/India","Jammu
> Kashmir","Hong
> Kong","India","Indonesia","Japan","Kazakhstan","Kyrgyzstan","Laos","Macao","Malaysia","Maldives","Mongolia","Myanmar/Burma","Nepal","North
> Korea","Pakistan","Papua New Guinea","Philippines","Singapore","South
> Korea","Sri Lanka","Taiwan_Province of
> China","Tajikistan","Thailand","Timor-Leste","Turkmenistan","Uzbekistan","VietNam"/)
>
> correctedlist_NA = (/"Canada","Saint Pierre and Miquelon","United States"/)
>
> correctedlist_EU =
> (/"Albania","Armenia","Austria","Azerbaijan","Belarus","Belgium","Bosnia
> and
> Herzegovina","Bulgaria","Croatia","Cyprus","Czechia","Denmark","Estonia","Faroes","Finland","France","Georgia","Germany","Gibraltar","Greece","Greenland","Hungary","Iceland","Ireland","Italy","Latvia","Lithuania","Luxembourg","North
> Macedonia","Malta","Moldova","Norway","Poland","Portugal","Romania","Russian
> Federation","Serbia","Slovakia","Slovenia","Spain","Sweden","Switzerland","Türkiye","Ukraine","United
> Kingdom"/)
>
> areas_of_interest = correctedlist_AS
>
> data_lowres  =
> addfile("/data/nosync/emissions/HTAPv3-Emissions-tan_regridMC/edgar_HTAPv3_2006_NMVOC.nc","r")
> data_highres =
> addfile("/data/nosync/emissions/HTAPv3-Fluxes-tan/edgar_HTAPv3_2006_NMVOC.nc","r")
>
> ;system("rm VOCregionmask2.nc")
> VOCregionmask = addfile("VOCregionmask.nc","w")
>
> ;---Read any 3d variable and lat/lon coordinates off wrfchemi file.
>   emislow    = data_lowres->HTAPv3_1_International_Shipping(0,:,:)
>   emishigh   = data_highres->HTAPv3_1_International_Shipping(0,:,:)
>
> ;---Set all temperature values to 0 except for those over areas of
> interest which will be equal to 1.
>   opt             = True
>   opt at debug       = True
>   opt at shape_var   = "NAME_ENGL"
>   opt at shape_names = areas_of_interest
>   opt at return_mask = True               ; THIS RETURNS A MATRIX OF 0 AND 1
> INSTEAD OF MASKED DATA
>
>   print("masking lowres data...")
>   emislowresmask  = shapefile_mask_data(emislow,sname,opt)
>
>   print("masking highres temperature data...")
>   emishighresmask   = shapefile_mask_data(emishigh,sname,opt)
>
>   VOCregionmask->AS_lowres  = (/emislowresmask/)
>   VOCregionmask->AS_highres = (/emishighresmask/)
>
> print("Success!!!")
>
> end
>
> ========================================================================
>
> Thanks a lot.
>
> with best regards,
>
> Tabish
> -------------------------------
> Dr Tabish Ansari
> Research Associate
> Air Quality Modelling Group
> IASS-Potsdam
> Germany
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20221130/f207f655/attachment.htm>


More information about the ncl-talk mailing list