0

I have monthly data from 2015-01 to 2099-12 with hundreds of variables (big dataset). Now I just want to extract single variable (say, FAREA_BURNED) from each nc files and save it as FAREA_BURNED.nc file. I find several ways on internet, but none of them perfectly worked for me.

Merging all nc files instead of variables is not possible because each nc files are big and merging 1020 files will make it even larger. So, I just want to merge each variable and create nc files for single variable.

The most popular way I find is:

cdo mergetime -selname,FAREA_BURNED ISSP*.nc FAREA_BURNED.nc

The problem with this code is it also checks other variables and if there is any difference in other variables (not FAREA_BURNED), it throws error. I am sure all of my nc files have "FAREA_BURNED".

I also used: cdo -selvar,FAREA_BURNED -cat ISSP*.nc output.nc but it abort and doesn't work.

enter image description here

The variables like ZSOI, DZSOI are variables I don't care about, but it is causing the problem. Many thanks in advance.

1 Answers1

0

You can get CDO to work if you use the apply option. This can apply subsetting etc. to files before merging.

So, you will need to change your original command

cdo mergetime -selname,FAREA_BURNED ISSP*.nc FAREA_BURNED.nc

to

cdo -mergetime -apply,-selname,FAREA_BURNED [ ISSP*.nc ] FAREA_BURNED.nc

Apply can be used in different ways, so please read the user guide to figure out the best for your purposes: https://code.mpimet.mpg.de/projects/cdo/embedded/cdo.pdf

Robert Wilson
  • 3,192
  • 11
  • 19