[ncl-talk] need help to understand how to change the scales in a spectrum plot

Ruksana Abedin ruksana.abedin at gmail.com
Mon Dec 5 12:09:03 MST 2016


Hi,

I could figure the required process out. This time followed the example 4
at http://www.ncl.ucar.edu/Applications/Scripts/spec_4.ncl. However, I
would still like to know how can I plot three spectrums of three colours in
one single plot. Your help is always useful.

Thank you for putting up wonderful resources.

Best regards,
Ruksana

On Mon, Dec 5, 2016 at 5:30 PM, Ruksana Abedin <ruksana.abedin at gmail.com>
wrote:

> Hi,
>
>
>
> I have followed the http://www.ncl.ucar.edu/Applications/Scripts/spec_1.
> ncl script to plot a spectrum for my data but the specs are very
> difficult to visualize clearly in the plot. Data is daily precipitation
> from model and two observations for 1988-2007.
>
>
> 1. How to change the x and y axis scales to make it more visible.
>
> 2. Can I have the cycles per day instead of months? How to change this
> aspect?
>
> 3. Can I plot three spectrums for three different files in a panel
> together?
>
>
> The variable summary, script and the resultant plot are attached. Your
> time and efforts to help me out is highly appreciated.
>
>
>
> Variable: PPT_mod
> Type: float
> Total Size: 25056000 bytes
>             6264000 values
> Number of Dimensions: 3
> Dimensions and sizes:   [time | 7200] x [lat | 30] x [lon | 29]
> Coordinates:
>             time: [52950.5..60149.5]
>             lat: [15.25..29.75]
>             lon: [  83..  97]
> Number Of Attributes: 10
>   z1 :   0
>   standard_name :       precipitation_flux
>   long_name :   TOTAL PRECIPITATION RATE KG/M2/S
>   units :       kg m-2 s-1
>   _FillValue :  1e+20
>   missing_value :       1e+20
>   stash_item :  216
>   stash_section :       5
>   field_code :  90
>   cell_method : time: mean
>
> Variable: PPT_obs1
> Type: float
> Total Size: 25056000 bytes
>             6264000 values
> Number of Dimensions: 3
> Dimensions and sizes:   [time | 7200] x [lat | 30] x [lon | 29]
> Coordinates:
>             time: [19880101.5..20071230.5]
>             lat: [15.25..29.75]
>             lon: [  83..  97]
> Number Of Attributes: 5
>   long_name :   daily precipitation analysis interpolated onto 0.5deg
> grids [mm/day]
>   units :       mm/day
>   _FillValue :  -99.9
>   missing_value :       -99.9
>   level_description :   Earth surface
>
> Variable: PPT_obs2
> Type: float
> Total Size: 25056000 bytes
>             6264000 values
> Number of Dimensions: 3
> Dimensions and sizes:   [time | 7200] x [lat | 30] x [lon | 29]
> Coordinates:
>             time: [19880101.5..20071230.5]
>             lat: [15.25..29.75]
>             lon: [  83..  97]
> Number Of Attributes: 5
>   long_name :   full data daily product version 1 precipitation per grid
>   units :       mm/day
>   code :        20
>   _FillValue :  -99999.99
>   missing_value :       -99999.99
>
>
>
> ;************************************************
> begin
> ;*****************************************************
> ;read in data
> ;*****************************************************
> f0 = addfile ("/../1WAH_daily_precip_b387clim_Bangladesh_100_1988_
> 2007_land_only.nc", "r");
> f1 = addfile("/../APHRO_1988_2007_correct_daily_precip.nc", "r")
> f2 = addfile("/../GPCC_1988_2007_correct_daily_precip.nc","r")
>
> ;*****************************************************
> ; parameters
> ;*****************************************************
>
> PPT_mod = f0->precip(:,0,:,:)
> PPT_mod = PPT_mod*60*60*24
> PPT_obs1 = f1->precip
> PPT_obs2 = f2->precip
>
> fldmean0 = wgt_areaave_Wrap(PPT_mod,1.0,1.0,1)
> fldmean1 = wgt_areaave_Wrap(PPT_obs1,1.0,1.0,1)
> fldmean2= wgt_areaave_Wrap(PPT_obs2,1.0,1.0,1)
>
> ;printVarSummary(time)
>
> printVarSummary(PPT_mod)
> printVarSummary(PPT_obs1)
> printVarSummary(PPT_obs2)
>
> ;************************************************
> ; set function arguments
> ;************************************************
> ; detrending opt: 0=>remove mean 1=>remove mean and detrend
>   d = 0
> ; smoothing periodogram: (0 <= sm <= ??.) should be at least 3 and odd
>   sm = 7
> ; percent tapered: (0.0 <= pct <= 1.0) 0.10 common.
>   pct = 0.10
> ;************************************************
> ; calculate spectrum
> ;************************************************
>   spec = specx_anal(fldmean2,d,sm,pct)
> ;************************************************
> ; plotting
> ;************************************************
>    wks  = gsn_open_wks("eps","spec")                ; Opens a eps file
>
>    res = True                       ; no plot mods desired
>    res at tiMainString = "Precipitation"                   ; title
>    res at tiXAxisString = "Frequency (cycles/month)"  ; xaxis
>    res at tiYAxisString = "Variance"                  ; yaxis
>
>    plot=gsn_csm_xy(wks,spec at frq,spec at spcx,res)     ; create plot
> ;***********************************************
> end
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20161205/949c8994/attachment.html 


More information about the ncl-talk mailing list