[ncl-talk] Sub: Interpolation
Karin Meier-Fleischer
meier-fleischer at dkrz.de
Fri Dec 18 01:41:05 MST 2015
Hi Adv,
have you read the warning messages NCL returned? Your latitude and
longitude arrays do not have the correct units like degrees_north or
degrees_east. The solution is to add the units attribute to lat and lon,
so NCL will know how to handle them.
lat at units = "degrees_north"
lon at units = "degrees_east"
Bye,
Karin
Am 18.12.15 um 08:24 schrieb Adv:
> Hi,
> I have been trying to do objective analysis only over the region of
> longitude from -116 to -90.35 and latitude of 40.01 to 49. While
> plotting the output, the values are spreaded over the global region. I
> don't understand where is wrong. It's been long I am kinda stuck with
> this objective analysis. I have attached here the output figure and
> code too. Could someone please help me to fix this?
>
> begin
> strll = asciiread("stationmac.txt", -1, "string") ;
> print(strll) ; STATION","STATION_NAME", "LAT", "LON"
> print("=====")
>
> sloc = str_get_field(strll , 2, ",")
> lat = tofloat( str_get_field(strll , 3, ",") )
> lon = tofloat( str_get_field(strll , 4, ",") )
> print(sloc +" : "+lat+" "+lon)
> mnlat=(min(lat))
> mxlat=(max(lat))
> mnlon=(min(lon))
> mxlon=(max(lon))
> ;print(lon)
> print(mnlon)
> print(mxlon)
> print(mnlat)
> print(mxlat)
> mlon = 390
> dlon = -90.35 / mlon
> lonn = fspan (-116, (mlon - 1) * dlon, mlon)
> print(lonn)
> mlat = 390
> dlat = 49.0 / mlat
> latt = fspan (40.01, (mlat - 1) * dlat, mlat)
> print(latt)
> ;gcdist = gc_latlon(mnlat,mnlon, mxlat,mxlon, 300,2)
> ;print(gcdist)
> ;print (gcdist at gclat+" "+gcdist at gclon )
> ;return
> ;latt=gcdist at gclat
> ;lonn=gcdist at gclon
> ;print(min(latt))
> ;print(max(latt))
> ;print(max(lonn))
> ;print(min(lonn))
> diri="/home/dailysimms/prec-obs/01/"
> z1 = asciiread(diri+"PrecJan1965-2014",-1,"float")
> ;print(z1)
> ;printVarSummary(z1)
> ;a = (/1,2,3,4,5,6,7,8/)
> ;390 rows by 50 columns
> a0 = onedtond(z1,(/390,50/))
> ;print(a0)
> x=dim_avg(a0)
> print(x)
> set_default_fillvalue("string", "")
> zi = natgrid(lon, lat, x, lonn, latt)
> print(zi)
> zi!0="lat"
> zi!1="lon"
> zi&lat=latt
> zi&lon=lonn
> printVarSummary(zi)
> print(zi)
> opt = True
> opt at timing = True
> rscan = (/20,15,10, 5,3 /)
> grid = obj_anal_ic_deprecated(lon, lat, x, lonn, latt, rscan, opt)
> printVarSummary(grid)
> print(grid)
> print(min(grid))
> print(max(grid))
> grid!0="lt"
> grid!1="ln"
> grid<=latt
> grid&ln=lonn
> printVarSummary(grid)
> ;return
> ;------------------------------------------------------------------
> ; plot
> ;------------------------------------------------------------------
> wks = gsn_open_wks("pdf","rdm2grid")
> gsn_define_colormap(wks,"amwg")
> plot = new(2,graphic)
>
> res = True
> res at gsnDraw = False ; don't draw
> res at gsnFrame = False ; don't advance frame
> res at cnFillOn = True ; turn on color
> ;res at cnLinesOn = False ; turn off contour lines
> res at cnLineLabelsOn = False ; turn off contour line labels
> res at gsnSpreadColors = True ; spread out color table
> res at lbLabelBarOn = False ; turn off individual cb's
>
>
> res at gsnCenterString = "Original grid"
> plot(0) = gsn_csm_contour_map_ce(wks,zi,res)
>
> plot(1) = gsn_csm_contour_map_ce(wks,grid,res)
> ;************************************************
> ; create panel
> ;************************************************
> resP = True ; modify the panel plot
> ;resP at txString = title
> resP at gsnMaximize = True ; make large
> resP at gsnPanelLabelBar = True ; add common colorbar
> resP at lbLabelAutoStride = True ; Let NCL decide spacing
> ;resP at lbLabelStride = 2 ; force every other label
> ;resP at lbLabelFontHeightF = 0.0125 ; make labels smaller
> [0.2 default]
>
> gsn_panel(wks,plot,(/2,1/),resP) ; now draw as one plot
>
> end
>
> Warning message:
> (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) 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'
>
>
>
>
>
>
>
> _______________________________________________
> 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/20151218/f26d32c6/attachment.html
More information about the ncl-talk
mailing list