Re: masked area shift

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Feb 14 2011 - 09:13:50 MST

Ioana,

For purposes of plotting, you don't need to worry about setting the "time" coordinate array. Try it with just setting the lat/lon coordinate arrays.

--Mary

On Feb 14, 2011, at 9:10 AM, Ioana Colfescu wrote:

> Thank you very much.
> I m making all the changes however I there is something I don't know - how can I extract the time compoent from the binary file ?
> It doesn't work as I do for the nc file with time= file->time. Is there a way to extract the time or should I create a vector with time moments ?
>
> Thanks
>
> Ioana
>
> ----- Original Message -----
> From: "Mary Haley" <haley@ucar.edu>
> To: "Ioana Colfescu" <colfescu@cola.iges.org>
> Cc: ncl-talk@ucar.edu
> Sent: Monday, February 14, 2011 10:53:19 AM
> Subject: Re: masked area shift
>
> Ioana,
>
> It looks like you are not providing any lat/lon information for the variable that you're trying to plot. This means that NCL doesn't know where to overlay your data on the map. I believe this is because "eof" is being calculated, but I don't see any lat/lon information being attached to it after the fact.
>
> What does "printVarSummary(eof)" report after you calculate it?
>
> Second, you are plotting "10*eof", so even if "eof" did have lat/lon coordinate arrays, they would disappear when you do "10*eof". NCL doesn't retain coordinate arrays or attributes when you do calculations like this on a variable.
>
> I think you need to do the following:
>
> 1. Attach lat/lon coordinate information to "ocean_only3"'.
>
> ocean_only3!0="time"
> ocean_only3!1="lat"
> ocean_only3!2="lon"
>
> ocean_only3&time = ..... ; You may need to get this off the file
> ocean_only3&lat = lat ; This is the variable you read off the file, I'm hoping this is the correct one.
> ocean_only3&lon = lon
>
> 2. Call "eofunc_Wrap" instead of "eofunc".
>
> eof = eofunc_Wrap(ocean_only3,5,False) ; This should retain metadata from ocean_only3
> printVarSummary(eof)
>
> 3. Don't pass "10*eof" to the plotting function. Do this outside the function:
>
> eof = 10*eof ; Metadata is retained because calculation is being put back into same variable.
> plot(0) = gsn_csm_contour_map_ce(wks,eof(0,:,:),res)
>
> --Mary
>
> On Feb 12, 2011, at 8:58 PM, Ioana Colfescu wrote:
>
>> Hi,
>>
>> I calculate EOFs for SST, the domain 62N - 62S and 0-360 longitude.
>> I used atmosphere temperature data but masked the land and used only the sst.
>> When I plot the EOFs the plots seem fine but the contours of the masked area doesn't overlap with the continents that I masked - the area of the EOFs where is masked ( white ) is much bigger than the actual continents. There is no shift rather a difference in scale.
>> I set up the plots only for 62S to 62N but still doesn't look correct.
>> Could anyone tell me please what should I do to fix this ?
>> The code is below :
>>
>>
>> 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"
>> ;****************************************************
>> ; the script calculates sst EOFs for data from CCSM3 b30.030b control run,
>> ; 1870-1999, for domain 62N-62S, 0-360 E/W
>> ;************************************************
>> begin
>> ;************************************************
>> path = ("/data/oldfarm2/colfi/cam3.1.p2/CCSM/IE85_test1/temp/ts_anom.dat")
>> nlat = 46
>> nlon = 128
>> nrec=1560
>> ts = new((/nrec,nlat,nlon/),float)
>> do ir=1,1559
>> rec=ir
>> ts(ir,:,:)=fbindirread(path,rec,(/nlat,nlon/),"float")
>> end do
>>
>> ins=addfile("/data/oldfarm2/colfi/cam3.1.p2/CCSM/IEt42_test1/scripts/IEt85_test1.cam.1870-01.nc","r")
>> oro = ins->LANDFRAC(0,10:55,:)
>> ; ice = ins->ICEFRAC(0,:,:)
>> lat=ins->lat(10:55)
>> lon=ins->lon
>> ;************************************************
>> ; use mask function to mask out land
>> ; ocean=0
>> ;************************************************
>> ocean_only = ts
>> ocean_only =mask(ts,oro,0) ; Return the values of ts where oro=0.1
>> ocean_only=lonFlip(ocean_only)
>>
>> ;***** make time the rightmost dimension to apply eof function
>> ocean_only!0="time"
>> ocean_only!1="latn"
>> ocean_only!2="lonn"
>> ocean_only2=ocean_only(latn|:,lonn|:,time|:)
>>
>>
>> ;******** weight the variables
>> wgt = sqrt(cos(lat*0.01745329))
>> ocean_only3 = ocean_only2*conform(ocean_only2, wgt, 0)
>>
>> ;********* calculate eofs**************************
>> eof = eofunc(ocean_only3,5,False)
>> cbinwrite("eof_tsanom",eof)
>>
>> ;************************************************
>> ; common resources
>> ;************************************************
>> wks = gsn_open_wks("ps","eof.ts.b30CCSM") ; open a ps file
>> plot = new(3,graphic)
>> gsn_define_colormap(wks,"BlAqGrYeOrRe") ; choose colormap
>>
>> res = True ; plot mods desired
>> res@gsnDraw = False ; don't draw
>> res@gsnFrame = False ; don't advance frame
>> res@cnInfoLabelOn = False ; turn off cn info label
>> res@cnFillOn = True ; turn on color fill
>> res@cnLinesOn = False ; turn of contour lines
>> res@gsnSpreadColors = True ; use full colormap
>> res@mpLimitMode = "LatLon" ; use lat/lon coordinates to limit area
>> res@mpMinLatF = -60.
>> res@mpMaxLatF = 60.
>> ; res@gsnCenterStringFontHeightF = 0.03 ; set the center string font height
>>
>> ;************************************************
>> ; individual plots
>> ;************************************************
>> res@tiMainString = "EOF 1, 1870-1999 TS anomalies, b30.030b CCSM Control "
>> plot(0) = gsn_csm_contour_map_ce(wks,10*eof(0,:,:),res)
>> res@tiMainString = "EOF 2, 1870-1999 TS anomalies, b30.030b CCSM Control "
>> plot(1) = gsn_csm_contour_map_ce(wks,10*eof(1,:,:),res)
>> res@tiMainString = "EOF 3, 1870-1999 TS anomalies, b30.030b CCSM Control "
>> plot(2) = gsn_csm_contour_map_ce(wks,10*eof(2,:,:),res)
>>
>> ;************************************************
>> ; create panel
>> ;************************************************
>> resP = True ; modify the panel plot
>> resP@txString = "EOF 1,2,3 for CCSM b30.030b control run TS anomalies "
>> gsn_panel(wks,plot,(/3,1/),False) ; now draw as one plot
>> end
>>
>>
>> Thanks,
>>
>> Ioana
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Feb 14 09:13:56 2011

This archive was generated by hypermail 2.1.8 : Tue Feb 15 2011 - 09:43:19 MST