[ncl-talk] Converting Weekly to Monthly data
Ipshita Majhi
ipmajhi at alaska.edu
Wed Sep 10 06:44:44 MDT 2014
Thank you I will do the needful
On Wednesday, September 10, 2014, Jatin Kala <jatin.kala.jk at gmail.com>
wrote:
> You can do this in one line using CDO tools:
> https://code.zmaw.de/projects/cdo
>
> cdo monmean input_file.nc outputfile.nc
>
> And with regards to your script, there is no "for" and "end" in NCL!
> You should use "do" and "end do"
> http://www.ncl.ucar.edu/Document/Language/loops.shtml
>
> Please read the documentation.
>
>
>
>
> On 10/09/14 2:55 PM, Ipshita Majhi wrote:
>
> Dear NCL
>
> How can I convert a weekly data to monthly and the time of the data is in
> georgian form:-
> Here are the global attributes for it
>
> netcdf nhsce_v01r01_19661004_20140602 {
> dimensions:
> cols = 88 ;
> rows = 88 ;
> time = UNLIMITED ; // (2487 currently)
> variables:
> char coord_system ;
> coord_system:grid_mapping_name = "latitude_longitude" ;
> coord_system:longitude_of_central_meridian = 0. ;
> coord_system:semimajor_axis = 6378137 ;
> coord_system:semiminor_axis = 6356752.3 ;
> int time(time) ;
> time:standard_name = "time" ;
> time:long_name = "time" ;
> time:units = "days since 1966-10-03" ;
> time:axis = "T" ;
> time:valid_range = 7, 17409 ;
> time:calendar = "gregorian" ;
> float snow_cover_threshold ;
> snow_cover_threshold:standard_name = "surface_snow_area_fraction" ;
> snow_cover_threshold:long_name = "threshold for the
> snow_cover_extent measurement" ;
> snow_cover_threshold:units = "1" ;
>
> ***********************************************************************
>
> Here is my code and one of the fatal error is that i is undefined
>
> ; This program is to calculate the area average for snow for all the data
> period
> ;*******************************************
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> ;*******************************************
>
> ;The intention is to average the sce for each year and for each month
>
> a=addfile("~/Documents/Snow_cover_IMS/nhsce_v01r01_19661004_20140602.nc
> ","r")
>
> sce=a->snow_cover_extent(0,:,:)
>
> t=a->time
> asciiwrite("time.txt",t); saving time as a text file
>
> ;Reading in the same text file
>
> time=asciiread("~/Documents/Snow_cover_IMS/NCL_codes/time.txt",-1,"float")
>
> jan=new((/47,2/); I want the data to go from 1966 to 2012 with one column
> with year information and other with data from sce
> feb=new((/47,2/);
> mar=new((/47,2/);
> apr=new((/47,2/);
> may=new((/47,2/);
> june=new((/47,2/);
> july=new((/47,2/);
> aug=new((/47,2/);
> sept=new((/47,2/);
> oct=new((/47,2/);
> nov=new((/47,2/);
> dec=new((/47,2/);
>
> x = ispan (1,10,1)
> years=ispan(1966,2012,1)
> month=ispan(1,12,1)
>
> for i=0,dimsizes(time)-1,7; since I saved time as a text file and the date
> appears in a horizontal manner I am attaching the txt file
> ;better clarity
> t(nyr)==year(i)
> if time(nyr+1)==1
> jan(i)=(year(i),sce(i,:,:))
> else if time(nyr+1)==2
> feb(i)=(year(i),sce(i,:,:))
> else if time(nyr+1)==3
> mar(i)=(year(i),sce(i,:,:))
> else if time(nyr+1)==4
> apr(i)=(year(i),sce(i,:,:))
> else if time(nyr+1)==5
> may(i)=(year(i),sce(i,:,:))
> else if time(nyr+1)==6
> june(i)=(year(i),sce(i,;,:))
> else if time(nyr+1)==7
> july(i)=(year(i),sce(i,:,:))
> else if time(nyr+1)==8
> aug(i)=(year(i),sce(i,:,:))
> else if time(nyr+1)==9
> sept(i)=(year(i),sce(i,:,:))
> else if time(nyr+1)==10
> oct(i)=(year(i),sce(i,:,:))
> else if time(nyr+1)==10
> nov(i)=(year(i),sce(i,:,:))
> else
> dec(i)=(year(i),sce(i,:,:))
> i=i+1
> end
>
> what is missing in the code!
>
> I would be grateful for any guidance
>
> Best Regards
> Ipshita
>
>
> _______________________________________________
> ncl-talk mailing list
> 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/20140910/102da26b/attachment.html
More information about the ncl-talk
mailing list