[ncl-talk] how to Calculate Seasonal average for a variable for different years
Soma Roy
somaroy892 at gmail.com
Fri Sep 13 08:08:44 MDT 2019
Use CDO..(seasmean, seasmon, splityear etc.)
Explore on net..
Thanks,
Soma
On Fri, Sep 13, 2019, 19:17 Adriana via ncl-talk <ncl-talk at ucar.edu> wrote:
> Hi everyone
>
> I have different .nc daily files and I want to calculate the seasonal
> (JJA) for several year and save in one variable that contain all the
> years for this three months. I did one code ncl that works for one year
> but after I don't realize how to continue. I think the problem is
> because I add time dimension after using dim_avg_n and the index doesn't
> change. I will put part of my code to be clear
>
>
> year1=2005
> year2=2007
> nyear=year2-year1
>
> month1=6
> month2=8
> nmonths=month2-month1+1
>
> do i = 1,nyear
> y= i+year1-1
> do j = 1,nmonths
> print(nmonths)
> if (month1+j-1 .ge. 10) then
> mois=10
> else
> mois="0"+(j-1+month1) ; ver aqui
> end if
> printVarSummary(mois)
>
>
> file1 := systemfunc(" ls
>
> /PROJETS/MOUSSON-NEW/MAM7_CMIP6_CAMS/MAM7_test10_MERRA2.cam.h0."+y+"-"+mois+"-*.nc")
>
> print(file1)
> setfileoption("nc","SuppressClose", False)
> f = addfiles(file1,"r")
>
> ListSetType (f, "cat")
>
>
> After I read different variables and for calculate the seasonal average
> I do the next:
>
> ;------------------
> if (j .eq. 1) then ;for JUN
> CO_press_JUN = new ((/60*nyear,nlev,nlat,nlon/),"float",CO_2 at _FillValue)
> CO_press_JUN(60*(i-1):60*(i)-1,:,:,:) = CO_2
> CO_JUN_avg = CO_press_JUN(0:0,:,:,:)
> CO_JUN_avg(0,:,:,:) = (/ dim_avg_n(CO_press_JUN,0)/)
> printMinMax(CO_JUN_avg, True)
> printVarSummary(CO_JUN_avg)
>
>
> if (j .eq. 2) then ; for JUL
> CO_press_JUL = new ((/62*nyear,nlev,nlat,nlon/),"float",CO_2 at _FillValue)
> CO_press_JUL(62*(i-1):62*(i)-1,:,:,:) = CO_2
> CO_JUL_avg = CO_press_JUL(0:0,:,:,:)
> CO_JUL_avg(0,:,:,:) = (/dim_avg_n(CO_press_JUL,0)/)
> printMinMax(CO_JUL_avg, True)
> printVarSummary(CO_JUL_avg)
>
> if (j .eq. 3) then ; For AUG
> CO_press_AUG = new ((/62*nyear,nlev,nlat,nlon/),"float",CO_2 at _FillValue)
> CO_press_AUG(62*(i-1):62*(i)-1,:,:,:) = CO_2
> CO_AUG_avg = CO_press_AUG(0:0,:,:,:)
> CO_AUG_avg(0,:,:,:) = (/dim_avg_n(CO_press_AUG,0)/)
> printMinMax(CO_AUG_avg, True)
> printVarSummary(CO_AUG_avg)
>
> end do ; boucle mois
> ;---------
>
> Now I want to create a variable
> CO_JJA = new((/nyear,nlev,nlat,nlon/),"float")
> which contain the number of year and the values CO_JUN_avg, CO_JUL_avg,
> CO_AUG_avg of each year
> However I didn't arrive to this because I think that the problem is due
> to this CO_AUG_avg = CO_press_AUG(0:0,:,:,:) and the index is always 0.
>
> I'm stuck with this! Can anyone give me any advice or help?
>
> I really appreciate
>
> Thank you in advance
>
> Adriana
> --
> Adriana Bossolasco
> LPC2E UMR 7328 (CNRS, Université d'Orléans)
> 3A avenue de la Recherche Scientifique
> 45071 Orléans Cedex 2 - FRANCE
> Tel +33 (0)2 38 25 52 85
> e-mail: adriana.bossolasco at cnrs-orleans.fr
> _______________________________________________
> 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/20190913/6f821970/attachment.html>
More information about the ncl-talk
mailing list