Extract WRF variable SWDOWN from multiple directories and multiple files
Added by Theodoros Gkousarov about 12 years ago
Hello Guys,
I have 11y worth of WRF model outpout in .nc files. the files are stored in that way
/directory/esscratch/2002/may/wrfout_sb3_2002-05-01_00:00:00.nc
there are 24 hourly files in each daily output.
the last file is in the directory
/directory/esscratch/2012/may/wrfout_sb3_2012-05-01_00:00:00.nc
How can I extract the SWDOWN variable from all the wrf files so that I can have one file with the name swouut.nc containing only one variable but including the different times so that later i can process it either with cdo or R ?
Thank you. every help is very appreciated.
Replies (3)
RE: Extract WRF variable SWDOWN from multiple directories and multiple files - Added by Uwe Schulzweida about 12 years ago
Try the undocumented CDO operator select. If you need only may of the 11y use:
cdo select,name=SWDOWN /directory/esscratch/20??/may/wrfout_sb3_20??-05-01_00:00:00.nc swouut.nc
Otherwise you have to create a variable with a sorted list of all files:
MYFILES="....." cdo select,name=SWDOWN $MYFILES swouut.nc
RE: Extract WRF variable SWDOWN from multiple directories and multiple files - Added by Theodoros Gkousarov about 12 years ago
Thank you very much,
I use NCL when trying to list all the files but dont know how to do it in CDO.
the $MYFILES could be comma seperated filenames? ( long string of words) How to do it in cdo ?
this is how the list starts .
(0) /gpfs/env/qrc09pau/esscratch/WRFout2011/wrfout_d03_2011-01-01_00:00:00
(1) /gpfs/env/qrc09pau/esscratch/WRFout2011/wrfout_d03_2011-01-02_00:00:00
(2) /gpfs/env/qrc09pau/esscratch/WRFout2011/wrfout_d03_2011-01-03_00:00:00
(3) /gpfs/env/qrc09pau/esscratch/WRFout2011/wrfout_d03_2011-01-04_00:00:00
(4) /gpfs/env/qrc09pau/esscratch/WRFout2011/wrfout_d03_2011-01-05_00:00:00
(5) /gpfs/env/qrc09pau/esscratch/WRFout2011/wrfout_d03_2011-01-06_00:00:00
(6) /gpfs/env/qrc09pau/esscratch/WRFout2011/wrfout_d03_2011-01-07_00:00:00
(7) /gpfs/env/qrc09pau/esscratch/WRFout2011/wrfout_d03_2011-01-08_00:00:00
(8) /gpfs/env/qrc09pau/esscratch/WRFout2011/wrfout_d03_2011-01-09_00:00:00
(227) /gpfs/env/nhm06sfu/esscratch/2011/aug/wrfout_sb3_2011-08-16_00:00:00
(228) /gpfs/env/nhm06sfu/esscratch/2011/aug/wrfout_sb3_2011-08-17_00:00:00
(229) /gpfs/env/nhm06sfu/esscratch/2011/aug/wrfout_sb3_2011-08-18_00:00:00
(230) /gpfs/env/nhm06sfu/esscratch/2011/aug/wrfout_sb3_2011-08-19_00:00:00
(359) /gpfs/env/qrc09pau/esscratch/WRFout2011/wrfout_d03_2011-12-26_00:00:00
(360) /gpfs/env/qrc09pau/esscratch/WRFout2011/wrfout_d03_2011-12-27_00:00:00
(361) /gpfs/env/qrc09pau/esscratch/WRFout2011/wrfout_d03_2011-12-28_00:00:00
(362) /gpfs/env/qrc09pau/esscratch/WRFout2011/wrfout_d03_2011-12-29_00:00:00
(363) /gpfs/env/qrc09pau/esscratch/WRFout2011/wrfout_d03_2011-12-30_00:00:00
(364) /gpfs/env/qrc09pau/esscratch/WRFout2011/wrfout_d03_2011-12-31_00:00:00
its actually 364 lines but to sort the space listed only these.
I want to extract the SWdown variable from all of these files, and to create 1 netcdf file which will contain all the timesteps of the SWdown variable.
Is it possible? I would be really grateful.
The above script is in ncl language but it shows where are the directories, could you tell me how to do that using CDO ?
RE: Extract WRF variable SWDOWN from multiple directories and multiple files - Added by Uwe Schulzweida about 12 years ago
This is more a UNIX related question. MYFILES should be a comma separated list of filenames. Store your above lines to a file, e.g. myfile. Then you can generate the variable MYFILES with:
MYFILES=`cat myfiles | cut -f2 -d" "`