Re: obtain fields in low resolutions by area_hi2lores_Wrap

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Mon Dec 09 2013 - 16:49:57 MST

Hi Yi-Chih,
I don't think it has anything to do with you regridding precipitation as
opposed to wind vectors. I think it has to do with your LAT/LON arrays.
I would think that the units attribute requirement would be necessary no
matter what the input LAT/LON arrays are, so I'm honestly not sure..
Adam

On 12/09/2013 04:45 PM, Yi-Chih Huang wrote:
> Adam,
>
> Thanks much for the suggestion. It was working. But a basic
> question is why to give units to LON and LAT is necessary for
> precipitation; while there is no need to do so in wind vectors? What
> made the difference?
>
> Thanks a lot,
>
> Yi-Chih
>
>
> On Tue, Dec 10, 2013 at 2:19 AM, Adam Phillips <asphilli@ucar.edu
> <mailto:asphilli@ucar.edu>> wrote:
>
> Hi Yi-Chih,
> Those error messages are hinting that the issue is either in your
> input latitude/longitude arrays into area_hi2lores_Wrap or when
> you go to plot the regridded arrays. (I am honestly unclear
> whether area_hi2lores_Wrap requires the units attribute to be set
> for input/output latitude/longitude arrays.)
>
> I would first try adding units attributes to the LAT/LON arrays,
> and add some print statements to make sure the input
> pcp&lat/pcp&lon arrays contain the necessary units attributes:
>
> LON = fspan( 31.25,158.75, 52)
> LAT = fspan(-28.75, 28.75, 24)
> LON@units = "degrees_east"
> LAT@units = "degrees_north"
> printVarSummary(pcp&lon) ; is a units attribute present?
> printVarSummary(pcp&lat)
>
> opt = True
> opt@critpc = 50 ; require only 50% of the values to
> be precent
> pLo = area_hi2lores_Wrap (pcp&lon,pcp&lat, pcp , True, 1, LON,
> LAT, False)
> printVarSummary(pLo&LON) ; is a units attribute present?
> printVarSummary(pLo&LAT)
>
> If you need to assign a units attribute to pcp&lat for instance:
> pcp&lat@units = "degrees_north"
>
> Hope that helps. If not, please respond to ncl-talk.
> Adam
>
>
> On 12/09/2013 12:37 AM, Yi-Chih Huang wrote:
>> Hello,
>>
>> I am trying to use area_hi2lores_Wrap to obtain the
>> precipitation and wind fields in different low resolutions. I
>> used the same commands; but the patterns of precipitation changed
>> dramatically; while the wind fields remained the same. When "pLo
>> = area_hi2lores_Wrap (pcp&lon,pcp&lat, pcp , True, 1, LON, LAT,
>> False)" was commented, there was no such a warning message as
>> "Data either does not contain a valid latitude coordinate array
>> or doesn't contain one at all." I attached the commands, output
>> of printVarSummary, warning message, and the script as follows.
>> Could anyone tell me what was wrong with precipitation field in
>> area_hi2lores_Wrap?
>>
>> Thanks much,
>>
>> Yi-Chih
>>
>> #####
>> LON = fspan( 31.25,158.75, 52)
>> LAT = fspan(-28.75, 28.75, 24)
>> opt = True
>> opt@critpc = 50 ; require only 50% of the values
>> to be precent
>> pLo = area_hi2lores_Wrap (pcp&lon,pcp&lat, pcp , True, 1, LON,
>> LAT, False)
>>
>> LON := fspan( 30.,160., 261)
>> LAT := fspan(-30., 30., 121)
>> opt = True
>> opt@critpc = 50 ; require only 50% of the values
>> to be precent
>> uLo = area_hi2lores_Wrap (uwnd&lon, uwnd&lat, uwnd, True, 1,
>> LON, LAT, False)
>> vLo = area_hi2lores_Wrap (vwnd&lon, vwnd&lat, vwnd, True, 1,
>> LON, LAT, False)
>> #####
>> Variable: uLo
>> Type: float
>> Total Size: 126324 bytes
>> 31581 values
>> Number of Dimensions: 2
>> Dimensions and sizes: [LAT | 121] x [LON | 261]
>> Coordinates:
>> LAT: [-30..30]
>> LON: [30..160]
>> Number Of Attributes: 13
>> DataFreq : Monthly
>> average_op_ncl : dim_avg_n over dimension(s): year
>> lv_ISBL1 : 850
>> center : US National Weather Service - NCEP (WMC)
>> long_name : u-component of wind
>> units : m/s
>> level_indicator : 100
>> gds_grid_type : 0
>> parameter_table_version : 2
>> parameter_number : 33
>> model : Climate Data Assimilation System (CDAS)
>> initial_time : 02/05/2006 (00:00)
>> _FillValue : 1e+20
>>
>> Variable: pLo
>> Type: float
>> Total Size: 4992 bytes
>> 1248 values
>> Number of Dimensions: 2
>> Dimensions and sizes: [lat | 24] x [lon | 52]
>> Coordinates:
>> lat: [-28.75..28.75]
>> lon: [31.25..158.75]
>> Number Of Attributes: 12
>> _FillValue : 1e+20
>> initial_time : 02/05/1981 (00:00)
>> model : Climate Data Assimilation System (CDAS)
>> parameter_number : 59
>> parameter_table_version : 2
>> gds_grid_type : 0
>> level_indicator : 1
>> units : kg/m^2/s
>> long_name : Precipitation rate
>> center : US National Weather Service - NCEP (WMC)
>> average_op_ncl : dim_avg_n over dimension(s): time
>> DataFreq : Monthly
>> (0) 0
>> (0) check_for_y_lat_coord: Warning: Data either does not
>> contain a valid latitude coordinate array or doesn't contain one
>> at all.
>> (0) A valid latitude coordinate array should have a 'units'
>> attribute equal to one of the following values:
>> (0) 'degrees_north' 'degrees-north' 'degree_north'
>> 'degrees north' 'degrees_N' 'Degrees_north' 'degree_N' 'degreeN'
>> 'degreesN' 'deg north'
>> (0) check_for_lon_coord: Warning: Data either does not
>> contain a valid longitude coordinate array or doesn't contain one
>> at all.
>> (0) A valid longitude coordinate array should have a 'units'
>> attribute equal to one of the following values:
>> (0) 'degrees_east' 'degrees-east' 'degree_east' 'degrees
>> east' 'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE'
>> 'deg east'
>> (0) 1
>> yhuang@arc-env:/fs3/yhuang/nmm$
>>
>> #####
>> load "$SysE/lib/ncl/helper_libs.ncl"
>>
>> begin
>> latS = -30.0
>> latN = 30.0
>> lonE = 30.0
>> lonW = 160.0
>>
>> dir1 = "/fs3/SysE_DB/nmm/NMM/Monthly/Mean/"
>> yrStrt = 1981
>> yrLast = 2006
>> year = ispan(yrStrt, yrLast,1) ; integer
>> yrDir = year + "/" ; string
>> varName= (/"precip"/)
>> nyr = dimsizes(year)
>>
>> dir = str_concat(dir1+yrDir(0))
>> fil = systemfunc("cd "+dir+" ; ls precip.nc
>> <http://precip.nc>") ;;;;;;;; read precipitation
>> f = addfile (dir+fil, "r")
>> x = f->$varName(0)$
>> dims= getfilevardims(f,varName(0))
>> xs = x(:,{latS:latN},{lonE:lonW}) ; JJAS tropical Pacific
>> xu = dim_avg_n_Wrap( xs,0)
>> ds = dimsizes(xs)
>> xx = new((/nyr,ds(0),ds(1),ds(2)/),float)
>> YYYYMM= new ( (/nyr,ds(0)/), double)
>> printVarSummary(xs)
>> printVarSummary(YYYYMM)
>>
>> delete (fil)
>> do ny= 0,nyr-1
>> dir = str_concat(dir1+yrDir(ny))
>> fil = systemfunc("cd "+dir+" ; ls precip.nc <http://precip.nc>")
>> f = addfile (dir+fil, "r")
>>
>> x := f->$varName(0)$
>> dims= getfilevardims(f,varName(0))
>> xs := x(:,{latS:latN},{lonE:lonW}) ; Indian Ocean
>> xx(ny,:,:,:)= xs
>> YYYYMM(ny,:) = cd_calendar(xs&$xs!0$, 1)
>> end do
>> printMinMax(xx,True)
>> print(YYYYMM(0:2,0:3))
>>
>> xx!0 = "year"
>> xx!1 = "month"
>> pcp = dim_avg_n_Wrap( xx,(/0,1/) ) *86400 ; kg/m^2/s -> mm/day
>> copy_VarMeta(xu,pcp)
>> printMinMax(pcp,True)
>> printVarSummary(pcp)
>>
>> LON = fspan( 31.25,158.75, 52)
>> LAT = fspan(-28.75, 28.75, 24)
>> opt = True
>> opt@critpc = 50 ; require only 50% of the values
>> to be precent
>> pLo = area_hi2lores_Wrap (pcp&lon,pcp&lat, pcp , True, 1, LON,
>> LAT, False)
>> pLo!0 = "lat"
>> pLo!1 = "lon"
>> printVarSummary(pcp&lon)
>> printVarSummary(pcp&lat)
>> printVarSummary(LON)
>> printVarSummary(LAT)
>>
>> delete ([/fil,varName/])
>> dir1= "/fs3/SysE_DB/nmm/NMM/Monthly/Mean/"
>> dir = str_concat(dir1+yrDir(0))
>> fil = systemfunc("cd "+dir+" ; ls *wnd_850.nc
>> <http://wnd_850.nc>") ; input file name(s)
>> f = addfile (dir+fil(0), "r")
>>
>> varName= (/"uwnd","vwnd"/)
>> x := f->$varName(0)$
>> dims = getfilevardims(f,varName(0))
>> xs := x(:,{latS:latN},{lonE:lonW}) ; Indian Ocean
>> ds = dimsizes(xs)
>> xx := new((/nyr,ds(1),ds(2)/),float,"No_FillValue")
>>
>> delete (fil)
>> do nf= 0,1
>> do ny= 0,nyr-1
>> dir = str_concat(dir1+yrDir(ny))
>> fil = systemfunc("cd "+dir+" ; ls *wnd_850.nc
>> <http://wnd_850.nc>") ; input file name(s)
>>
>> f = addfile (dir+fil(nf), "r")
>> x = f->$varName(nf)$
>> dims = getfilevardims(f,varName(nf))
>> xs := x(:,{latS:latN},{lonE:lonW}) ; Indian Ocean
>> xy = dim_avg_n_Wrap( xs, 0 )
>> xx(ny,:,:)= xy
>> xx!0 = "year"
>>
>> if ( ny .eq. nyr-1 .and. nf .eq. 0 ) then
>> uwnd= dim_avg_n_Wrap( xx, 0 )
>> else if ( ny .eq. nyr-1 .and. nf .eq. 1 ) then
>> vwnd= dim_avg_n_Wrap( xx, 0 )
>> end if
>> end if
>> end do
>> end do
>> printVarSummary(uwnd)
>>
>> LON := fspan( 30.,160., 261)
>> LAT := fspan(-30., 30., 121)
>> opt = True
>> opt@critpc = 50 ; require only 50% of the values
>> to be precent
>> uLo = area_hi2lores_Wrap (uwnd&lon, uwnd&lat, uwnd, True, 1,
>> LON, LAT, False)
>> vLo = area_hi2lores_Wrap (vwnd&lon, vwnd&lat, vwnd, True, 1,
>> LON, LAT, False)
>> printVarSummary(uwnd&lon)
>> printVarSummary(uLo)
>> printVarSummary(pLo)
>>
>> wks= gsn_open_wks("X11","pcpWind_nmm")
>> gsn_define_colormap(wks,"BlueRed")
>>
>> pres= True
>> opt= True
>> myfill(pres,opt)
>> pres@gsnAddCyclic = False
>> pres@mpMinLatF = -30
>> pres@mpMaxLatF = 30
>> pres@mpMinLonF = 30
>> pres@mpMaxLonF = 160
>>
>> pres@cnFillOn = True
>> pres@gsnSpreadColors = True ; use full colormap
>> pres@gsnSpreadColorStart = 10 ; for BlueRed
>> pres@gsnSpreadColorEnd = 250 ; for BlueRed
>> pres@cnLevelSelectionMode = "ManualLevels"
>> pres@cnMinLevelValF = 1.
>> pres@cnMaxLevelValF = 20.
>> pres@cnLevelSpacingF = 1.
>>
>> pres@lbLabelBarOn = True
>> pres@pmLabelBarWidthF= 0.8
>> pres@lbLabelStride = 4
>> pres@mpFillOn = False
>> pres@mpOutlineBoundarySets = "National" ; turns on
>> country boundaries.
>> pres@gsnRightString = "mm/day"
>> pres@gsnLeftString = "NMM: Average Monthly Precipitation Rate
>> during JJAS"
>> pres@cnFillDrawOrder = "Predraw"
>> pres@gsnDraw = False
>> pres@gsnFrame = False
>> print("0")
>> plot1= gsn_csm_contour_map(wks,pLo,pres)
>> print("1")
>>
>> wres= True
>> wres@vcRefMagnitudeF = 10.0 ; define vector
>> ref mag
>> wres@vcRefLengthF = 0.045 ; define length
>> of vec ref
>> wres@vcMinDistanceF = 0.025 ; thin out windbarbs
>> wres@vcVectorDrawOrder = "Predraw"
>> wres@gsnLeftString = "NMM: Average Monthly Wind
>> Vectors on 850 hPa during JJAS"
>> wres@gsnLeftStringFontHeightF = 0.025
>> wres@gsnRightStringFontHeightF = 0.025
>> wres@gsnDraw = False
>> wres@gsnFrame = False
>> plot2= gsn_csm_vector(wks,uLo,vLo,wres)
>>
>> overlay(plot1,plot2)
>> maximize_output(wks,True)
>> end
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> --
> ______________________________________________________________
> Adam Phillipsasphilli@ucar.edu <mailto:asphilli@ucar.edu>
> NCAR/Climate and Global Dynamics Division(303) 497-1726 <tel:%28303%29%20497-1726>
> P.O. Box 3000
> Boulder, CO 80307-3000http://www.cgd.ucar.edu/cas/asphilli
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
______________________________________________________________
Adam Phillips                                asphilli@ucar.edu
NCAR/Climate and Global Dynamics Division       (303) 497-1726
P.O. Box 3000				
Boulder, CO 80307-3000    http://www.cgd.ucar.edu/staff/asphilli

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Dec 9 16:50:14 2013

This archive was generated by hypermail 2.1.8 : Fri Dec 13 2013 - 11:39:30 MST