Try the attached script.
This is setup for a 1x1 offset grid. This is the "slow but clear"
version. It could be made faster via some array manipulations.
Variable: grid
Type: float
Total Size: 259200 bytes
64800 values
Number of Dimensions: 2
Dimensions and sizes: [lat | 180] x [lon | 360]
Coordinates:
lat: [-89.5..89.5]
lon: [-179.5..179.5]
Number Of Attributes: 3
units : ???
long_name : whatever
_FillValue : 1e+30
(0)
(0) whatever: min=1.46223 max=3.10375
Roberta Perkins wrote:
> Hello,
>
> I have a text file containing 3 columns of data: Longitude, Latitude and the
> their corresponding value.
> There are missing coordinate values but they are no included in the list. I want
> to be able to plot the data showing the gaps. If I do contour_map then
> everything gets filled in. It seems that the only way I can get around this is
> to manually put in the coordinates that have a missing value and assign a
> _FillValue attribute.
>
> Is there another way in NCL that I can plot the data on a map without having to
> include the missing values and just plot the coordinates that are listed?
>
> sample of my text file:
>
> -179.50 -83.50 2.06218422311191e+18
>
> -179.50 -82.50 2.20194218404584e+18
>
> -179.50 -81.50 2.13624203495919e+18
>
> -179.50 -80.50 1.92270691252096e+18
>
> -179.50 -79.50 1.97066905283356e+18
>
> -179.50 -77.50 1.87546962524897e+18
>
> -179.50 -76.50 1.73247078507269e+18
>
> -179.50 -75.50 1.69635004139386e+18
>
> -179.50 -74.50 3.10375392456632e+18
>
> -179.50 -71.50 1.83906513885069e+18
>
> -179.50 -70.50 1.94054532045052e+18
>
> -179.50 -69.50 1.86284145932606e+18
>
> -179.50 -68.50 1.89290891045765e+18
>
> -179.50 -67.50 1.65054741063768e+18
>
> -179.50 -52.50 1.84016698694068e+18
>
> -179.50 -51.50 1.86419956234479e+18
>
> -179.50 -50.50 1.79983511372746e+18
>
> -179.50 -49.50 1.84267036875869e+18
>
> -179.50 -48.50 1.7015316273787e+18
>
> -179.50 -47.50 1.64754931730665e+18
>
> -179.50 -46.50 1.46223171768628e+18
>
> -179.50 -39.50 1.7475926433674e+18
>
> -179.50 -38.50 1.70060666322184e+18
>
> Thank you,
> Roberta Perkins
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-- ====================================================== Dennis J. Shea tel: 303-497-1361 | P.O. Box 3000 fax: 303-497-1333 | Climate Analysis Section | Climate & Global Dynamics Div. | National Center for Atmospheric Research | Boulder, CO 80307 | USA email: shea 'at' ucar.edu | ======================================================
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
begin
ftxt = "data.txt"
npts = numAsciiRow(ftxt) ; number of rows
print(npts)
data = asciiread(ftxt, (/npts,3/), "float")
LON = data(:,0) ; for clarity
LAT = data(:,1)
VAL = data(:,2)
nlat = 180 ; target grid
lat = latGlobeFo(nlat, "lat", "latitude", "degrees_north")
mlon = 360
lon = lonGlobeFo(mlon, "lon", "longitude", "degrees_east")
lon = (/ lon - 180. /) ; subtract 180 from all values
lon&lon = lon ; update coordinates
;;print(lat)
;;print(lon)
grid = new ( (/nlat,mlon/), typeof(VAL), 1e30 )
grid!0 = "lat"
grid!1 = "lon"
grid&lat = lat
grid&lon = lon
grid_at_long_name = "whatever"
grid_at_units = "???"
; slow but clear
do n=0,npts-1
ml = ind(lon.eq.LON(n))
nl = ind(lat.eq.LAT(n))
print(n+" ml="+ml+" nl="+nl+" VAL="+VAL(n))
grid(nl,ml) = (/ VAL(n) /)
end do
scale = 1e18
grid = grid/scale
printVarSummary(grid)
printMinMax(grid, True)
wks = gsn_open_wks("x11","perkins")
gsn_define_colormap(wks,"BlAqGrYeOrRe") ; choose colormap
res = True ; plot mods desired
res_at_cnFillOn = True ; turn on color fill
res_at_cnFillMode = "RasterFill" ; Raster Mode
res_at_cnLinesOn = False ; turn of contour lines
;res_at_cnLevelSpacingF = 0.5 ; contour spacing
res_at_gsnSpreadColors = True ; use full range of color map
res_at_lbLabelAutoStride = True
plot = gsn_csm_contour_map_ce(wks,grid, res)
end
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Apr 25 2008 - 14:08:21 MDT
This archive was generated by hypermail 2.2.0 : Mon May 19 2008 - 08:42:48 MDT