[ncl-talk] how I can split one file to 12 files?
mireiyue
mireiyue at gmail.com
Thu Oct 22 19:24:37 MDT 2015
Thank you so much Adam
I got the netCDF operators and it works perfect!
Sun-
> On Oct 22, 2015, at 7:34 AM, Adam Phillips <asphilli at ucar.edu> wrote:
>
> Hi Sun,
> If you do want to create a netCDF file for each month from your files that contain 12 months of data, I would use the netCDF operators:
>
> ; Note: Script not tested, check that the results are as you would expect.
>
> begin
>
> year = (/"2007","2008","2009","2010","2011","2012","2013"/)
> varname = "MFLUX_GDS0_ISBL_S130"
> diri = "/Users/spark/vertical/00_DATA/20_JRA-55/"
> filo = "fcst_phy3m125.231_mflux."
> do gg = 0,dimsizes(year)-1
> fili = "fcst_phy3m125.231_mflux."+year(gg)+"01_"+year(gg)+"12. allen136024.nc <http://allen136024.nc/>"
> do hh = 1,12
> en = sprinti("%2.2i",hh))
> print("ncks -v "+varname+" -d time,"+(hh-1)+","+(hh-1)+" "+diri+fili+" "+filo+year(gg)+en+".nc")
> ; system("ncks -v "+varname+"-d time,"+(hh-1)+","+(hh-1)+" "+diri+fili+" "+diri+filo+year(gg)+en+".nc")
> end do
> print("Now done with year = "+year(gg))
> end do
>
> end
>
> If the print statements look good, then you could uncomment out the system statement.
>
> Hope that helps.. If not, or if I totally misunderstood what you are after, please respond to the ncl-talk email list and not to me personally.
> Adam
>
>
>
>
>
>
> On Tue, Oct 20, 2015 at 11:59 PM, mireiyue <mireiyue at gmail.com <mailto:mireiyue at gmail.com>> wrote:
> Dear NCL users
>
> I have a file it contains 12 months data (ec550aer_aero_NorESM1-M_historicalExt_r1i1p1_201201-201212.nc). I want to make file for each month. What nil function I should use? I tried to use reshape but It gives me
> fatal:_NclBuildArray: each element of a literal array must have the same dimension sizes, at least one item doesn’t (near L30). If I made mistake in the script please help me what I did wrong or if I have to use other function.
>
> I do appreciate any helps.
>
> year = (/"2007","2008","2009","2010","2011","2012","2013"/)
> diri = "/Users/spark/vertical/00_DATA/20_JRA-55/" ; path to file
> do ii=0,6
>
> fili = "fcst_phy3m125.231_mflux."+year(ii)+"01_"+year(ii)+"12.allen136024"
> varname = "MFLUX_GDS0_ISBL_S130"
> filenc = addfile (diri+fili+".nc", "r") ; entire file
> mf = filenc->$varname$ ; (time, ver, lat, lon)
>
> time =filenc->initial_time0
> lev =filenc->lv_ISBL1
> lat =filenc->g0_lat_2
> lon =filenc->g0_lon_3
> mf at _FillValue=1e+20
>
> printVarSummary(mf)
>
> ntim = dimsizes(time)
> nlev = dimsizes(lev)
> nlat = dimsizes(lat)
> nlon = dimsizes(lon)
> nyears = ntim/12
>
> mfreshape = reshape(mf,(/nyears,12,nlev,nlat,nlon/)) :an error occurs here
> printVarSummary(mfreshape)
>
> Thank you
> Sun-
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>
>
>
>
> --
> Adam Phillips
> Associate Scientist, Climate and Global Dynamics Laboratory, NCAR
> www.cgd.ucar.edu/staff/asphilli/ <http://www.cgd.ucar.edu/staff/asphilli/> 303-497-1726
>
> <http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151023/b98991e9/attachment.html
More information about the ncl-talk
mailing list