<div dir="ltr"><div>I believe we have been through some of this before:<br><br>-------------------------------------------------------<br>On 1 April 2017<br><br>There was an email about<br>"[ncl-talk] Plotting Multiple time series of same variable from 9 different files (2005-2013)"<br><br>Several people replied including me. In fact, I attached two scripts:<br> (1) read the txt (ascii) files and plotted the desired time series<br> (2) created a single netCDF file from one test (ascii) file<br><br>Requested by me:<br> "Please: Carefully go through the tutorial at:<br> <a href="http://www.ncl.ucar.edu/Document/Manuals/NCL_User_Guide/">http://www.ncl.ucar.edu/Document/Manuals/NCL_User_Guide/</a><br> You must put some effort into learning a computer language."<br><br>====<br>Your latest script:<br><br>[A]<br> files = systemfunc("ls " + wkdir +"AOT_550*.txt")<br> You are getting *txt* [text, ascii] files.<br><br>[B]<br> You use 'addfiles' and 'addfiles_GetVar'. **Neither reads text (ascii) files.**<br><br> <a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/addfiles.shtml">https://www.ncl.ucar.edu/Document/Functions/Built-in/addfiles.shtml</a><br><br> Further, addfiles_GetVar is "deprected" and the documentation says to use 'addfiles'<br> PLEASE read the documentation for the functions you are using.<br><br>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br><br>I have attached a script that will convert each .txt file to a netCDF file.<br>It also creates 3 different 'time' variables to facilitate usage: time, yyyyddd, yyyymmdd<br><br> %> ncl AOT_txt2nc.ncl<br><br>PLEASE examine the netCDF files produced by the above script via<br><br> %> ncl_filedump -v time,yyyyddd,yyyymmdd AOT_550_2005.nc<br>or<br> %> ncdump -v time,yyyyddd,yyyymmdd AOT_550_2005.nc<br><br>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br><br>The attached 'najiby_monthly.ncl' (requires NCL 6.4.0) script computes the monthly means.<br><br></div>NOTE: The most important rule of data processing is: LOOK AT YOUR DATA!<br><div><br>Some of the months have only one day (value). Computing a monthly mean based uoon one value is<br>not appropriate. In fact, not one year has complete daily values.<br><br> yyyy days<br> 2005 - 266<br> 2006 - 270<br> 2007 - 300<br> 2008 - 216<br> 2009 - 178<br> 2010 - 9<br> 2011 - 89<br> 2012 - 249<br> 2023 - 124<br> 2014 - 156<br><br>The driver script [ najiby_monthly.ncl ] that calculates the monthly means requires 10 values before a monthly mean is calculated.<br><br> <a href="https://www.ncl.ucar.edu/Document/Functions/Contributed/calculate_monthly_values.shtml">https://www.ncl.ucar.edu/Document/Functions/Contributed/calculate_monthly_values.shtml</a><br> You will need NCL 6.4.0<br><br>If you do not have NCL-6.4.0, I have attached the function: calculate_monthly_values.640.ncl<br>You will have to explicitily (manually) load it. [you must unzip the file: gzip -d ...]<br><br>===<br></div><div>Actually, I have decided to alos attache the ASCII (.txt) and netCDF (.nc) files containg the monthly mean data.<br></div><div><br>Again, **please read the documentation for the functions you are using.**<br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jun 17, 2017 at 4:22 AM, <span dir="ltr"><<a href="mailto:najib.yusuf@carnasrda.com" target="_blank">najib.yusuf@carnasrda.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Hi Rick,<br>
<br>
Thank you for your response. The asciiread part of the program works<br>
well, there is no error in there, that is why<br>
I didn't bother you with it, I only cut part that has the problem from<br>
the printed output as well as from the program due to length of the<br>
files. I will correct the addfiles command with ".txt" files and revert.<br>
<br>
Thank you.<br>
<br>
Najib<br>
<div><div class="h5"><br>
<br>
<br>
<br>
<br>
<br>
<br>
On 2017-06-16 13:48, Rick Brownrigg wrote:<br>
> Hi,<br>
><br>
> There must be more going on to this script than is shown. The printed<br>
> output does not align with print statements in the script, and I don't<br>
> believe an addfiles command works with ".txt" files. The error message<br>
> is coming from asciiread(), which does not appear anywhere in the<br>
> script you've shown. In any case, the error message is telling you<br>
> that there is no variable names AOT_550 in the files. Are there other<br>
> error messages from the script?<br>
><br>
> Rick<br>
><br>
> On Fri, Jun 16, 2017 at 8:41 AM, <<a href="mailto:najib.yusuf@carnasrda.com">najib.yusuf@carnasrda.com</a>> wrote:<br>
><br>
>> -------- Original Message --------<br>
>> Subject: Deriving monthly mean from files of ten years data<br>
>> Date: 2017-06-16 10:00<br>
>> From: <a href="mailto:najib.yusuf@carnasrda.com">najib.yusuf@carnasrda.com</a><br>
>> To: <a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
>> Cc: <a href="mailto:shea@ucar.edu">shea@ucar.edu</a><br>
>><br>
>> Dear ncl experts,<br>
>><br>
>> I am trying to derived monthly mean (for example all January,<br>
>> all<br>
>> February....all December) mean from 10 files (0-9) years of Julian<br>
>> date,<br>
>> so I can plot the mean on the bulk of the data. I tried but I got an<br>
>> error;<br>
>><br>
>> ; to derive the mean of the data<br>
>><br>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<wbr>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<wbr>;;;;;;;;;;;;;;;;;<br>
>> wkdir = "./"<br>
>> fil_dat = "AOT_550"<br>
>> ; list all AOT files for different years<br>
>> files = systemfunc("ls " + wkdir +"AOT_550*.txt")<br>
>> print(files)<br>
>><br>
>> ; read years (files)<br>
>> files10 = files(0:9)<br>
>> print(files10)<br>
>> f = addfiles(files10, "r")<br>
>> AOT = addfiles_GetVar(f,files10,"<wbr>AOT_550")<br>
>> time = addfiles_GetVar(f,files10,"<wbr>time")<br>
>><br>
>> ; get date<br>
>> t1=calendar_decode2(time,0)<br>
>> ; get day of year<br>
>> printVarSummary(t1)<br>
>> ndays = 365<br>
>> doy = ndays<br>
>> doy(9) = 365<br>
>> print(doy)<br>
>><br>
>> ; read only monthly mean (not sure?)<br>
>> AOT_550_all12 = AOT_550_all12(0:11)<br>
>> print(AOT_550_all12)<br>
>><br>
>> f = addfiles(files12, "r")<br>
>> AOT = addfiles_GetVar(f,AOT_550_<wbr>all12,"AOT_550_all")<br>
>> time = addfiles_GetVar(f,AOT_550_<wbr>all12,"time")<br>
>> ; get date<br>
>> t1=calendar_decode2(time,0)<br>
>> ; get day of year<br>
>> printVarSummary(t1)<br>
>><br>
> doy=day_of_year(floattoint(t1(<wbr>:,0)),floattoint(t1(:,1)),<wbr>floattoint(t1(:,2)))<br>
>> ; move to mid-months<br>
>> doy=doy-15<br>
>> doy(11:9) = 365 ;<br>
>> print(doy)<br>
>> AOT_550_all12 = AOT<br>
>><br>
>> printVarSummary(AOT)<br>
>><br>
>> Variable: variables<br>
>> Type: string<br>
>> Total Size: 56 bytes<br>
>> 7 values<br>
>> Number of Dimensions: 1<br>
>> Dimensions and sizes: [7]<br>
>> Coordinates:<br>
>> Number Of Attributes: 1<br>
>> _FillValue : missing<br>
>> (0) Day<br>
>> (1) AOT_675<br>
>> (2) AOT_500<br>
>> (3) AOT_440<br>
>> (4) 440-675Angstrom<br>
>> (5) ╬▒<br>
>> (6) AOT_550<br>
>><br>
>> Variable: files (subsection)<br>
>> Type: string<br>
>> Total Size: 8 bytes<br>
>> 1 values<br>
>> Number of Dimensions: 1<br>
>> Dimensions and sizes: [1]<br>
>> Coordinates:<br>
>> (0) /home/model-user/AOT_550_2014.<wbr>txt<br>
>> warning:asciiread: End of file reached and only (157) elements were<br>
>> read<br>
>> from the file, filling remaining elements with the default missing<br>
>> value<br>
>> for the requested type<br>
>><br>
>> Variable: z1<br>
>> Type: string<br>
>> Total Size: 2928 bytes<br>
>> 366 values<br>
>> Number of Dimensions: 1<br>
>> Dimensions and sizes: [366]<br>
>> Coordinates:<br>
>> Number Of Attributes: 1<br>
>> _FillValue : missing<br>
>><br>
>> Variable: new_str<br>
>> Type: string<br>
>> Total Size: 20496 bytes<br>
>> 2562 values<br>
>> Number of Dimensions: 2<br>
>> Dimensions and sizes: [366] x [7]<br>
>> Coordinates:<br>
>> Number Of Attributes: 1<br>
>> _FillValue : missing<br>
>><br>
>> Variable: variables<br>
>> Type: string<br>
>> Total Size: 56 bytes<br>
>> 7 values<br>
>> Number of Dimensions: 1<br>
>> Dimensions and sizes: [7]<br>
>> Coordinates:<br>
>> Number Of Attributes: 1<br>
>> _FillValue : missing<br>
>> (0) Day<br>
>> (1) AOT_675<br>
>> (2) AOT_500<br>
>> (3) AOT_440<br>
>> (4) 440-675Angstrom<br>
>> (5) ╬▒<br>
>> (6) AOT_550<br>
>><br>
>> Variable: AOT_550_all<br>
>> Type: float<br>
>> Total Size: 14600 bytes<br>
>> 3650 values<br>
>> Number of Dimensions: 2<br>
>> Dimensions and sizes: [years | 10] x [days | 365]<br>
>> Coordinates:<br>
>> Number Of Attributes: 1<br>
>> _FillValue : 9.96921e+36<br>
>><br>
>> Variable: files<br>
>> Type: string<br>
>> Total Size: 80 bytes<br>
>> 10 values<br>
>> Number of Dimensions: 1<br>
>> Dimensions and sizes: [10]<br>
>> Coordinates:<br>
>> (0) /home/model-user/AOT_550_2005.<wbr>txt<br>
>> (1) /home/model-user/AOT_550_2006.<wbr>txt<br>
>> (2) /home/model-user/AOT_550_2007.<wbr>txt<br>
>> (3) /home/model-user/AOT_550_2008.<wbr>txt<br>
>> (4) /home/model-user/AOT_550_2009.<wbr>txt<br>
>> (5) /home/model-user/AOT_550_2010.<wbr>txt<br>
>> (6) /home/model-user/AOT_550_2011.<wbr>txt<br>
>> (7) /home/model-user/AOT_550_2012.<wbr>txt<br>
>> (8) /home/model-user/AOT_550_2013.<wbr>txt<br>
>> (9) /home/model-user/AOT_550_2014.<wbr>txt<br>
>><br>
>> Variable: files10<br>
>> Type: string<br>
>> Total Size: 80 bytes<br>
>> 10 values<br>
>> Number of Dimensions: 1<br>
>> Dimensions and sizes: [10]<br>
>> Coordinates:<br>
>> (0) /home/model-user/AOT_550_2005.<wbr>txt<br>
>> (1) /home/model-user/AOT_550_2006.<wbr>txt<br>
>> (2) /home/model-user/AOT_550_2007.<wbr>txt<br>
>> (3) /home/model-user/AOT_550_2008.<wbr>txt<br>
>> (4) /home/model-user/AOT_550_2009.<wbr>txt<br>
>> (5) /home/model-user/AOT_550_2010.<wbr>txt<br>
>> (6) /home/model-user/AOT_550_2011.<wbr>txt<br>
>> (7) /home/model-user/AOT_550_2012.<wbr>txt<br>
>> (8) /home/model-user/AOT_550_2013.<wbr>txt<br>
>> (9) /home/model-user/AOT_550_2014.<wbr>txt<br>
>> fatal:No valid instance of variable AOT_550 found in file list<br>
>> fatal:["Execute.c":8575]:<wbr>Execute: Error occurred at or near line<br>
>> 6095 in<br>
>> file<br>
>><br>
> /home/model-user/NCL/ncl-6.3.<wbr>0/lib/ncarg/nclscripts/csm/<wbr>contributed.ncl<br>
>><br>
>> Please assist to put me through.<br>
>><br>
>> Thank you for your time.<br>
>><br>
>> Najib<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>
</div></div>>> <a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a> [1]<br>
><br>
><br>
><br>
> Links:<br>
> ------<br>
> [1] <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>
<div class="HOEnZb"><div class="h5">______________________________<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>
</div></div></blockquote></div><br></div>