Project

General

Profile

How to use expression with multiple files

Added by Purna Durga Geesupalli about 2 years ago

Dear CDO Support,
I am trying to add an expression BC*rho*10^9 from different .nc files.
First I have to sum all BC modes like BC=BC_KS+BC_AS+BC_CS+BC_KI /mnt/nas/DATA/anwesa/Baseline_NoForcing/output/baseline_200406.01_tracer.nc
after I have to multiply the above BC with rhoam1 from /mnt/nas/DATA/anwesa/Baseline_NoForcing/output/baseline_200406.01_vphysc.nc
At last i need to do BC*rhoam1*1000000000

For each netcdf file I wanna convert hybrid coordinates into pressure coordinates.

Thus, I have written

#!/bin/bash
export RELPATH=/mnt/nas/DATA/anwesa/Baseline_NoForcing/output
cdo -f nc -expr,'BC=BC_KS+BC_AS+BC_CS+BC_KI*rhoam1*1000000000' -ml2pl,100000,97500,95000,92500,90000,87500,85000,82500,80000,77500,75000,70000,65000,60000,55000,50000,45000,40000,35000,30000,25000,22500,20000,17500,15000,12500,10000 -selname,BC_KS,BC_AS,BC_CS,BC_KI "${RELPATH}"/baseline_200406.01_tracer.nc -ml2pl,100000,97500,95000,92500,90000,87500,85000,82500,80000,77500,75000,70000,65000,60000,55000,50000,45000,40000,35000,30000,25000,22500,20000,17500,15000,12500,10000 -selname,rhoam1 "${RELPATH}"/baseline_200406.01_vphysc.nc test.nc

But, I am facing the error like this.

cdo (Abort): Unprocessed Input, could not process all Operators/Files


Replies (3)

RE: How to use expression with multiple files - Added by Estanislao Gavilan about 2 years ago

Hi Purna,

You need to think that cdo works from right to left. Now if you want to interpolate the data before evaluating the expression you need to move the -ml2pl before the first expression (BC=blabla).

cdo -f nc -ml2pl,100000,97500,95000,92500,90000,87500,85000,82500,80000,77500,75000,70000,65000,60000,55000,50000,45000,40000,35000,30000,25000,22500,20000,17500,15000,12500,10000 -expr,'Total =BC*rhoam1*1e+9' -selname,rhoam1 "${RELPATH}"/baseline_200406.01_vphysc.nc -expr,'BC=BC_KS+BC_AS+BC_CS+BC_KI' -selname,BC_KS,BC_AS,BC_CS,BC_KI baseline_200406.01_tracer.nc test.nc

PD: I am not sure if this can work. You might need to do further work

Kind regards,

Estanislao

RE: How to use expression with multiple files - Added by Purna Durga Geesupalli about 2 years ago

Dear Estanislao,
Thank you for the reply. I have got an output my doing this. Hope you can also try..

#!/bin/bash
export RELPATH=input data path
export OUTPATH=output data path
export vars="BC_KS,BC_AS,BC_CS,BC_KI,aps"
export fun="BC_KS+BC_AS+BC_CS+BC_KI"

cdo -expr,Total=${fun}*rhoam1*1e+9 -ml2pl,100000,97500,95000,92500,90000,87500,85000,82500,80000,77500,75000,70000,65000,60000,55000,50000,45000,40000,35000,30000,25000,22500,20000,17500,15000,12500,10000 -merge -sp2gp "${RELPATH}"/baseline_200406.01_tracer.nc -sp2gp "${RELPATH}"/baseline_200406.01_vphysc.nc "${OUTPATH}"/test.nc

Regards,
Purna

RE: How to use expression with multiple files - Added by Estanislao Gavilan about 2 years ago

Hi Purna,

I am happy to hear that it seems working. You can also break each step into difference operations to make sure everything is working as it should be.

Kind regards,

Estanislao

    (1-3/3)