I'm using ncap2 to generate the mean and standard deviation of a given variable (ex: nsmz) from a given file (ex: NB_all_var_surface_04750.nc).
I would like to store the output values generated by ncdump as objects; right now, I am having to manually copy each output in terminal over to a numpy array in a separate Jupyter Notebook. There has to be a faster way!
Please see the shell commands below; any thoughts?
Edit: For clarity, my intention here was to append the value of nsmz_mean in a list, or otherwise name the value of nsmz_mean "object1" for later reference (because I have many files with many unique values). These are pythonic wishes, and I was able to find an answer by moving outside of bash.
ncap2 -h -O -s 'nsmz_mean=nsmz.avg();' NB_all_var_surface_0*.nc NB_nsmz_surface_mean.nc
ncdump -v nsmz_mean NB_nsmz_surface_mean.nc | sed -e '1,/data:/d' -e '$d'
$ nsmz_mean = 1.473794e-07 ;
ncap2 -s 'nsmz_sdn=(nsmz-nsmz.avg(ocean_time)).rmssdn(ocean_time)' NB_all_var_surface_0*.nc NB_nsmz_surface_sdn.nc
ncdump -v nsmz_sdn NB_nsmz_surface_sdn.nc | sed -e '1,/data:/d' -e '$d'
$ nsmz_sdn = 1.247375e-07 ;