[ncl-talk] how I can split one file to 12 files?

mireiyue mireiyue at gmail.com
Tue Oct 20 23:59:45 MDT 2015


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-

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151021/474b8f93/attachment.html 


More information about the ncl-talk mailing list