<div dir="ltr"><div class="gmail_default" style="font-size:small">Dear Moustapha,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Please send all follow-up questions to ncl-talk and not to just the person helping you. We request this so that other people can see the follow-up responses.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Without being able to run your script, I can't debug your code. There's too many variables to keep track of.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">As I explained before, the "ttest" calculation is giving you back a 1D array because of the input you are giving it. </div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">See the attached "climo_1.ncl" script, which I got from our examples website. It uses ttest. I modified it to add a lot of "printVarSummary" statements so you can see what goes into "ttest" and what comes out.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">You can get the "slpNCEP.nc" data file from our <a href="http://ftp.ucar.edu">ftp.ucar.edu</a> anonymous ftp in /pub/scd/haley:</div><div class="gmail_default" style="font-size:small">
<p class="">wget ftp.ucar.edu:/pub/scd/haley/slpNCEP.nc</p></div><div class="gmail_extra"><div class="gmail_default" style="font-size:small">--Mary</div><div class="gmail_default" style="font-size:small"></div><br><div class="gmail_quote">On Tue, Oct 27, 2015 at 1:28 PM, Moustapha Tall <span dir="ltr"><<a href="mailto:tall.moustapha89@gmail.com" target="_blank">tall.moustapha89@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div>Thanks Mary,<br></div>Sorry sending all script.<br></div>That i want to plot is (see in attached file) the dots showing the significativity from a ttest.<br></div>I've done the precipitation change and see the plot result, the problem is to plot the significativity pattern (i mean the "dots").<br></div>For exemple, i compute the change <br></div>1) Precipitation change (No problem here, OK!!!)<br><div><div> ;***************************************************************************<span class=""><br> diff1 = gcmfut1 - gcmpre1<br> diff1 = 100*diff1/mask(gcmpre1,(gcmpre1.ge.0.9),True)<br> diff1@long_name = " RCP4.5 - Present JJAS Precipitation (%)"<br> diff1@units = " "<br> printVarSummary(diff1) ; print a summary of the variable<br> copy_VarCoords(gcm pre1,diff1)<br>;***************************************************************************** <br><br></span></div><div>2) i set the plot of the t-test <br></div><div><div><span class=""> ;*******************************************************************************************************<br>; setting and plotting the t-test significance<br>;*******************************************************************************************************<br>aveX = dim_avg_n_Wrap(gcmpre1,0) ; average over the 0th dim<br>varX = dim_variance_n_Wrap(gcmpre1,0) ; compute variance<br> printVarSummary(aveX)<br> printVarSummary(varX) <br>aveY = dim_avg_n_Wrap(gcmfut1,0) ; average over the 0th dim<br>varY = dim_variance_n_Wrap(gcmfut1,0) ; compute variance<br> printVarSummary(aveY)<br> printVarSummary(varY)<br>sX = dimsizes (aveX)<br>sY = dimsizes (aveY) ; different sizes<br>alphat = 100.*(1. -ttest(aveX,varX,sX, aveY,varY,sY, False, False))<br></span>copy_VarCoords (aveX, alphat)<br><br></div><div>3) <br>I get the following error message after the overlay()<span class=""><br><br> Error: scalar_field: If the input data is 1-dimensional, you must set sfXArray and sfYArray to 1-dimensional arrays of the same length.<br>warning:create: Bad HLU id passed to create, ignoring it<br><br></span></div><div>I hope you understand me now!!!!<br></div><div><br></div><div>Thank you helping me!!!!<br></div><div>cheers<br></div><div><br></div></div></div></div><div class=""><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2015-10-27 19:06 GMT+00:00 Mary Haley <span dir="ltr"><<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.edu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div style="font-size:small">If you want help with a script, it helps if you can provide a *clean* script that demonstrates the problem, rather than a long script where we have no idea what line number the error is occurring on. It's very time-consuming for us to look through scripts like this, especially when we can't execute them.</div><div style="font-size:small"><br></div><div style="font-size:small">My guess is that the problem is with this line:</div><div style="font-size:small"><br></div><div style="font-size:small"><span style="font-size:12.8px">t_test_plot = gsn_csm_contour(wks,alphat,</span><span style="font-size:12.8px">rest_test)</span><br style="font-size:12.8px"></div><div style="font-size:small"><span style="font-size:12.8px"><br></span></div><div style="font-size:small"><span style="font-size:12.8px">If "alphat" is a 1D array, then NCL will see this as "unstructured" data, and in order to draw contours in a rectangular data space, you need to provide X and Y coordinate locations of each point. That's why you are getting an error saying that you need to set sfXArray and sfYArray. For more information on contouring 1D data, see:</span></div><div style="font-size:small"><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><a href="http://www.ncl.ucar.edu/Applications/contour1d.shtml" target="_blank">http://www.ncl.ucar.edu/Applications/contour1d.shtml</a></span><br></div><div style="font-size:small"><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">I'm not sure if you really meant to contour a 1D array, however. You may need to recheck that you are doing your calculations correctly.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">--Mary</span></div><div><span style="font-size:12.8px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Mon, Oct 26, 2015 at 12:22 PM, Moustapha Tall <span dir="ltr"><<a href="mailto:tall.moustapha89@gmail.com" target="_blank">tall.moustapha89@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><div dir="ltr"><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Moustapha Tall</b> <span dir="ltr"><<a href="mailto:tall.moustapha89@gmail.com" target="_blank">tall.moustapha89@gmail.com</a>></span><br>Date: 2015-10-26 16:17 GMT+00:00<br>Subject: problem with plotting "t-test" pattern with precipitation change<br>To: <a href="mailto:ncl-talk-request@ucar.edu" target="_blank">ncl-talk-request@ucar.edu</a><br><br><br><div dir="ltr"><div> Hi NCL webmasters and all,<br></div>I am tryning to plot the mid-century precipitation change for<br><div>a given model, thus plotting the rainfall change patterns with "stippling" where <br>they are statistically significant at the 95 percent confidence level (based on a t-test). <br></div><div>I get this message: <br>(0) Error: scalar_field: If the input data is 1-dimensional, you must set sfXArray and sfYArray to 1-dimensional arrays of the same length.<br>warning:create: Bad HLU id passed to create, ignoring it<br><br></div><div>My script is below,<br><br>;**************************************************************************************<br>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"<br>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"<br>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"<br><br>begin<br> <br>;*****************************************************************************************<br>; Creating Function to Read at once Precip and Convert Calendar to Human Readable YYYYMM<br>;*****************************************************************************************<br><br> undef("getPrecip")<br> function getPrecip(fname[1]:string, vname[1]:string)<br> <br> begin<br> f = addfile(fname, "r")<br> <br> x = f->$vname$(0,:,:) ; read specified time period <br> <br> return(x)<br> end<br>;*****************************************************************************************<br>; Reading Precip for each File for the Defined Period ymStrt - ymLast<br>;***************************************************************************************** <br> <br> gcmpre1 = getPrecip("remap_reg_jjas_mm_mmean_EC-EARTH_1976-2005.nc","pr")<br> <br> gcmfut1 = getPrecip("remap_pr_wafr_jjas_EC-EARTH_rcp45_2021-2050.nc","pr")<br> <br> ;*******************************************************************************<br>;Taking JJAS difference<br>;*******************************************************************************<br> <br> diff1 = gcmfut1 - gcmpre1<br> diff1 = 100*diff1/mask(gcmpre1,(gcmpre1.ge.0.9),True)<br> diff1@long_name = " RCP4.5 - Present JJAS Precipitation (%)"<br> diff1@units = " "<br> printVarSummary(diff1) ; print a summary of the variable<br> copy_VarCoords(gcmpre1,diff1)<br>;************************************************************************************************************<br>; Create graphic array for panel plot and Open a Work Station<br>;************************************************************************************************************<br><br> plots = new(1,graphic) ; Open a variale plots to store 4 Figures<br> wks = gsn_open_wks("ps","Precip_JJAS_Change") ; open a workstation<br> gsn_define_colormap(wks, "CBR_drywet") <br> <br>;*************************************************************************************************************<br>; Create plots options<br>;*************************************************************************************************************<br> <br> res = True ; plot options desired<br> res@gsnSpreadColors = True ; span full colormap<br> res@gsnDraw = False ; don't draw<br> res@gsnFrame = False ; don't advance frame<br> res@cnFillOn = True ; turn on color fill<br><br> res@cnLevelSelectionMode = "ExplicitLevels" ; set explicit contour levels<br> res@cnLevels = (/-75.,-50.,-25.,-10.,-5.,5.,10.,25.,50.,75./)<br> <br> res@cnLinesOn = False ; turn off contour lines<br> res@cnLineLabelsOn = False ; turn off the values that would be on the contours<br> res@mpFillOn = False ; turn off gray continents<br> res@gsnMaximize = True ; Use the full page<br> res@gsnPaperOrientation = "portrait" ; Change orientation <br> res@mpProjection = "Mercator"<br> res@mpLimitMode = "LatLon"<br> res@gsnAddCyclic = False ; Regional data<br>; res@mpMaxLatF = max(latitude) ; Taking the whole domain<br>; res@mpMinLatF = min(latitude)<br>; res@mpMaxLonF = max(longitude)<br>; res@mpMinLonF = min(longitude)<br><br> res@mpMaxLatF = 25.0 ; Zoom in West Africa<br> res@mpMinLatF = -5.0<br> res@mpMaxLonF = 25.0<br> res@mpMinLonF = -25.0<br><br> res@mpOutlineBoundarySets = "National" ; Display the conutries borders<br> res@mpOutlineOn = True ; Turn on the outline of the map<br> res@mpGeophysicalLineThicknessF = 3.0 ; Increase the thickness of map border<br> res@pmTickMarkDisplayMode = "Always" ; Turn on map tickmarks, i.e. writing lons and lats along the axes<br> res@lbLabelBarOn = False ; turn off individual colorbars<br>;*********************************************************************************************************************<br>; Changing the font seize<br>;*********************************************************************************************************************<br> res@tmXBLabelFontHeightF = 0.02 ; resize tick labels for X axis<br> res@tmYLLabelFontHeightF = 0.02 ; resize tick labels for Y axis<br> ; change label spacing to avoid overlap<br> ;res@lbLabelStride = 1 ; and write every other label<br> res@lbLabelFontHeightF = 0.018 ; change the size of the label bar<br> ;res@tiMainString = "1st Plot Test" ; Provide a main Tile<br><br> res@gsnStringFontHeightF = 0.025 ; Increase the title font size (long_name)<br> <br>;*******************************************************************************************************<br>; setting and plotting the t-test significance<br>;*******************************************************************************************************<br>aveX = dim_avg_n_Wrap(gcmpre1,0) ; average over the 0th dim<br>varX = dim_variance_n_Wrap(gcmpre1,0) ; compute variance<br> printVarSummary(aveX)<br> printVarSummary(varX) <br>aveY = dim_avg_n_Wrap(gcmfut1,0) ; average over the 0th dim<br>varY = dim_variance_n_Wrap(gcmfut1,0) ; compute variance<br> printVarSummary(aveY)<br> printVarSummary(varY)<br>sX = dimsizes (aveX)<br>sY = dimsizes (aveY) ; different sizes<br>alphat = 100.*(1. -ttest(aveX,varX,sX, aveY,varY,sY, False, False))<br>;;;;;;;;;;;;;creating ressources for T-TEST;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>rest_test = True ; plot options desired<br>rest_test@gsnSpreadColors = True ; span full colormap<br>rest_test@gsnDraw = False ; don't draw<br>rest_test@gsnFrame = False ; don't advance frame<br>rest_test@cnFillOn = True ; turn on color fill <br>rest_test@lbLabelBarOn = False ; turn off individual colorbars<br>rest_test@cnLinesOn = False ; turn off individual colorbars<br>rest_test@cnLineLabelsOn = False ; turn off individual colorbars<br>rest_test@cnInfoLabelOn = False ; turn off individual colorbars<br>rest_test@cnLevelSpacingF = 0.05 <br>rest_test@cnFillDotSizeF = 0.004<br>t_test_plot = gsn_csm_contour(wks,alphat,rest_test)<br>opt_t_test = True<br>opt_t_test@gsnShadeFillType = "Pattern"<br>opt_t_test@gsnShadeLow = 17<br>plot_t_test_plot = gsn_contour_shade(t_test_plot,0.05,999.,opt_t_test)<br>;*******************************************************************************************************<br>; Displaying the Panel Plot<br>;*******************************************************************************************************<br><br> plots(0) = gsn_csm_contour_map(wks,diff1,res)<br> <br> overlay(plots(0), plot_t_test_plot)<br><br> pnlres = True ; Add panel options<br> pnlres@gsnFrame = False ; Don't frame yet<br> ;pnlres@txString = "Default X and Y positions of all plots" ; add main title for the panel<br> pnlres@gsnPanelLabelBar = True ; Setting a common colorbar<br> pnlres@lbLabelFontHeightF = 0.02 ; Increase font size of the numbers in the label bar<br> pnlres@pmLabelBarWidthF = 0.9 ; label bar width<br> pnlres@pmLabelBarHeightF = 0.08 ; label bar height<br> pnlres@pmLabelBarOrthogonalPosF = 0.002 ; move the labelbar up and down<br> pnlres@pmLabelBarParallelPosF = 0.03 ;move the labelbar left or right<br> pnlres@lbLabelStride = 1 ; and write every other label<br>; pnlres@lbLabelAutoStride = True ; Optimal labels, i.e. avoid overlap<br> pnlres@gsnPanelDebug = True ; To get information from panel<br> pnlres@gsnPanelFigureStrings= (/"a)"/) ; add strings to panel<br> pnlres@gsnPanelFigureStringsFontHeightF = 0.016 ; Increase the size of these strings<br> pnlres@gsnPanelFigureStringsPerimOn = False ; Remove the box around these strings <br> pnlres@amJust = "TopLeft" ; Where to put these strings<br> pnlres@gsnPanelYWhiteSpacePercent = 5 ; Adds the white space to the panel plot<br> pnlres@gsnPanelXWhiteSpacePercent = 5 ; Adds the white space to the panel plot <br> pnlres@gsnPanelTop = 1.<br> pnlres@gsnPanelBottom = 0. <br> gsn_panel(wks,plots,(/1,1/),pnlres)<br><br>end<br>;**************************************************************************************<br></div><div> and <br><br>Variable: diff1<br>Type: float<br>Total Size: 33600 bytes<br> 8400 values<br>Number of Dimensions: 2<br>Dimensions and sizes: [70] x [120]<br>Coordinates: <br>Number Of Attributes: 3<br> units : <br> long_name : RCP4.5 - Present JJAS Precipitation (%)<br> _FillValue : 1e+20<br><br><br>Variable: aveX<br>Type: float<br>Total Size: 480 bytes<br> 120 values<br>Number of Dimensions: 1<br>Dimensions and sizes: [lon | 120]<br>Coordinates: <br> lon: [-29.75..29.75]<br>Number Of Attributes: 12<br> associated_files : baseURL: <a href="http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation" target="_blank">http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation</a> gridspecFile: gridspec_atmos_fx_EC-EARTH_historical_r0i0p0.nc areacella: areacella_fx_EC-EARTH_historical_r0i0p0.nc<br> history : 2012-05-10T11:28:56Z altered by CMOR: replaced missing value flag (1e+28) with standard missing value (1e+20). 2012-05-10T11:28:56Z altered by CMOR: Converted type from 'd' to 'f'. 2012-05-10T11:28:56Z altered by CMOR: Inverted axis: lat.<br> cell_methods : time: mean (interval: 3 hours)<br> original_name : TP=LSP+CP<br> comment : at surface; includes both liquid and solid phases from all types of clouds (both large-scale and convective)<br> missing_value : 1e+20<br> _FillValue : 1e+20<br> units : kg m-2 s-1<br> long_name : Precipitation<br> standard_name : precipitation_flux<br> time : 7699.5<br> average_op_ncl : dim_avg_n over dimension(s): lat<br><br>Variable: varX<br>Type: float<br>Total Size: 480 bytes<br> 120 values<br>Number of Dimensions: 1<br>Dimensions and sizes: [lon | 120]<br>Coordinates: <br> lon: [-29.75..29.75]<br>Number Of Attributes: 12<br> associated_files : baseURL: <a href="http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation" target="_blank">http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation</a> gridspecFile: gridspec_atmos_fx_EC-EARTH_historical_r0i0p0.nc areacella: areacella_fx_EC-EARTH_historical_r0i0p0.nc<br> history : 2012-05-10T11:28:56Z altered by CMOR: replaced missing value flag (1e+28) with standard missing value (1e+20). 2012-05-10T11:28:56Z altered by CMOR: Converted type from 'd' to 'f'. 2012-05-10T11:28:56Z altered by CMOR: Inverted axis: lat.<br> cell_methods : time: mean (interval: 3 hours)<br> original_name : TP=LSP+CP<br> comment : at surface; includes both liquid and solid phases from all types of clouds (both large-scale and convective)<br> missing_value : 1e+20<br> _FillValue : 1e+20<br> units : kg m-2 s-1<br> long_name : Precipitation<br> standard_name : precipitation_flux<br> time : 7699.5<br> variance_op_ncl : dim_variance_n over dimension(s): lat<br><br>Variable: aveY<br>Type: float<br>Total Size: 480 bytes<br> 120 values<br>Number of Dimensions: 1<br>Dimensions and sizes: [lon | 120]<br>Coordinates: <br> lon: [-29.75..29.75]<br>Number Of Attributes: 12<br> associated_files : baseURL: <a href="http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation" target="_blank">http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation</a> gridspecFile: gridspec_atmos_fx_EC-EARTH_rcp45_r0i0p0.nc areacella: areacella_fx_EC-EARTH_rcp45_r0i0p0.nc<br> history : 2012-03-19T15:13:27Z altered by CMOR: replaced missing value flag (1e+28) with standard missing value (1e+20). 2012-03-19T15:13:27Z altered by CMOR: Inverted axis: lat.<br> cell_methods : time: mean (interval: 3 hours)<br> original_name : TP=LSP+CP<br> comment : at surface; includes both liquid and solid phases from all types of clouds (both large-scale and convective)<br> missing_value : 1e+20<br> _FillValue : 1e+20<br> units : kg m-2 s-1<br> long_name : Precipitation<br> standard_name : precipitation_flux<br> time : 10987<br> average_op_ncl : dim_avg_n over dimension(s): lat<br><br>Variable: varY<br>Type: float<br>Total Size: 480 bytes<br> 120 values<br>Number of Dimensions: 1<br>Dimensions and sizes: [lon | 120]<br>Coordinates: <br> lon: [-29.75..29.75]<br>Number Of Attributes: 12<br> associated_files : baseURL: <a href="http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation" target="_blank">http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation</a> gridspecFile: gridspec_atmos_fx_EC-EARTH_rcp45_r0i0p0.nc areacella: areacella_fx_EC-EARTH_rcp45_r0i0p0.nc<br> history : 2012-03-19T15:13:27Z altered by CMOR: replaced missing value flag (1e+28) with standard missing value (1e+20). 2012-03-19T15:13:27Z altered by CMOR: Inverted axis: lat.<br> cell_methods : time: mean (interval: 3 hours)<br> original_name : TP=LSP+CP<br> comment : at surface; includes both liquid and solid phases from all types of clouds (both large-scale and convective)<br> missing_value : 1e+20<br> _FillValue : 1e+20<br> units : kg m-2 s-1<br> long_name : Precipitation<br> standard_name : precipitation_flux<br> time : 10987<br> variance_op_ncl : dim_variance_n over dimension(s): lat<br>(0) Error: scalar_field: If the input data is 1-dimensional, you must set sfXArray and sfYArray to 1-dimensional arrays of the same length.<br>warning:create: Bad HLU id passed to create, ignoring it<br><br></div><div><br></div><div>Can anyone help me for that!<br><br><br></div><div>cheers<span><font color="#888888"><span><font color="#888888"><br></font></span></font></span></div><span><font color="#888888"><span><font color="#888888"><div><br></div><div><br>-- <br><br>
</div></font></span></font></span></div><span><font color="#888888">
</font></span></div><span><font color="#888888"><br><br clear="all"><br>-- <br><div><div dir="ltr"><div><div><div>Tall Moustapha,<br></div>Laboratoire de Physique de l'Atmosphère et de l'Océan Siméon-Fongang (LPAO-SF)<br></div>École Supérieure Polytechnique (ESP) / Université Cheikh Anta DIOP (UCAD) <br></div><div>BP: 5085 Dakar fann ; Fax : <a href="tel:%28%2B221%29%2033%20825%2093%2064" value="+221338259364" target="_blank">(+221) 33 825 93 64</a><br>Tel perso : <a href="tel:%28%2B221%29%2077%20730%2080%2011" value="+221777308011" target="_blank">(+221) 77 730 80 11</a><br>Dakar / Sénégal<br><br></div></div></div>
</font></span></div>
<br></div></div>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br><br clear="all"><br>-- <br><div><div dir="ltr"><div><div><div>Tall Moustapha,<br></div>Laboratoire de Physique de l'Atmosphère et de l'Océan Siméon-Fongang (LPAO-SF)<br></div>École Supérieure Polytechnique (ESP) / Université Cheikh Anta DIOP (UCAD) <br></div><div>BP: 5085 Dakar fann ; Fax : <a href="tel:%28%2B221%29%2033%20825%2093%2064" value="+221338259364" target="_blank">(+221) 33 825 93 64</a><br>Tel perso : <a href="tel:%28%2B221%29%2077%20730%2080%2011" value="+221777308011" target="_blank">(+221) 77 730 80 11</a><br>Dakar / Sénégal<br><br></div></div></div>
</div>
</div></div></blockquote></div><br></div></div>