[ncl-talk] How to make the out of boundary white
Dave Allured - NOAA Affiliate
dave.allured at noaa.gov
Tue Apr 26 19:00:04 MDT 2022
Dana, please include the mailing list on all replies.
> how can i replace the random [data] to use netcdf file?
The example uses a function to generate an array of smoothed random data.
Comment out those lines, and add new lines to read an array from a Netcdf
file. If you are just learning NCL, then please visit the NCL examples
page for many sample programs that show how to read Netcdf data near the
top of each program. Also visit this documentation for an overview:
https://www.ncl.ucar.edu/Applications/read_support.shtml
Mini-language reference manual, section 3:
https://www.ncl.ucar.edu/Document/Manuals/language_man.pdf
After reading an array, use printVarSummary() and printMinMax() to display
basic information about the size and shape of the array, and the extent of
the data. Do this before trying to make any plots.
NCL automatically reads in attached lat and lon coordinate arrays if the
input file is well structured. For this example, it is important that you
confirm that the coordinate arrays are attached and spanning the expected
range. Read more about coordinate arrays in section 2.12 of the
mini-language reference manual.
> and if i have 6 plots in the same page how to do it with what you send?
This is complicated. Just get one plot working correctly for now. Then it
will be easier to move on to multiple plots.
On Tue, Apr 26, 2022 at 1:49 AM Dana Odeh <danaodeh21 at gmail.com> wrote:
> and if i have 6 plots in the same page how to doit with what you send ?
>
> On Tue, 26 Apr 2022 at 09:47, Dana Odeh <danaodeh21 at gmail.com> wrote:
>
>> Thank you for your replay
>> how can i replace the random date to use netcdf file??
>>
>> thank you again
>>
>> On Mon, 25 Apr 2022 at 17:34, Dave Allured - NOAA Affiliate <
>> dave.allured at noaa.gov> wrote:
>>
>>> Dana, there is more than one way to make surrounding areas white. I
>>> modified NCL example mask_4.ncl to show Jordan with surrounding areas
>>> white. See the two attached plots. Both examples use NCL built-in country
>>> outlines, not shape files. Earth..4 has higher resolution outlines. You
>>> can see that there was some change to the border of Jordan between Earth..2
>>> and Earth..4.
>>>
>>> Please compare the attached NCL scripts with mask_4.ncl to see what I
>>> changed.
>>>
>>>
>>> On Mon, Apr 25, 2022 at 1:02 AM Dana Odeh via ncl-talk <
>>> ncl-talk at mailman.ucar.edu> wrote:
>>>
>>>> Hello
>>>> How to make the out of boundary white i want just jordan has the
>>>> information about precipitation not out
>>>> this tihs my code
>>>> can you please help me i saw example 4 but i did not understand ant
>>>> thing
>>>>
>>>> ;open file
>>>>
>>>>
>>>>
>>>> a=addfile("ens_prAdjust_EUR-11_rcp45_1986-2005.nc","r")
>>>>
>>>> b=addfile("ens_prAdjust_EUR-11_rcp45_2046-2065.nc","r")
>>>>
>>>> c=addfile("ens_prAdjust_EUR-11_rcp45_2081-2100.nc","r")
>>>>
>>>>
>>>>
>>>> d=addfile("ens_prAdjust_EUR-11_rcp85_1986-2005.nc","r")
>>>>
>>>> e=addfile("ens_prAdjust_EUR-11_rcp85_2046-2065.nc","r")
>>>>
>>>> f=addfile("ens_prAdjust_EUR-11_rcp85_2081-2100.nc","r")
>>>>
>>>>
>>>>
>>>> apr=a->prAdjust(0,:,:)
>>>>
>>>> bpr=b->prAdjust(0,:,:)
>>>>
>>>> cpr=c->prAdjust(0,:,:)
>>>>
>>>> epr=d->prAdjust(0,:,:)
>>>>
>>>> dpr=e->prAdjust(0,:,:)
>>>>
>>>> fpr=f->prAdjust(0,:,:)
>>>>
>>>>
>>>>
>>>> apr at units=" "
>>>>
>>>> bpr at units=" "
>>>>
>>>> cpr at units=" "
>>>>
>>>> dpr at units=" "
>>>>
>>>> epr at units=" "
>>>>
>>>> fpr at units=" "
>>>>
>>>>
>>>>
>>>> apr at long_name= " "
>>>>
>>>> bpr at long_name= ""
>>>>
>>>> cpr at long_name= ""
>>>>
>>>> dpr at long_name= " "
>>>>
>>>> epr at long_name= ""
>>>>
>>>> fpr at long_name= ""
>>>>
>>>>
>>>>
>>>> pltDir = "./"
>>>>
>>>> pltName= "ppn_rain_Euro23"
>>>>
>>>> pltType= "png"
>>>>
>>>> pltPath = pltDir+pltName
>>>>
>>>> wks = gsn_open_wks(pltType, pltPath)
>>>>
>>>> ; Create the plots for the panel
>>>>
>>>> nrow = 2
>>>>
>>>> ncol = 3
>>>>
>>>> gsn_define_colormap(wks,"cmocean_deep")
>>>>
>>>>
>>>>
>>>> plot =new (nrow*ncol,”graphic”) ; create graphical array
>>>>
>>>> res = True
>>>>
>>>> res at gsnDraw = False
>>>>
>>>> res at gsnFrame = False
>>>>
>>>> res at gsnRightString = "" ; turn off special titles
>>>>
>>>> res at gsnLeftString = ""
>>>>
>>>>
>>>>
>>>> res at cnFillOn = True ; turn on
>>>> contour fill
>>>>
>>>> res at cnLinesOn = False ; turn off contour
>>>> lines
>>>>
>>>> res at cnLineLabelsOn = False ; turn off contour labels
>>>>
>>>> res at cnFillPalette = "cmocean_deep"
>>>>
>>>> res at gsnAddCyclic = False ;
>>>> regional data, don't add cyclic
>>>>
>>>>
>>>>
>>>> ; Set resources for tickmarks
>>>>
>>>> res at tmYLLabelsOn = True ; turn off lat
>>>> labels
>>>>
>>>> res at tmXBLabelsOn = True ; turn off lon
>>>> labels
>>>>
>>>>
>>>>
>>>> res at tmYROn = False
>>>>
>>>> res at tmYLOn = False
>>>>
>>>> res at tmXTOn = False
>>>>
>>>> res at tmXBOn = False
>>>>
>>>>
>>>>
>>>> res at mpFillDrawOrder = "PostDraw" ; draw map fill
>>>> last
>>>>
>>>> res at mpLimitMode = "LatLon"
>>>>
>>>> res at mpFillOn = False
>>>>
>>>> res at mpOutlineOn = False
>>>>
>>>> res at mpDataBaseVersion = "HighRes"
>>>>
>>>>
>>>>
>>>> res at mpDataSetName = "Earth..4"
>>>>
>>>> ; res at mpOutlineOn = True
>>>>
>>>> ; res at mpOutlineBoundarySets = "National"
>>>>
>>>>
>>>>
>>>> ;res at mpGeophysicalLineThicknessF = 2.5
>>>>
>>>> minlat = 29
>>>>
>>>> maxlat = 33.56
>>>>
>>>> minlon = 34.63
>>>>
>>>> maxlon = 39.691
>>>>
>>>>
>>>>
>>>> ; select a subregion
>>>>
>>>> res at mpMinLonF = minlon
>>>>
>>>> res at mpMaxLonF = maxlon
>>>>
>>>> res at mpMinLatF = minlat
>>>>
>>>> res at mpMaxLatF = maxlat
>>>>
>>>> res at cnFillPalette = "cmocean_deep"
>>>>
>>>>
>>>>
>>>> nlon=30.5852
>>>>
>>>> nlat=36.2384
>>>>
>>>>
>>>>
>>>> res at lbLabelBarOn = False ; turn off
>>>> labelbar
>>>>
>>>> res at lbOrientation = "horizontal"
>>>>
>>>> res at cnLevelSelectionMode = "ManualLevels" ; manually
>>>> specify contour levels
>>>>
>>>> res at cnMinLevelValF = 0 ; min level
>>>>
>>>> res at cnMaxLevelValF = 600 ; max level
>>>>
>>>> res at cnLevelSpacingF = 50 ; contour
>>>> interval
>>>>
>>>>
>>>>
>>>> txres = True
>>>>
>>>> txres at txFontHeightF = 0.03
>>>>
>>>> gsn_text_ndc(wks," Mean Annual precipitation ",0.5,0.95,txres)
>>>>
>>>> res at gsnCenterString = "1986-2005"
>>>>
>>>> Plot0=gsn_csm_contour_map(wks,apr,res)
>>>>
>>>>
>>>>
>>>> res at gsnCenterString = "2046-2065"
>>>>
>>>> Plot1=gsn_csm_contour_map(wks,bpr,res)
>>>>
>>>>
>>>>
>>>> res at gsnCenterString = "2081-2100"
>>>>
>>>> Plot2=gsn_csm_contour_map(wks,cpr,res)
>>>>
>>>>
>>>>
>>>> res at gsnCenterString = " "
>>>>
>>>> Plot3=gsn_csm_contour_map(wks,dpr,res)
>>>>
>>>> res at gsnCenterString = " "
>>>>
>>>> Plot4=gsn_csm_contour_map(wks,epr,res)
>>>>
>>>> res at gsnCenterString = " "
>>>>
>>>> Plot5=gsn_csm_contour_map(wks,fpr,res)
>>>>
>>>>
>>>>
>>>> res at gsnCenterString = ""
>>>>
>>>>
>>>>
>>>> filename1 = "gadm40_JOR_1.shp"
>>>>
>>>> filename2 = "jordan_water.shp"
>>>>
>>>> lnres = True
>>>>
>>>> lnres at gsLineThicknessF = 3.0
>>>>
>>>>
>>>>
>>>> poly1 = gsn_add_shapefile_polylines(wks,Plot0,filename1,lnres)
>>>>
>>>> poly2 = gsn_add_shapefile_polylines(wks,Plot0,filename2,lnres)
>>>>
>>>> poly3 = gsn_add_shapefile_polylines(wks,Plot1,filename1,lnres)
>>>>
>>>> poly4 = gsn_add_shapefile_polylines(wks,Plot1,filename2,lnres)
>>>>
>>>> poly5 = gsn_add_shapefile_polylines(wks,Plot2,filename1,lnres)
>>>>
>>>> poly6 = gsn_add_shapefile_polylines(wks,Plot2,filename2,lnres)
>>>>
>>>>
>>>>
>>>> poly7 = gsn_add_shapefile_polylines(wks,Plot3,filename1,lnres)
>>>>
>>>> poly8 = gsn_add_shapefile_polylines(wks,Plot3,filename2,lnres)
>>>>
>>>> poly9 = gsn_add_shapefile_polylines(wks,Plot4,filename1,lnres)
>>>>
>>>> poly10 = gsn_add_shapefile_polylines(wks,Plot4,filename2,lnres)
>>>>
>>>> poly11 = gsn_add_shapefile_polylines(wks,Plot5,filename1,lnres)
>>>>
>>>> poly12 = gsn_add_shapefile_polylines(wks,Plot5,filename2,lnres)
>>>>
>>>>
>>>>
>>>> res at mpOutlineBoundarySets = "National"
>>>>
>>>> mask_areas ="Jordan"
>>>>
>>>> res at mpMaskAreaSpecifiers = mask_areas
>>>>
>>>> res at mpOutlineSpecifiers = mask_areas
>>>>
>>>> res at mpLandFillColor = 0
>>>>
>>>> res at mpInlandWaterFillColor = 0
>>>>
>>>> res at mpFillDrawOrder = "PostDraw”
>>>>
>>>>
>>>>
>>>> resP = True
>>>>
>>>> resP at cnExplicitLabelBarLabelsOn = True
>>>>
>>>>
>>>>
>>>> resP at gsnPanelLabelBar = True ; turn on a common labelbar for the
>>>> entire panel plot
>>>>
>>>> resP at lbTitlePosition = "Bottom" ; put it below the plot
>>>>
>>>> resP at lbTitleString = "mm/year" ; give the labelbar a title
>>>>
>>>> resP at lbTitleFontHeightF = 0.018 ; tweak the size of the
>>>> labelbar title
>>>>
>>>> resP at lbTitleOffsetF = 0.2 ; positive values are up when the
>>>> labelbar is under the plot
>>>>
>>>>
>>>>
>>>> ;resP at gsnMaximize = True
>>>>
>>>> ;resP at lbTitleFontHeightF = .03 ; make title
>>>> smaller
>>>>
>>>> resP at lbTitleDirection = "Across" ; title
>>>> direction
>>>>
>>>> resP at lbLabelStride = 2
>>>>
>>>> ; resP at lbLabelFontHeightF = 0.025
>>>>
>>>> resP at pmLabelBarHeightF = 0.1
>>>>
>>>> resP at lbBoxEndCapStyle = "TriangleBothEnds"
>>>>
>>>> resP at pmLabelBarOrthogonalPosF = -0.02 ; move whole thing down
>>>>
>>>>
>>>>
>>>> resP at gsnFrame = True
>>>>
>>>> resP at gsnPanelLeft = 0.005
>>>>
>>>> resP at gsnPanelBottom = 0.08
>>>>
>>>> resP at gsnPanelSave = True
>>>>
>>>> gsn_panel(wks,(/ Plot0, Plot1, Plot2, Plot3, Plot4, Plot5/),
>>>> (/nrow,ncol/), resP) ; plots
>>>>
>>>> draw(plot)
>>>>
>>>> frame(wks)
>>>>
>>>>
>>>> thankyou
>>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20220426/0b9720dc/attachment.html>
More information about the ncl-talk
mailing list