Hi,
I am trying to create an ocean mask for global precipitation (so that the
map just shows precipitation over land areas, but the longitudes of my
precip plot and my mask don't match up -
Without wanting to create my own mask, via example 5 in
http://www.ncl.ucar.edu/Document/Functions/Shea_util/landsea_mask.shtml, is
there an easy way to do this... I tried
lon = (/lon - 180./) ; subtract 180 from all values
lon&lon = lon ; update coordinates
...but this didn't work - my mask was just drawn on the wrong part of the
map, (i.e. the map of precipitation didn't shift, but the outline of the
continents did shift - and was drawn in the wrong place, so that the same
rainfall patterns are shown in different continents.
I tried lonflip but this just aligned the continent outline (mask) with the
dislocated rainfall map.
Am I going to have to specify everything manually, as in example 5 above?
My script is below.
Thanks
Madeleine
*************
begin
; loading libraries
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"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
setfileoption("nc","SuppressClose",False)
; open 1st spi map;
in1 = addfile("/model1_precip.nc","r")
lat =in1->lat
lon=in1->lon
lon = (/lon - 180./) ; subtract 180 from all values
lon&lon = lon ; update coordinates
precip = in1->precip(:,:)
;precip1 = in1->precip(:,:)
;precip = lonFlip(precip1)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; CREATING A LAND/OCEAN MASK (TO MASK OUT THE OCEAN.....
; 0=ocean, 1=land, 2=lake, 3=small island, 4=ice shelf.
; Values at desired points (e.g. ocean) will be set to _FillValue in the
array data after creating a new land/sea mask from one-dimensional lat/lon
variables:
a = addfile("$NCARG_ROOT/lib/ncarg/data/cdf/landsea.nc","r")
lsdata = a->LSMASK
lsm = landsea_mask(lsdata,precip&lat,precip&lon)
precip = mask(precip,lsm.eq.0,False)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
wks1 =gsn_open_wks("newpdf","precip_mod1")
gsn_define_colormap(wks1,"BrownBlue12")
gsnMaximize = True
res1 = True
res1@cnLinesOn = False
res1@cnFillOn = True ; turn color on
;res1@gsnSpreadColors = True
res1@cnFillColors = (/2,3,4,5,6,7/)
res1@cnLevelSelectionMode = "ManualLevels" ; set manual contour
res1@cnMinLevelValF = 0.0 ; set min contour level
res1@cnMaxLevelValF = 0.10 ; set max contour level
res1@cnLevelSpacingF = 0.02
res1@tiMainString = "Model1 precip"
res1@tiDeltaF = 3.0
res1@lbAutoManage = True
;;;;
plot = gsn_csm_contour_map_ce(wks1,precip,res1)
end
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Oct 26 13:47:55 2012
This archive was generated by hypermail 2.1.8 : Wed Oct 31 2012 - 09:14:12 MDT