I'm a user of WRF V3.5 aiming at meteorological simulation.
Sometimes, I'll run the model for a long period.

My attempt

I split the long period(e.g 1 year) into serval short ones.

For example:

 ## WPS namelist.wps      
 start_date = '2014-01-01_06:00:00'
 end_date   = '2014-01-31_23:00:00'  

 ## WRF run period setting in .csh file.    
 set year = "2014"
 foreach strtime (010106010512 010500011012 011000011512 011500012012 012000012512 012500013012 013000020100)

 set smon = `echo ${strtime}|cut -c1-2`
 set sday = `echo ${strtime}|cut -c3-4`
 set shr  = `echo ${strtime}|cut -c5-6`
 set emon = `echo ${strtime}|cut -c7-8`
 set eday = `echo ${strtime}|cut -c9-10`
 set ehr  = `echo ${strtime}|cut -c11-12`  

 run_days                            = 0,
 run_hours                           = 132,
 run_minutes                         = 0,
 run_seconds                         = 0,
 start_year                          = ${year},${year},
 start_month                         = ${smon},${smon},
 start_day                           = ${sday},${sday},
 start_hour                          = ${shr},${shr},
 start_minute                        = 00,00,
 start_second                        = 00,00,
 end_year                            = ${year},${year},
 end_month                           = ${emon},${emon},
 end_day                             = ${eday},${eday},
 end_hour                            = ${ehr},${ehr},
 end_minute                          = 00,00,
 end_second                          = 00,00,
 interval_seconds                    = 21600

In these short period, I set the first 12-h as the spinning period(except the start one.)

This is the schematics of the temporal modeling setup which I clipped from the Internet.



It generate 8 .nc file which each contain 132 frames of data.
For now, I use the The netCDF Operators(NCO) to deal with the output files.

  1. Using ncks to delete the first 12-h frames for each file separately.

  2. Using ncrcatto concat all 8 .nc files together to get one file represent the whole simulation period.


I was using this method for a while. But when the amount of files are huge, it really a dump approach.

Are there someone offering your approaches to dealing with spin-up data deletion?

My target

  • The model can generate only one file which contain all the simulation period.
  • The spin-up time can be covered by last file's frames automatically.

Update: Wish you share your approaches!

  • 1
    $\begingroup$ I often do the same thing, except for trimming the spin-up period. Do you really need everything in just one file? What I do is have WRF output each time frame in a separate (in my case hourly) file, and I organize separate runs in individual directories. When I need the whole thing concatenated, I just select the files I need from a shell or Python script. $\endgroup$ – milancurcic Mar 17 '16 at 15:21
  • $\begingroup$ Thanks for your reply. So,you mean set per hour as one WRF output file. How to avoid the overlay by the latter frame? For example, wrfout_2016_03_17_00 was the last frame for one simulation. The next simulation start with wrfout_2016_03_17_00.Then the file would be rewritten. But I want to keep the older one. $\endgroup$ – Han Zhengzu Mar 17 '16 at 15:56
  • 2
    $\begingroup$ I store the output files from different runs in different directories in order to avoid the older output being overwritten by newer. $\endgroup$ – milancurcic Mar 17 '16 at 21:45

There is an feature of the -d option that makes the call of ncks redundant. However, it is available since NCO version 4.2.1 (Aug. 2012).

ncrcat -d Time,13,,132,120 wrfout* summary.nc
# -d dim,[min][,[max][,[stride][,[subcycle]]]]

This feature is deeply hidden in the online manual. You find it here: nco.sourceforge.net/nco.html#Subcycle .


  • 13: first time step we consider
  • [empty]: till the end
  • 132: we have a cycle length of 132 steps
  • 120: we take the first 120 values (starting from the 13th) of each cycle

If we write -d Time,13,0,132, which equals -d Time,13,0,132,1, we would only get each 132nd value starting with the 13th.

I do not process WRF output but we work with the Chemistry Transport Model CMAQ. We get hourly resolved concentration output files for each day. These files have 25 time steps (0 o'clock of the current and the next day) and we need to remove one of the ) o'clock time steps and append the files. For this purpose, I use ncrcat -d TSTEP,0,,25,24 [infiles] [outfile].

The straight forward approach would be to write a Fortran program for this purpose. But, I also prefer the NCO's. Maybe you could try the cdo's (code.zmaw.de/projects/cdo) as an alternative. However, my solution with cdo's for this task was more bulky than the NCO solution.

| improve this answer | |
  • $\begingroup$ Excited to read your answer. I'm think about learning WRF-CMAQ. So, you mean that in one day meteorology simulation, remove the first 1-h data is reasonable for CTM later? I haven't tried CTM now, just ask for curious. $\endgroup$ – Han Zhengzu Mar 27 '16 at 14:40
  • 1
    $\begingroup$ The reason for having 25 instead of 24 hours per output file is only of technical nature: The first time step contains the initial concentrations of that model day. Thus, for each day we have one time step with initial concentrations and 24 time steps with newly modeled concentrations. We have a spin-up period of approximately 4 days - I often take 10 days spin-up just to make sure. $\endgroup$ – daniel.heydebreck Mar 27 '16 at 15:19
  • 1
    $\begingroup$ Yes, cut the 10 days off - but for CMAQ runs. We don't use WRF for the meteorology. Colleagues in another department produce meteo hindcasts with the model COSMO-CLM. I am not sure how they set up COSMO-CLM with respect to spin-up. We just get their data and pre-process it as input for CMAQ. For CMAQ, the 4 days of spin-up are sufficient - a colleague test it for 2 days spin-up and it also looked quite good. I do 10 days because it is a round numger :-) . $\endgroup$ – daniel.heydebreck Mar 28 '16 at 12:31
  • 1
    $\begingroup$ Thanks for your reply! I have also heard some model that developed in Europe like COSMO-ART, REMO, etc. In China, WRF is the most popular one. $\endgroup$ – Han Zhengzu Mar 28 '16 at 12:39
  • 1
    $\begingroup$ There is a real model zoo in Europe ;-) . $\endgroup$ – daniel.heydebreck Mar 29 '16 at 8:45

Here is my present approach.

  1. All wrfout-files are located in the same path.
  2. Using pynco in python loop to split the spin-up dataframe

    import glob
    nco = Nco()
    for fn in glob.iglob('*.nc'):
        filename, extname = os.path.splitext(fn)
        output_fn = filename[11:22] + str(int(filename[22:24]) + 12) + extname
        nco.ncks(input=fn, output=output_fn, dimension='Time,13,')  

The input shows like: 2014-04-04_12.nc(120 frame inside)
The output shows like:wrfout_2014-04-04_00:00:00.nc(133 frame inside)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.