[ncl-talk] Plotting output of Mann-Kendall test(trend manken)

Mary Haley haley at ucar.edu
Wed Jun 21 13:41:38 MDT 2017


Lyndz,

You don't need to do anything special to save the output to a NetCDF file:

 opt = True
 opt at return_trend = False
 pq  = trend_manken(prec, opt, 0)
 printVarSummary(pq)

;--- Write "pq" to a new NetCDF file and call it "PQ" on the file
 output_file = "mynewfile.nc"
 system("rm -f " + output_file)
 fout = addfile(outputfile,"c")   ; Open file in "create" mode
 fout->PQ = pq                    ; Write pq to the file

However, if you do an "ncdump -h" on "mynewfile.nc", you will notice that
"PQ" has no metadata. Metadata is not required, but it's good practice to
attach metadata to a variable before writing it to a file.

If you look at example #2 on the trend_manken function page:

http://www.ncl.ucar.edu/Document/Functions/Built-in/trend_manken.shtml

you will see that it names the leftmost dimension of the return value and
copies metadata from the main input argument to the output argument:

     opt = False
     pq  = trend_manken(q, opt, 0)    ; ===> px(2,nlat,mlon)

                                      ; if meta data is desired
     copy_VarCoords(q(0,:,:),pq(0,:,:))
     pq!0= "prob_trend"               ; ===> size 2
     printVarSummary(pq)              ; ===> pq(prob_trend,lat,lon)

This will make "pq" more meaningful when writing it to a NetCDF file.

For more detailed information about writing NetCDF files, see:

http://www.ncl.ucar.edu/Applications/o-netcdf.shtml

--Mary






On Wed, Jun 21, 2017 at 4:11 AM, Lyndon Mark Olaguera <
olagueralyndonmark429 at gmail.com> wrote:

> Hi Sir Will and NCL-experts,
>
> Thank you for the help.
>
> I still have one more question though.
>
> I read the documentation of the trend_manken. To get the probability level
> only, I just have to do this:
>
>      opt = True
>      opt at return_trend = False
>      pq  = trend_manken(prec, opt, 0)
>      printVarSummary(pq)
>
> Variable: pq
> Type: float
> Total Size: 41472 bytes
>             10368 values
> Number of Dimensions: 2
> Dimensions and sizes: [72] x [144]
> Coordinates:
>
>
> But when I tried to print the output (print(pq)) there are three columns
> (array).
>
> How do I save the output so that I can save it as a netcdf file?
>
>
> I'll appreciate any suggestions on how I can do this correctly.
>
>
> *Lyndz*
>
>
> On Wed, Jun 21, 2017 at 6:17 PM, Will Hobbs <will.hobbs at utas.edu.au>
> wrote:
>
>> Lyndz
>>
>>
>>
>> The resources gsnDraw and gsnFrame should both be True (or commented out,
>> since the default is True).
>>
>>
>>
>> You only need to set them to False if you’re going to make adjustments
>> after plotting, for example making a panel plot, adding a polyline or an
>> overlay.
>>
>>
>>
>> If you do set them to False, you must still tell NCL to draw and frame
>> after plotting, so the last lines of your script would be:
>>
>>
>>
>> draw(plot)
>>
>> frame(wks)
>>
>>
>>
>>
>>
>> Will
>>
>>
>>
>> *From: *<ncl-talk-bounces at ucar.edu> on behalf of Lyndon Mark Olaguera <
>> olagueralyndonmark429 at gmail.com>
>> *Date: *Wednesday, 21 June 2017 at 7:08 PM
>> *To: *"ncl-talk at ucar.edu" <ncl-talk at ucar.edu>
>> *Subject: *[ncl-talk] Plotting output of Mann-Kendall test(trend manken)
>>
>>
>>
>> Dear fellow NCL-users,
>>
>>
>>
>> I am trying to perform a mann-kendall trend test on CMAP monthly
>> rainfall. I am using NCL v6.4.
>>
>>
>>
>> Attached is my script. The data can be accessed in the following link:
>>
>>
>>
>> https://drive.google.com/file/d/0B9faET7Bc2o8YTVEc3JXWFRRNk0
>> /view?usp=sharing
>>
>>
>>
>> The script returns *no error* , a netcdf file is created, but *no png
>> file is created*.
>>
>> I also cannot open the output netcdf file even in GrADS (No discernible
>> coordinate issue).
>>
>>
>>
>> I wanted to plot a spatial map of the probability level.
>>
>>
>>
>>
>>
>> I think my problem is this line?
>>
>> plot = *gsn_csm_contour_map(wks,pq(0,:,:),res)*
>>
>>
>>
>> Is this the correct way of just plotting the probability level?
>>
>>
>>
>> I'll appreciate any suggestion on how to do this correctly.
>>
>>
>>
>> Sincerely,
>>
>>
>>
>> Lyndz
>>
>>
>>
>> University of Tasmania Electronic Communications Policy (December, 2014).
>> This email is confidential, and is for the intended recipient only.
>> Access, disclosure, copying, distribution, or reliance on any of it by
>> anyone outside the intended recipient organisation is prohibited and may be
>> a criminal offence. Please delete if obtained in error and email
>> confirmation to the sender. The views expressed in this email are not
>> necessarily the views of the University of Tasmania, unless clearly
>> intended otherwise.
>>
>
>
> _______________________________________________
> 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/20170621/a58c3782/attachment.html 


More information about the ncl-talk mailing list