<div dir="ltr"><div class="gmail_default" style="font-size:small">Jie,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I noticed that nobody responded to this question, so I thought I'd jump in.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I'm not sure exactly what you want to calculate for the seasonal precipitation, but the month_to_season function is written in NCL, so perhaps you could modify it slightly to do what you need.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">The function is in the NCL script $NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/contributed.<wbr>ncl.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">You can copy this script and call it whatever you want. I'll use <span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><a href="http://month_to_season_pcp.cl" target="_blank">month_to_season_pcp.cl</a> as an example:</span></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><div class="gmail_default"><font face="monospace, monospace"> cp $NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/contributed.ncl month_to_season_pcp.ncl</font></div><div><br></div></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Edit month_to_season_pcp.ncl and remove all the lines before these lines:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace">; ------------------------                                                                                                  </font></div><div class="gmail_default"><font face="monospace, monospace"><br></font></div><div class="gmail_default"><font face="monospace, monospace">; D Shea                                                                                                                    </font></div><div class="gmail_default"><font face="monospace, monospace">; compute a user specified seasonal mean [all are three-month means]                                                        </font></div><div class="gmail_default"><font face="monospace, monospace">; DJF,JFM,FMA,MAM,AMJ,MJJ,JJA,<wbr>JAS,ASO,SON,OND,NDJ</font></div><div class="gmail_default"><br></div><div class="gmail_default">and all the lines after the "end" statement:</div><div class="gmail_default"><br></div><div class="gmail_default"><div class="gmail_default"><font face="monospace, monospace">  xSea@NMO = NMO   ; for possible use in subscripting                                                                       </font></div><div class="gmail_default"><font face="monospace, monospace">                   ; eg: nStrt= xSea@NMO ; time(nStrt:ntim-1,12)                                                            </font></div><div class="gmail_default"><font face="monospace, monospace">  return (xSea)</font></div><div class="gmail_default"><font face="monospace, monospace">  end</font></div><div class="gmail_default"><br></div><div class="gmail_default">This gives you a script that just has one function, month_to_season.  Rename the function to something different, like "month_to_season_pcp", by changing all occurrences of "month_to_season" to "<span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">month_to_season_pcp". For example, it's important to change this on both the "undef" and "function" lines:</span></div><div class="gmail_default"><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><font face="monospace, monospace"><br></font></span></div><div class="gmail_default"><span style="text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><font face="monospace, monospace">undef ("month_to_season_pcp")</font></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><font face="monospace, monospace">function month_to_season_pcp (xMon:numeric, SEASON:string)</font></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><br></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)">To be consistent, I also recommend changing any other references to "month_to_season", for example, inside of error messages:</div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><br></div><div class="gmail_default" style=""><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><font face="monospace, monospace">  NMO     = ind(season.eq.SEASON)  ; index corresponding to season                                                          </font></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><font face="monospace, monospace">  if (ismissing(NMO)) then</font></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><font face="monospace, monospace">      print ("contributed: month_to_season_pcp: bad season: SEASON="+SEASON)</font></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><font face="monospace, monospace">      exit</font></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><font face="monospace, monospace">  end if</font></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><br></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)">Once you are done, the hardest part is making the changes you need to do the calculation you want. You will need to study the function and understand what it's doing. You can see the seasonal averaging taking place on lines that look like this:</div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><br></div><div class="gmail_default" style=""><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><font face="monospace, monospace">      xSea = new ( nyrs, typeof(xMon), getFillValue(xMon))</font></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><font face="monospace, monospace">      do nyr=nyrStrt,nyrLast</font></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><font face="monospace, monospace">         n = nyr*nmos + NMO</font></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><font face="monospace, monospace">         xSea(nyr) = (xMon(n-1) + xMon(n) + xMon(n+1))*con</font></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><font face="monospace, monospace">      end do</font></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><font face="monospace, monospace"><br></font></div>and:<div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><font face="monospace, monospace"><br></font></div><font face="monospace, monospace">     if (NMO.eq.0) then<br>         n = 0<br>         xSea(0,:,:) = (xMon(n,:,:) + xMon(n+1,:,:))*0.5<br>     end if</font><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><font face="monospace, monospace"><br></font></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><br></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)">Most of the code is dealing with the different possible dimensions of the input (see the "rank" variable) and the corner cases of averaging data at the boundary points.</div></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><br></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)">Once you've made the necessary changes, you can save the file and then load it from your own script with:</div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><br></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)">"load ./month_to_season_pcp.ncl"</div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><br></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)">and use "month_to_season_pcp" instead of month_to_season.</div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><br></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)">Hopefully this helps you get started.  Or maybe somebody will be motivated to share some code with you that they've already modified for this purpose. :-)</div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><br></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)">Good luck,</div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><br></div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)">--Mary</div><div class="gmail_default" style="font-size:small;background-color:rgb(255,255,255)"><br></div></div></span></div><div class="gmail_default"><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div class="gmail_default"><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div></div><div class="gmail_default"><br></div><div class="gmail_default"><br></div></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Aug 5, 2018 at 4:57 AM, WUJIE <span dir="ltr"><<a href="mailto:393069045@qq.com" target="_blank">393069045@qq.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Hi Experts,</div><div><br></div><div>The function of "month_to_season" is very helpful in calculating seasonal temperature with monthly data. But it seems that it is only for "average" see <a href="https://www.ncl.ucar.edu/Document/Functions/Contributed/month_to_season.shtml" target="_blank">https://www.ncl.ucar.edu/<wbr>Document/Functions/<wbr>Contributed/month_to_season.<wbr>shtml</a>.</div><div><br></div><div>I want to calculate the seasonal precipitation using monthly precipitation data, is there a similar funtion for it? or Does anyone know some convenient steps/examples for it?</div><div><br></div><div>Thank you!</div><div><br></div><div>Regards</div><div>Jie</div><br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">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/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>