[ncl-talk] Computing monthly-mean using daily (Julian days) ascii files data

Dennis Shea shea at ucar.edu
Fri Jun 23 11:33:21 MDT 2017


Previously I sent some scripts and data files that I thought you could use
as a basis for further work. You chose an alternative approach. I scanned
the script you sent. In my opinion, it would take too much of my time to
determine all the necessary changes to make it work.

----
So, again .....

[1]

As I noted previously, *none* of the source daily data files contain every
day of the year. In fact, one year (2010) has only 9 daily values for the
*entire year*. How do you expect to compute monthly means using only 9
values?  Even if all 9 values were for the same month, a monthly mean based
on 9 out of 28/30/31 possible numbers may  *not* be appropriate.

      yyyy   days
      2005 - 266
      2006 - 270
      2007 - 300
      2008 - 216
      2009 - 178
      2010 -   9
      2011 -  89
      2012 - 249
      2023 - 124
      2014 - 156

[2]

The script 'AOT_txt2nc.ncl' reads the original yearly ascii (.txt) files
containing daily values and creates corresponding  netCDF files. Please run
this script so you can see the resulting netCDF files.

%> ncl AOT_txt2nc.ncl

You should get

AOT.2005.nc
AOT.2006.nc
AOT.2007.nc
AOT.2008.nc
AOT.2009.nc
AOT.2010.nc
AOT.2011.nc
AOT.2012.nc
AOT.2013.nc
AOT.2014.nc

Please *look* at (say)

%> ncl_filedump -v time,yyyyddd,yyyymmdd AOT.2010.nc

[SNIP]
 AOT_440 ( time )   <=== the daily values
 AOT_500 ( time )
 AOT_550 ( time )
 AOT_675 ( time )
 ALPHA ( time )
 ANGSTROM ( time )
[SNIP]

Variable No. 0
     time:

   1831.       1838.       1858.       1859.       1888.       1889.
   1894.       1897.       1910.

Variable No. 1
     yyyyddd:

   2010006   2010013   2010033   2010034   2010063   2010064   2010069
2010072
   2010085

Variable No. 2
     yyyymmdd:

   20100106   20100113   20100202   20100203   20100304   20100305
20100310
   20100313   20100326

*Computing any monthly mean for year 2010 is not appropriate.*  January and
February have 2 values each; March has 5 values. Yes, a mean could be
computed based on only 2 values BUT is that really a monthly mean???   Just
'any old number' will not do!!! Please think about it!

[2]

The 'najiby_monthly.ncl' script calculates monthly values using the netCDF
files created via [1]. It creates both netCDF and ascii files containing
the computed monthly means. I required that at least 10 daily values be
present before a mean is calculated.

%> gzip -d AOT.2005-2014.month*gz

Please carefully examine these monthly  files [Look at your data]

%> less AOT.2005-2014.month.txt

%> ncl_filedump AOT.2005-2014.month.nc

or
%> ncdump -h AOT.2005-2014.month.nc


[3] Thetwo scripts [ najiby_plot_monthly_txt.ncl,
najiby_plot_monthly_nc.ncl ] read the monthly files from [2] and plot a
user specified variable. *Please examine the scripts carefully.* Read the
documentation for any function being used. A simple sample plot is attached.







On Wed, Jun 21, 2017 at 6:21 AM, <najib.yusuf at carnasrda.com> wrote:

