cdo ensmean in looping
Added by mayna helena azevedo nina over 5 years ago
Hello everyone!
I have several hour files, and I am joining in days with "ensmean" help. The point is that I have data for one year, and this is divided into hour, hence 24/7, 24 hours a day, for 365 days. The intention is to gather the data in days. Does anyone know how to put this in looping?
I Tried to one month (month 01)
#! / bin / sh
for in (seq -f "% 03g" 1 365)
cdo ensmean 201801$i.nc 201801.
done
but it did not work. The files are in the following format: "20180101010000-OSISAF-L3C_GHRSST-SSTsubskin-GOES16-ssteqc_goes16_20180101_010000-v02.0-fv01.0.nc", the file's name have year, month, day, and hour.
Replies (7)
RE: cdo ensmean in looping - Added by Ralf Mueller over 5 years ago
hi mayna!
you missed the
iin the for-loop, but still your file would not be matched. Could you add more of these filenames so that I can see a pattern?
cheers
ralf
RE: cdo ensmean in looping - Added by mayna helena azevedo nina over 5 years ago
Hi there!
I add tree files, all same day, but different hour, to you see the pattern.
Yes, I forgot to write the i
. But it continues giving error, the following:
bash: syntax error next to unexpected token 'cdo'
graciously
Mayna
RE: cdo ensmean in looping - Added by Ralf Mueller over 5 years ago
mayna
please post the complete for-loop or a complete script for debugging - I cannot comment on something I don't know ;-)
cheers
ralf
RE: cdo ensmean in looping - Added by mayna helena azevedo nina over 5 years ago
Hi!
I got it sorted out. I did it another way, and it worked. The code is below if you are curious
#!/bin/bash
for month in `seq -w 4 12 ` ; do
for day in `seq -w 1 31 ` ; do
for hour in `seq -w 0 23 ` ; do
cdo -O -ensmean 2018${month}${day}${hour}0000-OSISAF-L3C_GHRSST-SSTsubskin-GOES16-ssteqc_goes16_2018${month}${day}_${hour}0000-v02.0-fv01.0.nc 2018${month}${day}.nc
done
done
done
Thanks
RE: cdo ensmean in looping - Added by Ralf Mueller over 5 years ago
thx for posting the solution - what I still don't understand is, why you call the ensmean
operators on a single file. All you get is a copy of your input, because CDO thinks the input is the only ensemble member (there is not file-internal dimension for numbering the ensemble members).
I don't have any clue on your entire processing, but this is a little mysterious ;-)
cheers
ralf
RE: cdo ensmean in looping - Added by mayna helena azevedo nina over 5 years ago
No, no, it's not a single file. I have one file per hour, 365 days, so is 8760 files. I want to mescle the hour in days, make a mean for either day, so in the end, I have 365 files.
I was trying to do a loopinp, but it never worked. Since I'm new to cdo, I thought some rules were different. Actually, I was just trying the wrong way.
Sorry, I did not explain it right.
RE: cdo ensmean in looping - Added by Ralf Mueller over 5 years ago
alrighty then - i was just a bit confused and wanted to be sure, it's doing the right thing.
if u r happy with it so am I ;-)
cheers
ralf