<div dir="ltr"><div>Dear Dennis,</div><div>So many thanks for your help and advice. Yes you're right I need <span style="background-color:rgb(255,229,153)">AOD550_2D = <b>dim_sum_n_Wrap</b>(AOD550_3D,1)</span> to sum over all layers.</div><div>I appreciate the time you consider to modify the script.</div><div>Best wishes, <br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Oct 9, 2022 at 12:10 AM Dennis Shea <<a href="mailto:shea@ucar.edu">shea@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Attached is a modified version of your script. <br></div><div><br></div><div>log(400/600) and integer divide (400/550) should be log(400.0/600.0) and 400.0/550.0</div><div>integer divide 400/600 and 400/550 yield 0s</div><div><br></div><div>NOTE: A division using integer values 400/600 (both integers) does not create a fraction.<br></div><div><br></div><div>I changed these to floats.</div><div>=======================<br></div><div><br></div><div>It is **VERY IMPORTANT** for you to look at the dimensionality of variables.</div><div><br></div><div>printVarSummary(a2) ; [Time | 8] x [bottom_top | 35] x [south_north | 199] x [west_east | 199]<br>=====================</div><div><a href="https://www.ncl.ucar.edu/Document/Functions/Contributed/calculate_daily_values.shtml" target="_blank"><b>calculate_daily_values </b></a>computes daily average; <br></div><div>; you have eight 3-hourly values for one day so the time dimension is dimension size 1</div><div>====================<br></div><div> a2Day = calculate_daily_values (a2, "avg", 0, opt_cdv)<br> printVarSummary(a2Day) ; [Time | 1] x [bottom_top | 35] x [south_north | 199] x [west_east | 199] <br></div><div>======================<br></div><div>I found the variable naming to be a bit confusing,</div><div><br></div><div> AOD550_3D = a2Day * ((400./550.)^angstrom_exponent) ; changed from 400/550<br> ;AOD550_3D@long_name = "AOD550_3D"<br> AOD550_3D@description = "AOD550_3D"<br> copy_VarCoords(a2Day,AOD550_3D )<br> printVarSummary(AOD550_3D) ; [Time | 1] x [bottom_top | 35] x [south_north | 199] x [west_east | 199]<br><br></div><div>The _3D implies (to me) that the variable is 3-dimensional.</div><div>It is 4-dimensional</div><div>===============<br></div><div> AOD550_2D = <b>dim_sum_n_Wrap</b>(AOD550_3D,0)<br> ;AOD550_2D@long_name = "AOD550_2D"<br> AOD550_2D@description = "AOD550_2D"<br> printVarSummary(AOD550_2D) ; [bottom_top | 35] x [south_north | 199] x [west_east | 199]<br> </div><div>AOD550_2D is 3 dimensional not 2-dimension</div><div>================================================================</div><div><br></div><div>When the plot function is used, it expects 2-dimensional data but you were using a 3D array<br></div><div><br></div><div>;;plot = gsn_csm_contour_map(wks,AOD550_2D( ???,:,:),res)</div><div><br></div><div><br></div><div>Maybe, instead of <br></div><div>AOD550_2D = <b>dim_sum_n_Wrap</b>(AOD550_3D,0) ; sum the Time which is dimension 0<br></div><div>you wanted <br></div><div><br></div><div>AOD550_2D = <b>dim_sum_n_Wrap</b>(AOD550_3D,1) ; 1 would mean all the levels</div><div>[Time | 1] x [south_north | 199] x [west_east | 199]</div><div><br></div><div>The plot c all would be</div><div><br></div><div>plot = gsn_csm_contour_map(wks,AOD550_2D( 0,:,:),res) ; Time is dimension number 0 of AOD550_2D</div><div><br></div><div>PLEASE look carefully at the code, the dimensionality and the results</div><div><br></div><div>Good Luck<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Oct 8, 2022 at 7:06 AM Setareh Rahimi <<a href="mailto:setareh.rahimi@gmail.com" target="_blank">setareh.rahimi@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Dear Dennis,</div><div>I executed the script you send. It also worked for me. But may I ask you please to execute the attached script?</div><div>Thanks in advance,</div><div>Best wishes,<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 7, 2022 at 10:57 PM Dennis Shea <<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Yes, I did "execute the entire script" I sent you.<br></div><div><br></div><div>%> /project/cas/shea/WRF> ncl setareh_chem.ncl >! setareh_chem.OUTPUT</div><div>====================================</div><div><br></div><div>My script has no "x"</div><div><br></div><div>I have no idea where or what the variable "x" is.</div><div><br></div><div>Did you execute the script I sent you ?</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 7, 2022 at 1:02 PM Setareh Rahimi <<a href="mailto:setareh.rahimi@gmail.com" target="_blank">setareh.rahimi@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Dear Dennis,</div><div>Did you execute the entire script?</div><div>Cause I still get errors! (attached)<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 7, 2022 at 9:31 PM Dennis Shea <<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div> My script follows.. There were no problems. The output is attached.</div><div><br></div><div><a class="gmail_plusreply" id="m_-6879602176333536311m_8274927179984035236m_-4984583423792556052m_-6691178788702211208m_4884182176720621085m_-3639608746660769309plusReplyChip-1">++++++++++++++++++++++++++++++++++++++++++++++++++++</a></div><div><br></div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"<br><br> f = addfile("<a href="http://setareh_chem.nc" target="_blank">setareh_chem.nc</a>","r")<br> print(f) ; same as "nmcdump -h"<br><br> Times = f->Times ; [Time | 41] x [DateStrLen | 19] (character)<br><br>; For fun: Examine "Times" in different formats <br><br> Time_0 = wrf_times_c( Times, 0 ) ; "hours since" initial time on file (double)<br> ; Time_0 is recognized by cd_calendar<br> ;Time_1 = wrf_times_c( Times, 1 ) ; "hours since 1901-01-01 00:00:00" (double)<br> ;Time_2 = wrf_times_c( Times, 2 ) ; yyyymmddhhmnss (double)<br> Time_3 = wrf_times_c( Times, 3 ) ; yyyymmddhh (integer)<br><br> ;print(Times)<br> ;print(Time_0)<br> ;print(Time_1)<br> ;print(Time_2)<br> print(Time_3) ; easy on the eyes<br> print("------------------------------------")<br><br> a2 = f->TAUAER2 ; (Time, south_north, west_east)<br> a2&Time = Time_0 ; associate the 'Time' coordinate with the variable using standard NCL & syntax<br> printVarSummary(a2)<br> print("------------------------------------")<br><br> opt_cdv = True ; option for calculate_daily_values (cdv)<br> opt_cdv@nval_crit = 4 ; default is 1<br><br> a2Day = calculate_daily_values (a2, "avg", 0, opt_cdv)<br> printVarSummary(a2Day)<br> printMinMax (a2Day,1)<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 7, 2022 at 9:28 AM Setareh Rahimi <<a href="mailto:setareh.rahimi@gmail.com" target="_blank">setareh.rahimi@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Dear Dennis,</div><div>I sent you the file via<span style="background-color:rgb(217,210,233)"> <a href="http://transfer.pcloud.com" target="_blank">transfer.pcloud.com</a></span>. I could not send it here due to the large size of the file. </div><div>Please check the script with the file and let me know your idea.</div><div>Many thanks for your help.</div><div>Best wishes,<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 7, 2022 at 3:18 PM Dennis Shea <<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>I do not understand 'x' either</div><div><br></div><div><span style="background-color:rgb(213,166,189)"><span style="background-color:rgb(255,255,255)">"I wonder about variable x; I did not define such a variable."</span></span></div><div><br></div><div>ncl 0> f = addfile(".....","r") ; I do not have your file<br></div><div>ncl 1> print(f) ; like ncdump -h <br></div><div>ncl 2> Times = f->Times ; Times(Time, DateStrLen) (type character)</div><div>ncl 4> Time = wrf_times_c( Times, 0 ) ; "hours since" initial time on file (double); units recognized by cd_calendar</div><div>ncl 5> print(Time)</div><div><br></div><div>ncl 7> T = f->T <br>ncl 8> printVarSummary(T)</div><div><br></div><div>ncl 9> T&Time = Time ; associate time coordinate<br>ncl 10> printVarSummary(T)<br><br>Variable: T<br>Type: float<br>Total Size: 19683000 bytes<br> 4920750 values<br>Number of Dimensions: 4<br>Dimensions and sizes: [Time | ??] x [bottom_top | 27] x [south_north | 81] x [west_east | 90]<br>Coordinates: <br> Time: [ 0.. ?]<br>Number Of Attributes: 5<br> FieldType : 104<br> MemoryOrder : XYZ<br> description : perturbation potential temperature (theta-t0)<br> units : K<br> stagger : <br>ncl 11> Tavg = calculate_daily_values (T, "avg", 0, True) <br>ncl 12> printVarSummary(Tavg) <br><br>Variable: Tavg<br>Type: float<br>Total Size: 1574640 bytes<br> 393660 values<br>Number of Dimensions: 4<br>Dimensions and sizes: [Time | ...] x [bottom_top | 27] x [south_north | 81] x [west_east | 90]<br>Coordinates: <br> Time: [ 0.. 12]<br>Number Of Attributes: 8<br> _FillValue : 9.96921e+36<br> FieldType : 104<br> MemoryOrder : XYZ<br> description : perturbation potential temperature (theta-t0)<br> units : K<br> stagger : <br> Time : 0<br> NCL_tag : calculate_daily_values</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 7, 2022 at 5:16 AM Setareh Rahimi <<a href="mailto:setareh.rahimi@gmail.com" target="_blank">setareh.rahimi@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Dear Dennis,</div><div>So many thanks for your advice. I made corrections to my script as you suggested, and attempted to calculate and plot the average AOD for 2011-06-28 but I still get errors. I attached the script and the errors. <br></div><div><br></div><div>As you can see from the error message, NCL says :<span style="background-color:rgb(255,229,153)">fatal: No coordinate variable exists for dimension (Time) in variable (x)</span></div><div><span style="background-color:rgb(213,166,189)"><span style="background-color:rgb(255,255,255)">I wonder about variable x; I did not define such a variable.</span><br></span></div><div><br></div><div>Please advise me on how to sort this issue out.</div><div>Many thanks in advance, <br></div><div>Best wishes,<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 7, 2022 at 6:02 AM Dennis Shea <<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>As noted in the documentation, <a href="https://www.ncl.ucar.edu/Document/Functions/Contributed/calculate_daily_values.shtml" target="_blank"><b>calculate_daily_values</b></a> requires that the variable have a **time coordinate** that is recognized by cd_calendar. <br><pre> Times = f->Times ; Times(Time, DateStrLen) (type character)
Time = <b>wrf_times_c</b>( Times, 0 ) ; "hours since" initial time on file (double); units recognized by cd_calendar</pre></div><div> a2 = f->TAUAER ; (Time, south_north, west_east)</div><div> a2&Time = Time ; associate the 'Time' coordinate with the variable using standard NCL & syntax<br></div><div> printVarSummary(a2)</div><div> print("------------------------------------") <br><pre> a2Day = calculate_daily_values (a2, "avg", 0, opt)
printVarSummary(a2Day)
printMinMax (a2Day,1)</pre></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 5, 2022 at 9:30 AM Setareh Rahimi via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Dear NCL users,</div><div><br></div><div>I am trying to plot the daily average of AOD (aerosol optical depth) from WRF-chem outputs. However, I can not define the time so that NCL plots the daily average of AOD.(the script has been attached, and the model output is too large and I just used ncdump to show the header of some varibles ).<br></div><div>I tried the following commands:</div><div> <br></div><div><br></div><div><span style="background-color:rgb(255,229,153)">times = wrf_user_getvar(f,"times",-1)<br>printVarSummary(times)<br>print(times)<br>ymdh = cd_calendar(a2×, -2)<br> print(ymdh)</span></div><div><br></div><div>but faced an error.</div><div>Would you please kindly advise me on how can I calculate the daily average of AOD from the hourly output of WRF-chem?</div><div>Many thanks in advance,</div><div>Best wishes,<br></div><div>-- <br><div dir="ltr">S.Rahimi<br><br></div></div></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr">S.Rahimi<br><br></div>
</blockquote></div>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr">S.Rahimi<br><br></div>
</blockquote></div>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr">S.Rahimi<br><br></div>
</blockquote></div>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr">S.Rahimi<br><br></div>
</blockquote></div>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">S.Rahimi<br><br></div>