>
>  Dear all,
>
>  I need assistance on how to compute monthly-mean from daily data (julian
> days)from ascii files. So that i can plot the means (All Jan, All Feb,
> .....All Dec means), obtaining 12 (mean) values and plot xy line on same
> plot.
>
>  I tried, I got the plot of all the "Marker" points correct but I couldn't
> succeed to compute and draw the mean xy-line. I tried the NUG_manual but I
> couldn't get ascii file but .nc example and when i tried to work-around,
> ofcourse, it did not work. Pls see other way I tried attached. And below is
> the some-part of Printed output summary from the attached file with error.
> The more i tried the more i get different error. Pls direct me on how to
> achieve this. Thank you
>
> Number Of Attributes: 1
>   _FillValue :  missing
>
>
> Variable: variables
> Type: string
> Total Size: 56 bytes
>             7 values
> Number of Dimensions: 1
> Dimensions and sizes:   [7]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
> (0)     Day
> (1)     AOT_675
> (2)     AOT_500
> (3)     AOT_440
> (4)     440-675Angstrom
> (5)     α
> (6)     AOT_550
>
>
> Variable: files (subsection)
> Type: string
> Total Size: 8 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:   [1]
> Coordinates:
> (0)     /home/model-user/AOT_550_2006.txt
> warning:asciiread: End of file reached and only (271) elements were read
> from the file, filling remaining elements with the default missing value
> for the requested type
>
> Variable: z1
> Type: string
> Total Size: 2928 bytes
>             366 values
> Number of Dimensions: 1
> Dimensions and sizes:   [366]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
>
> Variable: new_str
> Type: string
> Total Size: 20496 bytes
>             2562 values
> Number of Dimensions: 2
> Dimensions and sizes:   [366] x [7]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
>
>
> Variable: variables
> Type: string
> Total Size: 56 bytes
>             7 values
> Number of Dimensions: 1
> Dimensions and sizes:   [7]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
> (0)     Day
> (1)     AOT_675
> (2)     AOT_500
> (3)     AOT_440
> (4)     440-675Angstrom
> (5)     α
> (6)     AOT_550
>
>
> Variable: files (subsection)
> Type: string
> Total Size: 8 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:   [1]
> Coordinates:
> (0)     /home/model-user/AOT_550_2007.txt
> warning:asciiread: End of file reached and only (301) elements were read
> from the file, filling remaining elements with the default missing value
> for the requested type
>
> Variable: z1
> Type: string
> Total Size: 2928 bytes
>             366 values
> Number of Dimensions: 1
> Dimensions and sizes:   [366]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
>
> Variable: new_str
> Type: string
> Total Size: 20496 bytes
>             2562 values
> Number of Dimensions: 2
> Dimensions and sizes:   [366] x [7]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
>
>
> Variable: variables
> Type: string
> Total Size: 56 bytes
>             7 values
> Number of Dimensions: 1
> Dimensions and sizes:   [7]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
> (0)     Day
> (1)     AOT_675
> (2)     AOT_500
> (3)     AOT_440
> (4)     N[440-675Angstrom]
> (5)     α
> (6)     AOT_550
>
>
> Variable: files (subsection)
> Type: string
> Total Size: 8 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:   [1]
> Coordinates:
> (0)     /home/model-user/AOT_550_2008.txt
> warning:asciiread: End of file reached and only (217) elements were read
> from the file, filling remaining elements with the default missing value
> for the requested type
>
> Variable: z1
> Type: string
> Total Size: 2928 bytes
>             366 values
> Number of Dimensions: 1
> Dimensions and sizes:   [366]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
>
> Variable: new_str
> Type: string
> Total Size: 20496 bytes
>             2562 values
> Number of Dimensions: 2
> Dimensions and sizes:   [366] x [7]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
>
>
> Variable: variables
> Type: string
> Total Size: 56 bytes
>             7 values
> Number of Dimensions: 1
> Dimensions and sizes:   [7]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
> (0)     Day
> (1)     AOT_675
> (2)     AOT_500
> (3)     AOT_440
> (4)     440-675Angstrom
> (5)     α
> (6)     AOT_550
>
>
> Variable: files (subsection)
> Type: string
> Total Size: 8 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:   [1]
> Coordinates:
> (0)     /home/model-user/AOT_550_2009.txt
> warning:asciiread: End of file reached and only (179) elements were read
> from the file, filling remaining elements with the default missing value
> for the requested type
>
> Variable: z1
> Type: string
> Total Size: 2928 bytes
>             366 values
> Number of Dimensions: 1
> Dimensions and sizes:   [366]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
>
> Variable: new_str
> Type: string
> Total Size: 20496 bytes
>             2562 values
> Number of Dimensions: 2
> Dimensions and sizes:   [366] x [7]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
>
>
> Variable: variables
> Type: string
> Total Size: 56 bytes
>             7 values
> Number of Dimensions: 1
> Dimensions and sizes:   [7]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
> (0)     Day
> (1)     AOT_675
> (2)     AOT_500
> (3)     AOT_440
> (4)     440-675Angstrom
> (5)     α
> (6)     AOT_550
>
>
> Variable: files (subsection)
> Type: string
> Total Size: 8 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:   [1]
> Coordinates:
> (0)     /home/model-user/AOT_550_2010.txt
> warning:asciiread: End of file reached and only (10) elements were read
> from the file, filling remaining elements with the default missing value
> for the requested type
>
> Variable: z1
> Type: string
> Total Size: 2928 bytes
>             366 values
> Number of Dimensions: 1
> Dimensions and sizes:   [366]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
>
> Variable: new_str
> Type: string
> Total Size: 20496 bytes
>             2562 values
> Number of Dimensions: 2
> Dimensions and sizes:   [366] x [7]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
>
>
> Variable: variables
> Type: string
> Total Size: 56 bytes
>             7 values
> Number of Dimensions: 1
> Dimensions and sizes:   [7]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
> (0)     Day
> (1)     AOT_675
> (2)     AOT_500
> (3)     AOT_440
> (4)     440-675Angstrom
> (5)     α
> (6)     AOT_550
>
>
> Variable: files (subsection)
> Type: string
> Total Size: 8 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:   [1]
> Coordinates:
> (0)     /home/model-user/AOT_550_2011.txt
> warning:asciiread: End of file reached and only (90) elements were read
> from the file, filling remaining elements with the default missing value
> for the requested type
>
> Variable: z1
> Type: string
> Total Size: 2928 bytes
>             366 values
> Number of Dimensions: 1
> Dimensions and sizes:   [366]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
>
> Variable: new_str
> Type: string
> Total Size: 20496 bytes
>             2562 values
> Number of Dimensions: 2
> Dimensions and sizes:   [366] x [7]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
>
>
> Variable: variables
> Type: string
> Total Size: 56 bytes
>             7 values
> Number of Dimensions: 1
> Dimensions and sizes:   [7]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
> (0)     Day
> (1)     AOT_675
> (2)     AOT_500
> (3)     AOT_440
> (4)     440-675Angstrom
> (5)     α
> (6)     AOT_550
>
>
> Variable: files (subsection)
> Type: string
> Total Size: 8 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:   [1]
> Coordinates:
> (0)     /home/model-user/AOT_550_2012.txt
> warning:asciiread: End of file reached and only (250) elements were read
> from the file, filling remaining elements with the default missing value
> for the requested type
>
> Variable: z1
> Type: string
> Total Size: 2928 bytes
>             366 values
> Number of Dimensions: 1
> Dimensions and sizes:   [366]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
>
> Variable: new_str
> Type: string
> Total Size: 20496 bytes
>             2562 values
> Number of Dimensions: 2
> Dimensions and sizes:   [366] x [7]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
>
>
> Variable: variables
> Type: string
> Total Size: 56 bytes
>             7 values
> Number of Dimensions: 1
> Dimensions and sizes:   [7]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
> (0)     Day
> (1)     AOT_675
> (2)     AOT_500
> (3)     AOT_440
> (4)     440-675Angstrom
> (5)     α
> (6)     AOT_550
>
>
> Variable: files (subsection)
> Type: string
> Total Size: 8 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:   [1]
> Coordinates:
> (0)     /home/model-user/AOT_550_2013.txt
> warning:asciiread: End of file reached and only (125) elements were read
> from the file, filling remaining elements with the default missing value
> for the requested type
>
> Variable: z1
> Type: string
> Total Size: 2928 bytes
>             366 values
> Number of Dimensions: 1
> Dimensions and sizes:   [366]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
>
> Variable: new_str
> Type: string
> Total Size: 20496 bytes
>             2562 values
> Number of Dimensions: 2
> Dimensions and sizes:   [366] x [7]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
>
>
> Variable: variables
> Type: string
> Total Size: 56 bytes
>             7 values
> Number of Dimensions: 1
> Dimensions and sizes:   [7]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
> (0)     Day
> (1)     AOT_675
> (2)     AOT_500
> (3)     AOT_440
> (4)     440-675Angstrom
> (5)     α
> (6)     AOT_550
>
>
> Variable: files (subsection)
> Type: string
> Total Size: 8 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:   [1]
> Coordinates:
> (0)     /home/model-user/AOT_550_2014.txt
> warning:asciiread: End of file reached and only (157) elements were read
> from the file, filling remaining elements with the default missing value
> for the requested type
>
> Variable: z1
> Type: string
> Total Size: 2928 bytes
>             366 values
> Number of Dimensions: 1
> Dimensions and sizes:   [366]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
>
> Variable: new_str
> Type: string
> Total Size: 20496 bytes
>             2562 values
> Number of Dimensions: 2
> Dimensions and sizes:   [366] x [7]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
>
>
> Variable: variables
> Type: string
> Total Size: 56 bytes
>             7 values
> Number of Dimensions: 1
> Dimensions and sizes:   [7]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  missing
> (0)     Day
> (1)     AOT_675
> (2)     AOT_500
> (3)     AOT_440
> (4)     440-675Angstrom
> (5)     α
> (6)     AOT_550
>
> Variable: AOT_550_all
> Type: float
> Total Size: 14600 bytes
>             3650 values
> Number of Dimensions: 2
> Dimensions and sizes:   [years | 10] x [days | 365]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  9.96921e+36
>
>
> Variable: files
> Type: string
> Total Size: 80 bytes
>             10 values
> Number of Dimensions: 1
> Dimensions and sizes:   [10]
> Coordinates:
> (0)     /home/model-user/AOT_550_2005.txt
> (1)     /home/model-user/AOT_550_2006.txt
> (2)     /home/model-user/AOT_550_2007.txt
> (3)     /home/model-user/AOT_550_2008.txt
> (4)     /home/model-user/AOT_550_2009.txt
> (5)     /home/model-user/AOT_550_2010.txt
> (6)     /home/model-user/AOT_550_2011.txt
> (7)     /home/model-user/AOT_550_2012.txt
> (8)     /home/model-user/AOT_550_2013.txt
> (9)     /home/model-user/AOT_550_2014.txt
> fatal:Undefined identifier: (years) is undefined, can't continue
> fatal:["Execute.c":8573]:Execute: Error occurred at or near line 66
>
> ncl 105>
>
>
>
>   Any assistance will really be appreciated.
>
>   Thank you
>
>   Najib
> _______________________________________________
> 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/20170623/ba2292a9/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: AOT.2005-2014.month.nc.gz
Type: application/x-gzip
Size: 3263 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170623/ba2292a9/attachment.gz 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: AOT.2005-2014.month.txt.gz
Type: application/x-gzip
Size: 2402 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170623/ba2292a9/attachment-0001.gz 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: AOT_txt2nc.ncl
Type: application/octet-stream
Size: 4711 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170623/ba2292a9/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: najiby_plot_monthly_txt.ncl
Type: application/octet-stream
Size: 2756 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170623/ba2292a9/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: najiby_plot_monthly_nc.ncl
Type: application/octet-stream
Size: 2500 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170623/ba2292a9/attachment-0002.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: najib_txt_A550.png
Type: image/png
Size: 57877 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170623/ba2292a9/attachment.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: najiby_monthly.ncl
Type: application/octet-stream
Size: 5068 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170623/ba2292a9/attachment-0003.obj 


More information about the ncl-talk mailing list