Hi Henry, This worked: ncap2 -4 -O -s "model[model]=@all" in4.nc in4.nc The $model issue seems obvious now that you point it out. Thank you for helping me figure this out!
I see, that makes sense. Now it's failing with the following error: ncap2 -4 -O -s "model[$model]=@all" in4.nc in4.nc # ncap2: ERROR assign(): LHS cast for model - cannot make RHS global@all conform. I can't seem to find much documentation or posts in regards to this error. ncdump of in4.nc: netcdf in4.nc { dimensions: model = UNLIMITED ; // (2 currently) time = 74 ; y = 147 ; x = 124 ; bnds = 2 ; variables: float var(model, time, y, x) ; var:grid_mapping = "crs" ; var:cell_methods = "time: mean"...
Hi Henry, That makes sense, however, I'm receiving this error: ncap2 -O -4 -v -s @all="${MODEL}" in.nc out.nc ncap2 -4 -O -s "model[$model]=@all" in.nc out.nc # Fails here # ncap2: ERROR att_plain(): Unable to locate attribute global@all in input or output files. in.nc and out.nc are the same for both commands. Here are the contents of in.nc netcdf in.nc { dimensions: model = UNLIMITED ; // (2 currently) time = 74 ; y = 147 ; x = 124 ; bnds = 2 ; variables: float var(model, time, y, x) ; var:grid_mapping...
Hi Henry, Thanks for the response! Can you please explain what you mean by: Now you can use the global @all variable to assign model variable in your script. How would I use it in the ncap2 command? e.g.: ncap2 -4 -O -s 'model[$model]={"model1"s,"model2"s,"model3"s}' in.nc out.nc I don't quite understand how to use @all to assign new values to the record dimension. Thanks, Elyssa
Hi Charlie, Could you explain how to modify the ncap2 expression if you have an array of model names stored in a shell variable? For example, I have an array called model_names: echo "${model_names[@]}" # model1 model2 model3 ... and so on And I would like to input model_names into the ncap2 expression. Something like: # use shell variable in expressions in ncap2: https://sourceforge.net/p/nco/discussion/9830/thread/3f7a2ca2/ ncap2 -4 -O -s "model[$model]=\"${model_names[@]}\"" in.nc out.nc # ncap2:...
Hi Charlie, Could you explain how to modify the ncap2 expression if you have an array of model names stored in a shell variable? For example, I have an array called model_names: echo "${model_names[@]}" # model1 model2 model3 ... and so on And I would like to input model_names into the ncap2 expression. Something like: # use shell variable in expressions in ncap2: https://sourceforge.net/p/nco/discussion/9830/thread/3f7a2ca2/ ncap2 -4 -O -s "model[$model]=\"${model_names[@]}\"" in.nc out.nc # ncap2:...
Hi Charlie, Could you explain how to modify the ncap2 expression if you have an array of model names stored in a shell variable? For example, I have an array called model_names: echo "${model_names[@]}" # model1 model2 model3 ... and so on And I would like to input model_names into the ncap2 expression. Something like: # use shell variable in expressions in ncap2: https://sourceforge.net/p/nco/discussion/9830/thread/3f7a2ca2/ ncap2 -4 -O -s "model[$model]=\"${model_names[@]}\"" in.nc out.nc # ncap2:...